[PATCH 01/12] KVM: selftests: Minor improvements to asserts in test_vmx_nested_state()

Yosry Ahmed
2025-10-01T14:58:41Z

From: Yosry Ahmed <yosryahmed@google.com>

Display the address as hex if the asserts for the vmxon_pa and vmcs12_pa
fail, and assert that the flags are 0 as expected.

Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
---
.../selftests/kvm/x86/vmx_set_nested_state_test.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/x86/vmx_set_nested_state_test.c b/tools/testing/selftests/kvm/x86/vmx_set_nested_state_test.c
index 67a62a5a88951..c4c400d2824c1 100644
--- a/tools/testing/selftests/kvm/x86/vmx_set_nested_state_test.c
+++ b/tools/testing/selftests/kvm/x86/vmx_set_nested_state_test.c
@@ -241,8 +241,14 @@ void test_vmx_nested_state(struct kvm_vcpu *vcpu)
TEST_ASSERT(state->size >= sizeof(*state) && state->size <= state_sz,
"Size must be between %ld and %d. The size returned was %d.",
sizeof(*state), state_sz, state->size);
- TEST_ASSERT(state->hdr.vmx.vmxon_pa == -1ull, "vmxon_pa must be -1ull.");
- TEST_ASSERT(state->hdr.vmx.vmcs12_pa == -1ull, "vmcs_pa must be -1ull.");
+ TEST_ASSERT(state->hdr.vmx.vmxon_pa == -1ull,
+ "vmxon_pa must be 0x%llx, but was 0x%llx",
+ -1ull, state->hdr.vmx.vmxon_pa);
+ TEST_ASSERT(state->hdr.vmx.vmcs12_pa == -1ull,
+ "vmcs12_pa must be 0x%llx, but was 0x%llx",
+ -1llu, state->hdr.vmx.vmcs12_pa);
+ TEST_ASSERT(state->flags == 0,
+ "Flags must be equal to 0, but was 0x%hx", state->flags);

free(state);
}
--
2.51.0.618.g983fd99d29-goog