]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86: Trace hypercall register *after* truncating values for 32-bit
authorSean Christopherson <seanjc@google.com>
Fri, 29 May 2026 22:21:48 +0000 (15:21 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 3 Jun 2026 12:34:47 +0000 (05:34 -0700)
When tracing hypercalls, invoke the tracepoint *after* truncating the
register values for 32-bit guests so as not to record unused garbage (in
the extremely unlikely scenario that the guest left garbage in a register
after transitioning from 64-bit mode to 32-bit mode).

Fixes: 229456fc34b1 ("KVM: convert custom marker based tracing to event traces")
Reviewed-by: Yosry Ahmed <yosry@kernel.org>
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
Link: https://patch.msgid.link/20260529222223.870923-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c

index 57ce0f1f1860b29d79b30d03211e0d46e6735a0d..63ee091aed70993a47fb38e2c234b321195d590d 100644 (file)
@@ -10433,8 +10433,6 @@ int ____kvm_emulate_hypercall(struct kvm_vcpu *vcpu, int cpl,
 
        ++vcpu->stat.hypercalls;
 
-       trace_kvm_hypercall(nr, a0, a1, a2, a3);
-
        if (!op_64_bit) {
                nr &= 0xFFFFFFFF;
                a0 &= 0xFFFFFFFF;
@@ -10443,6 +10441,8 @@ int ____kvm_emulate_hypercall(struct kvm_vcpu *vcpu, int cpl,
                a3 &= 0xFFFFFFFF;
        }
 
+       trace_kvm_hypercall(nr, a0, a1, a2, a3);
+
        if (cpl) {
                ret = -KVM_EPERM;
                goto out;