Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp760847ybl; Fri, 6 Dec 2019 05:54:29 -0800 (PST) X-Google-Smtp-Source: APXvYqxXdbRA80CLF/cXQ4BMHAWyDHjXotDnVEm0vta2+TYMMDDcfT5Dsu19ekiesNA8cOWYHVOM X-Received: by 2002:aca:d544:: with SMTP id m65mr12442184oig.177.1575640469622; Fri, 06 Dec 2019 05:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575640469; cv=none; d=google.com; s=arc-20160816; b=YPpGs7w3zc6ERNdLlY+SODX1jlo9LlGNfDkyWTcgxVrkUb+PaggNsMiLFcESW8r71w N/Q8uo118lPNiSgoAdAEG1XYpPy1u4V5H0W/Cio67nRdRSX6uhUMS6k+63TvCLFbWp6/ RQkVgumEz6AaIwiVPGuO+uChBacgjMHLk5CinW/CAkf924MSlrQJRNeQqts3kV3a04W+ 3VN9l7giuSIHVIdjaod6+R3ZjmU03ieT4vP4qZnm2js6S5V0Za5amFYj3ED08A2VzKdv ouWXoO7d05pDBgkQ+P8eyXDj9bOf5v8q3cePZBO98l1waL5wC+7IJ0LFtIsepa0EU68r tEpg== 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=oUrc9+XM1A2VasyD7QcgBo2nDrZdIp+sFFwIVEuWv1c=; b=qhHyCsv34T6XE2qy0OEoBBxiKTE+VymFqvq2HP/yonPVttoIveVQ/CFGWhNuLKNcYZ Qsy63rF1swjQTFoFwnjVWsrsGsasnqK9teI6tYkR1A00ysthl1APQFUL87LGKe7wVAOw /NQ22kU3EWAGY3OUhnvDK1D003GR8dcOC7yu0R6LqvGlVKmkexSFBvG8WkNKONefACwd FBWfaGJmADyIeucm9q+5w1I6K9SCNipNkqQZ4G+mzXeiwGfg8bdPNit2GhgIpJgUFbzt d3ABKRL0MAmHnyZUPJ1ebBtVa4d3/nJQM06aI2XANafgG83iGf8Dh4tWrbJtHyK9nxqx Vomg== 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 w17si4900010otp.185.2019.12.06.05.54.17; Fri, 06 Dec 2019 05:54:29 -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 S1726370AbfLFNxr (ORCPT + 99 others); Fri, 6 Dec 2019 08:53:47 -0500 Received: from foss.arm.com ([217.140.110.172]:44364 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbfLFNxq (ORCPT ); Fri, 6 Dec 2019 08:53:46 -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 CA4F41FB; Fri, 6 Dec 2019 05:53:45 -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 300263F86C; Fri, 6 Dec 2019 05:53:43 -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" , Mark Rutland Subject: [PATCH v16 01/25] mm: Add generic p?d_leaf() macros Date: Fri, 6 Dec 2019 13:52:52 +0000 Message-Id: <20191206135316.47703-2-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 Exposing the pud/pgd levels of the page tables to walk_page_range() means we may come across the exotic large mappings that come with large areas of contiguous memory (such as the kernel's linear map). For architectures that don't provide all p?d_leaf() macros, provide generic do nothing default that are suitable where there cannot be leaf pages at that level. Futher patches will add implementations for individual architectures. The name p?d_leaf() is chosen to minimize the confusion with existing uses of "large" pages and "huge" pages which do not necessary mean that the entry is a leaf (for example it may be a set of contiguous entries that only take 1 TLB slot). For the purpose of walking the page tables we don't need to know how it will be represented in the TLB, but we do need to know for sure if it is a leaf of the tree. Signed-off-by: Steven Price Acked-by: Mark Rutland --- include/asm-generic/pgtable.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 798ea36a0549..e2e2bef07dd2 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -1238,4 +1238,24 @@ static inline bool arch_has_pfn_modify_check(void) #define mm_pmd_folded(mm) __is_defined(__PAGETABLE_PMD_FOLDED) #endif +/* + * p?d_leaf() - true if this entry is a final mapping to a physical address. + * This differs from p?d_huge() by the fact that they are always available (if + * the architecture supports large pages at the appropriate level) even + * if CONFIG_HUGETLB_PAGE is not defined. + * Only meaningful when called on a valid entry. + */ +#ifndef pgd_leaf +#define pgd_leaf(x) 0 +#endif +#ifndef p4d_leaf +#define p4d_leaf(x) 0 +#endif +#ifndef pud_leaf +#define pud_leaf(x) 0 +#endif +#ifndef pmd_leaf +#define pmd_leaf(x) 0 +#endif + #endif /* _ASM_GENERIC_PGTABLE_H */ -- 2.20.1