Skip to content

Commit c660d33

Browse files
committed
KVM: arm64: selftests: Convert to kernel's ESR terminology
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>
1 parent 9fb8e91 commit c660d33

File tree

6 files changed

+19
-30
lines changed

6 files changed

+19
-30
lines changed

tools/testing/selftests/kvm/aarch64/debug-exceptions.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,15 +433,15 @@ static void test_guest_debug_exceptions(uint8_t bpn, uint8_t wpn, uint8_t ctx_bp
433433
vcpu_init_descriptor_tables(vcpu);
434434

435435
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
436-
ESR_EC_BRK_INS, guest_sw_bp_handler);
436+
ESR_ELx_EC_BRK64, guest_sw_bp_handler);
437437
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
438-
ESR_EC_HW_BP_CURRENT, guest_hw_bp_handler);
438+
ESR_ELx_EC_BREAKPT_CUR, guest_hw_bp_handler);
439439
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
440-
ESR_EC_WP_CURRENT, guest_wp_handler);
440+
ESR_ELx_EC_WATCHPT_CUR, guest_wp_handler);
441441
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
442-
ESR_EC_SSTEP_CURRENT, guest_ss_handler);
442+
ESR_ELx_EC_SOFTSTP_CUR, guest_ss_handler);
443443
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
444-
ESR_EC_SVC64, guest_svc_handler);
444+
ESR_ELx_EC_SVC64, guest_svc_handler);
445445

446446
/* Specify bpn/wpn/ctx_bpn to be tested */
447447
vcpu_args_set(vcpu, 3, bpn, wpn, ctx_bpn);

tools/testing/selftests/kvm/aarch64/no-vgic-v3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static void test_guest_no_gicv3(void)
150150
vcpu_init_descriptor_tables(vcpu);
151151

152152
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
153-
ESR_EC_UNKNOWN, guest_undef_handler);
153+
ESR_ELx_EC_UNKNOWN, guest_undef_handler);
154154

155155
test_run_vcpu(vcpu);
156156

tools/testing/selftests/kvm/aarch64/page_fault_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,9 @@ static void setup_abort_handlers(struct kvm_vm *vm, struct kvm_vcpu *vcpu,
544544
vcpu_init_descriptor_tables(vcpu);
545545

546546
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
547-
ESR_EC_DABT, no_dabt_handler);
547+
ESR_ELx_EC_DABT_CUR, no_dabt_handler);
548548
vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
549-
ESR_EC_IABT, no_iabt_handler);
549+
ESR_ELx_EC_IABT_CUR, no_iabt_handler);
550550
}
551551

552552
static void setup_gva_maps(struct kvm_vm *vm)

tools/testing/selftests/kvm/aarch64/vpmu_counter_access.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ static void guest_sync_handler(struct ex_regs *regs)
300300
uint64_t esr, ec;
301301

302302
esr = read_sysreg(esr_el1);
303-
ec = (esr >> ESR_EC_SHIFT) & ESR_EC_MASK;
303+
ec = ESR_ELx_EC(esr);
304304

305305
__GUEST_ASSERT(expected_ec == ec,
306306
"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)
338338
* Reading/writing the event count/type registers should cause
339339
* an UNDEFINED exception.
340340
*/
341-
TEST_EXCEPTION(ESR_EC_UNKNOWN, acc->read_cntr(pmc_idx));
342-
TEST_EXCEPTION(ESR_EC_UNKNOWN, acc->write_cntr(pmc_idx, 0));
343-
TEST_EXCEPTION(ESR_EC_UNKNOWN, acc->read_typer(pmc_idx));
344-
TEST_EXCEPTION(ESR_EC_UNKNOWN, acc->write_typer(pmc_idx, 0));
341+
TEST_EXCEPTION(ESR_ELx_EC_UNKNOWN, acc->read_cntr(pmc_idx));
342+
TEST_EXCEPTION(ESR_ELx_EC_UNKNOWN, acc->write_cntr(pmc_idx, 0));
343+
TEST_EXCEPTION(ESR_ELx_EC_UNKNOWN, acc->read_typer(pmc_idx));
344+
TEST_EXCEPTION(ESR_ELx_EC_UNKNOWN, acc->write_typer(pmc_idx, 0));
345345
/*
346346
* The bit corresponding to the (unimplemented) counter in
347347
* {PMCNTEN,PMINTEN,PMOVS}{SET,CLR} registers should be RAZ.
@@ -425,7 +425,7 @@ static void create_vpmu_vm(void *guest_code)
425425

426426
vpmu_vm.vm = vm_create(1);
427427
vm_init_descriptor_tables(vpmu_vm.vm);
428-
for (ec = 0; ec < ESR_EC_NUM; ec++) {
428+
for (ec = 0; ec < ESR_ELx_EC_MAX + 1; ec++) {
429429
vm_install_sync_handler(vpmu_vm.vm, VECTOR_SYNC_CURRENT, ec,
430430
guest_sync_handler);
431431
}

tools/testing/selftests/kvm/include/aarch64/processor.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#include <linux/stringify.h>
1414
#include <linux/types.h>
15+
#include <asm/brk-imm.h>
16+
#include <asm/esr.h>
1517
#include <asm/sysreg.h>
1618

1719

@@ -100,19 +102,6 @@ enum {
100102
(v) == VECTOR_SYNC_LOWER_64 || \
101103
(v) == VECTOR_SYNC_LOWER_32)
102104

103-
#define ESR_EC_NUM 64
104-
#define ESR_EC_SHIFT 26
105-
#define ESR_EC_MASK (ESR_EC_NUM - 1)
106-
107-
#define ESR_EC_UNKNOWN 0x0
108-
#define ESR_EC_SVC64 0x15
109-
#define ESR_EC_IABT 0x21
110-
#define ESR_EC_DABT 0x25
111-
#define ESR_EC_HW_BP_CURRENT 0x31
112-
#define ESR_EC_SSTEP_CURRENT 0x33
113-
#define ESR_EC_WP_CURRENT 0x35
114-
#define ESR_EC_BRK_INS 0x3c
115-
116105
/* Access flag */
117106
#define PTE_AF (1ULL << 10)
118107

tools/testing/selftests/kvm/lib/aarch64/processor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ void assert_on_unhandled_exception(struct kvm_vcpu *vcpu)
450450
}
451451

452452
struct handlers {
453-
handler_fn exception_handlers[VECTOR_NUM][ESR_EC_NUM];
453+
handler_fn exception_handlers[VECTOR_NUM][ESR_ELx_EC_MAX + 1];
454454
};
455455

456456
void vcpu_init_descriptor_tables(struct kvm_vcpu *vcpu)
@@ -469,7 +469,7 @@ void route_exception(struct ex_regs *regs, int vector)
469469
switch (vector) {
470470
case VECTOR_SYNC_CURRENT:
471471
case VECTOR_SYNC_LOWER_64:
472-
ec = (read_sysreg(esr_el1) >> ESR_EC_SHIFT) & ESR_EC_MASK;
472+
ec = ESR_ELx_EC(read_sysreg(esr_el1));
473473
valid_ec = true;
474474
break;
475475
case VECTOR_IRQ_CURRENT:
@@ -508,7 +508,7 @@ void vm_install_sync_handler(struct kvm_vm *vm, int vector, int ec,
508508

509509
assert(VECTOR_IS_SYNC(vector));
510510
assert(vector < VECTOR_NUM);
511-
assert(ec < ESR_EC_NUM);
511+
assert(ec <= ESR_ELx_EC_MAX);
512512
handlers->exception_handlers[vector][ec] = handler;
513513
}
514514

0 commit comments

Comments
 (0)