Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp762225ybl; Fri, 6 Dec 2019 05:55:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxEEq+thfxJfQhz4YDNams/Af2NcCMNy0CG2UV7HimLX2JsM5OfVTf6kX2HsfIJ0Jg52F9q X-Received: by 2002:aca:3a41:: with SMTP id h62mr12693241oia.97.1575640555607; Fri, 06 Dec 2019 05:55:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575640555; cv=none; d=google.com; s=arc-20160816; b=EpImESyHp01NsxH0fTe5h6aUd/AvaZ76Y7/gM+7noBDp5BjYC/awKD8zjcriLME6DW dO+FtViJA+lcUuF+MpZzHo8DiaygJHO/6xf6inyrmBKkrih/S7tChSnZRhBvyGfjUZ6G c80YO6ORr207FEHftBw5WtT9HJhVhT8HStW67CTGZz7xtMFx8b4+BK6l/bVM5PZ71w/I hUBgnm96UnRIWqk2fiXmc5AWkMEj8LmReVUe3Xo/wBV52cNo7zm3l+jRnvdtnyLKNvCJ p7Xsukl/DrV/bJUhYAiK3L7UOZcqG0kIFAfZLAGcZGN3wvRyu2T59Ufa++n2cNj+paJF nECA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TGSH7MZi1KoAfqByCn1pzGnMVgBWmxytJcu4COwTbOU=; b=HYRIotkjjwFWmRfoasnnpzzGlfp4UBps5/3C1N9yb+Y30JYlxda8HpI3445KZtdhba Xyf/wKsHUjU6uySo11t1j8Ro6ADlVvlTetO7Lv+tJxTZwDq/zi+qEQwBRTA7FzV+djIP pDmjHso5zQcdzYIkNweHd+tne4rEhvl9vcMVLFCPhXRC/lFvNglR/54KuqxRHC/ZmhSy XDGJAe92uP+qqXGG+vbYkP+I52O8CMz4XssIkyi/AoAFRNpSCX4OjtM23HufDbbGUcf4 XVq9CGSmIdtX7uzbxoudMQeHGGUqEV5CxADuWfAhlFj1zHDa9aJGTxcobBhEZpzZxIKK R3yw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r21si6566274otd.276.2019.12.06.05.55.43; Fri, 06 Dec 2019 05:55:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726584AbfLFNyE (ORCPT + 99 others); Fri, 6 Dec 2019 08:54:04 -0500 Received: from foss.arm.com ([217.140.110.172]:44538 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbfLFNyB (ORCPT ); Fri, 6 Dec 2019 08:54:01 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2CF80113E; Fri, 6 Dec 2019 05:54:01 -0800 (PST) Received: from e112269-lin.cambridge.arm.com (e112269-lin.cambridge.arm.com [10.1.194.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C43AE3F718; Fri, 6 Dec 2019 05:53:57 -0800 (PST) From: Steven Price To: Andrew Morton , linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Peter Zijlstra , Thomas Gleixner , Will Deacon , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , "Liang, Kan" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org Subject: [PATCH v16 06/25] powerpc: mm: Add p?d_leaf() definitions Date: Fri, 6 Dec 2019 13:52:57 +0000 Message-Id: <20191206135316.47703-7-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191206135316.47703-1-steven.price@arm.com> References: <20191206135316.47703-1-steven.price@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org walk_page_range() is going to be allowed to walk page tables other than those of user space. For this it needs to know when it has reached a 'leaf' entry in the page tables. This information is provided by the p?d_leaf() functions/macros. For powerpc pmd_large() already exists and does what we want, so hoist it out of the CONFIG_TRANSPARENT_HUGEPAGE condition and implement the other levels. Macros are used to provide the generic p?d_leaf() names. CC: Benjamin Herrenschmidt CC: Paul Mackerras CC: Michael Ellerman CC: linuxppc-dev@lists.ozlabs.org CC: kvm-ppc@vger.kernel.org Signed-off-by: Steven Price --- arch/powerpc/include/asm/book3s/64/pgtable.h | 30 ++++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index b01624e5c467..3dd7b6f5edd0 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -923,6 +923,12 @@ static inline int pud_present(pud_t pud) return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PRESENT)); } +#define pud_leaf pud_large +static inline int pud_large(pud_t pud) +{ + return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); +} + extern struct page *pud_page(pud_t pud); extern struct page *pmd_page(pmd_t pmd); static inline pte_t pud_pte(pud_t pud) @@ -966,6 +972,12 @@ static inline int pgd_present(pgd_t pgd) return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT)); } +#define pgd_leaf pgd_large +static inline int pgd_large(pgd_t pgd) +{ + return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PTE)); +} + static inline pte_t pgd_pte(pgd_t pgd) { return __pte_raw(pgd_raw(pgd)); @@ -1133,6 +1145,15 @@ static inline bool pmd_access_permitted(pmd_t pmd, bool write) return pte_access_permitted(pmd_pte(pmd), write); } +#define pmd_leaf pmd_large +/* + * returns true for pmd migration entries, THP, devmap, hugetlb + */ +static inline int pmd_large(pmd_t pmd) +{ + return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); +} + #ifdef CONFIG_TRANSPARENT_HUGEPAGE extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot); extern pmd_t mk_pmd(struct page *page, pgprot_t pgprot); @@ -1159,15 +1180,6 @@ pmd_hugepage_update(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, return hash__pmd_hugepage_update(mm, addr, pmdp, clr, set); } -/* - * returns true for pmd migration entries, THP, devmap, hugetlb - * But compile time dependent on THP config - */ -static inline int pmd_large(pmd_t pmd) -{ - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); -} - static inline pmd_t pmd_mknotpresent(pmd_t pmd) { return __pmd(pmd_val(pmd) & ~_PAGE_PRESENT); -- 2.20.1