[PATCH v9 1/3] KVM: selftests: arm64: Report set_id_reg reads of test registers as tests
Sebastian Ott
seott at redhat.com
Wed Nov 4 03:32:17 PST 2026
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 at arm.com>
> Reviewed-by: Lorenzo Stoakes (ARM) <ljs at kernel.org>
> Signed-off-by: Mark Brown <broonie at kernel.org>
[...]
> @@ -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;
More information about the linux-arm-kernel
mailing list