]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: arm64: selftests: Convert to kernel's ESR terminology
authorOliver Upton <oliver.upton@linux.dev>
Fri, 25 Oct 2024 20:31:05 +0000 (20:31 +0000)
committerOliver Upton <oliver.upton@linux.dev>
Sat, 26 Oct 2024 14:37:49 +0000 (14:37 +0000)
Drop the KVM selftests specific flavoring of ESR in favor of the kernel
header.

Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20241025203106.3529261-4-oliver.upton@linux.dev
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
tools/testing/selftests/kvm/aarch64/debug-exceptions.c
tools/testing/selftests/kvm/aarch64/no-vgic-v3.c
tools/testing/selftests/kvm/aarch64/page_fault_test.c
tools/testing/selftests/kvm/aarch64/vpmu_counter_access.c
tools/testing/selftests/kvm/include/aarch64/processor.h
tools/testing/selftests/kvm/lib/aarch64/processor.c

index 2582c49e525adf64ddc0275eec65333bd4587a14..ff7a949fc96ad21c805c870992f073a63266c13c 100644 (file)
@@ -433,15 +433,15 @@ static void test_guest_debug_exceptions(uint8_t bpn, uint8_t wpn, uint8_t ctx_bp
        vcpu_init_descriptor_tables(vcpu);
 
        vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
-                               ESR_EC_BRK_INS, guest_sw_bp_handler);
+                               ESR_ELx_EC_BRK64, guest_sw_bp_handler);
        vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
-                               ESR_EC_HW_BP_CURRENT, guest_hw_bp_handler);
+                               ESR_ELx_EC_BREAKPT_CUR, guest_hw_bp_handler);
        vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
-                               ESR_EC_WP_CURRENT, guest_wp_handler);
+                               ESR_ELx_EC_WATCHPT_CUR, guest_wp_handler);
        vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
-                               ESR_EC_SSTEP_CURRENT, guest_ss_handler);
+                               ESR_ELx_EC_SOFTSTP_CUR, guest_ss_handler);
        vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
-                               ESR_EC_SVC64, guest_svc_handler);
+                               ESR_ELx_EC_SVC64, guest_svc_handler);
 
        /* Specify bpn/wpn/ctx_bpn to be tested */
        vcpu_args_set(vcpu, 3, bpn, wpn, ctx_bpn);
index 943d65fc6b0b9f5c5d8d213c069091236e9a51ab..58304bbc2036a561dc1bc32d7d4455652795e93a 100644 (file)
@@ -150,7 +150,7 @@ static void test_guest_no_gicv3(void)
        vcpu_init_descriptor_tables(vcpu);
 
        vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
-                               ESR_EC_UNKNOWN, guest_undef_handler);
+                               ESR_ELx_EC_UNKNOWN, guest_undef_handler);
 
        test_run_vcpu(vcpu);
 
index d29b08198b42e00a1826b689012757b0c79ab65d..ec33a8f9c908c8652abba89b1350e43e7dd7dbda 100644 (file)
@@ -544,9 +544,9 @@ static void setup_abort_handlers(struct kvm_vm *vm, struct kvm_vcpu *vcpu,
        vcpu_init_descriptor_tables(vcpu);
 
        vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
-                               ESR_EC_DABT, no_dabt_handler);
+                               ESR_ELx_EC_DABT_CUR, no_dabt_handler);
        vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
-                               ESR_EC_IABT, no_iabt_handler);
+                               ESR_ELx_EC_IABT_CUR, no_iabt_handler);
 }
 
 static void setup_gva_maps(struct kvm_vm *vm)
index d31b9f64ba1475f89d0697e7c56ace10e0c1459a..f9c0c86d7e854cf1b53dd8fbeb25b83f66eab655 100644 (file)
@@ -300,7 +300,7 @@ static void guest_sync_handler(struct ex_regs *regs)
        uint64_t esr, ec;
 
        esr = read_sysreg(esr_el1);
-       ec = (esr >> ESR_EC_SHIFT) & ESR_EC_MASK;
+       ec = ESR_ELx_EC(esr);
 
        __GUEST_ASSERT(expected_ec == ec,
                        "PC: 0x%lx; ESR: 0x%lx; EC: 0x%lx; EC expected: 0x%lx",
@@ -338,10 +338,10 @@ static void test_access_invalid_pmc_regs(struct pmc_accessor *acc, int pmc_idx)
         * Reading/writing the event count/type registers should cause
         * an UNDEFINED exception.
         */
-       TEST_EXCEPTION(ESR_EC_UNKNOWN, acc->read_cntr(pmc_idx));
-       TEST_EXCEPTION(ESR_EC_UNKNOWN, acc->write_cntr(pmc_idx, 0));
-       TEST_EXCEPTION(ESR_EC_UNKNOWN, acc->read_typer(pmc_idx));
-       TEST_EXCEPTION(ESR_EC_UNKNOWN, acc->write_typer(pmc_idx, 0));
+       TEST_EXCEPTION(ESR_ELx_EC_UNKNOWN, acc->read_cntr(pmc_idx));
+       TEST_EXCEPTION(ESR_ELx_EC_UNKNOWN, acc->write_cntr(pmc_idx, 0));
+       TEST_EXCEPTION(ESR_ELx_EC_UNKNOWN, acc->read_typer(pmc_idx));
+       TEST_EXCEPTION(ESR_ELx_EC_UNKNOWN, acc->write_typer(pmc_idx, 0));
        /*
         * The bit corresponding to the (unimplemented) counter in
         * {PMCNTEN,PMINTEN,PMOVS}{SET,CLR} registers should be RAZ.
@@ -425,7 +425,7 @@ static void create_vpmu_vm(void *guest_code)
 
        vpmu_vm.vm = vm_create(1);
        vm_init_descriptor_tables(vpmu_vm.vm);
-       for (ec = 0; ec < ESR_EC_NUM; ec++) {
+       for (ec = 0; ec < ESR_ELx_EC_MAX + 1; ec++) {
                vm_install_sync_handler(vpmu_vm.vm, VECTOR_SYNC_CURRENT, ec,
                                        guest_sync_handler);
        }
index de977d131082a12f9edb8420da3229b7cf8b6a5a..1e8d0d531fbd393580119274a8744c688cf61377 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <linux/stringify.h>
 #include <linux/types.h>
+#include <asm/brk-imm.h>
+#include <asm/esr.h>
 #include <asm/sysreg.h>
 
 
@@ -100,19 +102,6 @@ enum {
                           (v) == VECTOR_SYNC_LOWER_64    || \
                           (v) == VECTOR_SYNC_LOWER_32)
 
-#define ESR_EC_NUM             64
-#define ESR_EC_SHIFT           26
-#define ESR_EC_MASK            (ESR_EC_NUM - 1)
-
-#define ESR_EC_UNKNOWN         0x0
-#define ESR_EC_SVC64           0x15
-#define ESR_EC_IABT            0x21
-#define ESR_EC_DABT            0x25
-#define ESR_EC_HW_BP_CURRENT   0x31
-#define ESR_EC_SSTEP_CURRENT   0x33
-#define ESR_EC_WP_CURRENT      0x35
-#define ESR_EC_BRK_INS         0x3c
-
 /* Access flag */
 #define PTE_AF                 (1ULL << 10)
 
index fe4dc3693112429ab405e911540aa226b9bbb676..698e34f392419f868036ecc63e2213e51054018e 100644 (file)
@@ -450,7 +450,7 @@ void assert_on_unhandled_exception(struct kvm_vcpu *vcpu)
 }
 
 struct handlers {
-       handler_fn exception_handlers[VECTOR_NUM][ESR_EC_NUM];
+       handler_fn exception_handlers[VECTOR_NUM][ESR_ELx_EC_MAX + 1];
 };
 
 void vcpu_init_descriptor_tables(struct kvm_vcpu *vcpu)
@@ -469,7 +469,7 @@ void route_exception(struct ex_regs *regs, int vector)
        switch (vector) {
        case VECTOR_SYNC_CURRENT:
        case VECTOR_SYNC_LOWER_64:
-               ec = (read_sysreg(esr_el1) >> ESR_EC_SHIFT) & ESR_EC_MASK;
+               ec = ESR_ELx_EC(read_sysreg(esr_el1));
                valid_ec = true;
                break;
        case VECTOR_IRQ_CURRENT:
@@ -508,7 +508,7 @@ void vm_install_sync_handler(struct kvm_vm *vm, int vector, int ec,
 
        assert(VECTOR_IS_SYNC(vector));
        assert(vector < VECTOR_NUM);
-       assert(ec < ESR_EC_NUM);
+       assert(ec <= ESR_ELx_EC_MAX);
        handlers->exception_handlers[vector][ec] = handler;
 }