Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753014AbbEDOCA (ORCPT ); Mon, 4 May 2015 10:02:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50682 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752937AbbEDOBs (ORCPT ); Mon, 4 May 2015 10:01:48 -0400 Date: Mon, 4 May 2015 16:01:43 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, bsd@redhat.com, guangrong.xiao@linux.intel.com, Yang Zhang , wanpeng.li@linux.intel.com Subject: Re: [PATCH 05/13] KVM: x86: pass host_initiated to functions that read MSRs Message-ID: <20150504140143.GA11234@potion.brq.redhat.com> References: <1430393772-27208-1-git-send-email-pbonzini@redhat.com> <1430393772-27208-6-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1430393772-27208-6-git-send-email-pbonzini@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2013 Lines: 66 2015-04-30 13:36+0200, Paolo Bonzini: > SMBASE is only readable from SMM for the VCPU, but it must be always > accessible if userspace is accessing it. Thus, all functions that > read MSRs are changed to accept a struct msr_data; the host_initiated > and index fields are pre-initialized, while the data field is filled > on return. > > Signed-off-by: Paolo Bonzini > --- > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > @@ -1048,6 +1048,21 @@ EXPORT_SYMBOL_GPL(kvm_set_msr); > /* > * Adapt set_msr() to msr_io()'s calling convention > */ > +static int do_get_msr(struct kvm_vcpu *vcpu, unsigned index, u64 *data) > +{ > + struct msr_data msr; > + int r; > + > + msr.index = index; > + msr.host_initiated = true; > + r = kvm_set_msr(vcpu, &msr); Should be kvm_get_msr(). > + if (r) > + return r; > + > + *data = msr.data; > + return 0; > +} > + > @@ -3456,7 +3470,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp, > break; > } > case KVM_GET_MSRS: > - r = msr_io(vcpu, argp, kvm_get_msr, 1); > + r = msr_io(vcpu, argp, do_get_msr, 1); > break; > case KVM_SET_MSRS: > r = msr_io(vcpu, argp, do_set_msr, 0); > @@ -4948,7 +4962,17 @@ static void emulator_set_segment(struct x86_emulate_ctxt *ctxt, u16 selector, > static int emulator_get_msr(struct x86_emulate_ctxt *ctxt, > u32 msr_index, u64 *pdata) > { > - return kvm_get_msr(emul_to_vcpu(ctxt), msr_index, pdata); > + struct msr_data msr; > + int r; > + > + msr.index = msr_index; > + msr.host_initiated = false; > + r = kvm_get_msr(emul_to_vcpu(ctxt), &msr); > + if (r) > + return r; > + > + *pdata = msr.data; > + return 0; > } (Only msr.host_initiated changed from do_get_msr() ... I'd add a function with an extra bool arg and call it twice.) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/