Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: selftests: Select SMCCC conduit based on current EL

HVCs are taken within the VM when EL2 is in use. Ensure tests use the
SMC instruction when running at EL2 to interact with the host.

Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>

authored by

Oliver Upton and committed by
Marc Zyngier
d72543ac a1b91ac2

+21 -8
+1 -1
tools/testing/selftests/kvm/arm64/hypercalls.c
··· 108 108 109 109 for (i = 0; i < hvc_info_arr_sz; i++, hc_info++) { 110 110 memset(&res, 0, sizeof(res)); 111 - smccc_hvc(hc_info->func_id, hc_info->arg1, 0, 0, 0, 0, 0, 0, &res); 111 + do_smccc(hc_info->func_id, hc_info->arg1, 0, 0, 0, 0, 0, 0, &res); 112 112 113 113 switch (stage) { 114 114 case TEST_STAGE_HVC_IFACE_FEAT_DISABLED:
+1 -1
tools/testing/selftests/kvm/arm64/kvm-uuid.c
··· 25 25 { 26 26 struct arm_smccc_res res = {}; 27 27 28 - smccc_hvc(ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID, 0, 0, 0, 0, 0, 0, 0, &res); 28 + do_smccc(ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID, 0, 0, 0, 0, 0, 0, 0, &res); 29 29 30 30 __GUEST_ASSERT(res.a0 == ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_0 && 31 31 res.a1 == ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_1 &&
+5 -5
tools/testing/selftests/kvm/arm64/psci_test.c
··· 27 27 { 28 28 struct arm_smccc_res res; 29 29 30 - smccc_hvc(PSCI_0_2_FN64_CPU_ON, target_cpu, entry_addr, context_id, 30 + do_smccc(PSCI_0_2_FN64_CPU_ON, target_cpu, entry_addr, context_id, 31 31 0, 0, 0, 0, &res); 32 32 33 33 return res.a0; ··· 38 38 { 39 39 struct arm_smccc_res res; 40 40 41 - smccc_hvc(PSCI_0_2_FN64_AFFINITY_INFO, target_affinity, lowest_affinity_level, 41 + do_smccc(PSCI_0_2_FN64_AFFINITY_INFO, target_affinity, lowest_affinity_level, 42 42 0, 0, 0, 0, 0, &res); 43 43 44 44 return res.a0; ··· 48 48 { 49 49 struct arm_smccc_res res; 50 50 51 - smccc_hvc(PSCI_1_0_FN64_SYSTEM_SUSPEND, entry_addr, context_id, 51 + do_smccc(PSCI_1_0_FN64_SYSTEM_SUSPEND, entry_addr, context_id, 52 52 0, 0, 0, 0, 0, &res); 53 53 54 54 return res.a0; ··· 58 58 { 59 59 struct arm_smccc_res res; 60 60 61 - smccc_hvc(PSCI_1_3_FN64_SYSTEM_OFF2, type, cookie, 0, 0, 0, 0, 0, &res); 61 + do_smccc(PSCI_1_3_FN64_SYSTEM_OFF2, type, cookie, 0, 0, 0, 0, 0, &res); 62 62 63 63 return res.a0; 64 64 } ··· 67 67 { 68 68 struct arm_smccc_res res; 69 69 70 - smccc_hvc(PSCI_1_0_FN_PSCI_FEATURES, func_id, 0, 0, 0, 0, 0, 0, &res); 70 + do_smccc(PSCI_1_0_FN_PSCI_FEATURES, func_id, 0, 0, 0, 0, 0, 0, &res); 71 71 72 72 return res.a0; 73 73 }
+13
tools/testing/selftests/kvm/include/arm64/processor.h
··· 359 359 360 360 void kvm_get_default_vcpu_target(struct kvm_vm *vm, struct kvm_vcpu_init *init); 361 361 362 + static inline unsigned int get_current_el(void) 363 + { 364 + return (read_sysreg(CurrentEL) >> 2) & 0x3; 365 + } 366 + 367 + #define do_smccc(...) \ 368 + do { \ 369 + if (get_current_el() == 2) \ 370 + smccc_smc(__VA_ARGS__); \ 371 + else \ 372 + smccc_hvc(__VA_ARGS__); \ 373 + } while (0) 374 + 362 375 #endif /* SELFTEST_KVM_PROCESSOR_H */
+1 -1
tools/testing/selftests/kvm/steal_time.c
··· 118 118 { 119 119 struct arm_smccc_res res; 120 120 121 - smccc_hvc(func, arg, 0, 0, 0, 0, 0, 0, &res); 121 + do_smccc(func, arg, 0, 0, 0, 0, 0, 0, &res); 122 122 return res.a0; 123 123 } 124 124