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: 48142 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4A19A20553 for ; Fri, 8 May 2015 01:19:22 +0000 (UTC) Received: by wgiv13 with SMTP id v13sf17125736wgi.3 for ; Thu, 07 May 2015 18:19:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=rBHARuN/QXdKbNOdtAD0eP687x0OdtZePMz7CA9hb2Y=; b=WCP2frsazACdqYA5P3aBkjugN0s75lOQ+92xb1gEWW0AfneVhc8w2YRqPeqeoAQ+Ld JXPk0AWtB0fFGCIn9sX9KAwAz7yW/EUodfagDIUzBTh6dCublJFZPKI98MIaE/Es/NKg orL3gFTiPz14XKmEgOHYaChr7TfuepvNGs+PK/qKA6cfES6ZgmWpp5BmybwxjGr4oce5 0bvJW16+nQZtGIoEobP8L2pqM53Y/faR4H3uCxUOaEDGp4+ryBXKyp5IAm+Bovefm7NT uppW97r6QuhLDPKRmgtN0I2HVPosjrGYg8WBgrS/jXlpjfc2mAFm4ge825k7TDFcChUo ZbqA== X-Gm-Message-State: ALoCoQmtCVZzB1OfIgby/U/RTStYgpNRKPbxfV9lSFmB6tgLbXekinxkYVgPwvWjKJcZsjorh6hR X-Received: by 10.113.11.3 with SMTP id ee3mr694104lbd.9.1431047961602; Thu, 07 May 2015 18:19:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.133 with SMTP id kq5ls262787lac.102.gmail; Thu, 07 May 2015 18:19:21 -0700 (PDT) X-Received: by 10.152.179.195 with SMTP id di3mr981054lac.15.1431047961427; Thu, 07 May 2015 18:19:21 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id lc4si2316629lac.26.2015.05.07.18.19.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 May 2015 18:19:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbbuc2 with SMTP id uc2so43251757lbb.2 for ; Thu, 07 May 2015 18:19:21 -0700 (PDT) X-Received: by 10.112.13.6 with SMTP id d6mr933961lbc.117.1431047960984; Thu, 07 May 2015 18:19:20 -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.108.230 with SMTP id hn6csp175068lbb; Thu, 7 May 2015 18:19:20 -0700 (PDT) X-Received: by 10.70.36.102 with SMTP id p6mr2300072pdj.18.1431047959061; Thu, 07 May 2015 18:19:19 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ka3si4963110pad.32.2015.05.07.18.19.18; Thu, 07 May 2015 18:19:19 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752462AbbEHBTK (ORCPT + 28 others); Thu, 7 May 2015 21:19:10 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:36325 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752348AbbEHBTI (ORCPT ); Thu, 7 May 2015 21:19:08 -0400 Received: by pabsx10 with SMTP id sx10so54894986pab.3 for ; Thu, 07 May 2015 18:19:08 -0700 (PDT) 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 Cc: christoffer.dall@linaro.org, geoff@infradead.org, broonie@kernel.org, david.griego@linaro.org, freddy77@gmail.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, AKASHI Takahiro 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.217.171 as permitted sender) smtp.mail=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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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) {}