Skip to content

Commit 36fb4cd

Browse files
willdeaconMarc Zyngier
authored andcommitted
KVM: arm64: Remove kvm_arch_vm_ioctl_check_extension()
kvm_arch_vm_ioctl_check_extension() is only called from kvm_vm_ioctl_check_extension(), so we can inline it and remove the extra function. Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Marc Zyngier <maz@kernel.org> Cc: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20201118194402.2892-3-will@kernel.org
1 parent 8d14797 commit 36fb4cd

4 files changed

Lines changed: 34 additions & 55 deletions

File tree

‎arch/arm64/include/asm/cpufeature.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,11 @@ static inline bool system_supports_generic_auth(void)
697697
cpus_have_const_cap(ARM64_HAS_GENERIC_AUTH);
698698
}
699699

700+
static inline bool system_has_full_ptr_auth(void)
701+
{
702+
return system_supports_address_auth() && system_supports_generic_auth();
703+
}
704+
700705
static __always_inline bool system_uses_irq_prio_masking(void)
701706
{
702707
return IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI) &&

‎arch/arm64/include/asm/kvm_host.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ int kvm_arm_init_sve(void);
5858
int __attribute_const__ kvm_target_cpu(void);
5959
int kvm_reset_vcpu(struct kvm_vcpu *vcpu);
6060
void kvm_arm_vcpu_destroy(struct kvm_vcpu *vcpu);
61-
int kvm_arch_vm_ioctl_check_extension(struct kvm *kvm, long ext);
6261
void __extended_idmap_trampoline(phys_addr_t boot_pgd, phys_addr_t idmap_start);
6362

6463
struct kvm_vmid {

‎arch/arm64/kvm/arm.c‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
182182
case KVM_CAP_ARM_IRQ_LINE_LAYOUT_2:
183183
case KVM_CAP_ARM_NISV_TO_USER:
184184
case KVM_CAP_ARM_INJECT_EXT_DABT:
185+
case KVM_CAP_SET_GUEST_DEBUG:
186+
case KVM_CAP_VCPU_ATTRIBUTES:
185187
r = 1;
186188
break;
187189
case KVM_CAP_ARM_SET_DEVICE_ADDR:
@@ -213,10 +215,35 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
213215
case KVM_CAP_STEAL_TIME:
214216
r = kvm_arm_pvtime_supported();
215217
break;
216-
default:
217-
r = kvm_arch_vm_ioctl_check_extension(kvm, ext);
218+
case KVM_CAP_ARM_EL1_32BIT:
219+
r = cpus_have_const_cap(ARM64_HAS_32BIT_EL1);
220+
break;
221+
case KVM_CAP_GUEST_DEBUG_HW_BPS:
222+
r = get_num_brps();
223+
break;
224+
case KVM_CAP_GUEST_DEBUG_HW_WPS:
225+
r = get_num_wrps();
226+
break;
227+
case KVM_CAP_ARM_PMU_V3:
228+
r = kvm_arm_support_pmu_v3();
229+
break;
230+
case KVM_CAP_ARM_INJECT_SERROR_ESR:
231+
r = cpus_have_const_cap(ARM64_HAS_RAS_EXTN);
232+
break;
233+
case KVM_CAP_ARM_VM_IPA_SIZE:
234+
r = get_kvm_ipa_limit();
218235
break;
236+
case KVM_CAP_ARM_SVE:
237+
r = system_supports_sve();
238+
break;
239+
case KVM_CAP_ARM_PTRAUTH_ADDRESS:
240+
case KVM_CAP_ARM_PTRAUTH_GENERIC:
241+
r = system_has_full_ptr_auth();
242+
break;
243+
default:
244+
r = 0;
219245
}
246+
220247
return r;
221248
}
222249

‎arch/arm64/kvm/reset.c‎

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -42,58 +42,6 @@ static u32 kvm_ipa_limit;
4242
#define VCPU_RESET_PSTATE_SVC (PSR_AA32_MODE_SVC | PSR_AA32_A_BIT | \
4343
PSR_AA32_I_BIT | PSR_AA32_F_BIT)
4444

45-
static bool system_has_full_ptr_auth(void)
46-
{
47-
return system_supports_address_auth() && system_supports_generic_auth();
48-
}
49-
50-
/**
51-
* kvm_arch_vm_ioctl_check_extension
52-
*
53-
* We currently assume that the number of HW registers is uniform
54-
* across all CPUs (see cpuinfo_sanity_check).
55-
*/
56-
int kvm_arch_vm_ioctl_check_extension(struct kvm *kvm, long ext)
57-
{
58-
int r;
59-
60-
switch (ext) {
61-
case KVM_CAP_ARM_EL1_32BIT:
62-
r = cpus_have_const_cap(ARM64_HAS_32BIT_EL1);
63-
break;
64-
case KVM_CAP_GUEST_DEBUG_HW_BPS:
65-
r = get_num_brps();
66-
break;
67-
case KVM_CAP_GUEST_DEBUG_HW_WPS:
68-
r = get_num_wrps();
69-
break;
70-
case KVM_CAP_ARM_PMU_V3:
71-
r = kvm_arm_support_pmu_v3();
72-
break;
73-
case KVM_CAP_ARM_INJECT_SERROR_ESR:
74-
r = cpus_have_const_cap(ARM64_HAS_RAS_EXTN);
75-
break;
76-
case KVM_CAP_SET_GUEST_DEBUG:
77-
case KVM_CAP_VCPU_ATTRIBUTES:
78-
r = 1;
79-
break;
80-
case KVM_CAP_ARM_VM_IPA_SIZE:
81-
r = kvm_ipa_limit;
82-
break;
83-
case KVM_CAP_ARM_SVE:
84-
r = system_supports_sve();
85-
break;
86-
case KVM_CAP_ARM_PTRAUTH_ADDRESS:
87-
case KVM_CAP_ARM_PTRAUTH_GENERIC:
88-
r = system_has_full_ptr_auth();
89-
break;
90-
default:
91-
r = 0;
92-
}
93-
94-
return r;
95-
}
96-
9745
unsigned int kvm_sve_max_vl;
9846

9947
int kvm_arm_init_sve(void)

0 commit comments

Comments
 (0)