From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C61E31F9A7; Thu, 2 Jul 2026 16:03:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783008184; cv=none; b=l01o5t4OY8ck3dpQdAdKiuxKvh7DNCgWQEDgThh6k8Svp35F8PV/uBSwyAsHpy/Vh6L4e6XIriul17U5ulPSNbPJFYTbIYTjie+V9PD0rmCboHE50IUj7HSgEexOs/N3PaxwzwMZ3fwWt8JgDzlwskAHt2wG889WxYdSBxcSzxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783008184; c=relaxed/simple; bh=0HY0oB06IGdQgPmgg21HcNuZIUTuhLbyiw7dkynkLmI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VRo4gqFqcgExEYpfocl50abDucRj986E1Nqbdc0cXkHeorEynZMv/IRJblk4UAOfsOZ4EOp7JNq9HiS7gW09/WnNwN1CKzq7CWfc2ntT9bAGbS3du96k5gnq+6doRoN2ezN03gDOGIGNZjRC8Kx3OpiojtJsKcuxiba1KiWO7qs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NtdHDAdH; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NtdHDAdH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05B0D1F01559; Thu, 2 Jul 2026 16:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783008183; bh=h4295tykVcUmOhUIFRdTHsRo0fGF1FYPbLW1hKxstTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NtdHDAdHF+5VBiYhaIYgCwFUjF1/KA2q/TP3+2l79LjpjJHEyJeNRRdYkhzxcQr7o BCDrz8qZgg1mVRNHDoQ2M4B+D38awPW8byeEcwQZIAzYxUJ098URS2sYsBvcqT7Ic/ kXl49N3CntHCt5g0hKyENIbP9EH/+qXYLefHsblvB0fpITkVFkEt3jCIo9TobY9IQ2 l4kvu9yrr0imYvX01x32UTHfqK9/jeYheCVnQiMww0q1qz6CkgmhJJKgkKvkh4neHd XYq6vmkDAxvF57WJEZwceBn93ot1j2km8Qcrd7b3nxDQOIqK2ERIrG4hpA7ZP14XO0 l8PhTwVnm+ZTg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wfJsT-00000000ojd-1TPr; Thu, 02 Jul 2026 16:03:01 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: Steffen Eiden , Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu Subject: [PATCH 16/28] KVM: arm64: Split NV-specific exit fixups from the non-NV handling Date: Thu, 2 Jul 2026 17:02:36 +0100 Message-ID: <20260702160248.1377250-17-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260702160248.1377250-1-maz@kernel.org> References: <20260702160248.1377250-1-maz@kernel.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, seiden@linux.ibm.com, joey.gouly@arm.com, suzuki.poulose@arm.com, oupton@kernel.org, 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 In order to facilitate further changes, move the NV handling of early fixups in its own helper. This also makes the code slightly simpler to parse. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp/vhe/switch.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c index 361d3f8344dd8..8268779df4fa9 100644 --- a/arch/arm64/kvm/hyp/vhe/switch.c +++ b/arch/arm64/kvm/hyp/vhe/switch.c @@ -537,18 +537,15 @@ static const exit_handler_fn hyp_exit_handlers[] = { [0x3F] = kvm_hyp_handle_impdef, }; -static inline bool fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code) +static void fixup_nv_guest_exit(struct kvm_vcpu *vcpu) { - synchronize_vcpu_pstate(vcpu); - /* * If we were in HYP context on entry, adjust the PSTATE view * so that the usual helpers work correctly. This enforces our * invariant that the guest's HYP context status is preserved * across a run. */ - if (vcpu_has_nv(vcpu) && - unlikely(host_data_test_flag(VCPU_IN_HYP_CONTEXT))) { + if (unlikely(host_data_test_flag(VCPU_IN_HYP_CONTEXT))) { u64 mode = *vcpu_cpsr(vcpu) & (PSR_MODE_MASK | PSR_MODE32_BIT); switch (mode) { @@ -565,8 +562,15 @@ static inline bool fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code) } /* Apply extreme paranoia! */ - BUG_ON(vcpu_has_nv(vcpu) && - !!host_data_test_flag(VCPU_IN_HYP_CONTEXT) != is_hyp_ctxt(vcpu)); + BUG_ON(!!host_data_test_flag(VCPU_IN_HYP_CONTEXT) != is_hyp_ctxt(vcpu)); +} + +static bool fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code) +{ + synchronize_vcpu_pstate(vcpu); + + if (vcpu_has_nv(vcpu)) + fixup_nv_guest_exit(vcpu); return __fixup_guest_exit(vcpu, exit_code, hyp_exit_handlers); } -- 2.47.3