From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 234A9C54798 for ; Sat, 9 Mar 2024 13:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oEDNDKEsrumI0dqH+U8bqaVqzYdtKOzox8cMaAHjTto=; b=2UDNYZFE88KNP5 ivswuBY6Ik8XF4HwBq468fwjGWf4pcOGwLNCQfJ7P4s2GIoBdgp6AejdpX6mo4rvjB/x+nRudHwBr LBpdZOI1V1BEKanWMCKZguJECH4A9Fu74Qx/1Hcnj+ZNzWQw0KYFWCsSFkdlY+LvVamI3xKPCwU+p Kx5oBnBbLl+SbhNxkLHTXXFq7WPEeBhSrgj0bCCQcSpEBj20gZr8gQi8AzaeSagdw2TO8WQILmcgt 6UzL67mz/cfmc2XHFaNN2EvPt8AIm+02Anz8YxOLP3Gw7JOw6h6UYpsk8J44N2onf3KvaAkbsJn19 vm4G7DdkKkz7yvAly3FQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1riwJR-0000000DNMu-0xCE; Sat, 09 Mar 2024 13:00:29 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1riwJN-0000000DNME-45cP for linux-arm-kernel@lists.infradead.org; Sat, 09 Mar 2024 13:00:27 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id BB111CE01C6; Sat, 9 Mar 2024 13:00:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F392DC433F1; Sat, 9 Mar 2024 13:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709989222; bh=EQRrR2TRNjrh4HJhQWdHwRczLNwPKSMPTG3s7xq92mM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PAC58Cfb0ZHfe4VRPcJEfmCW51HFC+syzhrF8LRWD2Ue6baaByXVxzM7/KHFYAXVO lingc9tqWecO4C++NhFx6rT27xGI6x+0uJnz6EHDJc2B4Z4hZK6NYs40mgioLdV4xG 3nrjCyycTElHJPL+hDLFJ7LM7/vkq4qsVhharPaE4DvyoUKdvSn3EXOWEYZEhXK11G QENJHEifdzd/5nQ4/NCeceHUFAk85b5araYd/faAAzjF69LxmC8h9/REuc7z81FQPh IE6p20NrzJemyGLgIKo9ELxLoyeyXSZXiVo/Tfi62IZvcSdBZ6+PCiNcInvdP/TkPV KnooU7lCiYljg== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1riwJH-00AzHK-Mn; Sat, 09 Mar 2024 13:00:19 +0000 Date: Sat, 09 Mar 2024 13:00:18 +0000 Message-ID: <87y1arpnkt.wl-maz@kernel.org> From: Marc Zyngier To: Suzuki K Poulose Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, James Morse , Oliver Upton , Zenghui Yu , James Clark , Anshuman Khandual , Mark Brown Subject: Re: [PATCH 1/5] KVM: arm64: Add accessor for per-CPU state In-Reply-To: <4eba8428-fe6c-4c42-b135-ab831e5cf436@arm.com> References: <20240302111935.129994-1-maz@kernel.org> <20240302111935.129994-2-maz@kernel.org> <4eba8428-fe6c-4c42-b135-ab831e5cf436@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: suzuki.poulose@arm.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, james.morse@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, james.clark@arm.com, anshuman.khandual@arm.com, broonie@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240309_050026_393086_89644203 X-CRM114-Status: GOOD ( 29.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 04 Mar 2024 12:05:20 +0000, Suzuki K Poulose wrote: > > Hi Marc > > On 02/03/2024 11:19, Marc Zyngier wrote: > > In order to facilitate the introduction of new per-CPU state, > > add a new host_data_ptr() helped that hides some of the per-CPU > > verbosity, and make it easier to move that state around in the > > future. > > > > This series looks like a good cleanup to make the whole host > data handling cleaner. One comment below. > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/include/asm/kvm_host.h | 13 +++++++++++++ > > arch/arm64/kvm/arm.c | 2 +- > > arch/arm64/kvm/hyp/include/hyp/debug-sr.h | 4 ++-- > > arch/arm64/kvm/hyp/include/hyp/switch.h | 11 +++++------ > > arch/arm64/kvm/hyp/nvhe/psci-relay.c | 2 +- > > arch/arm64/kvm/hyp/nvhe/setup.c | 3 +-- > > arch/arm64/kvm/hyp/nvhe/switch.c | 4 ++-- > > arch/arm64/kvm/hyp/vhe/switch.c | 4 ++-- > > arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 4 ++-- > > arch/arm64/kvm/pmu.c | 2 +- > > 10 files changed, 30 insertions(+), 19 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > > index 21c57b812569..3ca2a9444f21 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -492,6 +492,17 @@ struct kvm_cpu_context { > > u64 *vncr_array; > > }; > > +/* > > + * This structure is instanciated on a per-CPU basis, and contains > > + * data that is: > > + * > > + * - tied to a single physical CPU, and > > + * - either have a lifetime that does not extend past vcpu_put() > > + * - or is an invariant for the lifetime of the system > > + * > > + * Use host_data_ptr(field) as a way to access a pointer to such a > > + * field. > > + */ > > struct kvm_host_data { > > struct kvm_cpu_context host_ctxt; > > }; > > @@ -1114,6 +1125,8 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr); > > DECLARE_KVM_HYP_PER_CPU(struct kvm_host_data, kvm_host_data); > > +#define host_data_ptr(f) (&this_cpu_ptr(&kvm_host_data)->f) > > + > > static inline void kvm_init_host_cpu_context(struct kvm_cpu_context *cpu_ctxt) > > { > > /* The host's MPIDR is immutable, so let's set it up at boot time */ > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > > index a25265aca432..d3d14cc41cb5 100644 > > --- a/arch/arm64/kvm/arm.c > > +++ b/arch/arm64/kvm/arm.c > > @@ -1960,7 +1960,7 @@ static void cpu_set_hyp_vector(void) > > static void cpu_hyp_init_context(void) > > { > > - kvm_init_host_cpu_context(&this_cpu_ptr_hyp_sym(kvm_host_data)->host_ctxt); > > + kvm_init_host_cpu_context(host_data_ptr(host_ctxt)); > > This silently changes the "this_cpu_ptr_hyp_sym" to "this_cpu_ptr()" > and thus we could be using the VHE host_data even in nVHE ? > Rest looks fine to me. Huh, well spotted. I'll switch the definition of host_data_ptr() outside of the hypervisor code to use this_cpu_ptr_hyp_sym() instead, like we have for some of the other helpers. Thanks again, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel