Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3125456ybg; Thu, 24 Oct 2019 22:36:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBHswjSdRkZyrKbV4PlFoJtxnRzLDhoSR0AYAa6etkVWmSW7Tzwg1Bgit4uSz/+lR+li7c X-Received: by 2002:a50:88a6:: with SMTP id d35mr351707edd.111.1571981763630; Thu, 24 Oct 2019 22:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571981763; cv=none; d=google.com; s=arc-20160816; b=Orz3ABWrtwqn+HaD7IaNxtx+cweSUV0ughZt9UGvoqhWXM03UsQ/YF7g1Avy7NKUar evZWA+Gp3xhhCPBp2udpCxj1fZV97B5DFlTPcaybgut7PjgFLTghUEQ+3tbB6YUwRk/c 2+2H171wwxZndRra+6QjoizpqUAHRtojRVBXT/+usy1BEBAi1f6Oau2JqjhV6v2jcQ4l +3KwIJXZ1odEhqqv0hQWywSWZyfMyoqLjoSwW0B4Bxrk41FQE0vSpB/PjGWg9PvTrK5Q uz5IZI1Bw0GJWimLTnzKdC7bEkLTQhJGVnOrsv8VEzHZfMISxv4CW+oEepbScxQpSYJp PLsg== 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=YlSZStztSSTjkoqAxhBAYIxbNXIdtfH9cl0Ty3k2rWk=; b=R80dOUXQA7adDbJgMyLz6gnwoIMBtRkCz1Ot6Suz050TsJXN+Gd4wMrsZFY0Cv2Fl9 JCc8XvY/a0yFxpqx/ozK8rp1y/b9IR02IYgmyw2qBUO1y3uzr+B/ZmtYNYUxQA+ot7DW v+o1Rk+7lxacSDfwG5hqToHF/2ebp3vjPGhZ16PpkMQ62d21zP4CaZyGJME6OF+bUdJM GOU2/5suu2gvrvY7APiWzk0sTJGZ/Gy+sc7/giu3qgKvKo2hxwuG3ZG0R9wAr/iM4DH5 Fg+W08Tg8cPEBmp+J18+LV0ZaSgkXvLTgmnTraS6yhgV5XA0IhLIJfdbuXbEiYMumb/U K+fA== 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 c17si506103edc.384.2019.10.24.22.35.39; Thu, 24 Oct 2019 22:36:03 -0700 (PDT) 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 S2438588AbfJXJh4 (ORCPT + 99 others); Thu, 24 Oct 2019 05:37:56 -0400 Received: from foss.arm.com ([217.140.110.172]:44392 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438561AbfJXJhz (ORCPT ); Thu, 24 Oct 2019 05:37:55 -0400 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 8E3C246A; Thu, 24 Oct 2019 02:37:39 -0700 (PDT) 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 042083F71F; Thu, 24 Oct 2019 02:37:36 -0700 (PDT) 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" , Andrew Morton Subject: [PATCH v13 04/22] arm64: mm: Add p?d_leaf() definitions Date: Thu, 24 Oct 2019 10:36:58 +0100 Message-Id: <20191024093716.49420-5-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024093716.49420-1-steven.price@arm.com> References: <20191024093716.49420-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 will be provided by the p?d_leaf() functions/macros. For arm64, we already have p?d_sect() macros which we can reuse for p?d_leaf(). pud_sect() is defined as a dummy function when CONFIG_PGTABLE_LEVELS < 3 or CONFIG_ARM64_64K_PAGES is defined. However when the kernel is configured this way then architecturally it isn't allowed to have a large page at this level, and any code using these page walking macros is implicitly relying on the page size/number of levels being the same as the kernel. So it is safe to reuse this for p?d_leaf() as it is an architectural restriction. CC: Catalin Marinas CC: Will Deacon Signed-off-by: Steven Price --- arch/arm64/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 7576df00eb50..fe1da5010b18 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -462,6 +462,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, PMD_TYPE_TABLE) #define pmd_sect(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ PMD_TYPE_SECT) +#define pmd_leaf(pmd) pmd_sect(pmd) #if defined(CONFIG_ARM64_64K_PAGES) || CONFIG_PGTABLE_LEVELS < 3 static inline bool pud_sect(pud_t pud) { return false; } @@ -546,6 +547,7 @@ static inline void pte_unmap(pte_t *pte) { } #define pud_none(pud) (!pud_val(pud)) #define pud_bad(pud) (!(pud_val(pud) & PUD_TABLE_BIT)) #define pud_present(pud) pte_present(pud_pte(pud)) +#define pud_leaf(pud) pud_sect(pud) #define pud_valid(pud) pte_valid(pud_pte(pud)) static inline void set_pud(pud_t *pudp, pud_t pud) -- 2.20.1