Commit 948f439c authored by Reiji Watanabe's avatar Reiji Watanabe Committed by Marc Zyngier

KVM: arm64: selftests: Stop unnecessary test stage tracking of debug-exceptions

Currently, debug-exceptions test unnecessarily tracks some test stages
using GUEST_SYNC().  The code for it needs to be updated as test cases
are added or removed.  Stop doing the unnecessary stage tracking,
as they are not so useful and are a bit pain to maintain.
Signed-off-by: default avatarReiji Watanabe <reijiw@google.com>
Reviewed-by: default avatarOliver Upton <oliver.upton@linux.dev>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221020054202.2119018-6-reijiw@google.com
parent 152880d8
...@@ -181,23 +181,17 @@ static volatile char write_data; ...@@ -181,23 +181,17 @@ static volatile char write_data;
static void guest_code(uint8_t bpn, uint8_t wpn) static void guest_code(uint8_t bpn, uint8_t wpn)
{ {
GUEST_SYNC(0);
/* Software-breakpoint */ /* Software-breakpoint */
reset_debug_state(); reset_debug_state();
asm volatile("sw_bp: brk #0"); asm volatile("sw_bp: brk #0");
GUEST_ASSERT_EQ(sw_bp_addr, PC(sw_bp)); GUEST_ASSERT_EQ(sw_bp_addr, PC(sw_bp));
GUEST_SYNC(1);
/* Hardware-breakpoint */ /* Hardware-breakpoint */
reset_debug_state(); reset_debug_state();
install_hw_bp(bpn, PC(hw_bp)); install_hw_bp(bpn, PC(hw_bp));
asm volatile("hw_bp: nop"); asm volatile("hw_bp: nop");
GUEST_ASSERT_EQ(hw_bp_addr, PC(hw_bp)); GUEST_ASSERT_EQ(hw_bp_addr, PC(hw_bp));
GUEST_SYNC(2);
/* Hardware-breakpoint + svc */ /* Hardware-breakpoint + svc */
reset_debug_state(); reset_debug_state();
install_hw_bp(bpn, PC(bp_svc)); install_hw_bp(bpn, PC(bp_svc));
...@@ -205,8 +199,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn) ...@@ -205,8 +199,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn)
GUEST_ASSERT_EQ(hw_bp_addr, PC(bp_svc)); GUEST_ASSERT_EQ(hw_bp_addr, PC(bp_svc));
GUEST_ASSERT_EQ(svc_addr, PC(bp_svc) + 4); GUEST_ASSERT_EQ(svc_addr, PC(bp_svc) + 4);
GUEST_SYNC(3);
/* Hardware-breakpoint + software-breakpoint */ /* Hardware-breakpoint + software-breakpoint */
reset_debug_state(); reset_debug_state();
install_hw_bp(bpn, PC(bp_brk)); install_hw_bp(bpn, PC(bp_brk));
...@@ -214,8 +206,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn) ...@@ -214,8 +206,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn)
GUEST_ASSERT_EQ(sw_bp_addr, PC(bp_brk)); GUEST_ASSERT_EQ(sw_bp_addr, PC(bp_brk));
GUEST_ASSERT_EQ(hw_bp_addr, PC(bp_brk)); GUEST_ASSERT_EQ(hw_bp_addr, PC(bp_brk));
GUEST_SYNC(4);
/* Watchpoint */ /* Watchpoint */
reset_debug_state(); reset_debug_state();
install_wp(wpn, PC(write_data)); install_wp(wpn, PC(write_data));
...@@ -223,8 +213,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn) ...@@ -223,8 +213,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn)
GUEST_ASSERT_EQ(write_data, 'x'); GUEST_ASSERT_EQ(write_data, 'x');
GUEST_ASSERT_EQ(wp_data_addr, PC(write_data)); GUEST_ASSERT_EQ(wp_data_addr, PC(write_data));
GUEST_SYNC(5);
/* Single-step */ /* Single-step */
reset_debug_state(); reset_debug_state();
install_ss(); install_ss();
...@@ -238,8 +226,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn) ...@@ -238,8 +226,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn)
GUEST_ASSERT_EQ(ss_addr[1], PC(ss_start) + 4); GUEST_ASSERT_EQ(ss_addr[1], PC(ss_start) + 4);
GUEST_ASSERT_EQ(ss_addr[2], PC(ss_start) + 8); GUEST_ASSERT_EQ(ss_addr[2], PC(ss_start) + 8);
GUEST_SYNC(6);
/* OS Lock does not block software-breakpoint */ /* OS Lock does not block software-breakpoint */
reset_debug_state(); reset_debug_state();
enable_os_lock(); enable_os_lock();
...@@ -247,8 +233,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn) ...@@ -247,8 +233,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn)
asm volatile("sw_bp2: brk #0"); asm volatile("sw_bp2: brk #0");
GUEST_ASSERT_EQ(sw_bp_addr, PC(sw_bp2)); GUEST_ASSERT_EQ(sw_bp_addr, PC(sw_bp2));
GUEST_SYNC(7);
/* OS Lock blocking hardware-breakpoint */ /* OS Lock blocking hardware-breakpoint */
reset_debug_state(); reset_debug_state();
enable_os_lock(); enable_os_lock();
...@@ -257,8 +241,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn) ...@@ -257,8 +241,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn)
asm volatile("hw_bp2: nop"); asm volatile("hw_bp2: nop");
GUEST_ASSERT_EQ(hw_bp_addr, 0); GUEST_ASSERT_EQ(hw_bp_addr, 0);
GUEST_SYNC(8);
/* OS Lock blocking watchpoint */ /* OS Lock blocking watchpoint */
reset_debug_state(); reset_debug_state();
enable_os_lock(); enable_os_lock();
...@@ -269,8 +251,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn) ...@@ -269,8 +251,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn)
GUEST_ASSERT_EQ(write_data, 'x'); GUEST_ASSERT_EQ(write_data, 'x');
GUEST_ASSERT_EQ(wp_data_addr, 0); GUEST_ASSERT_EQ(wp_data_addr, 0);
GUEST_SYNC(9);
/* OS Lock blocking single-step */ /* OS Lock blocking single-step */
reset_debug_state(); reset_debug_state();
enable_os_lock(); enable_os_lock();
...@@ -370,7 +350,6 @@ static void test_guest_debug_exceptions(void) ...@@ -370,7 +350,6 @@ static void test_guest_debug_exceptions(void)
struct kvm_vcpu *vcpu; struct kvm_vcpu *vcpu;
struct kvm_vm *vm; struct kvm_vm *vm;
struct ucall uc; struct ucall uc;
int stage;
vm = vm_create_with_one_vcpu(&vcpu, guest_code); vm = vm_create_with_one_vcpu(&vcpu, guest_code);
ucall_init(vm, NULL); ucall_init(vm, NULL);
...@@ -391,15 +370,9 @@ static void test_guest_debug_exceptions(void) ...@@ -391,15 +370,9 @@ static void test_guest_debug_exceptions(void)
/* Run tests with breakpoint#0 and watchpoint#0. */ /* Run tests with breakpoint#0 and watchpoint#0. */
vcpu_args_set(vcpu, 2, 0, 0); vcpu_args_set(vcpu, 2, 0, 0);
for (stage = 0; stage < 11; stage++) {
vcpu_run(vcpu);
vcpu_run(vcpu);
switch (get_ucall(vcpu, &uc)) { switch (get_ucall(vcpu, &uc)) {
case UCALL_SYNC:
TEST_ASSERT(uc.args[1] == stage,
"Stage %d: Unexpected sync ucall, got %lx",
stage, (ulong)uc.args[1]);
break;
case UCALL_ABORT: case UCALL_ABORT:
REPORT_GUEST_ASSERT_2(uc, "values: %#lx, %#lx"); REPORT_GUEST_ASSERT_2(uc, "values: %#lx, %#lx");
break; break;
...@@ -408,7 +381,6 @@ static void test_guest_debug_exceptions(void) ...@@ -408,7 +381,6 @@ static void test_guest_debug_exceptions(void)
default: default:
TEST_FAIL("Unknown ucall %lu", uc.cmd); TEST_FAIL("Unknown ucall %lu", uc.cmd);
} }
}
done: done:
kvm_vm_free(vm); kvm_vm_free(vm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment