Re: [PATCH v9 1/3] KVM: selftests: arm64: Report set_id_reg reads of test registers as tests

From: Sebastian Ott

Date: Wed Nov 04 2026 - 06:33:44 EST


On Tue, 3 Nov 2026, Mark Brown wrote:
Currently when we run guest code to validate that the values we wrote to
the registers are seen by the guest we assert that these values match using
a KVM selftests level assert, resulting in unclear diagnostics if the test
fails. Replace this assert with reporting a kselftest test per register.

In order to support getting the names of the registers we repaint the array
of ID_ registers to store the names and open code the rest.

Reviewed-by: Ben Horgan <ben.horgan@xxxxxxx>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
[...]
@@ -684,11 +719,20 @@ static void test_guest_reg_read(struct kvm_vcpu *vcpu)
REPORT_GUEST_ASSERT(uc);
break;
case UCALL_SYNC:
- val = test_reg_vals[encoding_to_range_idx(uc.args[2])];
- val = reset_mutable_bits(uc.args[2], val);
+ expected_val = test_reg_vals[encoding_to_range_idx(uc.args[2])];
+ expected_val = reset_mutable_bits(uc.args[2], expected_val);

/* Make sure the written values are seen by guest */
- TEST_ASSERT_EQ(val, reset_mutable_bits(uc.args[2], uc.args[3]));
+ reg_id = uc.args[2];
^
Minor nit: this could be moved above and be used in 3 more places.

+ guest_val = reset_mutable_bits(uc.args[2], uc.args[3]);
+
+ match = expected_val == guest_val;
+ if (!match)
+ ksft_print_msg("%lx != %lx\n",
+ expected_val, guest_val);
+ ksft_test_result(match,
+ "%s value seen in guest\n",
+ get_reg_name(reg_id));
break;
case UCALL_DONE:
done = true;