VMX: sync VM-exit perf counters with known VM-exit reasons
authorJan Beulich <jbeulich@suse.com>
Mon, 31 Jan 2022 09:56:28 +0000 (10:56 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 31 Jan 2022 09:56:28 +0000 (10:56 +0100)
This has gone out of sync over time. Introduce a simplistic mechanism to
hopefully keep things in sync going forward.

Also limit the array index to just the "basic exit reason" part, which is
what the pseudo-enumeration covers.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/include/asm/hvm/vmx/vmx.h
xen/arch/x86/include/asm/perfc_defn.h

index 9765cfd90a0a9472d34c99233846b20f2239ad03..36c8a12cfe7d03eb312892e42f63b7b708606fa0 100644 (file)
@@ -3928,7 +3928,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
     else
         HVMTRACE_ND(VMEXIT, 0, 1/*cycles*/, exit_reason, regs->eip);
 
-    perfc_incra(vmexits, exit_reason);
+    perfc_incra(vmexits, (uint16_t)exit_reason);
 
     /* Handle the interrupt we missed before allowing any more in. */
     switch ( (uint16_t)exit_reason )
index 85530d2e0e26ac1bcfe20d668127c1706c1e2180..97e7652aa12c232df1c7a975682495d142a3aa2e 100644 (file)
@@ -219,6 +219,7 @@ static inline void pi_clear_sn(struct pi_desc *pi_desc)
 #define EXIT_REASON_PML_FULL            62
 #define EXIT_REASON_XSAVES              63
 #define EXIT_REASON_XRSTORS             64
+/* Remember to also update VMX_PERF_EXIT_REASON_SIZE! */
 
 /*
  * Interruption-information format
index a98df515d951fba1499a0ed25c080316a4b16767..896c5397f5b1c229e4d10ecf52301c26ec5c7759 100644 (file)
@@ -6,7 +6,7 @@ PERFCOUNTER_ARRAY(exceptions,           "exceptions", 32)
 
 #ifdef CONFIG_HVM
 
-#define VMX_PERF_EXIT_REASON_SIZE 56
+#define VMX_PERF_EXIT_REASON_SIZE 65
 #define VMX_PERF_VECTOR_SIZE 0x20
 PERFCOUNTER_ARRAY(vmexits,              "vmexits", VMX_PERF_EXIT_REASON_SIZE)
 PERFCOUNTER_ARRAY(cause_vector,         "cause vector", VMX_PERF_VECTOR_SIZE)