Re: [PATCH 05/13] KVM: x86: pass host_initiated to functions that read MSRs

From: Radim KrÄmÃÅ
Date: Mon May 04 2015 - 10:02:02 EST


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@xxxxxxxxxx>
> ---
> 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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/