Skip to content

Commit c5c1763

Browse files
Fuad TabbaMarc Zyngier
authored andcommitted
KVM: arm64: Remove PtrAuth guest vcpu flag
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 1eccad3 commit c5c1763

File tree

4 files changed

+3
-26
lines changed

4 files changed

+3
-26
lines changed

arch/arm64/include/asm/kvm_emulate.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,9 +691,4 @@ static inline bool guest_hyp_sve_traps_enabled(const struct kvm_vcpu *vcpu)
691691
{
692692
return __guest_hyp_cptr_xen_trap_enabled(vcpu, ZEN);
693693
}
694-
695-
static inline void kvm_vcpu_enable_ptrauth(struct kvm_vcpu *vcpu)
696-
{
697-
vcpu_set_flag(vcpu, GUEST_HAS_PTRAUTH);
698-
}
699694
#endif /* __ARM64_KVM_EMULATE_H__ */

arch/arm64/include/asm/kvm_host.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -866,10 +866,8 @@ struct kvm_vcpu_arch {
866866
#define GUEST_HAS_SVE __vcpu_single_flag(cflags, BIT(0))
867867
/* SVE config completed */
868868
#define VCPU_SVE_FINALIZED __vcpu_single_flag(cflags, BIT(1))
869-
/* PTRAUTH exposed to guest */
870-
#define GUEST_HAS_PTRAUTH __vcpu_single_flag(cflags, BIT(2))
871869
/* KVM_ARM_VCPU_INIT completed */
872-
#define VCPU_INITIALIZED __vcpu_single_flag(cflags, BIT(3))
870+
#define VCPU_INITIALIZED __vcpu_single_flag(cflags, BIT(2))
873871

874872
/* Exception pending */
875873
#define PENDING_EXCEPTION __vcpu_single_flag(iflags, BIT(0))
@@ -965,7 +963,8 @@ struct kvm_vcpu_arch {
965963
#define vcpu_has_ptrauth(vcpu) \
966964
((cpus_have_final_cap(ARM64_HAS_ADDRESS_AUTH) || \
967965
cpus_have_final_cap(ARM64_HAS_GENERIC_AUTH)) && \
968-
vcpu_get_flag(vcpu, GUEST_HAS_PTRAUTH))
966+
(vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_ADDRESS) || \
967+
vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_GENERIC)))
969968
#else
970969
#define vcpu_has_ptrauth(vcpu) false
971970
#endif

arch/arm64/kvm/hyp/nvhe/pkvm.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -278,18 +278,6 @@ static void pkvm_init_features_from_host(struct pkvm_hyp_vm *hyp_vm, const struc
278278
allowed_features, KVM_VCPU_MAX_FEATURES);
279279
}
280280

281-
static void pkvm_vcpu_init_ptrauth(struct pkvm_hyp_vcpu *hyp_vcpu)
282-
{
283-
struct kvm_vcpu *vcpu = &hyp_vcpu->vcpu;
284-
285-
if (vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_ADDRESS) ||
286-
vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_GENERIC)) {
287-
kvm_vcpu_enable_ptrauth(vcpu);
288-
} else {
289-
vcpu_clear_flag(&hyp_vcpu->vcpu, GUEST_HAS_PTRAUTH);
290-
}
291-
}
292-
293281
static void unpin_host_vcpu(struct kvm_vcpu *host_vcpu)
294282
{
295283
if (host_vcpu)
@@ -359,7 +347,6 @@ static int init_pkvm_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu,
359347
goto done;
360348

361349
pkvm_vcpu_init_sve(hyp_vcpu, host_vcpu);
362-
pkvm_vcpu_init_ptrauth(hyp_vcpu);
363350
done:
364351
if (ret)
365352
unpin_host_vcpu(host_vcpu);

arch/arm64/kvm/reset.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,6 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu)
211211
kvm_vcpu_reset_sve(vcpu);
212212
}
213213

214-
if (vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_ADDRESS) ||
215-
vcpu_has_feature(vcpu, KVM_ARM_VCPU_PTRAUTH_GENERIC))
216-
kvm_vcpu_enable_ptrauth(vcpu);
217-
218214
if (vcpu_el1_is_32bit(vcpu))
219215
pstate = VCPU_RESET_PSTATE_SVC;
220216
else if (vcpu_has_nv(vcpu))

0 commit comments

Comments
 (0)