Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4342222imb; Wed, 6 Mar 2019 11:00:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyzoMAvyF0/Qgwt2fo8vCVXgY0Ezl/bh02bmmE6RdbZSp6vOOyItRNpDk2msedphV3OeNXd X-Received: by 2002:a62:6d81:: with SMTP id i123mr8588393pfc.235.1551898831977; Wed, 06 Mar 2019 11:00:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551898831; cv=none; d=google.com; s=arc-20160816; b=Qy9e8/jghdEOcZCzg3fI+kezggTAgWwHJCAevlWrkZ8+jCMneVpBZm7nkBTqk2mfcn CNCTpmviCkh8c7SUSHDZYQBAbcMyamXAw1I7uoiQEe2sV31FIcsi+tioRny70bbpgZml U+Pf0eg8qqiwTGPLi+LfCp7OfJPzSw8K3WWSkkcZ1rcWa2ifUrWfjh3aH/dvJ+iH/Mx5 PiMTkHFCWsXS99o0m2FZ+TskAMrycuNmIkXaYC3awcu5KKtik2FJL9kitmadg6M0ZLxI yieBf0fNRB2pBJ/z0JaFiSE4zCH3vvoCc8PfqWEQ8/PvoHFarZKg/fDPzTCYpnlbkn9a pKTQ== 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=w/JFdsJDPYSKc00MKHrpcbCJk0SkUKoK6gsDYp4bqCg=; b=rbXsHl01k4nqggU5UqZNjnTWU8Er8rdeUMeZkAfhiWRhrHcj4c0laC1U+vFgJqzyOO QdMQ/YdsCiEDiv1Xdu6sgODOcZhfVSRZT5pT8g7yiYwrlxhJOmLsk2+p74OlaaLnr4xx FNP0CHS9R43HzTUx5HGdt7XXTfpSI6gC9JOK1pWfmz5NXLUk2VFhdcrxmSWDPFeo0xQr 4szlO2f0tWIvE4QozuMBX+cVmcuVRaO0h1qEp+7QtPI58y6oh/QNH9YJHs2bgmXhLbjI fXcQAB0O2fy82I5DSbuWEX4DjYgj4Eoc3aXi87cyQYx3P0HnblI1GGCN4L/o3yhkrWiR LOrA== 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 l7si2172822plb.366.2019.03.06.11.00.15; Wed, 06 Mar 2019 11:00:31 -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 S1727048AbfCFPxD (ORCPT + 99 others); Wed, 6 Mar 2019 10:53:03 -0500 Received: from foss.arm.com ([217.140.101.70]:34440 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729944AbfCFPvQ (ORCPT ); Wed, 6 Mar 2019 10:51:16 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8F9B41713; Wed, 6 Mar 2019 07:51:16 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 54A923F703; Wed, 6 Mar 2019 07:51:13 -0800 (PST) From: Steven Price To: 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" Subject: [PATCH v4 08/19] x86: mm: Add p?d_large() definitions Date: Wed, 6 Mar 2019 15:50:20 +0000 Message-Id: <20190306155031.4291-9-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-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_large() functions/macros. For x86 we already have static inline functions, so simply add #defines to prevent the generic versions (added in a later patch) from being picked up. We also need to add corresponding #undefs in dump_pagetables.c. This code will be removed when x86 is switched over to using the generic pagewalk code in a later patch. Signed-off-by: Steven Price --- arch/x86/include/asm/pgtable.h | 5 +++++ arch/x86/mm/dump_pagetables.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 2779ace16d23..0dd04cf6ebeb 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -222,6 +222,7 @@ static inline unsigned long pgd_pfn(pgd_t pgd) return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT; } +#define p4d_large p4d_large static inline int p4d_large(p4d_t p4d) { /* No 512 GiB pages yet */ @@ -230,6 +231,7 @@ static inline int p4d_large(p4d_t p4d) #define pte_page(pte) pfn_to_page(pte_pfn(pte)) +#define pmd_large pmd_large static inline int pmd_large(pmd_t pte) { return pmd_flags(pte) & _PAGE_PSE; @@ -857,6 +859,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address) return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address); } +#define pud_large pud_large static inline int pud_large(pud_t pud) { return (pud_val(pud) & (_PAGE_PSE | _PAGE_PRESENT)) == @@ -868,6 +871,7 @@ static inline int pud_bad(pud_t pud) return (pud_flags(pud) & ~(_KERNPG_TABLE | _PAGE_USER)) != 0; } #else +#define pud_large pud_large static inline int pud_large(pud_t pud) { return 0; @@ -1213,6 +1217,7 @@ static inline bool pgdp_maps_userspace(void *__ptr) return (((ptr & ~PAGE_MASK) / sizeof(pgd_t)) < PGD_KERNEL_START); } +#define pgd_large pgd_large static inline int pgd_large(pgd_t pgd) { return 0; } #ifdef CONFIG_PAGE_TABLE_ISOLATION diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index e3cdc85ce5b6..cf37abc0f58a 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -432,6 +432,7 @@ static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr, #else #define walk_pmd_level(m,s,a,e,p) walk_pte_level(m,s,__pmd(pud_val(a)),e,p) +#undef pud_large #define pud_large(a) pmd_large(__pmd(pud_val(a))) #define pud_none(a) pmd_none(__pmd(pud_val(a))) #endif @@ -469,6 +470,7 @@ static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr, #else #define walk_pud_level(m,s,a,e,p) walk_pmd_level(m,s,__pud(p4d_val(a)),e,p) +#undef p4d_large #define p4d_large(a) pud_large(__pud(p4d_val(a))) #define p4d_none(a) pud_none(__pud(p4d_val(a))) #endif @@ -503,6 +505,7 @@ static void walk_p4d_level(struct seq_file *m, struct pg_state *st, pgd_t addr, } } +#undef pgd_large #define pgd_large(a) (pgtable_l5_enabled() ? pgd_large(a) : p4d_large(__p4d(pgd_val(a)))) #define pgd_none(a) (pgtable_l5_enabled() ? pgd_none(a) : p4d_none(__p4d(pgd_val(a)))) -- 2.20.1