mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2026-01-27 12:47:24 +01:00
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>
This commit is contained in:
parent
a1b91ac238
commit
d72543ac72
|
|
@ -108,7 +108,7 @@ static void guest_test_hvc(const struct test_hvc_info *hc_info)
|
|||
|
||||
for (i = 0; i < hvc_info_arr_sz; i++, hc_info++) {
|
||||
memset(&res, 0, sizeof(res));
|
||||
smccc_hvc(hc_info->func_id, hc_info->arg1, 0, 0, 0, 0, 0, 0, &res);
|
||||
do_smccc(hc_info->func_id, hc_info->arg1, 0, 0, 0, 0, 0, 0, &res);
|
||||
|
||||
switch (stage) {
|
||||
case TEST_STAGE_HVC_IFACE_FEAT_DISABLED:
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ static void guest_code(void)
|
|||
{
|
||||
struct arm_smccc_res res = {};
|
||||
|
||||
smccc_hvc(ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID, 0, 0, 0, 0, 0, 0, 0, &res);
|
||||
do_smccc(ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID, 0, 0, 0, 0, 0, 0, 0, &res);
|
||||
|
||||
__GUEST_ASSERT(res.a0 == ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_0 &&
|
||||
res.a1 == ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_1 &&
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ static uint64_t psci_cpu_on(uint64_t target_cpu, uint64_t entry_addr,
|
|||
{
|
||||
struct arm_smccc_res res;
|
||||
|
||||
smccc_hvc(PSCI_0_2_FN64_CPU_ON, target_cpu, entry_addr, context_id,
|
||||
do_smccc(PSCI_0_2_FN64_CPU_ON, target_cpu, entry_addr, context_id,
|
||||
0, 0, 0, 0, &res);
|
||||
|
||||
return res.a0;
|
||||
|
|
@ -38,7 +38,7 @@ static uint64_t psci_affinity_info(uint64_t target_affinity,
|
|||
{
|
||||
struct arm_smccc_res res;
|
||||
|
||||
smccc_hvc(PSCI_0_2_FN64_AFFINITY_INFO, target_affinity, lowest_affinity_level,
|
||||
do_smccc(PSCI_0_2_FN64_AFFINITY_INFO, target_affinity, lowest_affinity_level,
|
||||
0, 0, 0, 0, 0, &res);
|
||||
|
||||
return res.a0;
|
||||
|
|
@ -48,7 +48,7 @@ static uint64_t psci_system_suspend(uint64_t entry_addr, uint64_t context_id)
|
|||
{
|
||||
struct arm_smccc_res res;
|
||||
|
||||
smccc_hvc(PSCI_1_0_FN64_SYSTEM_SUSPEND, entry_addr, context_id,
|
||||
do_smccc(PSCI_1_0_FN64_SYSTEM_SUSPEND, entry_addr, context_id,
|
||||
0, 0, 0, 0, 0, &res);
|
||||
|
||||
return res.a0;
|
||||
|
|
@ -58,7 +58,7 @@ static uint64_t psci_system_off2(uint64_t type, uint64_t cookie)
|
|||
{
|
||||
struct arm_smccc_res res;
|
||||
|
||||
smccc_hvc(PSCI_1_3_FN64_SYSTEM_OFF2, type, cookie, 0, 0, 0, 0, 0, &res);
|
||||
do_smccc(PSCI_1_3_FN64_SYSTEM_OFF2, type, cookie, 0, 0, 0, 0, 0, &res);
|
||||
|
||||
return res.a0;
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ static uint64_t psci_features(uint32_t func_id)
|
|||
{
|
||||
struct arm_smccc_res res;
|
||||
|
||||
smccc_hvc(PSCI_1_0_FN_PSCI_FEATURES, func_id, 0, 0, 0, 0, 0, 0, &res);
|
||||
do_smccc(PSCI_1_0_FN_PSCI_FEATURES, func_id, 0, 0, 0, 0, 0, 0, &res);
|
||||
|
||||
return res.a0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ static int64_t smccc(uint32_t func, uint64_t arg)
|
|||
{
|
||||
struct arm_smccc_res res;
|
||||
|
||||
smccc_hvc(func, arg, 0, 0, 0, 0, 0, 0, &res);
|
||||
do_smccc(func, arg, 0, 0, 0, 0, 0, 0, &res);
|
||||
return res.a0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user