[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 06/16] hypervisor part of convert vmware_port to xentrace usage
Reduce the VMPORT_DBG_LOG calls. Signed-off-by: Don Slutz <dslutz@xxxxxxxxxxx> --- xen/arch/x86/hvm/svm/svm.c | 21 +++++++++------ xen/arch/x86/hvm/vmware/vmport.c | 57 ++++++++++++++++++++++------------------ xen/arch/x86/hvm/vmx/vmx.c | 20 ++++++++------ xen/include/asm-x86/hvm/trace.h | 38 +++++++++++++++++++++++++++ xen/include/asm-x86/hvm/vmport.h | 7 ----- xen/include/public/trace.h | 12 +++++++++ 6 files changed, 107 insertions(+), 48 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 12079be..4acbbee 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -2081,19 +2081,24 @@ static void svm_vmexit_gp_intercept(struct cpu_user_regs *regs, inst_len = __get_instruction_length_from_list( v, list, ARRAY_SIZE(list), 0); + if ( hvm_long_mode_enabled(v) ) + HVMTRACE_LONG_C3D(TRAP_GP, inst_len, regs->error_code, + TRC_PAR_LONG(vmcb->exitinfo2)); + else + HVMTRACE_C3D(TRAP_GP, inst_len, regs->error_code, vmcb->exitinfo2); + rc = vmport_gp_check(regs, v, inst_len, inst_addr, vmcb->exitinfo2); if ( !rc ) __update_guest_eip(regs, inst_len); else { - VMPORT_DBG_LOG(VMPORT_LOG_GP_UNKNOWN, - "gp: rc=%d e2=%lx ec=%lx ip=%"PRIx64" (%ld) ax=%"PRIx64 - " bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%"PRIx64 - " di=%"PRIx64, rc, - (unsigned long)vmcb->exitinfo2, - (unsigned long)regs->error_code, - regs->rip, inst_len, regs->rax, regs->rbx, regs->rcx, - regs->rdx, regs->rsi, regs->rdi); + if ( hvm_long_mode_enabled(v) ) + HVMTRACE_LONG_C5D(TRAP_GP_UNKNOWN, rc, regs->rax, regs->rbx, regs->rcx, + TRC_PAR_LONG(inst_addr)); + else + HVMTRACE_C5D(TRAP_GP_UNKNOWN, rc, regs->rax, regs->rbx, regs->rcx, + inst_addr); + hvm_inject_hw_exception(TRAP_gp_fault, regs->error_code); } } diff --git a/xen/arch/x86/hvm/vmware/vmport.c b/xen/arch/x86/hvm/vmware/vmport.c index a6fd95c..0ee2db3 100644 --- a/xen/arch/x86/hvm/vmware/vmport.c +++ b/xen/arch/x86/hvm/vmware/vmport.c @@ -18,6 +18,7 @@ #include <asm/hvm/hvm.h> #include <asm/hvm/support.h> #include <asm/hvm/vmport.h> +#include <asm/hvm/trace.h> #include "backdoor_def.h" #include "guest_msg_def.h" @@ -69,12 +70,15 @@ int vmport_ioport(int dir, uint32_t port, uint32_t bytes, uint32_t *val) uint64_t saved_rax = regs->rax; uint64_t value; - VMPORT_DBG_LOG(VMPORT_LOG_TRACE, - "VMware trace dir=%d bytes=%u ip=%"PRIx64" cmd=%d ax=%" - PRIx64" bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%" - PRIx64" di=%"PRIx64"\n", dir, bytes, - regs->rip, cmd, regs->rax, regs->rbx, regs->rcx, - regs->rdx, regs->rsi, regs->rdi); + if ( dir == IOREQ_READ ) + HVMTRACE_ND(VMPORT_READ_BEFORE, 0, 1/*cycles*/, 6, + regs->rax, regs->rbx, regs->rcx, + regs->rdx, regs->rsi, regs->rdi); + else + HVMTRACE_ND(VMPORT_WRITE_AFTER_BEFORE, 0, 1/*cycles*/, 6, + regs->rax, regs->rbx, regs->rcx, + regs->rdx, regs->rsi, regs->rdi); + switch ( cmd ) { case BDOOR_CMD_GETMHZ: @@ -144,19 +148,17 @@ int vmport_ioport(int dir, uint32_t port, uint32_t bytes, uint32_t *val) regs->rax = 0x0; break; default: - VMPORT_DBG_LOG(VMPORT_LOG_ERROR, - "VMware bytes=%d dir=%d cmd=%d", - bytes, dir, cmd); + HVMTRACE_ND(VMPORT_UNKNOWN, 0, 1/*cycles*/, 6, + (bytes << 8) + dir, cmd, regs->rbx, + regs->rcx, regs->rsi, regs->rdi); break; } - VMPORT_DBG_LOG(VMPORT_LOG_VMWARE_AFTER, - "VMware after ip=%"PRIx64" cmd=%d ax=%"PRIx64" bx=%" - PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%"PRIx64" di=%" - PRIx64"\n", - regs->rip, cmd, regs->rax, regs->rbx, regs->rcx, - regs->rdx, regs->rsi, regs->rdi); + if ( dir == IOREQ_READ ) { + HVMTRACE_ND(VMPORT_READ_AFTER, 0, 1/*cycles*/, 6, + regs->rax, regs->rbx, regs->rcx, + regs->rdx, regs->rsi, regs->rdi); switch ( bytes ) { case 1: @@ -172,17 +174,22 @@ int vmport_ioport(int dir, uint32_t port, uint32_t bytes, uint32_t *val) *val = regs->rax; } else + { + HVMTRACE_ND(VMPORT_WRITE_AFTER, 0, 1/*cycles*/, 6, + regs->rax, regs->rbx, regs->rcx, + regs->rdx, regs->rsi, regs->rdi); regs->rax = saved_rax; + } } else { + if ( hvm_long_mode_enabled(current) ) + HVMTRACE_LONG_C4D(VMPORT_BAD, dir, bytes, regs->rax, + TRC_PAR_LONG(regs->rip)); + else + HVMTRACE_C4D(VMPORT_BAD, dir, bytes, regs->rax, regs->rip); + rc = X86EMUL_UNHANDLEABLE; - VMPORT_DBG_LOG(VMPORT_LOG_ERROR, - "Not VMware %x vs %x; ip=%"PRIx64" ax=%"PRIx64 - " bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%"PRIx64 - " di=%"PRIx64"", - magic, BDOOR_MAGIC, regs->rip, regs->rax, regs->rbx, - regs->rcx, regs->rdx, regs->rsi, regs->rdi); } return rc; @@ -243,7 +250,7 @@ int vmport_gp_check(struct cpu_user_regs *regs, struct vcpu *v, if ( bytes[i] == 0xed ) /* in (%dx),%eax or in (%dx),%ax */ { rc = vmport_ioport(IOREQ_READ, BDOOR_PORT, byte_cnt, &val); - VMPORT_DBG_LOG(VMPORT_LOG_VMWARE_AFTER, + VMPORT_DBG_LOG(VMPORT_LOG_GP_VMWARE_AFTER, "gp: VMwareIn rc=%d ip=%"PRIx64" byte_cnt=%d ax=%" PRIx64" bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64 " si=%"PRIx64" di=%"PRIx64, rc, @@ -254,7 +261,7 @@ int vmport_gp_check(struct cpu_user_regs *regs, struct vcpu *v, else if ( bytes[i] == 0xec ) /* in (%dx),%al */ { rc = vmport_ioport(IOREQ_READ, BDOOR_PORT, 1, &val); - VMPORT_DBG_LOG(VMPORT_LOG_VMWARE_AFTER, + VMPORT_DBG_LOG(VMPORT_LOG_GP_VMWARE_AFTER, "gp: VMwareIn rc=%d ip=%"PRIx64" byte_cnt=1 ax=%" PRIx64" bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64 " si=%"PRIx64" di=%"PRIx64, rc, @@ -265,7 +272,7 @@ int vmport_gp_check(struct cpu_user_regs *regs, struct vcpu *v, else if ( bytes[i] == 0xef ) /* out %eax,(%dx) or out %ax,(%dx) */ { rc = vmport_ioport(IOREQ_WRITE, BDOOR_PORT, byte_cnt, &val); - VMPORT_DBG_LOG(VMPORT_LOG_VMWARE_AFTER, + VMPORT_DBG_LOG(VMPORT_LOG_GP_VMWARE_AFTER, "gp: VMwareOut rc=%d ip=%"PRIx64" byte_cnt=%d ax=%" PRIx64" bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64 " si=%"PRIx64" di=%"PRIx64, rc, @@ -276,7 +283,7 @@ int vmport_gp_check(struct cpu_user_regs *regs, struct vcpu *v, else if ( bytes[i] == 0xee ) /* out %al,(%dx) */ { rc = vmport_ioport(IOREQ_WRITE, BDOOR_PORT, 1, &val); - VMPORT_DBG_LOG(VMPORT_LOG_VMWARE_AFTER, + VMPORT_DBG_LOG(VMPORT_LOG_GP_VMWARE_AFTER, "gp: VMwareOut rc=%d ip=%"PRIx64" byte_cnt=1 ax=%" PRIx64" bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64 " si=%"PRIx64" di=%"PRIx64, rc, diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index eaa6df2..9d9ee9d 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2594,19 +2594,23 @@ static void vmx_vmexit_gp_intercept(struct cpu_user_regs *regs, __vmread(VM_EXIT_INTR_ERROR_CODE, &ecode); regs->error_code = ecode; + if ( hvm_long_mode_enabled(v) ) + HVMTRACE_LONG_C3D(TRAP_GP, inst_len, ecode, + TRC_PAR_LONG(exit_qualification)); + else + HVMTRACE_C3D(TRAP_GP, inst_len, ecode, exit_qualification); + rc = vmport_gp_check(regs, v, inst_len, inst_addr, exit_qualification); if ( !rc ) update_guest_eip(); else { - VMPORT_DBG_LOG(VMPORT_LOG_GP_UNKNOWN, - "gp: rc=%d e2=%lx ec=%lx ip=%"PRIx64" (%ld) ax=%"PRIx64 - " bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%"PRIx64 - " di=%"PRIx64, rc, - (unsigned long)exit_qualification, - (unsigned long)regs->error_code, - regs->rip, inst_len, regs->rax, regs->rbx, regs->rcx, - regs->rdx, regs->rsi, regs->rdi); + if ( hvm_long_mode_enabled(v) ) + HVMTRACE_LONG_C5D(TRAP_GP_UNKNOWN, rc, regs->rax, regs->rbx, regs->rcx, + TRC_PAR_LONG(inst_addr)); + else + HVMTRACE_C5D(TRAP_GP_UNKNOWN, rc, regs->rax, regs->rbx, regs->rcx, + inst_addr); hvm_inject_hw_exception(TRAP_gp_fault, regs->error_code); } } diff --git a/xen/include/asm-x86/hvm/trace.h b/xen/include/asm-x86/hvm/trace.h index de802a6..86c0548 100644 --- a/xen/include/asm-x86/hvm/trace.h +++ b/xen/include/asm-x86/hvm/trace.h @@ -52,8 +52,20 @@ #define DO_TRC_HVM_LMSW64 DEFAULT_HVM_MISC #define DO_TRC_HVM_REALMODE_EMULATE DEFAULT_HVM_MISC #define DO_TRC_HVM_TRAP DEFAULT_HVM_MISC +#define DO_TRC_HVM_TRAP64 DEFAULT_HVM_MISC #define DO_TRC_HVM_TRAP_DEBUG DEFAULT_HVM_MISC #define DO_TRC_HVM_VLAPIC DEFAULT_HVM_MISC +#define DO_TRC_HVM_TRAP_GP DEFAULT_HVM_MISC +#define DO_TRC_HVM_TRAP_GP64 DEFAULT_HVM_MISC +#define DO_TRC_HVM_TRAP_GP_UNKNOWN DEFAULT_HVM_MISC +#define DO_TRC_HVM_TRAP_GP_UNKNOWN64 DEFAULT_HVM_MISC +#define DO_TRC_HVM_VMPORT_READ_BEFORE DEFAULT_HVM_IO +#define DO_TRC_HVM_VMPORT_WRITE_AFTER_BEFORE DEFAULT_HVM_IO +#define DO_TRC_HVM_VMPORT_READ_AFTER DEFAULT_HVM_IO +#define DO_TRC_HVM_VMPORT_WRITE_AFTER DEFAULT_HVM_IO +#define DO_TRC_HVM_VMPORT_BAD DEFAULT_HVM_IO +#define DO_TRC_HVM_VMPORT_BAD64 DEFAULT_HVM_IO +#define DO_TRC_HVM_VMPORT_UNKNOWN DEFAULT_HVM_IO #define TRC_PAR_LONG(par) ((par)&0xFFFFFFFF),((par)>>32) @@ -98,6 +110,21 @@ #define HVMTRACE_0D(evt) \ HVMTRACE_ND(evt, 0, 0, 0, 0, 0, 0, 0, 0, 0) +#define HVMTRACE_C6D(evt, d1, d2, d3, d4, d5, d6) \ + HVMTRACE_ND(evt, 0, 1, 6, d1, d2, d3, d4, d5, d6) +#define HVMTRACE_C5D(evt, d1, d2, d3, d4, d5) \ + HVMTRACE_ND(evt, 0, 1, 5, d1, d2, d3, d4, d5, 0) +#define HVMTRACE_C4D(evt, d1, d2, d3, d4) \ + HVMTRACE_ND(evt, 0, 1, 4, d1, d2, d3, d4, 0, 0) +#define HVMTRACE_C3D(evt, d1, d2, d3) \ + HVMTRACE_ND(evt, 0, 1, 3, d1, d2, d3, 0, 0, 0) +#define HVMTRACE_C2D(evt, d1, d2) \ + HVMTRACE_ND(evt, 0, 1, 2, d1, d2, 0, 0, 0, 0) +#define HVMTRACE_C1D(evt, d1) \ + HVMTRACE_ND(evt, 0, 1, 1, d1, 0, 0, 0, 0, 0) +#define HVMTRACE_C0D(evt) \ + HVMTRACE_ND(evt, 0, 1, 0, 0, 0, 0, 0, 0, 0) + #define HVMTRACE_LONG_1D(evt, d1) \ HVMTRACE_2D(evt ## 64, (d1) & 0xFFFFFFFF, (d1) >> 32) #define HVMTRACE_LONG_2D(evt, d1, d2, ...) \ @@ -107,6 +134,17 @@ #define HVMTRACE_LONG_4D(evt, d1, d2, d3, d4, ...) \ HVMTRACE_5D(evt ## 64, d1, d2, d3, d4) +#define HVMTRACE_LONG_C1D(evt, d1) \ + HVMTRACE_C2D(evt ## 64, (d1) & 0xFFFFFFFF, (d1) >> 32) +#define HVMTRACE_LONG_C2D(evt, d1, d2, ...) \ + HVMTRACE_C3D(evt ## 64, d1, d2) +#define HVMTRACE_LONG_C3D(evt, d1, d2, d3, ...) \ + HVMTRACE_C4D(evt ## 64, d1, d2, d3) +#define HVMTRACE_LONG_C4D(evt, d1, d2, d3, d4, ...) \ + HVMTRACE_C5D(evt ## 64, d1, d2, d3, d4) +#define HVMTRACE_LONG_C5D(evt, d1, d2, d3, d4, d5, ...) \ + HVMTRACE_C6D(evt ## 64, d1, d2, d3, d4, d5) + #endif /* __ASM_X86_HVM_TRACE_H__ */ /* diff --git a/xen/include/asm-x86/hvm/vmport.h b/xen/include/asm-x86/hvm/vmport.h index 9d72b37..4dec094 100644 --- a/xen/include/asm-x86/hvm/vmport.h +++ b/xen/include/asm-x86/hvm/vmport.h @@ -24,13 +24,6 @@ #define VMPORT_LOG_VGP_UNKNOWN (1 << 2) #define VMPORT_LOG_REALMODE_GP (1 << 3) -#define VMPORT_LOG_GP_UNKNOWN (1 << 8) -#define VMPORT_LOG_GP_NOT_VMWARE (1 << 9) - -#define VMPORT_LOG_TRACE (1 << 16) -#define VMPORT_LOG_ERROR (1 << 17) -#define VMPORT_LOG_VMWARE_AFTER (1 << 18) - extern unsigned int opt_vmport_debug; #define VMPORT_DBG_LOG(level, _f, _a...) \ do { \ diff --git a/xen/include/public/trace.h b/xen/include/public/trace.h index cfcf4aa..ae3613c 100644 --- a/xen/include/public/trace.h +++ b/xen/include/public/trace.h @@ -224,11 +224,23 @@ #define TRC_HVM_NPF (TRC_HVM_HANDLER + 0x21) #define TRC_HVM_REALMODE_EMULATE (TRC_HVM_HANDLER + 0x22) #define TRC_HVM_TRAP (TRC_HVM_HANDLER + 0x23) +#define TRC_HVM_TRAP64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x23) #define TRC_HVM_TRAP_DEBUG (TRC_HVM_HANDLER + 0x24) #define TRC_HVM_VLAPIC (TRC_HVM_HANDLER + 0x25) +#define TRC_HVM_TRAP_GP (TRC_HVM_HANDLER + 0x26) +#define TRC_HVM_TRAP_GP64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x26) +#define TRC_HVM_TRAP_GP_UNKNOWN (TRC_HVM_HANDLER + 0x27) +#define TRC_HVM_TRAP_GP_UNKNOWN64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x27) +#define TRC_HVM_VMPORT_READ_BEFORE (TRC_HVM_HANDLER + 0x28) +#define TRC_HVM_VMPORT_READ_AFTER (TRC_HVM_HANDLER + 0x29) +#define TRC_HVM_VMPORT_BAD (TRC_HVM_HANDLER + 0x2a) +#define TRC_HVM_VMPORT_BAD64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x2a) +#define TRC_HVM_VMPORT_UNKNOWN (TRC_HVM_HANDLER + 0x2b) #define TRC_HVM_IOPORT_WRITE (TRC_HVM_HANDLER + 0x216) #define TRC_HVM_IOMEM_WRITE (TRC_HVM_HANDLER + 0x217) +#define TRC_HVM_VMPORT_WRITE_AFTER_BEFORE (TRC_HVM_HANDLER + 0x228) +#define TRC_HVM_VMPORT_WRITE_AFTER (TRC_HVM_HANDLER + 0x229) /* Trace events for emulated devices */ #define TRC_HVM_EMUL_HPET_START_TIMER (TRC_HVM_EMUL + 0x1) -- 1.8.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |