Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Fuad Tabba <tabba@google.com>
To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org
Cc: maz@kernel.org, oliver.upton@linux.dev, james.clark@linaro.org,
	 will@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com,
	 yuzenghui@huawei.com, catalin.marinas@arm.com,
	broonie@kernel.org,  qperret@google.com,
	kristina.martsenko@arm.com, tabba@google.com
Subject: [PATCH v4 13/14] KVM: arm64: Remove PtrAuth guest vcpu flag
Date: Mon,  2 Dec 2024 15:47:40 +0000	[thread overview]
Message-ID: <20241202154742.3611749-14-tabba@google.com> (raw)
In-Reply-To: <20241202154742.3611749-1-tabba@google.com>

The vcpu flag GUEST_HAS_PTRAUTH is always associated with the
vcpu PtrAuth features, which are defined per vm rather than per
vcpu.

Remove the flag, and replace it with checks for the features
instead.

Signed-off-by: Fuad Tabba <tabba@google.com>
---
 arch/arm64/include/asm/kvm_emulate.h |  5 -----
 arch/arm64/include/asm/kvm_host.h    |  7 +++----
 arch/arm64/kvm/hyp/nvhe/pkvm.c       | 13 -------------
 arch/arm64/kvm/reset.c               |  4 ----
 4 files changed, 3 insertions(+), 26 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
index 6602a4c091ac..406e99a452bf 100644
--- a/arch/arm64/include/asm/kvm_emulate.h
+++ b/arch/arm64/include/asm/kvm_emulate.h
@@ -691,9 +691,4 @@ static inline bool guest_hyp_sve_traps_enabled(const struct kvm_vcpu *vcpu)
 {
 	return __guest_hyp_cptr_xen_trap_enabled(vcpu, ZEN);
 }
-
-static inline void kvm_vcpu_enable_ptrauth(struct kvm_vcpu *vcpu)
-{
-	vcpu_set_flag(vcpu, GUEST_HAS_PTRAUTH);
-}
 #endif /* __ARM64_KVM_EMULATE_H__ */
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 69cb88c9ce3e..e6be8fe6627a 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -866,10 +866,8 @@ struct kvm_vcpu_arch {
 #define GUEST_HAS_SVE		__vcpu_single_flag(cflags, BIT(0))
 /* SVE config completed */
 #define VCPU_SVE_FINALIZED	__vcpu_single_flag(cflags, BIT(1))
-/* PTRAUTH exposed to guest */
-#define GUEST_HAS_PTRAUTH	__vcpu_single_flag(cflags, BIT(2))
 /* KVM_ARM_VCPU_INIT completed */
-#define VCPU_INITIALIZED	__vcpu_single_flag(cflags, BIT(3))
+#define VCPU_INITIALIZED	__vcpu_single_flag(cflags, BIT(2))
 
 /* Exception pending */
 #define PENDING_EXCEPTION	__vcpu_single_flag(iflags, BIT(0))
@@ -965,7 +963,8 @@ struct kvm_vcpu_arch {
 #define vcpu_has_ptrauth(vcpu)						\
 	((cpus_have_final_cap(ARM64_HAS_ADDRESS_AUTH) ||		\
 	  cpus_have_final_cap(ARM64_HAS_GENERIC_AUTH)) &&		\
-	  vcpu_get_flag(vcpu, GUEST_HAS_PTRAUTH))
+	 (vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_ADDRESS) ||       \
+	  vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_GENERIC)))
 #else
 #define vcpu_has_ptrauth(vcpu)		false
 #endif
diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c
index c8ab3e59f4b1..dfd031acde31 100644
--- a/arch/arm64/kvm/hyp/nvhe/pkvm.c
+++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c
@@ -278,18 +278,6 @@ static void pkvm_init_features_from_host(struct pkvm_hyp_vm *hyp_vm, const struc
 		   allowed_features, KVM_VCPU_MAX_FEATURES);
 }
 
-static void pkvm_vcpu_init_ptrauth(struct pkvm_hyp_vcpu *hyp_vcpu)
-{
-	struct kvm_vcpu *vcpu = &hyp_vcpu->vcpu;
-
-	if (vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_ADDRESS) ||
-	    vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_GENERIC)) {
-		kvm_vcpu_enable_ptrauth(vcpu);
-	} else {
-		vcpu_clear_flag(&hyp_vcpu->vcpu, GUEST_HAS_PTRAUTH);
-	}
-}
-
 static void unpin_host_vcpu(struct kvm_vcpu *host_vcpu)
 {
 	if (host_vcpu)
@@ -359,7 +347,6 @@ static int init_pkvm_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu,
 		goto done;
 
 	pkvm_vcpu_init_sve(hyp_vcpu, host_vcpu);
-	pkvm_vcpu_init_ptrauth(hyp_vcpu);
 done:
 	if (ret)
 		unpin_host_vcpu(host_vcpu);
diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
index 470524b31951..1cfab6a5d8a5 100644
--- a/arch/arm64/kvm/reset.c
+++ b/arch/arm64/kvm/reset.c
@@ -211,10 +211,6 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu)
 		kvm_vcpu_reset_sve(vcpu);
 	}
 
-	if (vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_ADDRESS) ||
-	    vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_GENERIC))
-		kvm_vcpu_enable_ptrauth(vcpu);
-
 	if (vcpu_el1_is_32bit(vcpu))
 		pstate = VCPU_RESET_PSTATE_SVC;
 	else if (vcpu_has_nv(vcpu))
-- 
2.47.0.338.g60cca15819-goog


  parent reply	other threads:[~2024-12-02 15:48 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02 15:47 [PATCH v4 00/14] KVM: arm64: Rework guest VM fixed feature handling and trapping in pKVM Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 01/14] KVM: arm64: Consolidate allowed and restricted VM feature checks Fuad Tabba
2024-12-06 16:12   ` Quentin Perret
2024-12-09  8:03     ` Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 02/14] KVM: arm64: Group setting traps for protected VMs by control register Fuad Tabba
2024-12-06 16:44   ` Quentin Perret
2024-12-09  8:06     ` Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 03/14] KVM: arm64: Move checking protected vcpu features to a separate function Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 04/14] KVM: arm64: Use KVM extension checks for allowed protected VM capabilities Fuad Tabba
2024-12-06 17:10   ` Quentin Perret
2024-12-09  8:14     ` Fuad Tabba
2024-12-11 13:29       ` Quentin Perret
2024-12-11 13:30         ` Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 05/14] KVM: arm64: Initialize feature id registers for protected VMs Fuad Tabba
2024-12-06  1:02   ` Oliver Upton
2024-12-06 10:04     ` Fuad Tabba
2024-12-06 17:13   ` Quentin Perret
2024-12-09  8:09     ` Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 06/14] KVM: arm64: Set protected VM traps based on its view of feature registers Fuad Tabba
2024-12-06 17:31   ` Quentin Perret
2024-12-06 17:43     ` Mark Brown
2024-12-06 18:22       ` Marc Zyngier
2024-12-09  8:11         ` Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 07/14] KVM: arm64: Rework specifying restricted features for protected VMs Fuad Tabba
2024-12-11 12:34   ` Quentin Perret
2024-12-11 13:11     ` Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 08/14] KVM: arm64: Remove fixed_config.h header Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 09/14] KVM: arm64: Remove redundant setting of HCR_EL2 trap bit Fuad Tabba
2024-12-11 12:38   ` Quentin Perret
2024-12-11 12:52     ` Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 10/14] KVM: arm64: Calculate cptr_el2 traps on activating traps Fuad Tabba
2024-12-11 12:46   ` Quentin Perret
2024-12-11 12:55     ` Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 11/14] KVM: arm64: Refactor kvm_reset_cptr_el2() Fuad Tabba
2024-12-02 15:47 ` [PATCH v4 12/14] KVM: arm64: Fix the value of the CPTR_EL2 RES1 bitmask for nVHE Fuad Tabba
2024-12-02 15:47 ` Fuad Tabba [this message]
2024-12-02 15:47 ` [PATCH v4 14/14] KVM: arm64: Convert the SVE guest vcpu flag to a vm flag Fuad Tabba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241202154742.3611749-14-tabba@google.com \
    --to=tabba@google.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.clark@linaro.org \
    --cc=joey.gouly@arm.com \
    --cc=kristina.martsenko@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=qperret@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox