diff options
| author | Oliver Upton <oliver.upton@linux.dev> | 2025-09-17 14:20:38 -0700 |
|---|---|---|
| committer | Marc Zyngier <maz@kernel.org> | 2025-09-24 19:23:32 +0100 |
| commit | d72543ac728ae4a4708cbefad2761df84599c268 (patch) | |
| tree | 23fe597e9c160bc2abb62199c87082a4df3aa3fc /tools/testing/selftests/kvm/include/arm64/processor.h | |
| parent | a1b91ac2381d86aa47b7109bbcde0c71e775f6d9 (diff) | |
| download | linux-next-d72543ac728ae4a4708cbefad2761df84599c268.tar.gz linux-next-d72543ac728ae4a4708cbefad2761df84599c268.zip | |
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>
Diffstat (limited to 'tools/testing/selftests/kvm/include/arm64/processor.h')
| -rw-r--r-- | tools/testing/selftests/kvm/include/arm64/processor.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/arm64/processor.h b/tools/testing/selftests/kvm/include/arm64/processor.h index 87f50efed720..f037c1bb8e63 100644 --- a/tools/testing/selftests/kvm/include/arm64/processor.h +++ b/tools/testing/selftests/kvm/include/arm64/processor.h @@ -359,4 +359,17 @@ static __always_inline u64 ctxt_reg_alias(struct kvm_vcpu *vcpu, u32 encoding) void kvm_get_default_vcpu_target(struct kvm_vm *vm, struct kvm_vcpu_init *init); +static inline unsigned int get_current_el(void) +{ + return (read_sysreg(CurrentEL) >> 2) & 0x3; +} + +#define do_smccc(...) \ +do { \ + if (get_current_el() == 2) \ + smccc_smc(__VA_ARGS__); \ + else \ + smccc_hvc(__VA_ARGS__); \ +} while (0) + #endif /* SELFTEST_KVM_PROCESSOR_H */ |
