linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Mark CR4.UMIP as reserved based on associated CPUID bit
@ 2020-01-28 23:53 Sean Christopherson
  2020-01-29 15:08 ` Vitaly Kuznetsov
  2020-02-05 15:30 ` Paolo Bonzini
  0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2020-01-28 23:53 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, kvm, linux-kernel

Re-add code to mark CR4.UMIP as reserved if UMIP is not supported by the
host.  The UMIP handling was unintentionally dropped during a recent
refactoring.

Not flagging CR4.UMIP allows the guest to set its CR4.UMIP regardless of
host support or userspace desires.  On CPUs with UMIP support, including
emulated UMIP, this allows the guest to enable UMIP against the wishes
of the userspace VMM.  On CPUs without any form of UMIP, this results in
a failed VM-Enter due to invalid guest state.

Fixes: 345599f9a2928 ("KVM: x86: Add macro to ensure reserved cr4 bits checks stay in sync")
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/kvm/x86.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 7e3f1d937224..e70d1215638a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -898,6 +898,8 @@ EXPORT_SYMBOL_GPL(kvm_set_xcr);
 		__reserved_bits |= X86_CR4_PKE;		\
 	if (!__cpu_has(__c, X86_FEATURE_LA57))		\
 		__reserved_bits |= X86_CR4_LA57;	\
+	if (!__cpu_has(__c, X86_FEATURE_UMIP))		\
+		__reserved_bits |= X86_CR4_UMIP;	\
 	__reserved_bits;				\
 })
 
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: x86: Mark CR4.UMIP as reserved based on associated CPUID bit
  2020-01-28 23:53 [PATCH] KVM: x86: Mark CR4.UMIP as reserved based on associated CPUID bit Sean Christopherson
@ 2020-01-29 15:08 ` Vitaly Kuznetsov
  2020-02-05 15:30 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Vitaly Kuznetsov @ 2020-01-29 15:08 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: Wanpeng Li, Jim Mattson, Joerg Roedel, kvm, linux-kernel, Paolo Bonzini

Sean Christopherson <sean.j.christopherson@intel.com> writes:

> Re-add code to mark CR4.UMIP as reserved if UMIP is not supported by the
> host.  The UMIP handling was unintentionally dropped during a recent
> refactoring.
>
> Not flagging CR4.UMIP allows the guest to set its CR4.UMIP regardless of
> host support or userspace desires.  On CPUs with UMIP support, including
> emulated UMIP, this allows the guest to enable UMIP against the wishes
> of the userspace VMM.  On CPUs without any form of UMIP, this results in
> a failed VM-Enter due to invalid guest state.
>
> Fixes: 345599f9a2928 ("KVM: x86: Add macro to ensure reserved cr4 bits checks stay in sync")

This one in only in kvm/next so just in case another force-push is
around the corner I'd suggest we squash this change in :-)

> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  arch/x86/kvm/x86.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 7e3f1d937224..e70d1215638a 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -898,6 +898,8 @@ EXPORT_SYMBOL_GPL(kvm_set_xcr);
>  		__reserved_bits |= X86_CR4_PKE;		\
>  	if (!__cpu_has(__c, X86_FEATURE_LA57))		\
>  		__reserved_bits |= X86_CR4_LA57;	\
> +	if (!__cpu_has(__c, X86_FEATURE_UMIP))		\
> +		__reserved_bits |= X86_CR4_UMIP;	\
>  	__reserved_bits;				\
>  })

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

-- 
Vitaly


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: x86: Mark CR4.UMIP as reserved based on associated CPUID bit
  2020-01-28 23:53 [PATCH] KVM: x86: Mark CR4.UMIP as reserved based on associated CPUID bit Sean Christopherson
  2020-01-29 15:08 ` Vitaly Kuznetsov
@ 2020-02-05 15:30 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-02-05 15:30 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: Vitaly Kuznetsov, Wanpeng Li, Jim Mattson, Joerg Roedel, kvm,
	linux-kernel

On 29/01/20 00:53, Sean Christopherson wrote:
> Re-add code to mark CR4.UMIP as reserved if UMIP is not supported by the
> host.  The UMIP handling was unintentionally dropped during a recent
> refactoring.
> 
> Not flagging CR4.UMIP allows the guest to set its CR4.UMIP regardless of
> host support or userspace desires.  On CPUs with UMIP support, including
> emulated UMIP, this allows the guest to enable UMIP against the wishes
> of the userspace VMM.  On CPUs without any form of UMIP, this results in
> a failed VM-Enter due to invalid guest state.
> 
> Fixes: 345599f9a2928 ("KVM: x86: Add macro to ensure reserved cr4 bits checks stay in sync")
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  arch/x86/kvm/x86.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 7e3f1d937224..e70d1215638a 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -898,6 +898,8 @@ EXPORT_SYMBOL_GPL(kvm_set_xcr);
>  		__reserved_bits |= X86_CR4_PKE;		\
>  	if (!__cpu_has(__c, X86_FEATURE_LA57))		\
>  		__reserved_bits |= X86_CR4_LA57;	\
> +	if (!__cpu_has(__c, X86_FEATURE_UMIP))		\
> +		__reserved_bits |= X86_CR4_UMIP;	\
>  	__reserved_bits;				\
>  })
>  
> 

Queued, thanks.

Paolo


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-05 15:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-28 23:53 [PATCH] KVM: x86: Mark CR4.UMIP as reserved based on associated CPUID bit Sean Christopherson
2020-01-29 15:08 ` Vitaly Kuznetsov
2020-02-05 15:30 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).