KVM: selftests: x86: sync_regs_test: Get regs structure before modifying it
authorThomas Huth <thuth@redhat.com>
Thu, 8 Feb 2024 20:48:38 +0000 (21:48 +0100)
committerSean Christopherson <seanjc@google.com>
Tue, 27 Feb 2024 02:08:36 +0000 (18:08 -0800)
The regs structure just accidentally contains the right values
from the previous test in the spot where we want to change rbx.
It's cleaner if we properly initialize the structure here before
using it.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Link: https://lore.kernel.org/r/20240208204844.119326-3-thuth@redhat.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/x86_64/sync_regs_test.c

index 8c3898cf79b319f91aca0dee4cc7604a7102b222..1cd19dfa0046c47791aa248446a02673f8fdb205 100644 (file)
@@ -315,6 +315,7 @@ int main(int argc, char *argv[])
        run->kvm_valid_regs = 0;
        run->kvm_dirty_regs = 0;
        run->s.regs.regs.rbx = 0xAAAA;
+       vcpu_regs_get(vcpu, &regs);
        regs.rbx = 0xBAC0;
        vcpu_regs_set(vcpu, &regs);
        vcpu_run(vcpu);