linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND][PATCH] kvm: x86: Do not handle MMIO request in fast_page_fault
@ 2017-09-05 10:37 changbin.du
  2017-09-13 14:39 ` Radim Krčmář
  0 siblings, 1 reply; 3+ messages in thread
From: changbin.du @ 2017-09-05 10:37 UTC (permalink / raw)
  To: pbonzini, rkrcmar, tglx, mingo, hpa; +Cc: x86, kvm, linux-kernel, Changbin Du

From: Changbin Du <changbin.du@intel.com>

If it is a MMIO request, it should be handled by slow path. This patch
actually fixed below warning when mmu debug is enabled.

WARNING: CPU: 5 PID: 2282 at arch/x86/kvm/mmu.c:226 fast_page_fault+0x41b/0x520
CPU: 5 PID: 2282 Comm: qemu-system-x86 Not tainted 4.13.0-rc6+ #34
task: ffff9b47f5286000 task.stack: ffffb18d03b28000
RIP: 0010:fast_page_fault+0x41b/0x520
Call Trace:
  tdp_page_fault+0xfb/0x290
  kvm_mmu_page_fault+0x61/0x120
  handle_ept_misconfig+0x1ba/0x1c0
  vmx_handle_exit+0xb8/0xd70
  ? kvm_arch_vcpu_ioctl_run+0x9b6/0x18e0
  kvm_arch_vcpu_ioctl_run+0xa5a/0x18e0
  ? kvm_arch_vcpu_load+0x62/0x230
  kvm_vcpu_ioctl+0x340/0x6c0
  ? kvm_vcpu_ioctl+0x340/0x6c0
  ? lock_acquire+0xf5/0x1f0
  do_vfs_ioctl+0xa2/0x670
  ? __fget+0x107/0x200
  SyS_ioctl+0x79/0x90
  entry_SYSCALL_64_fastpath+0x23/0xc2

Signed-off-by: Changbin Du <changbin.du@intel.com>
---
 arch/x86/kvm/mmu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 9d3f275..63c3360 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3180,6 +3180,9 @@ static bool fast_page_fault(struct kvm_vcpu *vcpu, gva_t gva, int level,
 			    iterator.level < level)
 				break;
 
+		if (is_mmio_spte(spte))
+			break;
+
 		sp = page_header(__pa(iterator.sptep));
 		if (!is_last_spte(spte, sp->role.level))
 			break;
-- 
2.7.4

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

* Re: [RESEND][PATCH] kvm: x86: Do not handle MMIO request in fast_page_fault
  2017-09-05 10:37 [RESEND][PATCH] kvm: x86: Do not handle MMIO request in fast_page_fault changbin.du
@ 2017-09-13 14:39 ` Radim Krčmář
  2017-09-14  3:55   ` Du, Changbin
  0 siblings, 1 reply; 3+ messages in thread
From: Radim Krčmář @ 2017-09-13 14:39 UTC (permalink / raw)
  To: changbin.du; +Cc: pbonzini, tglx, mingo, hpa, x86, kvm, linux-kernel

2017-09-05 18:37+0800, changbin.du@intel.com:
> From: Changbin Du <changbin.du@intel.com>
> 
> If it is a MMIO request, it should be handled by slow path. This patch
> actually fixed below warning when mmu debug is enabled.
> 
> WARNING: CPU: 5 PID: 2282 at arch/x86/kvm/mmu.c:226 fast_page_fault+0x41b/0x520
> CPU: 5 PID: 2282 Comm: qemu-system-x86 Not tainted 4.13.0-rc6+ #34
> task: ffff9b47f5286000 task.stack: ffffb18d03b28000
> RIP: 0010:fast_page_fault+0x41b/0x520
> Call Trace:
>   tdp_page_fault+0xfb/0x290
>   kvm_mmu_page_fault+0x61/0x120
>   handle_ept_misconfig+0x1ba/0x1c0
>   vmx_handle_exit+0xb8/0xd70
>   ? kvm_arch_vcpu_ioctl_run+0x9b6/0x18e0
>   kvm_arch_vcpu_ioctl_run+0xa5a/0x18e0
>   ? kvm_arch_vcpu_load+0x62/0x230
>   kvm_vcpu_ioctl+0x340/0x6c0
>   ? kvm_vcpu_ioctl+0x340/0x6c0
>   ? lock_acquire+0xf5/0x1f0
>   do_vfs_ioctl+0xa2/0x670
>   ? __fget+0x107/0x200
>   SyS_ioctl+0x79/0x90
>   entry_SYSCALL_64_fastpath+0x23/0xc2
> 
> Signed-off-by: Changbin Du <changbin.du@intel.com>
> ---
>  arch/x86/kvm/mmu.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 9d3f275..63c3360 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -3180,6 +3180,9 @@ static bool fast_page_fault(struct kvm_vcpu *vcpu, gva_t gva, int level,
>  			    iterator.level < level)
>  				break;
>  
> +		if (is_mmio_spte(spte))
> +			break;

Hm, handle_ept_misconfig() calls kvm_mmu_page_fault with error_code =
PFERR_RSVD_MASK.  This error_code gets propagated and checked at the
beginning of page_fault_can_be_fast(), where it should break the
function execution.

How did the execution get all the way to the loop?

Thanks.

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

* Re: [RESEND][PATCH] kvm: x86: Do not handle MMIO request in fast_page_fault
  2017-09-13 14:39 ` Radim Krčmář
@ 2017-09-14  3:55   ` Du, Changbin
  0 siblings, 0 replies; 3+ messages in thread
From: Du, Changbin @ 2017-09-14  3:55 UTC (permalink / raw)
  To: Radim Krčmář
  Cc: changbin.du, pbonzini, tglx, mingo, hpa, x86, kvm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2136 bytes --]

On Wed, Sep 13, 2017 at 04:39:56PM +0200, Radim Krčmář wrote:
> 2017-09-05 18:37+0800, changbin.du@intel.com:
> > From: Changbin Du <changbin.du@intel.com>
> > 
> > If it is a MMIO request, it should be handled by slow path. This patch
> > actually fixed below warning when mmu debug is enabled.
> > 
> > WARNING: CPU: 5 PID: 2282 at arch/x86/kvm/mmu.c:226 fast_page_fault+0x41b/0x520
> > CPU: 5 PID: 2282 Comm: qemu-system-x86 Not tainted 4.13.0-rc6+ #34
> > task: ffff9b47f5286000 task.stack: ffffb18d03b28000
> > RIP: 0010:fast_page_fault+0x41b/0x520
> > Call Trace:
> >   tdp_page_fault+0xfb/0x290
> >   kvm_mmu_page_fault+0x61/0x120
> >   handle_ept_misconfig+0x1ba/0x1c0
> >   vmx_handle_exit+0xb8/0xd70
> >   ? kvm_arch_vcpu_ioctl_run+0x9b6/0x18e0
> >   kvm_arch_vcpu_ioctl_run+0xa5a/0x18e0
> >   ? kvm_arch_vcpu_load+0x62/0x230
> >   kvm_vcpu_ioctl+0x340/0x6c0
> >   ? kvm_vcpu_ioctl+0x340/0x6c0
> >   ? lock_acquire+0xf5/0x1f0
> >   do_vfs_ioctl+0xa2/0x670
> >   ? __fget+0x107/0x200
> >   SyS_ioctl+0x79/0x90
> >   entry_SYSCALL_64_fastpath+0x23/0xc2
> > 
> > Signed-off-by: Changbin Du <changbin.du@intel.com>
> > ---
> >  arch/x86/kvm/mmu.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> > index 9d3f275..63c3360 100644
> > --- a/arch/x86/kvm/mmu.c
> > +++ b/arch/x86/kvm/mmu.c
> > @@ -3180,6 +3180,9 @@ static bool fast_page_fault(struct kvm_vcpu *vcpu, gva_t gva, int level,
> >  			    iterator.level < level)
> >  				break;
> >  
> > +		if (is_mmio_spte(spte))
> > +			break;
> 
> Hm, handle_ept_misconfig() calls kvm_mmu_page_fault with error_code =
> PFERR_RSVD_MASK.  This error_code gets propagated and checked at the
> beginning of page_fault_can_be_fast(), where it should break the
> function execution.
> 
> How did the execution get all the way to the loop?
> 
hmm, a recent Paolo's cleanup patch already fixed it.
e08d26f ("KVM: x86: simplify ept_misconfig")

In the past, PFERR_RSVD_MASK is not set.

So this patch doesnt need any more. thanks.

> Thanks.

-- 
Thanks,
Changbin Du

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

end of thread, other threads:[~2017-09-14  4:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-05 10:37 [RESEND][PATCH] kvm: x86: Do not handle MMIO request in fast_page_fault changbin.du
2017-09-13 14:39 ` Radim Krčmář
2017-09-14  3:55   ` Du, Changbin

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