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 0DBDFC25B7A for ; Tue, 21 May 2024 22:56:11 +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=SAQFPY4edgLUvrK1HbBh+LS/EahdgiIRFYzPLPsqiy4=; b=IoMH6f6Gs9CVWH x5HSx2p+EQhaUdKxA5T+Ejac9/HPfav7x6hoZJEo/cvbkc3X/SSGdriX6+qE5XuyYQYAP40EeinJ1 B2SGaT2etEbbbeRmGSW2CAYTGQLpv7HgRtfCkaNIAiVJv8+fx2MXlmKWCZcNFfCP84k6eweYax5B0 YN7NEV/fO46HWE/uWEy4uPdXgZqe+tLYaIAtVla66PUVjBRg0P8y8bj+0zekBhK1rjlmbxBvJ9vs7 JFALLEZWS+M2+L80rRtg9yVk5qHPWfOvTz7Ls8Ec0Dla3sJ3uWPCJjvaSkaM79MP7PiAnEZ6gM/Gj w6QuoK0iKy+duEIWEbFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s9YOo-00000001IZI-3Tv9; Tue, 21 May 2024 22:56:02 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s9YOl-00000001IYe-2maT for linux-arm-kernel@lists.infradead.org; Tue, 21 May 2024 22:56:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B605D62615; Tue, 21 May 2024 22:55:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F7AAC2BD11; Tue, 21 May 2024 22:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716332158; bh=AiTbcE+29X20WEPWmFk8QjzgFfmySto3RrFAFrXbOFo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tk3i1jzl6Hj7UFXPmRA9QbaAb+iFgIdbZKh6Jffk5+Mfv0oMjwFZnxOSW9QRFhaCm KBWsiwrvZD71HN4BFWoM/zc6SmtbyaUgRZph6+nmxvqNzfP3D2X2k3PsLyJ11C3kEh P2tL+AAmaRRxpKjl/KoTQ8Rw7yH2P8gEOpCHZ1OcCoqpRRh1FSCPmRHPFOMfn5j9z8 crURMuuMs5IkecfyfU6ze7rSzCQZsxWgIjFZ0B5B7p+x8xClwy3LpbcU6Ob69TcjFr Gn9CrtQrv2dS0gyhi45+2zDgjmoBxOjHk95Y/mxwRMAIQ/XJsMcmRiq4sZ5VnlC2uX QXGzpWeuftfvQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.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 1s9YOh-00EojB-T8; Tue, 21 May 2024 23:55:56 +0100 Date: Tue, 21 May 2024 23:55:55 +0100 Message-ID: <86msoin5ac.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, will@kernel.org, qperret@google.com, seanjc@google.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, philmd@linaro.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, mark.rutland@arm.com, broonie@kernel.org, joey.gouly@arm.com, rananta@google.com, yuzenghui@huawei.com Subject: Re: [PATCH v2 7/7] KVM: arm64: Consolidate initializing the host data's fpsimd_state/sve in pKVM In-Reply-To: <20240521163720.3812851-8-tabba@google.com> References: <20240521163720.3812851-1-tabba@google.com> <20240521163720.3812851-8-tabba@google.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/29.2 (aarch64-unknown-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: tabba@google.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, will@kernel.org, qperret@google.com, seanjc@google.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, philmd@linaro.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, mark.rutland@arm.com, broonie@kernel.org, joey.gouly@arm.com, rananta@google.com, yuzenghui@huawei.com 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-20240521_155559_836121_4645FF7F X-CRM114-Status: GOOD ( 24.92 ) 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 Tue, 21 May 2024 17:37:20 +0100, Fuad Tabba wrote: > > Now that we have introduced finalize_init_hyp_mode(), lets > consolidate the initializing of the host_data fpsimd_state and > sve state. > > Signed-off-by: Fuad Tabba > --- > arch/arm64/include/asm/kvm_host.h | 10 ++++++++-- > arch/arm64/kvm/arm.c | 18 ++++++++++++------ > arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 1 - > arch/arm64/kvm/hyp/nvhe/pkvm.c | 11 ----------- > arch/arm64/kvm/hyp/nvhe/setup.c | 1 - > 5 files changed, 20 insertions(+), 21 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 7b3745ef1d73..8a170f314498 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -536,8 +536,14 @@ struct kvm_cpu_context { > struct kvm_host_data { > struct kvm_cpu_context host_ctxt; > > - struct user_fpsimd_state *fpsimd_state; /* hyp VA */ > - struct user_sve_state *sve_state; /* hyp VA */ > + /* > + * All pointers in this union are hyp VA. > + * sve_state is only used in pKVM and if system_supports_sve(). > + */ > + union { > + struct user_fpsimd_state *fpsimd_state; > + struct user_sve_state *sve_state; > + }; > > /* Ownership of the FP regs */ > enum { > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index a9b1b0e9c319..a1c7e0ad6951 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -2445,14 +2445,20 @@ static void finalize_init_hyp_mode(void) > { > int cpu; > > - if (!is_protected_kvm_enabled() || !system_supports_sve()) > - return; > - > for_each_possible_cpu(cpu) { > - struct user_sve_state *sve_state; > + if (system_supports_sve() && is_protected_kvm_enabled()) { > + struct user_sve_state *sve_state; > > - sve_state = per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_state; > - per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_state = kern_hyp_va(sve_state); > + sve_state = per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_state; > + per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_state = > + kern_hyp_va(sve_state); > + } else { > + struct user_fpsimd_state *fpsimd_state; > + > + fpsimd_state = &per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->host_ctxt.fp_regs; > + per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->fpsimd_state = > + kern_hyp_va(fpsimd_state); > + } nit: SVE support and protected state do not change on a per CPU basis, so checking for these inside the loop is pretty counter intuitive. Thanks, 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