Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6127284ybi; Wed, 31 Jul 2019 08:47:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdzgouSyaQ5ttFYzf0xo9wTP98xYEV7Zd1DyHMJ6rF3g6wTUtLQ4w6vnqwxKhFpY8WAGBx X-Received: by 2002:a62:483:: with SMTP id 125mr49515048pfe.245.1564588049786; Wed, 31 Jul 2019 08:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564588049; cv=none; d=google.com; s=arc-20160816; b=O9BN7QgXPvGXwQvb2zv7RRD3UsM98SQGzPSr3Hzm5B54qKxbjmZKzmA9Ksos0iBsvD vHaeGMxu8PiOq4WeAi/8ck1UxdjtMi6pGIZca8X7jAW8w3QLJMaiDqDOoDF7SBkNWjWy e0L2HvxHpcrCzJ+n/hlvNkCfBcdhHmo141Pyeuezch0s0UUB/i4jsEVl3EPNkJlSsTHx 76sWZ2wXbygyuzMuJAO+AUjkHC55378BD27ZSnUlZbxgJihys9+0u7+aQlBrSTqubz1b 7UAL9Za6aSL8z2WlYDliFFHkH4aTcgJ3Zplej0nyyTmOU6fRL60fTw/AJ0vAg53x1Xwj lR8g== 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=7eguvhFG3vFIX+cjWUMgrCPyT9l1sSVqWaOQbfj+tXE=; b=me9wO+awnIhPiluPQJJqq+bofk9+CxHGVF3/e2l8kO+oIedtL3RIj1MzGtbpeSEru9 BM9wfV93AiqmTi7BuzzvIRIqt1qjaV6hQ4w6NqRu8MLdWslhmLq9lJ7Ynf2JpLs+1Rda SzpxpxwpcTYAfows39gFNBFbC8VHTtMDIONlxXiRsxxN/eBe73DRCt1YqzWqWlpfjAuw 7eXtYLM4MP9RD1l5B9MgJo5xe40Cb7EoTreL1EkGzHg74Mt4iFAIbrw57WLetvdG3stN 5HhY+pHoVNR32u+Iow7jzxd8BIaHHw44Egb4JAxPihIPtT2pixBif1vJSVWArm33JJTu F/tg== 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 e16si32339758pgt.2.2019.07.31.08.47.13; Wed, 31 Jul 2019 08:47:29 -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 S1729686AbfGaPqZ (ORCPT + 99 others); Wed, 31 Jul 2019 11:46:25 -0400 Received: from foss.arm.com ([217.140.110.172]:49584 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbfGaPqX (ORCPT ); Wed, 31 Jul 2019 11:46:23 -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 342EC344; Wed, 31 Jul 2019 08:46:23 -0700 (PDT) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9D62A3F694; Wed, 31 Jul 2019 08:46:20 -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 v10 04/22] arm64: mm: Add p?d_leaf() definitions Date: Wed, 31 Jul 2019 16:45:45 +0100 Message-Id: <20190731154603.41797-5-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190731154603.41797-1-steven.price@arm.com> References: <20190731154603.41797-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 87a4b2ddc1a1..2c123d59dbff 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -446,6 +446,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 #define pud_sect(pud) (0) @@ -528,6 +529,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