diff mbox

[v2] KVM: PPC: cache flush for kernel managed pages

Message ID 1366907637-30969-1-git-send-email-bharat.bhushan@freescale.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bharat Bhushan April 25, 2013, 4:33 p.m. UTC
From: Bharat Bhushan <Bharat.Bhushan@freescale.com>

Kernel can only access pages which maps as memory.
So flush only the valid kernel pages.

Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
---
v1->v2
 - move pfn_valid() check in kvmppc_mmu_flush_icache
 - Added comment to describe why this is needed

 arch/powerpc/include/asm/kvm_ppc.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

Comments

Alexander Graf April 26, 2013, 7:38 a.m. UTC | #1
On 25.04.2013, at 18:33, Bharat Bhushan wrote:

> From: Bharat Bhushan <Bharat.Bhushan@freescale.com>
> 
> Kernel can only access pages which maps as memory.
> So flush only the valid kernel pages.
> 
> Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>

Thanks, applied to kvm-ppc-queue.


Alex

> ---
> v1->v2
> - move pfn_valid() check in kvmppc_mmu_flush_icache
> - Added comment to describe why this is needed
> 
> arch/powerpc/include/asm/kvm_ppc.h |    9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
> index f589307..4794de6 100644
> --- a/arch/powerpc/include/asm/kvm_ppc.h
> +++ b/arch/powerpc/include/asm/kvm_ppc.h
> @@ -282,8 +282,15 @@ void kvmppc_init_lpid(unsigned long nr_lpids);
> 
> static inline void kvmppc_mmu_flush_icache(pfn_t pfn)
> {
> -	/* Clear i-cache for new pages */
> 	struct page *page;
> +	/*
> +	 * We can only access pages that the kernel maps
> +	 * as memory. Bail out for unmapped ones.
> +	 */
> +	if (!pfn_valid(pfn))
> +		return;
> +
> +	/* Clear i-cache for new pages */
> 	page = pfn_to_page(pfn);
> 	if (!test_bit(PG_arch_1, &page->flags)) {
> 		flush_dcache_icache_page(page);
> -- 
> 1.7.0.4
> 
> 

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

Patch

diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index f589307..4794de6 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -282,8 +282,15 @@  void kvmppc_init_lpid(unsigned long nr_lpids);
 
 static inline void kvmppc_mmu_flush_icache(pfn_t pfn)
 {
-	/* Clear i-cache for new pages */
 	struct page *page;
+	/*
+	 * We can only access pages that the kernel maps
+	 * as memory. Bail out for unmapped ones.
+	 */
+	if (!pfn_valid(pfn))
+		return;
+
+	/* Clear i-cache for new pages */
 	page = pfn_to_page(pfn);
 	if (!test_bit(PG_arch_1, &page->flags)) {
 		flush_dcache_icache_page(page);