KVM: arm64: Test that SMC64 arch calls are reserved
authorOliver Upton <oliver.upton@linux.dev>
Sat, 8 Apr 2023 12:17:32 +0000 (12:17 +0000)
committerMarc Zyngier <maz@kernel.org>
Sat, 8 Apr 2023 14:22:55 +0000 (15:22 +0100)
Assert that the SMC64 view of the Arm architecture range is reserved by
KVM and cannot be filtered by userspace.

Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230408121732.3411329-3-oliver.upton@linux.dev
tools/testing/selftests/kvm/aarch64/smccc_filter.c

index 0f9db06..dab671f 100644 (file)
@@ -99,6 +99,7 @@ static void test_filter_reserved_range(void)
 {
        struct kvm_vcpu *vcpu;
        struct kvm_vm *vm = setup_vm(&vcpu);
+       uint32_t smc64_fn;
        int r;
 
        r = __set_smccc_filter(vm, ARM_SMCCC_ARCH_WORKAROUND_1,
@@ -106,6 +107,13 @@ static void test_filter_reserved_range(void)
        TEST_ASSERT(r < 0 && errno == EEXIST,
                    "Attempt to filter reserved range should return EEXIST");
 
+       smc64_fn = ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_64,
+                                     0, 0);
+
+       r = __set_smccc_filter(vm, smc64_fn, 1, KVM_SMCCC_FILTER_DENY);
+       TEST_ASSERT(r < 0 && errno == EEXIST,
+                   "Attempt to filter reserved range should return EEXIST");
+
        kvm_vm_free(vm);
 }