x86/monitor: include EAX/ECX in CPUID monitor events
authorTamas K Lengyel <tamas.lengyel@zentific.com>
Mon, 5 Sep 2016 10:47:16 +0000 (12:47 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 5 Sep 2016 10:47:16 +0000 (12:47 +0200)
Extend the CPUID monitor event to include EAX and ECX values that were used
when CPUID was executed. This is useful in identifying which leaf was queried.
We also adjust the xen-access output format to more closely resemble the output
of the Linux cpuid tool's raw format.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/tests/xen-access/xen-access.c
xen/arch/x86/hvm/monitor.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/monitor.h
xen/include/public/vm_event.h

index ebb63b168e9f544b773f29f882aa57c36c347af9..ed18c71f96e47fe11fc69ce6764c9b48bfd2ef69 100644 (file)
@@ -735,10 +735,12 @@ int main(int argc, char *argv[])
                 break;
             case VM_EVENT_REASON_CPUID:
                 printf("CPUID executed: rip=%016"PRIx64", vcpu %d. Insn length: %"PRIu32" " \
-                       "EAX: 0x%"PRIx64" EBX: 0x%"PRIx64" ECX: 0x%"PRIx64" EDX: 0x%"PRIx64"\n",
+                       "0x%"PRIx32" 0x%"PRIx32": EAX=0x%"PRIx64" EBX=0x%"PRIx64" ECX=0x%"PRIx64" EDX=0x%"PRIx64"\n",
                        req.data.regs.x86.rip,
                        req.vcpu_id,
                        req.u.cpuid.insn_length,
+                       req.u.cpuid.leaf,
+                       req.u.cpuid.subleaf,
                        req.data.regs.x86.rax,
                        req.data.regs.x86.rbx,
                        req.data.regs.x86.rcx,
index 7277c127d91153e59d466b25e7fbd4b63b43deef..53ab804be183ad6b4ce03a29b9e39d442eaeda95 100644 (file)
@@ -136,7 +136,8 @@ int hvm_monitor_debug(unsigned long rip, enum hvm_monitor_debug_type type,
     return monitor_traps(curr, sync, &req);
 }
 
-int hvm_monitor_cpuid(unsigned long insn_length)
+int hvm_monitor_cpuid(unsigned long insn_length, unsigned int leaf,
+                      unsigned int subleaf)
 {
     struct vcpu *curr = current;
     struct arch_domain *ad = &curr->domain->arch;
@@ -148,6 +149,8 @@ int hvm_monitor_cpuid(unsigned long insn_length)
     req.reason = VM_EVENT_REASON_CPUID;
     req.vcpu_id = curr->vcpu_id;
     req.u.cpuid.insn_length = insn_length;
+    req.u.cpuid.leaf = leaf;
+    req.u.cpuid.subleaf = subleaf;
 
     return monitor_traps(curr, 1, &req);
 }
index 3d330b6eedc0613e86df9d4ff06d69d13dc9b521..bb7a329ab8f9001b8b3af8c2cd733c98bfd623eb 100644 (file)
@@ -2402,12 +2402,16 @@ static void vmx_cpuid_intercept(
 static int vmx_do_cpuid(struct cpu_user_regs *regs)
 {
     unsigned int eax, ebx, ecx, edx;
+    unsigned int leaf, subleaf;
 
     eax = regs->eax;
     ebx = regs->ebx;
     ecx = regs->ecx;
     edx = regs->edx;
 
+    leaf = regs->eax;
+    subleaf = regs->ecx;
+
     vmx_cpuid_intercept(&eax, &ebx, &ecx, &edx);
 
     regs->eax = eax;
@@ -2415,7 +2419,7 @@ static int vmx_do_cpuid(struct cpu_user_regs *regs)
     regs->ecx = ecx;
     regs->edx = edx;
 
-    return hvm_monitor_cpuid(get_instruction_length());
+    return hvm_monitor_cpuid(get_instruction_length(), leaf, subleaf);
 }
 
 static void vmx_dr_access(unsigned long exit_qualification,
index a92f3fc9a1411f18aa6846df877f179b06c052fe..82b85ecd72fcb5973e6023e4ba54107f9a0859c8 100644 (file)
@@ -40,7 +40,8 @@ bool_t hvm_monitor_cr(unsigned int index, unsigned long value,
 void hvm_monitor_msr(unsigned int msr, uint64_t value);
 int hvm_monitor_debug(unsigned long rip, enum hvm_monitor_debug_type type,
                       unsigned long trap_type, unsigned long insn_length);
-int hvm_monitor_cpuid(unsigned long insn_length);
+int hvm_monitor_cpuid(unsigned long insn_length, unsigned int leaf,
+                      unsigned int subleaf);
 
 #endif /* __ASM_X86_HVM_MONITOR_H__ */
 
index 64e6857ed947db9aa88b23029232f5f9fe9f7df5..99d60ead9989efc91c43e7bb0745cbfeef93361e 100644 (file)
@@ -226,6 +226,8 @@ struct vm_event_mov_to_msr {
 
 struct vm_event_cpuid {
     uint32_t insn_length;
+    uint32_t leaf;
+    uint32_t subleaf;
     uint32_t _pad;
 };