aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorUlrich Obergfell <uobergfe@redhat.com>2014-05-02 11:57:47 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-05-05 16:42:05 -0400
commit1171903d899b1930f502b4c10a2a3565d6603c71 (patch)
treecdceb9525188eee17817b28b6eee5fc6f648cd32 /arch/x86
parent719d93cd5f5c5c8775b7a38192069e8e1d1ac46e (diff)
KVM: x86: improve the usability of the 'kvm_pio' tracepoint
This patch moves the 'kvm_pio' tracepoint to emulator_pio_in_emulated() and emulator_pio_out_emulated(), and it adds an argument (a pointer to the 'pio_data'). A single 8-bit or 16-bit or 32-bit data item is fetched from 'pio_data' (depending on 'size'), and the value is included in the trace record ('val'). If 'count' is greater than one, this is indicated by the string "(...)" in the trace output. Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com> Reviewed-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/trace.h20
-rw-r--r--arch/x86/kvm/x86.c4
2 files changed, 18 insertions, 6 deletions
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index 545245d7cc63..33574c95220d 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -91,16 +91,21 @@ TRACE_EVENT(kvm_hv_hypercall,
91/* 91/*
92 * Tracepoint for PIO. 92 * Tracepoint for PIO.
93 */ 93 */
94
95#define KVM_PIO_IN 0
96#define KVM_PIO_OUT 1
97
94TRACE_EVENT(kvm_pio, 98TRACE_EVENT(kvm_pio,
95 TP_PROTO(unsigned int rw, unsigned int port, unsigned int size, 99 TP_PROTO(unsigned int rw, unsigned int port, unsigned int size,
96 unsigned int count), 100 unsigned int count, void *data),
97 TP_ARGS(rw, port, size, count), 101 TP_ARGS(rw, port, size, count, data),
98 102
99 TP_STRUCT__entry( 103 TP_STRUCT__entry(
100 __field( unsigned int, rw ) 104 __field( unsigned int, rw )
101 __field( unsigned int, port ) 105 __field( unsigned int, port )
102 __field( unsigned int, size ) 106 __field( unsigned int, size )
103 __field( unsigned int, count ) 107 __field( unsigned int, count )
108 __field( unsigned int, val )
104 ), 109 ),
105 110
106 TP_fast_assign( 111 TP_fast_assign(
@@ -108,11 +113,18 @@ TRACE_EVENT(kvm_pio,
108 __entry->port = port; 113 __entry->port = port;
109 __entry->size = size; 114 __entry->size = size;
110 __entry->count = count; 115 __entry->count = count;
116 if (size == 1)
117 __entry->val = *(unsigned char *)data;
118 else if (size == 2)
119 __entry->val = *(unsigned short *)data;
120 else
121 __entry->val = *(unsigned int *)data;
111 ), 122 ),
112 123
113 TP_printk("pio_%s at 0x%x size %d count %d", 124 TP_printk("pio_%s at 0x%x size %d count %d val 0x%x %s",
114 __entry->rw ? "write" : "read", 125 __entry->rw ? "write" : "read",
115 __entry->port, __entry->size, __entry->count) 126 __entry->port, __entry->size, __entry->count, __entry->val,
127 __entry->count > 1 ? "(...)" : "")
116); 128);
117 129
118/* 130/*
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c5582c385bc0..de0931cb3f58 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4480,8 +4480,6 @@ static int emulator_pio_in_out(struct kvm_vcpu *vcpu, int size,
4480 unsigned short port, void *val, 4480 unsigned short port, void *val,
4481 unsigned int count, bool in) 4481 unsigned int count, bool in)
4482{ 4482{
4483 trace_kvm_pio(!in, port, size, count);
4484
4485 vcpu->arch.pio.port = port; 4483 vcpu->arch.pio.port = port;
4486 vcpu->arch.pio.in = in; 4484 vcpu->arch.pio.in = in;
4487 vcpu->arch.pio.count = count; 4485 vcpu->arch.pio.count = count;
@@ -4516,6 +4514,7 @@ static int emulator_pio_in_emulated(struct x86_emulate_ctxt *ctxt,
4516 if (ret) { 4514 if (ret) {
4517data_avail: 4515data_avail:
4518 memcpy(val, vcpu->arch.pio_data, size * count); 4516 memcpy(val, vcpu->arch.pio_data, size * count);
4517 trace_kvm_pio(KVM_PIO_IN, port, size, count, vcpu->arch.pio_data);
4519 vcpu->arch.pio.count = 0; 4518 vcpu->arch.pio.count = 0;
4520 return 1; 4519 return 1;
4521 } 4520 }
@@ -4530,6 +4529,7 @@ static int emulator_pio_out_emulated(struct x86_emulate_ctxt *ctxt,
4530 struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt); 4529 struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
4531 4530
4532 memcpy(vcpu->arch.pio_data, val, size * count); 4531 memcpy(vcpu->arch.pio_data, val, size * count);
4532 trace_kvm_pio(KVM_PIO_OUT, port, size, count, vcpu->arch.pio_data);
4533 return emulator_pio_in_out(vcpu, size, port, (void *)val, count, false); 4533 return emulator_pio_in_out(vcpu, size, port, (void *)val, count, false);
4534} 4534}
4535 4535