From patchwork Mon Oct 28 10:22:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharat Bhushan X-Patchwork-Id: 3101531 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 66F6E9F2B7 for ; Mon, 28 Oct 2013 10:30:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4E22C20170 for ; Mon, 28 Oct 2013 10:30:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4127620158 for ; Mon, 28 Oct 2013 10:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756367Ab3J1KaB (ORCPT ); Mon, 28 Oct 2013 06:30:01 -0400 Received: from mail-db8lp0184.outbound.messaging.microsoft.com ([213.199.154.184]:11429 "EHLO db8outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756217Ab3J1K3S (ORCPT ); Mon, 28 Oct 2013 06:29:18 -0400 Received: from mail207-db8-R.bigfish.com (10.174.8.232) by DB8EHSOBE011.bigfish.com (10.174.4.74) with Microsoft SMTP Server id 14.1.225.22; Mon, 28 Oct 2013 10:29:16 +0000 Received: from mail207-db8 (localhost [127.0.0.1]) by mail207-db8-R.bigfish.com (Postfix) with ESMTP id BE4044C02FF; Mon, 28 Oct 2013 10:29:16 +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(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6h1082kzz1de098h8275bh1de097hz2dh2a8h839he5bhf0ah107ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh1fb3h1d0ch1d2eh1d3fh1dfeh1dffh1e1dh1e23h1fe8h1ff5h1155h) Received: from mail207-db8 (localhost.localdomain [127.0.0.1]) by mail207-db8 (MessageSwitch) id 1382956154125537_8520; Mon, 28 Oct 2013 10:29:14 +0000 (UTC) Received: from DB8EHSMHS031.bigfish.com (unknown [10.174.8.253]) by mail207-db8.bigfish.com (Postfix) with ESMTP id 161FA1E0080; Mon, 28 Oct 2013 10:29:14 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB8EHSMHS031.bigfish.com (10.174.4.41) with Microsoft SMTP Server (TLS) id 14.16.227.3; Mon, 28 Oct 2013 10:29:13 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-005.039d.mgd.msft.net (10.84.1.17) with Microsoft SMTP Server (TLS) id 14.3.158.2; Mon, 28 Oct 2013 10:29:12 +0000 Received: from freescale.com ([10.232.15.72]) by az84smr01.freescale.net (8.14.3/8.14.0) with SMTP id r9SAT73d009941; Mon, 28 Oct 2013 03:29:08 -0700 Received: by freescale.com (sSMTP sendmail emulation); Mon, 28 Oct 2013 15:52:48 +0530 From: Bharat Bhushan To: , , , , CC: Bharat Bhushan , Bharat Bhushan Subject: [PATCH 3/4 v2] kvm: powerpc: define a linux pte lookup function Date: Mon, 28 Oct 2013 15:52:29 +0530 Message-ID: <1382955750-32249-4-git-send-email-Bharat.Bhushan@freescale.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1382955750-32249-1-git-send-email-Bharat.Bhushan@freescale.com> References: <1382955750-32249-1-git-send-email-Bharat.Bhushan@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to search linux "pte" to get "pte" attributes for setting TLB in KVM. This patch defines a linux_pte_lookup() function for same. Signed-off-by: Bharat Bhushan --- v1->v2 -- removed _PAGE_BUSY and _PAGE_PRESENT as suggested by PaulS -- Added _PAGE_SPLITTING arch/powerpc/include/asm/pgtable.h | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 7d6eacf..a7151df 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -223,6 +223,33 @@ extern int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, #endif pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea, unsigned *shift); + +static inline pte_t lookup_linux_pte(pgd_t *pgdir, unsigned long hva, + unsigned long *pte_sizep) +{ + pte_t *ptep; + unsigned long ps = *pte_sizep; + unsigned int shift; + + ptep = find_linux_pte_or_hugepte(pgdir, hva, &shift); + if (!ptep) + return __pte(0); + if (shift) + *pte_sizep = 1ul << shift; + else + *pte_sizep = PAGE_SIZE; + + if (ps > *pte_sizep) + return __pte(0); + +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + /* If hugepage and is trans splitting return None */ + if (unlikely(hugepage && pmd_trans_splitting(pte_pmd(*ptep)))) + return __pte(0); +#endif + + return pte_val(*ptep);; +} #endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */