[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2] x86/monitor: Include EAX/ECX in CPUID monitor events
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@xxxxxxxxxxxx> --- Cc: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Wei Liu <wei.liu2@xxxxxxxxxx> Cc: Jan Beulich <jbeulich@xxxxxxxx> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Cc: Jun Nakajima <jun.nakajima@xxxxxxxxx> Cc: Kevin Tian <kevin.tian@xxxxxxxxx> v2: Rename eax/ecx to leaf and subleaf Correct typo --- tools/tests/xen-access/xen-access.c | 4 +++- xen/arch/x86/hvm/monitor.c | 5 ++++- xen/arch/x86/hvm/vmx/vmx.c | 6 +++++- xen/include/asm-x86/hvm/monitor.h | 3 ++- xen/include/public/vm_event.h | 2 ++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/tests/xen-access/xen-access.c b/tools/tests/xen-access/xen-access.c index ebb63b1..ed18c71 100644 --- a/tools/tests/xen-access/xen-access.c +++ b/tools/tests/xen-access/xen-access.c @@ -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, diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c index 7277c12..53ab804 100644 --- a/xen/arch/x86/hvm/monitor.c +++ b/xen/arch/x86/hvm/monitor.c @@ -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); } diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 3d330b6..bb7a329 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -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, diff --git a/xen/include/asm-x86/hvm/monitor.h b/xen/include/asm-x86/hvm/monitor.h index a92f3fc..82b85ec 100644 --- a/xen/include/asm-x86/hvm/monitor.h +++ b/xen/include/asm-x86/hvm/monitor.h @@ -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__ */ diff --git a/xen/include/public/vm_event.h b/xen/include/public/vm_event.h index 64e6857..99d60ea 100644 --- a/xen/include/public/vm_event.h +++ b/xen/include/public/vm_event.h @@ -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; }; -- 2.9.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |