From patchwork Tue Oct 8 06:03:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharat Bhushan X-Patchwork-Id: 3000791 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 0147E9F245 for ; Tue, 8 Oct 2013 06:11:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0EA24201A4 for ; Tue, 8 Oct 2013 06:10:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 07EAC2018A for ; Tue, 8 Oct 2013 06:10:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754372Ab3JHGKy (ORCPT ); Tue, 8 Oct 2013 02:10:54 -0400 Received: from mail-db8lp0186.outbound.messaging.microsoft.com ([213.199.154.186]:39982 "EHLO db8outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754356Ab3JHGKx (ORCPT ); Tue, 8 Oct 2013 02:10:53 -0400 Received: from mail27-db8-R.bigfish.com (10.174.8.231) by DB8EHSOBE038.bigfish.com (10.174.4.101) with Microsoft SMTP Server id 14.1.225.22; Tue, 8 Oct 2013 06:10:52 +0000 Received: from mail27-db8 (localhost [127.0.0.1]) by mail27-db8-R.bigfish.com (Postfix) with ESMTP id 688ADDE0068; Tue, 8 Oct 2013 06:10:52 +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(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6h1082kzz1de098h1de097h8275bhz2dh2a8h839he5bhf0ah107ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh1fb3h1d0ch1d2eh1d3fh1dfeh1dffh1e1dh1e23h1fe8h1ff5h1155h) Received: from mail27-db8 (localhost.localdomain [127.0.0.1]) by mail27-db8 (MessageSwitch) id 1381212650760071_7428; Tue, 8 Oct 2013 06:10:50 +0000 (UTC) Received: from DB8EHSMHS004.bigfish.com (unknown [10.174.8.239]) by mail27-db8.bigfish.com (Postfix) with ESMTP id B321D14C0047; Tue, 8 Oct 2013 06:10:50 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB8EHSMHS004.bigfish.com (10.174.4.14) with Microsoft SMTP Server (TLS) id 14.16.227.3; Tue, 8 Oct 2013 06:10:45 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.3.158.2; Tue, 8 Oct 2013 06:10:43 +0000 Received: from freescale.com ([10.232.15.72]) by az84smr01.freescale.net (8.14.3/8.14.0) with SMTP id r986AcTF019825; Mon, 7 Oct 2013 23:10:39 -0700 Received: by freescale.com (sSMTP sendmail emulation); Tue, 08 Oct 2013 11:33:51 +0530 From: Bharat Bhushan To: , , , , , CC: Bharat Bhushan , Bharat Bhushan Subject: [PATCH 3/4] kvm: powerpc: define a linux pte lookup function Date: Tue, 8 Oct 2013 11:33:31 +0530 Message-ID: <1381212212-29641-4-git-send-email-Bharat.Bhushan@freescale.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1381212212-29641-1-git-send-email-Bharat.Bhushan@freescale.com> References: <1381212212-29641-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.2 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 --- arch/powerpc/include/asm/pgtable.h | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 7d6eacf..fd26c04 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -223,6 +223,41 @@ 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; + pte_t pte; + 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); + + /* wait until _PAGE_BUSY is clear */ + while (1) { + pte = pte_val(*ptep); + if (unlikely(pte & _PAGE_BUSY)) { + cpu_relax(); + continue; + } + } + + /* If pte is not present return None */ + if (unlikely(!(pte & _PAGE_PRESENT))) + return __pte(0); + + return pte; +} #endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */