From patchwork Fri May 8 01:18:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 6362011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D38D19F32E for ; Fri, 8 May 2015 01:21:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E5141203B1 for ; Fri, 8 May 2015 01:21:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0009A20340 for ; Fri, 8 May 2015 01:21:44 +0000 (UTC) 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 1YqWwy-0007mj-GL; Fri, 08 May 2015 01:19:36 +0000 Received: from mail-pa0-f45.google.com ([209.85.220.45]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YqWwr-0007bq-KA for linux-arm-kernel@lists.infradead.org; Fri, 08 May 2015 01:19:30 +0000 Received: by pabsx10 with SMTP id sx10so54894987pab.3 for ; Thu, 07 May 2015 18:19:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xiTOAS346acXrqWpjDRWmv43d6R1fFF7K6QjAe4jZt4=; b=Rh8jW/vZGvAk/3IP4nfaBzcowHF6xU+SYxiWXRFirClLBojVGDiLbmbwlc13iCZMHe iJUcOwDlYjCiTz8Efijg7Kokcg4VVCMCjXOsZJkxRqAqlTNiZVIo0AsTlozWtKMdohHC RVWwSLpKC4JeXTPVPTYJxP4fJgiPIkesrZBSVfOaGJX9SKiPIAJ4uD/7IsQZRAkJKl4p sikTuNQHeMLq6yIpAYy3+tB1gQL1oFvyjb0j/jhYbJhMTi3HD7gnAKz4mlRKngRIffQB WeqcYH7yjPdiCID4MIqRVH56QTjbt3ZzZF4wVv3IMQaDbsLx9kPtgQAEdqOxRactFarC pHmA== X-Gm-Message-State: ALoCoQls3aHDNKnOL90yjkDHLQMLkjFwYLHGx0Mp7mrrIWa25GpUZAtGhBC2CpJ6n9rEHJ7C0RB3 X-Received: by 10.66.216.136 with SMTP id oq8mr2172555pac.97.1431047948282; Thu, 07 May 2015 18:19:08 -0700 (PDT) Received: from localhost.localdomain (61-205-5-101m5.grp1.mineo.jp. [61.205.5.101]) by mx.google.com with ESMTPSA id z10sm3353675pas.18.2015.05.07.18.19.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 May 2015 18:19:06 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, mark.rutland@arm.com Subject: [v4 2/4] arm64: kvm: add kvm cpu hotplug Date: Fri, 8 May 2015 10:18:02 +0900 Message-Id: <1431047884-5637-3-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431047884-5637-1-git-send-email-takahiro.akashi@linaro.org> References: <1431047884-5637-1-git-send-email-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150507_181929_682844_73C3B02C X-CRM114-Status: GOOD ( 13.66 ) X-Spam-Score: -0.7 (/) Cc: linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, geoff@infradead.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro , broonie@kernel.org, david.griego@linaro.org, christoffer.dall@linaro.org, freddy77@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch allows cpu cores to be up and down by adding kvm_arch_hardware_enable/isable(). This way, especially in kexec case, cores are reset to initial states and kexec can gracefully shutdown the system and reboot a new kernel from EL2. Signed-off-by: AKASHI Takahiro --- arch/arm/include/asm/kvm_host.h | 1 - arch/arm/kvm/arm.c | 29 +++++++++++++++++++---------- arch/arm64/include/asm/kvm_host.h | 1 - 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 41008cd..ca97764 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -237,7 +237,6 @@ void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot); struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr); -static inline void kvm_arch_hardware_disable(void) {} static inline void kvm_arch_hardware_unsetup(void) {} static inline void kvm_arch_sync_events(struct kvm *kvm) {} static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {} diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 251ab9e..e989925 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -87,11 +87,6 @@ struct kvm_vcpu * __percpu *kvm_get_running_vcpus(void) return &kvm_arm_running_vcpu; } -int kvm_arch_hardware_enable(void) -{ - return 0; -} - int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu) { return kvm_vcpu_exiting_guest_mode(vcpu) == IN_GUEST_MODE; @@ -885,6 +880,9 @@ static void cpu_init_hyp_mode(void *dummy) unsigned long stack_page; unsigned long vector_ptr; + if (__hyp_get_vectors() != hyp_default_vectors) + return; + /* Switch from the HYP stub to our own HYP init vector */ __hyp_set_vectors(kvm_get_idmap_vector()); @@ -921,6 +919,10 @@ static int hyp_init_cpu_notify(struct notifier_block *self, if (__hyp_get_vectors() == hyp_default_vectors) cpu_init_hyp_mode(NULL); break; + case CPU_DYING: + case CPU_DYING_FROZEN: + kvm_cpu_reset(NULL); + break; } return NOTIFY_OK; @@ -936,6 +938,7 @@ static int hyp_init_cpu_pm_notifier(struct notifier_block *self, void *v) { if (cmd == CPU_PM_EXIT && + kvm_arm_get_running_vcpu() && __hyp_get_vectors() == hyp_default_vectors) { cpu_init_hyp_mode(NULL); return NOTIFY_OK; @@ -1039,11 +1042,6 @@ static int init_hyp_mode(void) } /* - * Execute the init code on each CPU. - */ - on_each_cpu(cpu_init_hyp_mode, NULL, 1); - - /* * Init HYP view of VGIC */ err = kvm_vgic_hyp_init(); @@ -1144,6 +1142,17 @@ out_err: return err; } +int kvm_arch_hardware_enable(void) +{ + cpu_init_hyp_mode(NULL); + return 0; +} + +void kvm_arch_hardware_disable(void) +{ + kvm_cpu_reset(NULL); +} + /* NOP: Compiling as a module not supported */ void kvm_arch_exit(void) { diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 6a8da9c..831e6a4 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -262,7 +262,6 @@ static inline void vgic_arch_setup(const struct vgic_params *vgic) } } -static inline void kvm_arch_hardware_disable(void) {} static inline void kvm_arch_hardware_unsetup(void) {} static inline void kvm_arch_sync_events(struct kvm *kvm) {} static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {}