Skip to content

Commit 948f439

Browse files
reijiw-kvmMarc Zyngier
authored andcommitted
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: Reiji Watanabe <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 152880d commit 948f439

File tree

1 file changed

+9
-37
lines changed

1 file changed

+9
-37
lines changed

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

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -181,50 +181,38 @@ static volatile char write_data;
181181

182182
static void guest_code(uint8_t bpn, uint8_t wpn)
183183
{
184-
GUEST_SYNC(0);
185-
186184
/* Software-breakpoint */
187185
reset_debug_state();
188186
asm volatile("sw_bp: brk #0");
189187
GUEST_ASSERT_EQ(sw_bp_addr, PC(sw_bp));
190188

191-
GUEST_SYNC(1);
192-
193189
/* Hardware-breakpoint */
194190
reset_debug_state();
195191
install_hw_bp(bpn, PC(hw_bp));
196192
asm volatile("hw_bp: nop");
197193
GUEST_ASSERT_EQ(hw_bp_addr, PC(hw_bp));
198194

199-
GUEST_SYNC(2);
200-
201195
/* Hardware-breakpoint + svc */
202196
reset_debug_state();
203197
install_hw_bp(bpn, PC(bp_svc));
204198
asm volatile("bp_svc: svc #0");
205199
GUEST_ASSERT_EQ(hw_bp_addr, PC(bp_svc));
206200
GUEST_ASSERT_EQ(svc_addr, PC(bp_svc) + 4);
207201

208-
GUEST_SYNC(3);
209-
210202
/* Hardware-breakpoint + software-breakpoint */
211203
reset_debug_state();
212204
install_hw_bp(bpn, PC(bp_brk));
213205
asm volatile("bp_brk: brk #0");
214206
GUEST_ASSERT_EQ(sw_bp_addr, PC(bp_brk));
215207
GUEST_ASSERT_EQ(hw_bp_addr, PC(bp_brk));
216208

217-
GUEST_SYNC(4);
218-
219209
/* Watchpoint */
220210
reset_debug_state();
221211
install_wp(wpn, PC(write_data));
222212
write_data = 'x';
223213
GUEST_ASSERT_EQ(write_data, 'x');
224214
GUEST_ASSERT_EQ(wp_data_addr, PC(write_data));
225215

226-
GUEST_SYNC(5);
227-
228216
/* Single-step */
229217
reset_debug_state();
230218
install_ss();
@@ -238,17 +226,13 @@ static void guest_code(uint8_t bpn, uint8_t wpn)
238226
GUEST_ASSERT_EQ(ss_addr[1], PC(ss_start) + 4);
239227
GUEST_ASSERT_EQ(ss_addr[2], PC(ss_start) + 8);
240228

241-
GUEST_SYNC(6);
242-
243229
/* OS Lock does not block software-breakpoint */
244230
reset_debug_state();
245231
enable_os_lock();
246232
sw_bp_addr = 0;
247233
asm volatile("sw_bp2: brk #0");
248234
GUEST_ASSERT_EQ(sw_bp_addr, PC(sw_bp2));
249235

250-
GUEST_SYNC(7);
251-
252236
/* OS Lock blocking hardware-breakpoint */
253237
reset_debug_state();
254238
enable_os_lock();
@@ -257,8 +241,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn)
257241
asm volatile("hw_bp2: nop");
258242
GUEST_ASSERT_EQ(hw_bp_addr, 0);
259243

260-
GUEST_SYNC(8);
261-
262244
/* OS Lock blocking watchpoint */
263245
reset_debug_state();
264246
enable_os_lock();
@@ -269,8 +251,6 @@ static void guest_code(uint8_t bpn, uint8_t wpn)
269251
GUEST_ASSERT_EQ(write_data, 'x');
270252
GUEST_ASSERT_EQ(wp_data_addr, 0);
271253

272-
GUEST_SYNC(9);
273-
274254
/* OS Lock blocking single-step */
275255
reset_debug_state();
276256
enable_os_lock();
@@ -370,7 +350,6 @@ static void test_guest_debug_exceptions(void)
370350
struct kvm_vcpu *vcpu;
371351
struct kvm_vm *vm;
372352
struct ucall uc;
373-
int stage;
374353

375354
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
376355
ucall_init(vm, NULL);
@@ -391,23 +370,16 @@ static void test_guest_debug_exceptions(void)
391370

392371
/* Run tests with breakpoint#0 and watchpoint#0. */
393372
vcpu_args_set(vcpu, 2, 0, 0);
394-
for (stage = 0; stage < 11; stage++) {
395-
vcpu_run(vcpu);
396373

397-
switch (get_ucall(vcpu, &uc)) {
398-
case UCALL_SYNC:
399-
TEST_ASSERT(uc.args[1] == stage,
400-
"Stage %d: Unexpected sync ucall, got %lx",
401-
stage, (ulong)uc.args[1]);
402-
break;
403-
case UCALL_ABORT:
404-
REPORT_GUEST_ASSERT_2(uc, "values: %#lx, %#lx");
405-
break;
406-
case UCALL_DONE:
407-
goto done;
408-
default:
409-
TEST_FAIL("Unknown ucall %lu", uc.cmd);
410-
}
374+
vcpu_run(vcpu);
375+
switch (get_ucall(vcpu, &uc)) {
376+
case UCALL_ABORT:
377+
REPORT_GUEST_ASSERT_2(uc, "values: %#lx, %#lx");
378+
break;
379+
case UCALL_DONE:
380+
goto done;
381+
default:
382+
TEST_FAIL("Unknown ucall %lu", uc.cmd);
411383
}
412384

413385
done:

0 commit comments

Comments
 (0)