From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 1/2] Add code to track call origin for msr assignment. Date: Fri, 16 Nov 2012 19:58:47 -0200 Message-ID: <20121116215847.GA12864@amt.cnet> References: <1353011145.918.11.camel@WillAuldHomeLinux> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: gleb@redhat.com, "xiantao.zhang@intel.com" , "jinsong.liu@intel.com" , "avi@redhat.com" , "kvm@vger.kernel.org" , "donald.d.dugger@intel.com" To: will.auld@intel.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:59284 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753271Ab2KPWSa (ORCPT ); Fri, 16 Nov 2012 17:18:30 -0500 Content-Disposition: inline In-Reply-To: <1353011145.918.11.camel@WillAuldHomeLinux> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Nov 15, 2012 at 12:25:45PM -0800, Will Auld wrote: > In order to track who initiated the call (host or guest) to modify an msr > value I have changed function call parameters along the call path. The > specific change is to add a struct pointer parameter that points to (index, > data, caller) information rather than having this information passed as > individual parameters. > > The initial use for this capability is for updating the IA32_TSC_ADJUST > msr while setting the tsc value. It is anticipated that this capability > is useful other tasks. > > Signed-off-by: Will Auld > --- > arch/x86/include/asm/kvm_host.h | 12 +++++++++--- > arch/x86/kvm/svm.c | 21 +++++++++++++++------ > arch/x86/kvm/vmx.c | 24 +++++++++++++++++------- > arch/x86/kvm/x86.c | 23 +++++++++++++++++------ > arch/x86/kvm/x86.h | 2 +- > 5 files changed, 59 insertions(+), 23 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 42bce48..a3aac1c 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -883,9 +883,9 @@ EXPORT_SYMBOL_GPL(kvm_enable_efer_bits); > * Returns 0 on success, non-0 otherwise. > * Assumes vcpu_load() was already called. > */ > -int kvm_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data) > +int kvm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr) > { > - return kvm_x86_ops->set_msr(vcpu, msr_index, data); > + return kvm_x86_ops->set_msr(vcpu, msr); > } > > /* > @@ -4286,7 +4293,11 @@ static int emulator_get_msr(struct x86_emulate_ctxt *ctxt, > static int emulator_set_msr(struct x86_emulate_ctxt *ctxt, > u32 msr_index, u64 data) > { > - return kvm_set_msr(emul_to_vcpu(ctxt), msr_index, data); > + struct msr_data msr; > + msr.data = data; > + msr.index = msr_index; > + msr.host_initiated = true; false, this is guest instruction emulation.