From patchwork Tue Oct 20 07:58:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 55277 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id C077E22EA2 for ; Tue, 20 Oct 2015 08:01:26 +0000 (UTC) Received: by wiyb4 with SMTP id b4sf6231902wiy.2 for ; Tue, 20 Oct 2015 01:01:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=CKe/kZVQ850Yd40tuQk4Zn8QsqRymT2CzG7UdjRVhK0=; b=Qwop4g7jykFrTvB/yEdUxVMGDrDiJpjEkYXS7hAyzqN6H87q6crcouQy88m5ZSX+1e 47Kugc0IY8yBdIfv06D9Fzfg2c/ee5zrEGSBBlGG0UugtyJus3i7spcWgKss+rhj25+t VQF+zJf0dQEsnd95YC94CcTAwVzA6AcLBbdqpwn685GeNVxUdHsO/Tu58IuNBxrDtFt3 ehZkNFsBsqaTpWbKcaCmwdsVhhLdDUPu+pjPyamtSPefzaKxGVkxiLGlvx0HnUEURGPZ WdzzJXv7Wqfj70FQ0dohCzuFep1kHFCYAFrv6KXPl8rki9DyaCLKV7HvuhDljaqQkLhX 2deQ== X-Gm-Message-State: ALoCoQnykmB3Gfc88fUhNkopwJcaFQsLAPiVBYna0xTmcodMbxWzIBDl9xnCRJ+X73AauMIiVavM X-Received: by 10.180.160.194 with SMTP id xm2mr2709335wib.6.1445328086080; Tue, 20 Oct 2015 01:01:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.145.136 with SMTP id t130ls39061lfd.89.gmail; Tue, 20 Oct 2015 01:01:25 -0700 (PDT) X-Received: by 10.112.142.9 with SMTP id rs9mr899695lbb.39.1445328085934; Tue, 20 Oct 2015 01:01:25 -0700 (PDT) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id n34si1345935lfi.16.2015.10.20.01.01.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2015 01:01:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lffy185 with SMTP id y185so1517775lff.2 for ; Tue, 20 Oct 2015 01:01:25 -0700 (PDT) X-Received: by 10.25.154.203 with SMTP id c194mr623198lfe.32.1445328085294; Tue, 20 Oct 2015 01:01:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1921434lbq; Tue, 20 Oct 2015 01:01:24 -0700 (PDT) X-Received: by 10.50.43.201 with SMTP id y9mr2270823igl.18.1445328084286; Tue, 20 Oct 2015 01:01:24 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id l102si1769681iod.201.2015.10.20.01.01.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2015 01:01:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoRqG-0006YT-6g; Tue, 20 Oct 2015 08:00:20 +0000 Received: from mail-pa0-f43.google.com ([209.85.220.43]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoRq6-0005Fc-H5 for linux-arm-kernel@lists.infradead.org; Tue, 20 Oct 2015 08:00:12 +0000 Received: by pasz6 with SMTP id z6so13924144pas.2 for ; Tue, 20 Oct 2015 00:59:50 -0700 (PDT) X-Received: by 10.68.57.197 with SMTP id k5mr2420495pbq.142.1445327990002; Tue, 20 Oct 2015 00:59:50 -0700 (PDT) Received: from localhost.localdomain (61-205-5-101m5.grp1.mineo.jp. [61.205.5.101]) by smtp.googlemail.com with ESMTPSA id mk5sm2108500pab.44.2015.10.20.00.59.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Oct 2015 00:59:48 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, geoff@infradead.org, marc.zyngier@arm.com Subject: [PATCH 2/2] fixup! arm64: kvm: allows kvm cpu hotplug Date: Tue, 20 Oct 2015 16:58:27 +0900 Message-Id: <1445327907-23274-3-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445327907-23274-1-git-send-email-takahiro.akashi@linaro.org> References: <1445327907-23274-1-git-send-email-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151020_010010_754449_16F2BC70 X-CRM114-Status: GOOD ( 15.48 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.220.43 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.43 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: mark.rutland@arm.com, kexec@lists.infradead.org, AKASHI Takahiro , broonie@kernel.org, david.griego@linaro.org, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: takahiro.akashi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Without this patch, kvm cannot start a guest when cpuidle is enabled if the hardware does not retain cpu state (EL2) in idle state. This patch re-initailizes EL2 state at CPU_PM_EXIT by calling kvm_arch_hardware_enable() if and only if kvm has been initialized before CPU_PM_ENTER, that is, if any vcpus have been created. Signed-off-by: AKASHI Takahiro Tested-By: James Morse --- arch/arm/kvm/arm.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 0871809..fbff638 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -60,6 +60,8 @@ static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1); static u8 kvm_next_vmid; static DEFINE_SPINLOCK(kvm_vmid_lock); +static DEFINE_PER_CPU(unsigned char, kvm_arm_hardware_enabled); + static void kvm_arm_set_running_vcpu(struct kvm_vcpu *vcpu) { BUG_ON(preemptible()); @@ -955,12 +957,27 @@ static int hyp_init_cpu_pm_notifier(struct notifier_block *self, unsigned long cmd, void *v) { - if (cmd == CPU_PM_EXIT && kvm_arm_get_running_vcpu()) { - kvm_arch_hardware_enable(); + switch (cmd) { + case CPU_PM_ENTER: + if (__hyp_get_vectors() != hyp_default_vectors) + __this_cpu_write(kvm_arm_hardware_enabled, 1); + else + __this_cpu_write(kvm_arm_hardware_enabled, 0); + /* + * don't call kvm_arch_hardware_disable() in case of + * CPU_PM_ENTER because it does't actually save any state. + */ + + return NOTIFY_OK; + case CPU_PM_EXIT: + if (__this_cpu_read(kvm_arm_hardware_enabled)) + kvm_arch_hardware_enable(); + return NOTIFY_OK; - } - return NOTIFY_DONE; + default: + return NOTIFY_DONE; + } } static struct notifier_block hyp_init_cpu_pm_nb = {