On Wed, Feb 26, 2020 at 06:11:25PM +0100, Vitaly Kuznetsov wrote: > Sean Christopherson <sean.j.christopherson@xxxxxxxxx> writes: > > > Explicitly pass the emulation context to the emulate tracepoint in > > preparation of dynamically allocation the emulation context. > > > > Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > > --- > > arch/x86/kvm/trace.h | 22 +++++++++++----------- > > arch/x86/kvm/x86.c | 13 ++++++++----- > > 2 files changed, 19 insertions(+), 16 deletions(-) > > > > diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h > > index f194dd058470..5605000ca5f6 100644 > > --- a/arch/x86/kvm/trace.h > > +++ b/arch/x86/kvm/trace.h > > @@ -731,8 +731,9 @@ TRACE_EVENT(kvm_skinit, > > }) > > > > TRACE_EVENT(kvm_emulate_insn, > > - TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed), > > - TP_ARGS(vcpu, failed), > > + TP_PROTO(struct kvm_vcpu *vcpu, struct x86_emulate_ctxt *ctxt, > > + __u8 failed), > > + TP_ARGS(vcpu, ctxt, failed), > > > > TP_STRUCT__entry( > > __field( __u64, rip ) > > @@ -745,13 +746,10 @@ TRACE_EVENT(kvm_emulate_insn, > > > > TP_fast_assign( > > __entry->csbase = kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS); > > This seems the only usage of 'vcpu' parameter now; I checked and even > after switching to dynamic emulation context allocation we still set > ctxt->vcpu in alloc_emulate_ctxt(), can we get rid of 'vcpu' parameter > here then (and use ctxt->vcpu instead)? Hmm, ya, not sure what I was thinking here. > > - __entry->len = vcpu->arch.emulate_ctxt.fetch.ptr > > - - vcpu->arch.emulate_ctxt.fetch.data; > > - __entry->rip = vcpu->arch.emulate_ctxt._eip - __entry->len; > > - memcpy(__entry->insn, > > - vcpu->arch.emulate_ctxt.fetch.data, > > - 15); > > - __entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt.mode); > > + __entry->len = ctxt->fetch.ptr - ctxt->fetch.data; > > + __entry->rip = ctxt->_eip - __entry->len; > > + memcpy(__entry->insn, ctxt->fetch.data, 15); > > + __entry->flags = kei_decode_mode(ctxt->mode); > > __entry->failed = failed; > > ), > > > > @@ -764,8 +762,10 @@ TRACE_EVENT(kvm_emulate_insn, > > ) > > ); > > > > -#define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0) > > -#define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1) > > +#define trace_kvm_emulate_insn_start(vcpu, ctxt) \ > > + trace_kvm_emulate_insn(vcpu, ctxt, 0) > > +#define trace_kvm_emulate_insn_failed(vcpu, ctxt) \ > > + trace_kvm_emulate_insn(vcpu, ctxt, 1) > > > > TRACE_EVENT( > > vcpu_match_mmio,