linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM/nVMX: Do not validate that posted_intr_desc_addr is page aligned
@ 2018-10-20 21:42 KarimAllah Ahmed
  2018-10-20 22:50 ` [PATCH v2] " KarimAllah Ahmed
  2018-10-24 11:01 ` [PATCH] " Sean Christopherson
  0 siblings, 2 replies; 6+ messages in thread
From: KarimAllah Ahmed @ 2018-10-20 21:42 UTC (permalink / raw)
  To: kvm, linux-kernel
  Cc: KarimAllah Ahmed, Paolo Bonzini, Radim Krčmář,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86

The spec only requires the posted interrupt descriptor address to be
64-bytes aligned (i.e. bits[0:5] == 0). Using page_address_valid also
forces the address to be page aligned.

Only validate that the address does not cross the maximum physical address
without enforcing a page alignment.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Fixes: 6de84e581c0 ("nVMX x86: check posted-interrupt descriptor addresss on vmentry of L2")
Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de>
---
 arch/x86/kvm/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 30bf860..47962f2 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -11668,7 +11668,7 @@ static int nested_vmx_check_apicv_controls(struct kvm_vcpu *vcpu,
 	    !nested_exit_intr_ack_set(vcpu) ||
 	    (vmcs12->posted_intr_nv & 0xff00) ||
 	    (vmcs12->posted_intr_desc_addr & 0x3f) ||
-	    (!page_address_valid(vcpu, vmcs12->posted_intr_desc_addr))))
+	    (vmcs12->posted_intr_desc_addr >> cpuid_maxphyaddr(vcpu)))
 		return -EINVAL;
 
 	/* tpr shadow is needed by all apicv features. */
-- 
2.7.4


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

* [PATCH v2] KVM/nVMX: Do not validate that posted_intr_desc_addr is page aligned
  2018-10-20 21:42 [PATCH] KVM/nVMX: Do not validate that posted_intr_desc_addr is page aligned KarimAllah Ahmed
@ 2018-10-20 22:50 ` KarimAllah Ahmed
  2018-10-22 17:12   ` Jim Mattson
  2018-10-22 23:23   ` Krish Sadhukhan
  2018-10-24 11:01 ` [PATCH] " Sean Christopherson
  1 sibling, 2 replies; 6+ messages in thread
From: KarimAllah Ahmed @ 2018-10-20 22:50 UTC (permalink / raw)
  To: kvm, linux-kernel
  Cc: KarimAllah Ahmed, Paolo Bonzini, Radim Krčmář,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86

The spec only requires the posted interrupt descriptor address to be
64-bytes aligned (i.e. bits[0:5] == 0). Using page_address_valid also
forces the address to be page aligned.

Only validate that the address does not cross the maximum physical address
without enforcing a page alignment.

v1 -> v2:
- Add a missing parenthesis (dropped while merging!)

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Fixes: 6de84e581c0 ("nVMX x86: check posted-interrupt descriptor addresss on vmentry of L2")
Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de>
---
 arch/x86/kvm/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 38f1a16..bb0fcdb 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -11667,7 +11667,7 @@ static int nested_vmx_check_apicv_controls(struct kvm_vcpu *vcpu,
 	    !nested_exit_intr_ack_set(vcpu) ||
 	    (vmcs12->posted_intr_nv & 0xff00) ||
 	    (vmcs12->posted_intr_desc_addr & 0x3f) ||
-	    (!page_address_valid(vcpu, vmcs12->posted_intr_desc_addr))))
+	    (vmcs12->posted_intr_desc_addr >> cpuid_maxphyaddr(vcpu))))
 		return -EINVAL;
 
 	/* tpr shadow is needed by all apicv features. */
-- 
2.7.4


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

* Re: [PATCH v2] KVM/nVMX: Do not validate that posted_intr_desc_addr is page aligned
  2018-10-20 22:50 ` [PATCH v2] " KarimAllah Ahmed
@ 2018-10-22 17:12   ` Jim Mattson
  2018-10-22 23:23   ` Krish Sadhukhan
  1 sibling, 0 replies; 6+ messages in thread
From: Jim Mattson @ 2018-10-22 17:12 UTC (permalink / raw)
  To: KarimAllah Ahmed
  Cc: kvm list, LKML, Paolo Bonzini, Radim Krčmář,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	the arch/x86 maintainers

On Sat, Oct 20, 2018 at 3:50 PM, KarimAllah Ahmed <karahmed@amazon.de> wrote:
> The spec only requires the posted interrupt descriptor address to be
> 64-bytes aligned (i.e. bits[0:5] == 0). Using page_address_valid also
> forces the address to be page aligned.
>
> Only validate that the address does not cross the maximum physical address
> without enforcing a page alignment.
>
> v1 -> v2:
> - Add a missing parenthesis (dropped while merging!)
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: kvm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Fixes: 6de84e581c0 ("nVMX x86: check posted-interrupt descriptor addresss on vmentry of L2")
> Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de>
Reviewed-by: Jim Mattson <jmattson@google.com>

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

* Re: [PATCH v2] KVM/nVMX: Do not validate that posted_intr_desc_addr is page aligned
  2018-10-20 22:50 ` [PATCH v2] " KarimAllah Ahmed
  2018-10-22 17:12   ` Jim Mattson
@ 2018-10-22 23:23   ` Krish Sadhukhan
  1 sibling, 0 replies; 6+ messages in thread
From: Krish Sadhukhan @ 2018-10-22 23:23 UTC (permalink / raw)
  To: KarimAllah Ahmed, kvm, linux-kernel
  Cc: Paolo Bonzini, Radim Krčmář,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86



On 10/20/2018 03:50 PM, KarimAllah Ahmed wrote:
> The spec only requires the posted interrupt descriptor address to be
> 64-bytes aligned (i.e. bits[0:5] == 0). Using page_address_valid also
> forces the address to be page aligned.
>
> Only validate that the address does not cross the maximum physical address
> without enforcing a page alignment.
>
> v1 -> v2:
> - Add a missing parenthesis (dropped while merging!)
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: kvm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Fixes: 6de84e581c0 ("nVMX x86: check posted-interrupt descriptor addresss on vmentry of L2")
> Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de>
> ---
>   arch/x86/kvm/vmx.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 38f1a16..bb0fcdb 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -11667,7 +11667,7 @@ static int nested_vmx_check_apicv_controls(struct kvm_vcpu *vcpu,
>   	    !nested_exit_intr_ack_set(vcpu) ||
>   	    (vmcs12->posted_intr_nv & 0xff00) ||
>   	    (vmcs12->posted_intr_desc_addr & 0x3f) ||
> -	    (!page_address_valid(vcpu, vmcs12->posted_intr_desc_addr))))
> +	    (vmcs12->posted_intr_desc_addr >> cpuid_maxphyaddr(vcpu))))
>   		return -EINVAL;
>   
>   	/* tpr shadow is needed by all apicv features. */

Reviewed-by: Krish Sadhuhan <krish.sadhukhan@oracle.com>

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

* Re: [PATCH] KVM/nVMX: Do not validate that posted_intr_desc_addr is page aligned
  2018-10-20 21:42 [PATCH] KVM/nVMX: Do not validate that posted_intr_desc_addr is page aligned KarimAllah Ahmed
  2018-10-20 22:50 ` [PATCH v2] " KarimAllah Ahmed
@ 2018-10-24 11:01 ` Sean Christopherson
  2018-10-24 11:17   ` Radim Krčmář
  1 sibling, 1 reply; 6+ messages in thread
From: Sean Christopherson @ 2018-10-24 11:01 UTC (permalink / raw)
  To: KarimAllah Ahmed
  Cc: kvm, linux-kernel, Paolo Bonzini, Radim Krčmář,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86

On Sat, Oct 20, 2018 at 11:42:59PM +0200, KarimAllah Ahmed wrote:
> The spec only requires the posted interrupt descriptor address to be
> 64-bytes aligned (i.e. bits[0:5] == 0). Using page_address_valid also
> forces the address to be page aligned.
> 
> Only validate that the address does not cross the maximum physical address
> without enforcing a page alignment.
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: kvm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Fixes: 6de84e581c0 ("nVMX x86: check posted-interrupt descriptor addresss on vmentry of L2")
> Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de>
> ---
>  arch/x86/kvm/vmx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 30bf860..47962f2 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -11668,7 +11668,7 @@ static int nested_vmx_check_apicv_controls(struct kvm_vcpu *vcpu,
>  	    !nested_exit_intr_ack_set(vcpu) ||
>  	    (vmcs12->posted_intr_nv & 0xff00) ||
>  	    (vmcs12->posted_intr_desc_addr & 0x3f) ||
> -	    (!page_address_valid(vcpu, vmcs12->posted_intr_desc_addr))))
> +	    (vmcs12->posted_intr_desc_addr >> cpuid_maxphyaddr(vcpu)))
>  		return -EINVAL;

Can you update the comment for this code block?  It has a stale blurb
about "the descriptor address has been already checked in
nested_get_vmcs12_pages" and it'd be nice to state why bits[5:0] must
be zero (your changelog is much more helpful than the current comment).

With that:

Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>

>  
>  	/* tpr shadow is needed by all apicv features. */
> -- 
> 2.7.4
> 

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

* Re: [PATCH] KVM/nVMX: Do not validate that posted_intr_desc_addr is page aligned
  2018-10-24 11:01 ` [PATCH] " Sean Christopherson
@ 2018-10-24 11:17   ` Radim Krčmář
  0 siblings, 0 replies; 6+ messages in thread
From: Radim Krčmář @ 2018-10-24 11:17 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: KarimAllah Ahmed, kvm, linux-kernel, Paolo Bonzini,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86

2018-10-24 04:01-0700, Sean Christopherson:
> On Sat, Oct 20, 2018 at 11:42:59PM +0200, KarimAllah Ahmed wrote:
> > The spec only requires the posted interrupt descriptor address to be
> > 64-bytes aligned (i.e. bits[0:5] == 0). Using page_address_valid also
> > forces the address to be page aligned.
> > 
> > Only validate that the address does not cross the maximum physical address
> > without enforcing a page alignment.
> > 
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: Radim Krčmář <rkrcmar@redhat.com>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: Borislav Petkov <bp@alien8.de>
> > Cc: H. Peter Anvin <hpa@zytor.com>
> > Cc: x86@kernel.org
> > Cc: kvm@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Fixes: 6de84e581c0 ("nVMX x86: check posted-interrupt descriptor addresss on vmentry of L2")
> > Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de>
> > ---
> >  arch/x86/kvm/vmx.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> > index 30bf860..47962f2 100644
> > --- a/arch/x86/kvm/vmx.c
> > +++ b/arch/x86/kvm/vmx.c
> > @@ -11668,7 +11668,7 @@ static int nested_vmx_check_apicv_controls(struct kvm_vcpu *vcpu,
> >  	    !nested_exit_intr_ack_set(vcpu) ||
> >  	    (vmcs12->posted_intr_nv & 0xff00) ||
> >  	    (vmcs12->posted_intr_desc_addr & 0x3f) ||
> > -	    (!page_address_valid(vcpu, vmcs12->posted_intr_desc_addr))))
> > +	    (vmcs12->posted_intr_desc_addr >> cpuid_maxphyaddr(vcpu)))
> >  		return -EINVAL;
> 
> Can you update the comment for this code block?  It has a stale blurb
> about "the descriptor address has been already checked in
> nested_get_vmcs12_pages" and it'd be nice to state why bits[5:0] must
> be zero (your changelog is much more helpful than the current comment).
> 
> With that:
> 
> Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>

I have just sent a pull request with the stale comment. :(

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

end of thread, other threads:[~2018-10-24 11:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-20 21:42 [PATCH] KVM/nVMX: Do not validate that posted_intr_desc_addr is page aligned KarimAllah Ahmed
2018-10-20 22:50 ` [PATCH v2] " KarimAllah Ahmed
2018-10-22 17:12   ` Jim Mattson
2018-10-22 23:23   ` Krish Sadhukhan
2018-10-24 11:01 ` [PATCH] " Sean Christopherson
2018-10-24 11:17   ` Radim Krčmář

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).