diff mbox series

[WIP,11/14] x86/trace: Add trace to xsetbv svm/vmx handler path

Message ID 20240626133853.4150731-12-george.dunlap@cloud.com (mailing list archive)
State New
Headers show
Series AMD Nested Virt Preparation | expand

Commit Message

George Dunlap June 26, 2024, 1:38 p.m. UTC
There are already "HVM handler" trace records for writing to XCRs in
the context of an HVM guest.  This trace is currently taken in
hvmemul_write_xcr.

However, both VMX and SVM vmexits call hvm_handle_xsetbv as a result
of an XSETBV vmexit, and hvm_handle_xsetbv calls x86emul_write_xcr
directly, bypassing the trace, resulting in no "HVM handler" trace
record for that VMEXIT.

For maximal DRY-ness, we would want hvm_handle_xsetbv to call
hvmemul_write_xcr; but since the intent seems to be for hvmemul_* to
be only accesible via hvm_emulate(), just duplicate the trace.

Signed-off-by: George Dunlap <george.dunlap@cloud.com>
---
CC: Andrew Cooper <andrew.cooper@cloud.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Roger Pau Monne <roger.pau@cloud.com>
---
 xen/arch/x86/hvm/hvm.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 0fe2b85b16..628a131399 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2073,6 +2073,8 @@  int hvm_handle_xsetbv(u32 index, u64 new_bv)
     if ( index == 0 )
         hvm_monitor_crX(XCR0, new_bv, current->arch.xcr0);
 
+    TRACE(TRC_HVM_XCR_WRITE64, index, new_bv, new_bv >> 32);
+
     rc = x86emul_write_xcr(index, new_bv, NULL);
     if ( rc != X86EMUL_OKAY )
         hvm_inject_hw_exception(X86_EXC_GP, 0);