Patchwork KVM : PPC : cache flush for kernel managed pages

login
register
mail settings
Submitter Bharat Bhushan
Date April 23, 2013, 6:39 a.m.
Message ID <1366699172-25260-1-git-send-email-bharat.bhushan@freescale.com>
Download mbox | patch
Permalink /patch/238768/
State New
Headers show

Comments

Bharat Bhushan - April 23, 2013, 6:39 a.m.
Kernel should only try flushing pages which are managed by kernel.
pfn_to_page will returns junk struct page for pages not managed by kernel,
so if kernel will try to flush direct mapped memory or direct assigned device
mapping then it will work on junk struct page.

Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
---
 arch/powerpc/kvm/e500_mmu_host.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Alexander Graf - April 25, 2013, 3:05 p.m.
On 23.04.2013, at 08:39, Bharat Bhushan wrote:

> Kernel should only try flushing pages which are managed by kernel.
> pfn_to_page will returns junk struct page for pages not managed by kernel,
> so if kernel will try to flush direct mapped memory or direct assigned device
> mapping then it will work on junk struct page.
> 
> Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
> ---
> arch/powerpc/kvm/e500_mmu_host.c |    3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
> index 1c6a9d7..e07da21 100644
> --- a/arch/powerpc/kvm/e500_mmu_host.c
> +++ b/arch/powerpc/kvm/e500_mmu_host.c
> @@ -455,7 +455,8 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
> 				ref, gvaddr, stlbe);
> 
> 	/* Clear i-cache for new pages */
> -	kvmppc_mmu_flush_icache(pfn);
> +	if (pfn_valid(pfn))
> +		kvmppc_mmu_flush_icache(pfn);

Could you please move the check into kvmppc_mmu_flush_icache()? That way we're guaranteed we can't screw up cache flushes ever :).

Also, please add a comment saying why we need this.


Alex

> 
> 	/* Drop refcount on page, so that mmu notifiers can clear it */
> 	kvm_release_pfn_clean(pfn);
> -- 
> 1.7.0.4
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bharat Bhushan - April 25, 2013, 3:07 p.m.
> -----Original Message-----
> From: Alexander Graf [mailto:agraf@suse.de]
> Sent: Thursday, April 25, 2013 8:36 PM
> To: Bhushan Bharat-R65777
> Cc: kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; Wood Scott-B07421; Bhushan
> Bharat-R65777
> Subject: Re: [PATCH] KVM : PPC : cache flush for kernel managed pages
> 
> 
> On 23.04.2013, at 08:39, Bharat Bhushan wrote:
> 
> > Kernel should only try flushing pages which are managed by kernel.
> > pfn_to_page will returns junk struct page for pages not managed by
> > kernel, so if kernel will try to flush direct mapped memory or direct
> > assigned device mapping then it will work on junk struct page.
> >
> > Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
> > ---
> > arch/powerpc/kvm/e500_mmu_host.c |    3 ++-
> > 1 files changed, 2 insertions(+), 1 deletions(-)
> >
> > diff --git a/arch/powerpc/kvm/e500_mmu_host.c
> > b/arch/powerpc/kvm/e500_mmu_host.c
> > index 1c6a9d7..e07da21 100644
> > --- a/arch/powerpc/kvm/e500_mmu_host.c
> > +++ b/arch/powerpc/kvm/e500_mmu_host.c
> > @@ -455,7 +455,8 @@ static inline int kvmppc_e500_shadow_map(struct
> kvmppc_vcpu_e500 *vcpu_e500,
> > 				ref, gvaddr, stlbe);
> >
> > 	/* Clear i-cache for new pages */
> > -	kvmppc_mmu_flush_icache(pfn);
> > +	if (pfn_valid(pfn))
> > +		kvmppc_mmu_flush_icache(pfn);
> 
> Could you please move the check into kvmppc_mmu_flush_icache()? That way we're
> guaranteed we can't screw up cache flushes ever :).
> 
> Also, please add a comment saying why we need this.

Ok

-Bharat

> 
> 
> Alex
> 
> >
> > 	/* Drop refcount on page, so that mmu notifiers can clear it */
> > 	kvm_release_pfn_clean(pfn);
> > --
> > 1.7.0.4
> >
> >
> 


--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index 1c6a9d7..e07da21 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -455,7 +455,8 @@  static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
 				ref, gvaddr, stlbe);
 
 	/* Clear i-cache for new pages */
-	kvmppc_mmu_flush_icache(pfn);
+	if (pfn_valid(pfn))
+		kvmppc_mmu_flush_icache(pfn);
 
 	/* Drop refcount on page, so that mmu notifiers can clear it */
 	kvm_release_pfn_clean(pfn);