lkml.org 
[lkml]   [2015]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 05/13] KVM: x86: pass host_initiated to functions that read MSRs
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 <pbonzini@redhat.com>
> ---
> 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.)


\
 
 \ /
  Last update: 2015-05-04 16:41    [W:0.297 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site