diff mbox series

[2/3] KVM: nVMX: allow setting the VMFUNC controls MSR

Message ID 1562079876-20756-3-git-send-email-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show
Series KVM: nVMX: fixes for host get/set MSR | expand

Commit Message

Paolo Bonzini July 2, 2019, 3:04 p.m. UTC
Allow userspace to set a custom value for the VMFUNC controls MSR, as long
as the capabilities it advertises do not exceed those of the host.

Fixes: 27c42a1bb ("KVM: nVMX: Enable VMFUNC for the L1 hypervisor", 2017-08-03)
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/vmx/nested.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Liran Alon July 2, 2019, 3:27 p.m. UTC | #1
> On 2 Jul 2019, at 18:04, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> Allow userspace to set a custom value for the VMFUNC controls MSR, as long
> as the capabilities it advertises do not exceed those of the host.
> 
> Fixes: 27c42a1bb ("KVM: nVMX: Enable VMFUNC for the L1 hypervisor", 2017-08-03)
> Cc: stable@vger.kernel.org
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Liran Alon <liran.alon@oracle.com>

> ---
> arch/x86/kvm/vmx/nested.c | 5 +++++
> 1 file changed, 5 insertions(+)
> 
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index c4e29ef0b21e..163d226efa96 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -1234,6 +1234,11 @@ int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
> 	case MSR_IA32_VMX_VMCS_ENUM:
> 		vmx->nested.msrs.vmcs_enum = data;
> 		return 0;
> +	case MSR_IA32_VMX_VMFUNC:
> +		if (data & ~vmx->nested.msrs.vmfunc_controls)
> +			return -EINVAL;
> +		vmx->nested.msrs.vmfunc_controls = data;
> +		return 0;
> 	default:
> 		/*
> 		 * The rest of the VMX capability MSRs do not support restore.
> -- 
> 1.8.3.1
> 
>
diff mbox series

Patch

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index c4e29ef0b21e..163d226efa96 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -1234,6 +1234,11 @@  int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
 	case MSR_IA32_VMX_VMCS_ENUM:
 		vmx->nested.msrs.vmcs_enum = data;
 		return 0;
+	case MSR_IA32_VMX_VMFUNC:
+		if (data & ~vmx->nested.msrs.vmfunc_controls)
+			return -EINVAL;
+		vmx->nested.msrs.vmfunc_controls = data;
+		return 0;
 	default:
 		/*
 		 * The rest of the VMX capability MSRs do not support restore.