From patchwork Thu Apr 25 16:33:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharat Bhushan X-Patchwork-Id: 2488691 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 77FA0DF5B1 for ; Thu, 25 Apr 2013 16:33:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758843Ab3DYQdT (ORCPT ); Thu, 25 Apr 2013 12:33:19 -0400 Received: from [65.55.88.12] ([65.55.88.12]:2631 "EHLO tx2outboundpool.messaging.microsoft.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1756869Ab3DYQdS (ORCPT ); Thu, 25 Apr 2013 12:33:18 -0400 Received: from mail124-tx2-R.bigfish.com (10.9.14.252) by TX2EHSOBE002.bigfish.com (10.9.40.22) with Microsoft SMTP Server id 14.1.225.23; Thu, 25 Apr 2013 16:31:47 +0000 Received: from mail124-tx2 (localhost [127.0.0.1]) by mail124-tx2-R.bigfish.com (Postfix) with ESMTP id 5F85F120245; Thu, 25 Apr 2013 16:31:47 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zzzz1f42h1fc6h1ee6h1de0h1fdah1202h1e76h1d1ah1d2ah1082kzz8275bhz2dh2a8h668h839hd24he5bhf0ah107ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1d0ch1155h) Received: from mail124-tx2 (localhost.localdomain [127.0.0.1]) by mail124-tx2 (MessageSwitch) id 1366907505599742_30362; Thu, 25 Apr 2013 16:31:45 +0000 (UTC) Received: from TX2EHSMHS008.bigfish.com (unknown [10.9.14.232]) by mail124-tx2.bigfish.com (Postfix) with ESMTP id 8E9A9400061; Thu, 25 Apr 2013 16:31:45 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS008.bigfish.com (10.9.99.108) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 25 Apr 2013 16:31:44 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.328.11; Thu, 25 Apr 2013 16:31:44 +0000 Received: from freescale.com ([10.232.15.72]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with SMTP id r3PGVYeE007699; Thu, 25 Apr 2013 09:31:36 -0700 Received: by freescale.com (sSMTP sendmail emulation); Thu, 25 Apr 2013 22:03:59 +0530 From: Bharat Bhushan To: , , , CC: Bharat Bhushan , Bharat Bhushan Subject: [PATCH v2] KVM: PPC: cache flush for kernel managed pages Date: Thu, 25 Apr 2013 22:03:57 +0530 Message-ID: <1366907637-30969-1-git-send-email-bharat.bhushan@freescale.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Bharat Bhushan Kernel can only access pages which maps as memory. So flush only the valid kernel pages. Signed-off-by: Bharat Bhushan --- 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);