[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] trace/vvmx: Correctly report TRC_HVM_NESTEDFLAG flag



Currently all VMEXITs are reported as if it occured "non-nested",
even when the vCPU is in "guest mode". Making distinguishing
"nested virt" VMEXIT to regular ones much harder.

Fix this by adding TRC_HVM_NESTEDFLAG flag when the guest is in guest
mode, matching the svm logic.

Fixes: ??? (???)
Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
---
I can't really find the commit that introduced vVMX. But I guess it
would be the candidate for the fixes tag.

 xen/arch/x86/hvm/vmx/vmx.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index da657187bc..d13603254d 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -4209,9 +4209,13 @@ void asmlinkage vmx_vmexit_handler(struct cpu_user_regs 
*regs)
     __vmread(VM_EXIT_REASON, &exit_reason);
 
     if ( hvm_long_mode_active(v) )
-        TRACE_TIME(TRC_HVM_VMX_EXIT64, exit_reason, regs->rip, regs->rip >> 
32);
+        TRACE_TIME(TRC_HVM_VMX_EXIT64 |
+                   (nestedhvm_vcpu_in_guestmode(v) ? TRC_HVM_NESTEDFLAG : 0),
+                   exit_reason, regs->rip, regs->rip >> 32);
     else
-        TRACE_TIME(TRC_HVM_VMX_EXIT, exit_reason, regs->eip);
+        TRACE_TIME(TRC_HVM_VMX_EXIT |
+                   (nestedhvm_vcpu_in_guestmode(v) ? TRC_HVM_NESTEDFLAG : 0),
+                   exit_reason, regs->eip);
 
     perfc_incra(vmexits, (uint16_t)exit_reason);
 
@@ -5025,7 +5029,8 @@ bool asmlinkage vmx_vmenter_helper(const struct 
cpu_user_regs *regs)
     if ( unlikely(curr->arch.hvm.vmx.lbr_flags & LBR_FIXUP_MASK) )
         lbr_fixup();
 
-    TRACE_TIME(TRC_HVM_VMENTRY);
+    TRACE_TIME(TRC_HVM_VMENTRY  |
+               (nestedhvm_vcpu_in_guestmode(curr) ? TRC_HVM_NESTEDFLAG : 0));
 
     __vmwrite(GUEST_RIP,    regs->rip);
     __vmwrite(GUEST_RSP,    regs->rsp);
-- 
2.56.0



--
Teddy Astie | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.