From patchwork Wed Apr 3 14:16:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF68917E9 for ; Wed, 3 Apr 2019 14:17:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9F86289BF for ; Wed, 3 Apr 2019 14:17:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7D1D28A0E; Wed, 3 Apr 2019 14:17:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2491C28A27 for ; Wed, 3 Apr 2019 14:17:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B9796B000A; Wed, 3 Apr 2019 10:17:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 969366B000C; Wed, 3 Apr 2019 10:17:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 808B56B000D; Wed, 3 Apr 2019 10:17:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 34D986B000A for ; Wed, 3 Apr 2019 10:17:18 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id h27so7509317eda.8 for ; Wed, 03 Apr 2019 07:17:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3GzvBNszJ2F9qzyq8uNQC4ioxjUcI3EqpQkesdmXCx4=; b=oV6bi4qCwI6esbCxTRPn71LCs/3mTqqw9El6WyAIfS2EWwyutlF9AeQiRbLqs+Y/i/ m5+MTjCBch38zrZvK1OGdjKE/ZugYeQUKOWlkwXDYK7azFTMr1SZmzzQ7c3OH9vVe7Tj anD8irsbXF+u5YYStV3gH6n++96Ui2EtKlQlTTZlGTJCbb2p7DB1+VO+rK98GlBdVOTP JgqG9VzJmuHnxhdx1A7gFhm114gS5Br1Q+WcCx0L4fHgbV0265f7+jS29wqYiGhD6SoH 3mw/bfytomRKiirmW/sFR+G0iwi7BARJ8dl+48G32bii5UaghmH1kXNenr8T22j19Pxt 30eg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAVNAHtEuWCiq/Xh4/MwjMtnADBMUYU81wPbLh/OTXCZKSKp98k2 SsCeW7q3aH/htHNnZxU8SxZT4sXtBOMZg6DyrybISavWkZDPcQRV5whLEM91YaSML+BJxm1c4Wz gLgpPxeOvb8SNV/TucOGwicfPOjNG+yZ3vxLe9T/v0EPxtS5pDYgE0i3aeGyGWM1aLg== X-Received: by 2002:a17:906:950b:: with SMTP id u11mr4775ejx.154.1554301037682; Wed, 03 Apr 2019 07:17:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8gdkcOm4S6/Ynw4bWrhpaWnsaZH10XXPlh8b0VIA0cTJZNytDu/f81XTcQzpBxeCg0I/L X-Received: by 2002:a17:906:950b:: with SMTP id u11mr4706ejx.154.1554301036420; Wed, 03 Apr 2019 07:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301036; cv=none; d=google.com; s=arc-20160816; b=MmPyXIDqIGwGmWCz9fMu9PVv8j85iuYjDjQEIk3AhE6AUuxA9KzSzAZm2kPWdyW9hc DrXnJbCojNal5w12Ojx+siGQgcalXL9sKpVDZgHSYgEFUwMs7baixRYajQGc5qugNKXR 8tU7h2RM9VlxV9ZtjcvbGDVfknsZF6TxpE1hkYYUJFfqaS5Vcr+wOq5RcykiZTdv3LJt bKX5J6guLM01x0zmJSdczjCc5BDP5zwba9tjOcBzk1tv45zJgtZAgLn2yg/N0BFp14P3 f4zQ40IzEqAvUOCZaG1B81y8dVpDDXtVaX2ri/mvwWL60GkFH3NGgAbFNUXE93f0SaMR qcxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=3GzvBNszJ2F9qzyq8uNQC4ioxjUcI3EqpQkesdmXCx4=; b=dsFEm/dnyrZhuNDgv1Q7Kt03FbUfmAMcwc+fushhUGq77yJjqFNJNryHZKxMJ4EHOD qZs/xuOFPGGohun/UDhBHdHaEodRWuAkHZ0LU/y2nREJ+htusboctT1z5j6T2FW8nxPh wD+CUti9DhalZBeJ/DxUZP4GYgY9Aa5scpFMUXYK0Ieh+NrBJE7JAtq2neDG5rwVm0+x BAfMCKb59WXTvYxErFBGa8U0E7XGy5P43eqTXj9bG7F5AAO2qfdAH1FK5vnfWc2UDVbF q0v66vyIEHPNksYn94Hc/dBazfgV/4ZB5bLa0Wz6OsGaMlSBtZbwYbf6Br1en+83/bKO tESg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id p5si3352535edr.211.2019.04.03.07.17.16 for ; Wed, 03 Apr 2019 07:17:16 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 6F9FEEBD; Wed, 3 Apr 2019 07:17:15 -0700 (PDT) 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 BE3033F68F; Wed, 3 Apr 2019 07:17:11 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 , Vineet Gupta , linux-snps-arc@lists.infradead.org Subject: [PATCH v8 01/20] arc: mm: Add p?d_large() definitions Date: Wed, 3 Apr 2019 15:16:08 +0100 Message-Id: <20190403141627.11664-2-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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_large() functions/macros. For arc, we only have two levels, so only pmd_large() is needed. CC: Vineet Gupta CC: linux-snps-arc@lists.infradead.org Signed-off-by: Steven Price Acked-by: Vineet Gupta --- arch/arc/include/asm/pgtable.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h index cf4be70d5892..0edd27bc7018 100644 --- a/arch/arc/include/asm/pgtable.h +++ b/arch/arc/include/asm/pgtable.h @@ -277,6 +277,7 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep) #define pmd_none(x) (!pmd_val(x)) #define pmd_bad(x) ((pmd_val(x) & ~PAGE_MASK)) #define pmd_present(x) (pmd_val(x)) +#define pmd_large(x) (pmd_val(pmd) & _PAGE_HW_SZ) #define pmd_clear(xp) do { pmd_val(*(xp)) = 0; } while (0) #define pte_page(pte) pfn_to_page(pte_pfn(pte)) From patchwork Wed Apr 3 14:16:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EAA7817E1 for ; Wed, 3 Apr 2019 14:17:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D11ED28A2D for ; Wed, 3 Apr 2019 14:17:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF1EE28A31; Wed, 3 Apr 2019 14:17:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BCA5288EE for ; Wed, 3 Apr 2019 14:17:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 043106B000C; Wed, 3 Apr 2019 10:17:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F34856B000D; Wed, 3 Apr 2019 10:17:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E23E46B000E; Wed, 3 Apr 2019 10:17:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 91E2C6B000C for ; Wed, 3 Apr 2019 10:17:21 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id k8so7582078edl.22 for ; Wed, 03 Apr 2019 07:17:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0eNmL9jfrpxDxa34qI8mFbQ8g1QTc4gDo9JxlJwzabQ=; b=Bm5KiMJ9HhyKAOjyqJQuVbwM9g8XUvlaZSUz4dirpnsG++ipFi6GLM8dgUw7sfKp2z rG0tBVjfJ/rHLFo5Ip3LGBbKjF6TYkPxAotB9FhCAvTwuRLWDOvntAXwwDcokEAQPkqd ARia2F8inRHlGpYtbLhc8sV5FfbPN+sTlAMXkE9tyNgaUJ+gM+sD0qROQPmo99zCruTc 0Uh+Sw2obtofWg5ZKLY/bg8kbZDCVXJn39+29SZF7hBZK2cXz76MYVmdS4PRSzqn0X4w Fm1sZwdGXcEVKlrl/TyHQm2mPq6gawSC9bRAAPZlxew9CYEKmasiVxb+i1WCGPJiOoJt /FLA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAVyu+EpU7zGJsgyyDv+aAkawNhJ9SH2qFxolL0LdCQ5/zlj2loK YQEk/7vU1F7bip1a+B2UmiwXBCcIGd5l/XRSSUO5hbqrfpiwpEqMQLOLkhjNca4V1RbBTwcPttO 5l0oCgCFBDhu2tliUVw0Z1BEW1rGCjgUT+9hz5JNOETuGpJ0cPXCmKWEuUVTe/mj+FA== X-Received: by 2002:a50:91ac:: with SMTP id g41mr48831564eda.188.1554301041105; Wed, 03 Apr 2019 07:17:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyZd5FDIyrDYxBfJVaPs8YlOaK0zlgnBcrVgxE/6XaPQ8cD8jY6eo6DbRBVHjRAEd+lO51 X-Received: by 2002:a50:91ac:: with SMTP id g41mr48831511eda.188.1554301040065; Wed, 03 Apr 2019 07:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301040; cv=none; d=google.com; s=arc-20160816; b=I0L803pVY+dhp8wu0Or+3tpjHnoJXVaRdm8R/PeEpzMIoEnjJ2CB50tGTqRPVBJCj9 6Kh1MHpkDHRp+hqo+/QHYGbCeJIxGoqhQNQ77q4sBOJ7aptqOVMXmOtU8iZnSALPUcKI OAroUiXle80cE/H8e88lSoacYcLpwRdsSoBIjYDov5GHcBtLQ8a8kVEvWpAWVtU0sXB4 fnIVw7GeHuMSL4KfoOgg4Lt9KM8/qUPa5hSejhl3XNqcNj1zG0o/WSgsEE0TSN1CK9vk MdZcT0a/RlerejHQRpqlp6T9iNp0mmyvHdjYLkak+p6C5TEI7Afqej6rJY/u3853p7J6 Fw3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=0eNmL9jfrpxDxa34qI8mFbQ8g1QTc4gDo9JxlJwzabQ=; b=vfYFo9L1HoMGcS1V6zG9ZIfW9Jxgkab1cqQ8yShjRjbK7VmoKVm8R2mCsP9n4SG8GU r8yayHWWnS4OXpiSwdzWAJijSgBq/2WDxwtodbXa0ywJelcGzmfeX4QKmRwAf0KBLBCk Lk9qN3MX31/ueFfhhYQIFy642OAt2hfSVeGVAhXqGom7oQP5N6wV5sWP2UIG3CoLUd/Z nh9FuH+I3ySip89gIt0nCT5q93radTG1s4mEhMvvbOnB9s7mPAyhOZlg61tevCzhydCK dOIByNzVLb6GB1oq3cuYPgM5esWPA7oVlko7VZ+2XQSNmpnx8NnnCwcFfC7mCgG2YDPC fnlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id p4si1349570ejj.274.2019.04.03.07.17.19 for ; Wed, 03 Apr 2019 07:17:20 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 1ABA01682; Wed, 3 Apr 2019 07:17:19 -0700 (PDT) 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 AF9D83F68F; Wed, 3 Apr 2019 07:17:15 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 02/20] arm64: mm: Add p?d_large() definitions Date: Wed, 3 Apr 2019 15:16:09 +0100 Message-Id: <20190403141627.11664-3-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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_large() functions/macros. For arm64, we already have p?d_sect() macros which we can reuse for p?d_large(). 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 that 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_large() as it is an architectural restriction. CC: Catalin Marinas CC: Will Deacon Signed-off-by: Steven Price Acked-by: Will Deacon --- 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 de70c1eabf33..6eef345dbaf4 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -428,6 +428,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_large(pmd) pmd_sect(pmd) #if defined(CONFIG_ARM64_64K_PAGES) || CONFIG_PGTABLE_LEVELS < 3 #define pud_sect(pud) (0) @@ -511,6 +512,7 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd) #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_large(pud) pud_sect(pud) #define pud_valid(pud) pte_valid(pud_pte(pud)) static inline void set_pud(pud_t *pudp, pud_t pud) From patchwork Wed Apr 3 14:16:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA12717E9 for ; Wed, 3 Apr 2019 14:17:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F45C28A30 for ; Wed, 3 Apr 2019 14:17:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8310F28A13; Wed, 3 Apr 2019 14:17:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4D3628A27 for ; Wed, 3 Apr 2019 14:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17A566B000D; Wed, 3 Apr 2019 10:17:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 12C736B000E; Wed, 3 Apr 2019 10:17:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 019E56B0010; Wed, 3 Apr 2019 10:17:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id A7F3A6B000D for ; Wed, 3 Apr 2019 10:17:25 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id l19so7505505edr.12 for ; Wed, 03 Apr 2019 07:17:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MqMqukGILHQS5vjuNGdSQFWysz8AgSB4keSNgmoOKiU=; b=o8Qk1cc6LFZ8YLvUQNDoV2i0gv6OtOf7vsEtPqrWMrKItUrqs94liwd3STbszBnJdg 46/DqSKGe/lif0+BYw7GHw3si/sp3cMYu38CQw08sFpWh4LoUP505rEwi4GKUeyFP0rj lJeuSawovU/ophqFqKVlG1uSqnJnL0/S3KGpSi6rdKcjUihqbC+5+CzHshaW+kmfXN1v bP9VH7v/lkUFFRUV4Do2DzuqnmDRMLbW6SmIUrb7Z3aieoXGrj9MFNAcn71KS1dn9aS1 RVKCIBfg5KrdCsJ+gua7NBoS/lteUH7eoMRzZsM42y903gaVEt4MSBD85wk9L0ZguCSt 2PJQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAU/ILlmRDxf9rlG1RlMfAYRhyKzq7/z1FjdYOfmc8gUW/OLbQ1V x0iR4IZSL5gYPt8cq1LbSIla9pFRUSLfUsikZzMIFIFafTSEyVpN/FL0hUBDHB2znNrgaIaW21+ AbumMfTRXQ5LAU8MdCrC2WpOLV810yD4Wn5f4KEDcg00Af7R2KHuwIPz8ywWauW1ucQ== X-Received: by 2002:a50:b6a9:: with SMTP id d38mr50401035ede.98.1554301045211; Wed, 03 Apr 2019 07:17:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfeB19XcgSAHCGppBvscGbZbZ5gJefz0Tbm9nutsLt8y2P1ALT5M6OM5aGHCb2/OfvI+/X X-Received: by 2002:a50:b6a9:: with SMTP id d38mr50400988ede.98.1554301044371; Wed, 03 Apr 2019 07:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301044; cv=none; d=google.com; s=arc-20160816; b=gPKHl2HUP8uCo70kZSNfZAQJ2CoKHwqniF2j7BghBUUrqtgYkUCMHPJouBCumd1OTd 6z2e20OLkQPf2wxVgLmdHSoa6L21h0Vdff59q4AJTv+qTeUHTtzrJoqskNApJ3OHvd6k uH8TFtRfG8BeVdtBT5EfmUrfo91Kr0NZ1V2tm3DR9Q8QUONBJqHGLuqAE+tGcGlZhI9Z skoTs7Wfjs8I1KPFdsRtqgyeTilLbuhl7312qfr6GlRf4VmL+xfcELqHTmACVwS0vKZi XbtPCdQW1m/52hE9mIDqsSRMVvYKP/R9XdN5zdO9oWAuqPmjlvVZS8ptdOoieNHbUp9s dHEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=MqMqukGILHQS5vjuNGdSQFWysz8AgSB4keSNgmoOKiU=; b=Y/g8q6JyFhyUyO/M4tJnadGXKfyiJvX7FGBSCKGQiG/jEYhsl4CDrJCiq5ckK14ozM ndql2l6Wl0f80RZ92h67ErbLMZTwOJ/UIbx8H4fBL1hPXW4i7akPxNUeFpF4AtcgQG3C fNftQcyYyzQEFVQvOY8L16herXcuAIQGe/CZBiDEhkxgUUNZcLpe59uZY7+2ORvEvtpE yYvGChAbBY+sR7NFCtj26kByDweJIqBO0r/wW3+uHF5KdEjeMVlU5AGLpcbdSiFWtHN/ KpYX3FgU5czlv+7mglT8ZddEB4rla1qeDoC6bfya/0MeBu/kQecsoNfeIL1Yaa1ftWjL JhQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id e4si2203466ejl.232.2019.04.03.07.17.24 for ; Wed, 03 Apr 2019 07:17:24 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 52CBD1596; Wed, 3 Apr 2019 07:17:23 -0700 (PDT) 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 5A7813F68F; Wed, 3 Apr 2019 07:17:19 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 , Ralf Baechle , Paul Burton , James Hogan , linux-mips@vger.kernel.org Subject: [PATCH v8 03/20] mips: mm: Add p?d_large() definitions Date: Wed, 3 Apr 2019 15:16:10 +0100 Message-Id: <20190403141627.11664-4-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 mips, we only support large pages on 64 bit. For 64 bit if _PAGE_HUGE is defined we can simply look for it. When not defined we can be confident that there are no large pages in existence and fall back on the generic implementation (added in a later patch) which returns 0. CC: Ralf Baechle CC: Paul Burton CC: James Hogan CC: linux-mips@vger.kernel.org Signed-off-by: Steven Price Acked-by: Paul Burton --- arch/mips/include/asm/pgtable-64.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h index 93a9dce31f25..42162877ac62 100644 --- a/arch/mips/include/asm/pgtable-64.h +++ b/arch/mips/include/asm/pgtable-64.h @@ -273,6 +273,10 @@ static inline int pmd_present(pmd_t pmd) return pmd_val(pmd) != (unsigned long) invalid_pte_table; } +#ifdef _PAGE_HUGE +#define pmd_large(pmd) ((pmd_val(pmd) & _PAGE_HUGE) != 0) +#endif + static inline void pmd_clear(pmd_t *pmdp) { pmd_val(*pmdp) = ((unsigned long) invalid_pte_table); @@ -297,6 +301,10 @@ static inline int pud_present(pud_t pud) return pud_val(pud) != (unsigned long) invalid_pmd_table; } +#ifdef _PAGE_HUGE +#define pud_large(pud) ((pud_val(pud) & _PAGE_HUGE) != 0) +#endif + static inline void pud_clear(pud_t *pudp) { pud_val(*pudp) = ((unsigned long) invalid_pmd_table); From patchwork Wed Apr 3 14:16:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 311B217E9 for ; Wed, 3 Apr 2019 14:17:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D0C226255 for ; Wed, 3 Apr 2019 14:17:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A3E5289F6; Wed, 3 Apr 2019 14:17:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A953B2896F for ; Wed, 3 Apr 2019 14:17:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 217ED6B000E; Wed, 3 Apr 2019 10:17:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1C97C6B0010; Wed, 3 Apr 2019 10:17:31 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B7036B0266; Wed, 3 Apr 2019 10:17:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id B33786B000E for ; Wed, 3 Apr 2019 10:17:30 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id n12so7649389edo.5 for ; Wed, 03 Apr 2019 07:17:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6VnZSWrBLPP0YYU4zKMRDn5dbPSJfXU3wTa2rjMcHkk=; b=PN0U2uu3qH+uYnn3XEmNXeWGdl4WlIaQF89xQPuPOqEUWZPCnR2i7QGl29WYZMMx/C V/kgihZKPwvVXfuXLNjMnQDchSOi6Qy6A1ngUPSY5tOqY6RTI5WYky3T1ZxvuEZXdyDS k+BpAbCYE19eFr6wK2tRcI9GogCdN7IGdDM4YSyD2iQW3SVmNgXUV+ChLtCCTm8ST9U4 Sc2IC5ifb5Nm6ezfzzv0+VKolaG7ihhw5ScSOMlkJWL/7zxvPHsGMUNfAa8zICUbO6nH hQOK62hCDD0PCsLnFxr++0y8EK85pRkMIUWGaimAAbwkvENBNLlhg5oFV2LjPn6amCSI du9A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAW2Kc7rgsCPXNO5VC7TArKQlomZ5WM1dxR1IOZZ1XtiGS3FEwA7 OM8qKhq0eBc8Ep1lbNbW119PyBtnsxRByQ4omT4MT4aD2ntUIoJdS6uE0r2huQ/qzUaThShPgqv dvwWEmTjbvYD88yIHZolu1mO2jMhkdWWidIy9+z9Wk4K1WtTdfOVbM1emYRKzi2ZI6A== X-Received: by 2002:a17:906:8247:: with SMTP id f7mr17824320ejx.216.1554301050223; Wed, 03 Apr 2019 07:17:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVNl96F6woXc1It+RPym0tJdtkZxkKWJ2HLcgo3r5Y9pG57YlE6I72Khw59Hi51iwKw0US X-Received: by 2002:a17:906:8247:: with SMTP id f7mr17824258ejx.216.1554301048885; Wed, 03 Apr 2019 07:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301048; cv=none; d=google.com; s=arc-20160816; b=P48inbPyu+vrkxJXE8fUv1aiaPtqxojj7InQD1myavA7BV1kj+JQLu+25tNr8gfnJm dxhQxufwzppas+iU9KD6VIPfElkXEEch2GFcw5qIxMFAasnuvcLVX54zQnzXAmsjt3jS 8HUlxU2mfQSG6gm3E7YblL9BguxTEAmSGEgHVTolvWszJpNx9qX1wZCi5puEIxSuqt3e Lz2uQlj/mDsiIdJ6Yo8rHne0gGs7y90rJAcHRH+SSlgNBQ9e5gAng1Gtgul9GBtA34wc VbX9yYPWfIzi8arFJGuai0PCSwcnxKHaTIcRl4mtqow9Zn7v5veNq7Kr6saXRnWAhLNH yosw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=6VnZSWrBLPP0YYU4zKMRDn5dbPSJfXU3wTa2rjMcHkk=; b=DmdN0kGih08a/nwFcUW3b06RQVOlGmU9Imu1Sjmo2dK2WCsIFM/k3o9DvII5HpEYbE /mm/tBio1mBAazrc0vqTfWZQs/NGA4+jEAXx09UCRt4sS3e/5yyNsumk7MgY5KxY4QJd givkLCea9YV2ZpGcYkoZc/aHHtbwuLCZ/j++zqTtL1J+3rOofEyznsAl8VNrQpLjvtOK VZcfGPXDN9ENldpSTz9fJRYZ14c4su5sJP4ijhJI7+E/bzLyKTMXy4wEzEpnxHv9coMQ KASRSVwYGyicLW3KlVt/IpzXI4KEeh/mE0q49D1Fg8vA+K62ECMpR3B02iAlrQ2s1ZB6 4D+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id o26si356003ejx.277.2019.04.03.07.17.28 for ; Wed, 03 Apr 2019 07:17:28 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 B25BC1684; Wed, 3 Apr 2019 07:17:27 -0700 (PDT) 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 936F23F68F; Wed, 3 Apr 2019 07:17:23 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org Subject: [PATCH v8 04/20] powerpc: mm: Add p?d_large() definitions Date: Wed, 3 Apr 2019 15:16:11 +0100 Message-Id: <20190403141627.11664-5-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 powerpc pmd_large() was already implemented, so hoist it out of the CONFIG_TRANSPARENT_HUGEPAGE condition and implement the other levels. 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 581f91be9dd4..f6d1ac8b832e 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -897,6 +897,12 @@ static inline int pud_present(pud_t pud) return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PRESENT)); } +#define pud_large 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) @@ -940,6 +946,12 @@ static inline int pgd_present(pgd_t pgd) return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT)); } +#define pgd_large 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)); @@ -1093,6 +1105,15 @@ static inline bool pmd_access_permitted(pmd_t pmd, bool write) return pte_access_permitted(pmd_pte(pmd), write); } +#define pmd_large 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); @@ -1119,15 +1140,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); From patchwork Wed Apr 3 14:16:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883897 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6B9E17E1 for ; Wed, 3 Apr 2019 14:17:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DD0028A14 for ; Wed, 3 Apr 2019 14:17:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8196B2858B; Wed, 3 Apr 2019 14:17:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E995C28A13 for ; Wed, 3 Apr 2019 14:17:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43BEC6B0010; Wed, 3 Apr 2019 10:17:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3EAA36B0266; Wed, 3 Apr 2019 10:17:35 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D8986B026B; Wed, 3 Apr 2019 10:17:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id D65776B0010 for ; Wed, 3 Apr 2019 10:17:34 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id w27so7691238edb.13 for ; Wed, 03 Apr 2019 07:17:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=SYRxLnl8XLiyLdkh6TtJG1FrMibEOdTkR6dxxuI72gg=; b=JA91eqYxfjl0B6PbDAB1vj1DjrAgCkVooYiRmca9WtrGPZPsKp3oqExgY7Gc15snZO /U9DU4aurcUmYZSGWADI1PVxHRTajkIAzTWgu4NDwxbqloNA5yF2bLHS5eN1OMEaGEpD 3KkBR/pygPrTp6ssyHkcRmxaYgFoAUuaHPr5NGN75e3foOSaKSQUG/FP9d7uvfXxH/K4 2ysZSJd9q5oN2bYXw3CNzQJcLL7w0au4w+vXJJTQWI80oY5mOZx2n1UlfzP52lUF/fXg 0iefOpdArAqiq1RigTbHHJ5t450Mjk51WF7qeYHkCzyHx6x7MwEEgQzsRqorv//TBtNA u6Eg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAWr8B2eO7slJ4HrlLD6T3cYZXNjG8JNFXHsVeTlEekebDtLqlTf F05KCmOFN7JhhYfdehgJ2lSvfu8gAWoM3Gr2pJek7Si5reaEO5GC6DP7Vf7hiLtXSFriroN14jV Q5CLKJluy5DYY2Pu5MxmvMAj4sbEHaso9LmwmVx5OpWrAXeZgxT/yewr9YFdwvbfpmA== X-Received: by 2002:a17:906:3581:: with SMTP id o1mr2935008ejb.163.1554301054378; Wed, 03 Apr 2019 07:17:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwI8hh+KzTDIYhDJg3x5DDThpZl39M0AD6RGiarnnjXXfvTtT9Ntr/NvZCKnH08dMwylja3 X-Received: by 2002:a17:906:3581:: with SMTP id o1mr2934943ejb.163.1554301052997; Wed, 03 Apr 2019 07:17:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301052; cv=none; d=google.com; s=arc-20160816; b=brBNlhUaARVV1RLicnDy0YNw+KOEFuvTATUixEloOXTw4pV/INb4339cFtGsYIPcbz TcjSefuxKt1UqdSJ7hZBeA6/Op8NN6kod9oYS8ez9H+2OtgIw+WBa+l97BKME01Y6EkC 4i/CQajkxhGNT/MtJ4VHPRbnFTjw/myhUXTHPHhsjk5G5yIHieJHQzZYwmt1O/hPHLE+ gDb4H3+UxPQwJh/tIQ/0z9VYOx4JXZiq+e/IU/tJG4pGA059ZASxRBVUPn1cbDznxwZd qOJrRBsiNnUb74Nt+/tzh+9xhLFwJzjgLo80jhpm0zqlFoLnM1Xz34zvn7NTFmJIT71i hwzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=SYRxLnl8XLiyLdkh6TtJG1FrMibEOdTkR6dxxuI72gg=; b=TXrtVMEfFlKOD3dog+kL96DmWDRRWPvRCq5Yz86ztayW1F68eXwVQkKyGGFxQngFMY YmesPXa/wrVIiiSX9DwHrM3qNvioKmGlP5AW8IMD3SwDK3LaBPy8UO88Ztbk4DeDPzBp 1UBLMRhj5Ac3vT0RqXYkRQzHsoebN+XFN26ZkZQC9NojAQXC8PpxT5ZdCcB8m06OHfNz FrzTSBeIonDo2Lhj0yuPMz1dHLhCOhXDo5poVCChaX3yFq4/fpXCBQ71bXm84WwhlLer +QokShePDbmwuOdE79xKv5/PpAMHbb5zemVbypqcb5iTjYmQ3+MDVe0EizKrJwev/Slk 4E6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id u31si537432edm.308.2019.04.03.07.17.32 for ; Wed, 03 Apr 2019 07:17:32 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 1A197EBD; Wed, 3 Apr 2019 07:17:32 -0700 (PDT) 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 F06A03F68F; Wed, 3 Apr 2019 07:17:27 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 , Benjamin Herrenschmidt , Michael Ellerman , Paul Mackerras , kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v8 05/20] KVM: PPC: Book3S HV: Remove pmd_is_leaf() Date: Wed, 3 Apr 2019 15:16:12 +0100 Message-Id: <20190403141627.11664-6-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Since pmd_large() is now always available, pmd_is_leaf() is redundant. Replace all uses with calls to pmd_large(). CC: Benjamin Herrenschmidt CC: Michael Ellerman CC: Paul Mackerras CC: kvm-ppc@vger.kernel.org CC: linuxppc-dev@lists.ozlabs.org Signed-off-by: Steven Price --- arch/powerpc/kvm/book3s_64_mmu_radix.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c index f55ef071883f..1b57b4e3f819 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c @@ -363,12 +363,6 @@ static void kvmppc_pte_free(pte_t *ptep) kmem_cache_free(kvm_pte_cache, ptep); } -/* Like pmd_huge() and pmd_large(), but works regardless of config options */ -static inline int pmd_is_leaf(pmd_t pmd) -{ - return !!(pmd_val(pmd) & _PAGE_PTE); -} - static pmd_t *kvmppc_pmd_alloc(void) { return kmem_cache_alloc(kvm_pmd_cache, GFP_KERNEL); @@ -460,7 +454,7 @@ static void kvmppc_unmap_free_pmd(struct kvm *kvm, pmd_t *pmd, bool full, for (im = 0; im < PTRS_PER_PMD; ++im, ++p) { if (!pmd_present(*p)) continue; - if (pmd_is_leaf(*p)) { + if (pmd_large(*p)) { if (full) { pmd_clear(p); } else { @@ -593,7 +587,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, pte_t pte, else if (level <= 1) new_pmd = kvmppc_pmd_alloc(); - if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_is_leaf(*pmd))) + if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_large(*pmd))) new_ptep = kvmppc_pte_alloc(); /* Check if we might have been invalidated; let the guest retry if so */ @@ -662,7 +656,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, pte_t pte, new_pmd = NULL; } pmd = pmd_offset(pud, gpa); - if (pmd_is_leaf(*pmd)) { + if (pmd_large(*pmd)) { unsigned long lgpa = gpa & PMD_MASK; /* Check if we raced and someone else has set the same thing */ From patchwork Wed Apr 3 14:16:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883901 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 47B23184E for ; Wed, 3 Apr 2019 14:17:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32F5228A01 for ; Wed, 3 Apr 2019 14:17:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26AFD1FF73; Wed, 3 Apr 2019 14:17:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96699287B8 for ; Wed, 3 Apr 2019 14:17:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 091886B0266; Wed, 3 Apr 2019 10:17:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 01B7A6B026B; Wed, 3 Apr 2019 10:17:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFE5D6B026C; Wed, 3 Apr 2019 10:17:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 94FB36B0266 for ; Wed, 3 Apr 2019 10:17:38 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id 41so7661513edq.0 for ; Wed, 03 Apr 2019 07:17:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1lP5uxd4lkeHOs2R/letx90Hs4gQDKi/XVW6tvSp3kc=; b=FvcyzKLEZQJBI986iOwqesMegd1cgDsqEbtzL2ojxh+vHgALz5fy34dYwYX3YxfmiB X4b91m2m46WhzniWktsKc3ao8Xpjjgr8SuQc0H9xRUXJ2/0EecaOaQPL5xUIkqM8DXok 8wN9PkIT4kaKOr1dUhsv/jn7D9/PgazV0Ozg/pd8SqWVY9NBndZBo3YJUde8/bVadoQl aB/DUa/5NOmCDnq/ok/3mfOpWziBXF2X8KyBi4Kq/if0LMfW73LguOXiLvWlBHjjpYi0 Q/pQw4N+PR9wtxTFoJKXEv8K4aLaopNBFET3ow34n7vns6i4r1dYw/koXq7iVgprtHX2 dNnQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAVgUgKSefulDnMElWMRdWiIaxGdXwBlLA8g7nsMj8vmFaYlLjSY UZD8ikp4Ktcu07h9s5Fd+ffNmJOAXnutESh1zX/Xb2wAKQI/DKISRK1arukd13gGnm2X82QBe00 cs1bw/AkUh9SN5w90/vv8TiHlGYrsAj+8sFJD0AFZXSom/wKPnIiqeC9RSaZ62d+N9g== X-Received: by 2002:a50:a6db:: with SMTP id f27mr50837308edc.117.1554301058106; Wed, 03 Apr 2019 07:17:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXvKDU8mHg61+kfBbcR1e+isvHzv6G0hbLCNeOJ8QT6GCWunvpjFTNBXpmEtRlaWc9HsBH X-Received: by 2002:a50:a6db:: with SMTP id f27mr50837263edc.117.1554301057250; Wed, 03 Apr 2019 07:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301057; cv=none; d=google.com; s=arc-20160816; b=oAybVYDrrpv+gzcWMkEsgAHjPoYcNCTsy2QAZPmXBEYKVjOsPvsfpH5xwRQwMxxQ/8 YHMYEzcEENd9rAs0Poe861qUSVfEJVOylOihr+iRL6nhE0TPEXrtFj+lq0AWJ2j4uVzr E5KeW6+W8v9E4xvLUz2wrHlfAflc0rP+b6cycDl6yxEGMBOJcsnBcSqk+EEkXg2OedIJ nqOYfJtZjT/uXDOa62ozIFXqLy/Knxi2l6QHhk8htfFcUvdA3iUOjG8KPPSrZvvREFbU t5GeZzhxvE+tIa7asijcctau0M0SwgdHNH2yDgyZQl8wNRuktUqK1NmENnFb/MLyogbW 2D2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=1lP5uxd4lkeHOs2R/letx90Hs4gQDKi/XVW6tvSp3kc=; b=VYPgWACA+KWFqBSd86UF0hIwwdScicBp09lanxoDy3lzN1l1fwHotbPZIuPOwau+Ie 3TruNYrQBlWQsN2N4P/wQMI7BsvisEjWzfe84S5+n1mqIrZA1xB8kquh2WGcR2hnYV05 xnlinT/I4QDb92Zq+Y4+2DFsrK4yeznHqZFrndeFA9L23Cs3MW1C8tGwfHxKOwEsCNSW eUAUUmxR2po2mOzT63xIBTMfvghSTlM7+R3lEZZ9+Z7vf2Rx+xVnKg8XDzsUuRczkRQc o9Hu6eXDptL4dcsUDhkvRMq7bntPz/wo7C6jXLShCuWp0p/9/c9mTxwvEyBD1gbtXSPq /S9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id m29si3453588edm.213.2019.04.03.07.17.36 for ; Wed, 03 Apr 2019 07:17:37 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 358D41596; Wed, 3 Apr 2019 07:17:36 -0700 (PDT) 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 5A3383F68F; Wed, 3 Apr 2019 07:17:32 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org Subject: [PATCH v8 06/20] riscv: mm: Add p?d_large() definitions Date: Wed, 3 Apr 2019 15:16:13 +0100 Message-Id: <20190403141627.11664-7-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 riscv a page is large when it has a read, write or execute bit set on it. CC: Palmer Dabbelt CC: Albert Ou CC: linux-riscv@lists.infradead.org Signed-off-by: Steven Price Reviewed-by: Anup Patel --- arch/riscv/include/asm/pgtable-64.h | 7 +++++++ arch/riscv/include/asm/pgtable.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h index 7aa0ea9bd8bb..73747d9d7c66 100644 --- a/arch/riscv/include/asm/pgtable-64.h +++ b/arch/riscv/include/asm/pgtable-64.h @@ -51,6 +51,13 @@ static inline int pud_bad(pud_t pud) return !pud_present(pud); } +#define pud_large pud_large +static inline int pud_large(pud_t pud) +{ + return pud_present(pud) + && (pud_val(pud) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)); +} + static inline void set_pud(pud_t *pudp, pud_t pud) { *pudp = pud; diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 1141364d990e..9570883c79e7 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -111,6 +111,13 @@ static inline int pmd_bad(pmd_t pmd) return !pmd_present(pmd); } +#define pmd_large pmd_large +static inline int pmd_large(pmd_t pmd) +{ + return pmd_present(pmd) + && (pmd_val(pmd) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)); +} + static inline void set_pmd(pmd_t *pmdp, pmd_t pmd) { *pmdp = pmd; From patchwork Wed Apr 3 14:16:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC03B17E9 for ; Wed, 3 Apr 2019 14:17:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5884287B8 for ; Wed, 3 Apr 2019 14:17:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C952528A12; Wed, 3 Apr 2019 14:17:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D8CA288E1 for ; Wed, 3 Apr 2019 14:17:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 23FD66B026B; Wed, 3 Apr 2019 10:17:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 214DA6B026C; Wed, 3 Apr 2019 10:17:43 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 105486B026D; Wed, 3 Apr 2019 10:17:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id B5DDB6B026B for ; Wed, 3 Apr 2019 10:17:42 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id c41so7596391edb.7 for ; Wed, 03 Apr 2019 07:17:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=EIMxzs3KcJ4jmgX2iikj+tJ0Q4+Nen0h2D0kdVtq1V0=; b=fgnA1Pb7dnyzUXRQgHajqu0Y0pwcykM5+fHo5EH1YZtCiqndkYGwkrbSxhkFBUmpUs DUJyeFuoeZb9irGuvF8PNqmAGiEGCJqQkPriBFnNra58Y9Kydd0+PuBbDXjZGUsCVjxp lPu311d61XkPLmM91MT9mIGRjIUY17LGxq/5m0N4sf44WxuTG3Xmi6Av039O1kbe2+En umx/foqRTZlc/iheziCCRGU7Gake/hCm7j91N5c80vRd5D/t7DpgPi3U3/kFSuTyknTl MLuDfj8lpRMsaBZu49rrgjfrCeUHgPaGSIUsjleUc4Mzkt8Te2dDZSWIS/3Jm5tbq7+u C/Vg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAWKfPsQViBgcwBs5jLQqa+qEyQHgjF95rcrw9cMOvId1pf5PgVP HsnaRG4fBIafKb8Hgr4VImqR+PrrseXOup2beJjgY04y5AvNb1e2NXD0Oj/h6uG8B4rV8K9C+a1 vW0WNzBLLnE4cp8ihXPig01JVQXqJSY0447Dlo1v6FBUt6fw72UvyJFrrARQCy0xJfQ== X-Received: by 2002:a50:92f6:: with SMTP id l51mr53032957eda.15.1554301062266; Wed, 03 Apr 2019 07:17:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZuhDng9RjdCCV5e/qY5OJXa7Q/58y65yQNB6MQDejGMo4sIA9yNrliZCY4ijfDX8gmHH7 X-Received: by 2002:a50:92f6:: with SMTP id l51mr53032893eda.15.1554301061148; Wed, 03 Apr 2019 07:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301061; cv=none; d=google.com; s=arc-20160816; b=Kiz9h0RCwcDsQ70WJrnLHSPfov/ElQKOUoVKDSt/d5ZwyhXqBGS7dmyiDNzj53RKm7 si9OUjdnx3YtWqxYTVF16eIkqsVpf00kfgZH8aXkoHQ4SLoZgM1u89o04qhs/eawwCzb N3YwpxSirFsW50B1VCDAsR99cjsvxfh/ISQQZ43Y0YgOH+RrRNQM/eGVTNSf8Ox4GjJ5 4RpifJpc2cbtUrgMt6i6jy0PjGDXOwzq7xd5HkOkoCenERLQp7dA3w9rcHTjakIYDeif U0RYmPwy4zNWp56N05R/71OTvIEbPcXxw+YEpY8KOLqmLhjNlkYTu0G4U8w78UiZ3mjh TciA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=EIMxzs3KcJ4jmgX2iikj+tJ0Q4+Nen0h2D0kdVtq1V0=; b=Q2QtEUHwvhphL0q6TIUsnXeplmnoCuXGk9R39ItQBlriP1H32KFUW+3mM04V3UZ9vM saHQjk0PTUVJ6Y87cA1FFlYOZAr97YzHLh49eAP5NCrXWjcUetoPnXHGAQxw6Xuagz7l DpIBF2ZUXJfL8XhmT6FZs5gXh1wTLI1YG7/lvPTdc+fThdUoj9pT8mSlpJjny2Gaa3Tt 9jg9ix7JAmajbtTinHBmJo0UsTdQrBKO1pTWxZSddy6nd/Mggrg5HS4VFphoM/TEWZaq s541g180Gl6hkDKiMHD9pkrP5ZDEInKebKGLUa4qJ8tCCCxTP26+ylc20fy72Q1vqk5d 4yCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id b41si6892897eda.179.2019.04.03.07.17.40 for ; Wed, 03 Apr 2019 07:17:41 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 4F4521682; Wed, 3 Apr 2019 07:17:40 -0700 (PDT) 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 75C643F68F; Wed, 3 Apr 2019 07:17: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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 , Martin Schwidefsky , Heiko Carstens , linux-s390@vger.kernel.org Subject: [PATCH v8 07/20] s390: mm: Add p?d_large() definitions Date: Wed, 3 Apr 2019 15:16:14 +0100 Message-Id: <20190403141627.11664-8-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 s390, pud_large() and pmd_large() are already implemented as static inline functions. Add a #define so we don't pick up the generic version introduced in a later patch. CC: Martin Schwidefsky CC: Heiko Carstens CC: linux-s390@vger.kernel.org Signed-off-by: Steven Price --- arch/s390/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 76dc344edb8c..3ad4c69e1f2d 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -679,6 +679,7 @@ static inline int pud_none(pud_t pud) return pud_val(pud) == _REGION3_ENTRY_EMPTY; } +#define pud_large pud_large static inline int pud_large(pud_t pud) { if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) != _REGION_ENTRY_TYPE_R3) @@ -696,6 +697,7 @@ static inline unsigned long pud_pfn(pud_t pud) return (pud_val(pud) & origin_mask) >> PAGE_SHIFT; } +#define pmd_large pmd_large static inline int pmd_large(pmd_t pmd) { return (pmd_val(pmd) & _SEGMENT_ENTRY_LARGE) != 0; From patchwork Wed Apr 3 14:16:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4524317E9 for ; Wed, 3 Apr 2019 14:17:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E55B288E1 for ; Wed, 3 Apr 2019 14:17:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21F0928A1B; Wed, 3 Apr 2019 14:17:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 896E0288E1 for ; Wed, 3 Apr 2019 14:17:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5FC66B026C; Wed, 3 Apr 2019 10:17:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D37CF6B026D; Wed, 3 Apr 2019 10:17:46 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C29486B026F; Wed, 3 Apr 2019 10:17:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 7727B6B026C for ; Wed, 3 Apr 2019 10:17:46 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id w3so1095859edt.2 for ; Wed, 03 Apr 2019 07:17:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PlduaFV1LjO5scXRf9kwcI+ukcg7zXNoRrXpWadVZPc=; b=WxPh95VNghjy+vXGPiLpsq+DwrhRnv0b5GJp+yxxYUapsk4GSurhKPDRK2/fWwnksV cFPPbvC5MH4yjsjZW+Tz6BTjv0N6igGiC90kTulJch/PL+BbANnmcFKZ75o+C+eX5/Lh CR5Ry7n1oyTZMlsRxV3bEpfcQQl9bE70VZ8ucJRvPsSBvTfwSOE3Pi/e0B84ZmReks5u lB6alYYhsgHIJP7GZAqmFvt0oDV8SUlEOT0NjgxHOPHM9m16hCnKib/V22O3lm/+6Gjo IyoC2oSd8m0WRlnpO7uPaNtqbGr0p6J61HoYjLTnZyjaWuKo/xi55KA59a9yczEVlGM2 76gQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAVzhKgr36d/DB6ZZmGN+xBKp4gMcDWXAoKTGCmAfwNALbX2m5Gl E/YpyaE/7Xdi+Zt7yHfHYhU82Au/Qb5/rAJewAiI127DExeRnR9o6azP/sMiqkeC36NF0mfFMdU nWDepA1i0K3WUngGUT5vnegNyIVEEDwC7n7cRIn3S2V5epzlCpbFvbDQVUWoUkIILow== X-Received: by 2002:a17:906:4d81:: with SMTP id s1mr35694855eju.231.1554301066010; Wed, 03 Apr 2019 07:17:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqweXZDzyfuvMCyUQZLn/z95mtzGbxe5hhWG98NOtkkndHe1RL4g9AnK2iwG4+X5tp+WTeBx X-Received: by 2002:a17:906:4d81:: with SMTP id s1mr35694817eju.231.1554301065150; Wed, 03 Apr 2019 07:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301065; cv=none; d=google.com; s=arc-20160816; b=lAlXOFG1Fjz+jstjibzKjeDhiEtfXK9MqqkhjHlsAnCXncIggSoTx1nbFgKB07wigE KbsLdSsI9liSvmbr2V7uCzZdmHrJTds7I+VxrTXs/c5A2IFiSH8t3XpnjXjjnlpd+H8t CmlYnDnxbVNZrVaepq6PYCnEk7Xb7T6BS/iwDIyKHTwG9SicoZiWuElWscFyFNQrm/iw MxLerolt6RMYcEJHAlYCFYRx7AcSiGflD2gH7KoguCukPfeL6WB5/O6l6Uctcy217xki XvJco4VoTbKoZ2Lrf0k5OY7sP++GcyuZfsPaS65coQXgjAusXdv3BhgWYpLB3Q50eJ4v LChA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=PlduaFV1LjO5scXRf9kwcI+ukcg7zXNoRrXpWadVZPc=; b=bhpaRr6rwP/9s/2RFJX7NkKNtrjoBywTU4rgE2kDk7vyIbaar0vu21RCFIkepFsFs0 H9PgFevUZ5RlysXz0HZmIq08KZBY1Hi8ILyYrSqDn2CwwKonD5183lRQ3ukVZ9lg1zvg vz8in6Es2aqtGvS0OC3+0VoN2nEX+yiuCsX2R9Zqo9jQob5hQ16I2VWUC9wRPIimkdXu Zmt9dQEXAZzfApKCJ0hED5uW7BL4P4Wx90KQZ45KXDX0ufaQ3hIddurljpFNbtJJkKyP 8jqEInZRZljCxd9Y+ASKDu+nFysr9oimAtPOokIJN9Vk9/ESLM7SElNorN9SeEThJ7l2 v4DQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id c22si2694161ejd.12.2019.04.03.07.17.44 for ; Wed, 03 Apr 2019 07:17:45 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 41BC4A78; Wed, 3 Apr 2019 07:17:44 -0700 (PDT) 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 8F2073F68F; Wed, 3 Apr 2019 07:17:40 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 , "David S. Miller" , sparclinux@vger.kernel.org Subject: [PATCH v8 08/20] sparc: mm: Add p?d_large() definitions Date: Wed, 3 Apr 2019 15:16:15 +0100 Message-Id: <20190403141627.11664-9-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 sparc 64 bit, pmd_large() and pud_large() are already provided, so add #defines to prevent the generic versions (added in a later patch) from being used. CC: "David S. Miller" CC: sparclinux@vger.kernel.org Signed-off-by: Steven Price Acked-by: David S. Miller --- arch/sparc/include/asm/pgtable_64.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index 1393a8ac596b..f502e937c8fe 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -713,6 +713,7 @@ static inline unsigned long pte_special(pte_t pte) return pte_val(pte) & _PAGE_SPECIAL; } +#define pmd_large pmd_large static inline unsigned long pmd_large(pmd_t pmd) { pte_t pte = __pte(pmd_val(pmd)); @@ -894,6 +895,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud) #define pgd_present(pgd) (pgd_val(pgd) != 0U) #define pgd_clear(pgdp) (pgd_val(*(pgdp)) = 0UL) +#define pud_large pud_large static inline unsigned long pud_large(pud_t pud) { pte_t pte = __pte(pud_val(pud)); From patchwork Wed Apr 3 14:16:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD91017E9 for ; Wed, 3 Apr 2019 14:17:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7A2528952 for ; Wed, 3 Apr 2019 14:17:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBABB2896F; Wed, 3 Apr 2019 14:17:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A7C128A0E for ; Wed, 3 Apr 2019 14:17:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A6B96B026D; Wed, 3 Apr 2019 10:17:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 87E336B026F; Wed, 3 Apr 2019 10:17:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 745986B0271; Wed, 3 Apr 2019 10:17:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 215C06B026D for ; Wed, 3 Apr 2019 10:17:51 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id z98so7701234ede.3 for ; Wed, 03 Apr 2019 07:17:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3QT6OWyC9JAMeDMFDYFJBPhytDtBHqA6u+Xz2reowKo=; b=cnCgbn3G1oue2Q6ezE+RmQ3dWIug0ec4Yqeob+MYLpnm68s3Zh/6zq3aZ4BGDsTmLl AWI139OLuSa0Q1n5oXWW1q/oxK4tJTBm4SKKN9+cHHtzAd5gm/J00xfEnYHIsLC5IWMA HfCXZcikUStBaOST62TL+zifxmGzTuFsxgq09D4MaTVvKjUfyAmkB2BPIpLV9vqCwds+ kAK22aHIp5bTqhUqTdLYWLK9owOEevc4pJCMrxNoc/w9/3NEsCHiwKU5PUd6Pm+ta6xQ uOvaGCPOJS1trEI6iB0AfBiZ37PcWrWteNQSy2vTvjwa/RUyyqCIYkhiN1lIFdjIkPnJ meYg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAVTuHytq4vvYfaRc5t5bgpw9GLT1mj6spjKrkWLasNHm8VvvDVa 0Qekmkll4JSoCSkvm/iVjsZBKLf0Hvcu08A3s+Y1AsauOkZvm3ZbzntOwIQqyh9gS4BIUI33oZC CPpDXUx/p4fMthj1I8XTwxQ74A6RQ5US6wM/w5QXM/63oLdnEdDJp45BR83QwFYFyMw== X-Received: by 2002:a50:9833:: with SMTP id g48mr51033078edb.141.1554301070626; Wed, 03 Apr 2019 07:17:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/mjyf9Kt9chBeb7ZNRXw179gGfci8J2edDcnJN8ndmxTovDJbkfmRM0VUKM7d0VDSW8DF X-Received: by 2002:a50:9833:: with SMTP id g48mr51032983edb.141.1554301069020; Wed, 03 Apr 2019 07:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301069; cv=none; d=google.com; s=arc-20160816; b=xx87dE2EkmQ33VUQZO80dWIDEXVxVnsRXk1yKwwgjZKOIOfaCwjnnUPlnaBuZ3672R sGRuqF509VRdhZqfARNkIiD5MEoybhH+o2gRMGbREsdmeE7cBRmSAkxq59ci4g7CHEZy OvCzGqmgogVV70bt5R44D7uGDqzuwbQLaMbGrgXVCVsu8oYQNTm3SDxjLUFtA1ePwQfa F4M6ZiOAMbhJyekZNEYd33dnsT925X0helFSfCT76b6hgcUqfnwCrpgCO7+TpMGUpV2s RLIgndIHdblmHdH3LBiY/8f6/gV3hvQ1froLnZH644b+rJvsXT4AwcAkjk6AkuUR9BoZ 5cWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=3QT6OWyC9JAMeDMFDYFJBPhytDtBHqA6u+Xz2reowKo=; b=smnvos1IotI6Utjtgf6jj3a2FvWlQd8pUNt98FlqPjschAZV56fDRx7ClrMXGsFYhf exTYeh9mFbBdmWrjoPSL5AQcsbIcR95OXCuEys2171HTBDMPUTZSo8nq3kLgY8HMfo2y D3hJIXeRvOhm4njmCsi9EfWJcSyi1VMe97wvC4kTZqiwPF0ICLngi5Urq6TLp3O58CNS QWiTNJ6bzdkF3NmleshaQN3KP1gKzUT0Ue6EpYI65PfTGQGI96K9Axi/u4JPA59LzBVf v+APAlQqLdShCGRh8C5AslEqFToGzCABSvUMC6c4MUAEINCVL2EFksjVY7SaSYsPTJ8H BGsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id x56si2202090eda.297.2019.04.03.07.17.48 for ; Wed, 03 Apr 2019 07:17:49 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 E0DB71682; Wed, 3 Apr 2019 07:17:47 -0700 (PDT) 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 8158D3F68F; Wed, 3 Apr 2019 07:17:44 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 09/20] x86: mm: Add p?d_large() definitions Date: Wed, 3 Apr 2019 15:16:16 +0100 Message-Id: <20190403141627.11664-10-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 ee8f8ab46941..ca270fb00805 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 @@ -467,6 +468,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 @@ -501,6 +503,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)))) From patchwork Wed Apr 3 14:16:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE54C17E1 for ; Wed, 3 Apr 2019 14:18:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A85101FF7E for ; Wed, 3 Apr 2019 14:18:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A653B28A21; Wed, 3 Apr 2019 14:18:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A32328A38 for ; Wed, 3 Apr 2019 14:18:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F8AC6B0272; Wed, 3 Apr 2019 10:17:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6D15F6B0274; Wed, 3 Apr 2019 10:17:59 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E6046B0275; Wed, 3 Apr 2019 10:17:59 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 128226B0272 for ; Wed, 3 Apr 2019 10:17:59 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id y17so7627799edd.20 for ; Wed, 03 Apr 2019 07:17:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=U1aR140X7RnjOrD7ClczvI1VvyAi5tuJM37h24SqYlk=; b=VTNPESJwhi29S6jj7MQupQ0VEvGInRpTqj5FqFWLobsZugBu2ijgv3vWvmXMkwKB5p k0gAZYHJcbqdVONMa8c9Sg7kffY4YS0MBcoLhVSYc2Ezw+wQku3Igsji1UpcdaCCOLVO qkU2ioccdY1r6XTqN6IlmgKy1U6I2Bxg0OgcoD0EdKBx3K5G1Y+IRql1RmWPc63fEtBN Hbirl+Oy6vzok4l0bR/TGbYUpjR5pRnhCg6QQPsn8nNWBjn3tZWHxzpsP+APBCAs7TPN 7duw0i2qUmpj62U3yPHP1fUdGSTc1R4cJFis9NW9Y1WVZ7MUFaJ7IX3x/GKyLyGL+qHu s+mQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAW0sfNA1S/7g3HMhpzluqyOFBP9qlMS4lwInH3vCbpoIUWbARqy Pqelt2MtTeltNXS2C+5Oa/iZlNZsydClh174U4EvN9u2aTBSKYSuesOGUklpUilev5kBcsI/bNJ c5MTwdMvjvsjEOFjoN8Rava9ycU81Hk4w3cTwh6IrBmQVvL8evOzor+OIZgi/u/HGkA== X-Received: by 2002:a17:906:2781:: with SMTP id j1mr44049938ejc.238.1554301078581; Wed, 03 Apr 2019 07:17:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMA3wPPzhF0l2+ShmdWv3kbFpFtfnT0Stvkiy2ko0romvWCKhe9Bbg5zmaKhNM5YBJcS/B X-Received: by 2002:a17:906:2781:: with SMTP id j1mr44049863ejc.238.1554301077101; Wed, 03 Apr 2019 07:17:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301072; cv=none; d=google.com; s=arc-20160816; b=tfYPR7010SV5F05rTGfPxFy3kAk3LxvloRVMBHRV/Vuaz69E0N/mzT++IqVKQJi4si 05kXAz7IP6+lrroByxHGuAr0ALr44TSuHNdIZvWA3jev0pnhdRGG1BupoqHtygI3e4ai 3c0jhha6xSh10+xXPrHAsqfiKHoHAdIb/vmIATtCE3YWCA5PQLATne8d6EO8ae+fqUlq oqx1nHPPXC4fph6qAtlD5pq4E+Khx1LWd6au8E/yURVDeqXX0nlFz0NlYX8IkRdelm16 mp/+9gd5RsigO24yxE3aYLMAtU0SB2Akj9QWlnUn/Kz0rfGzejiZU4IZL55+MQJ3jjbG 4QVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=U1aR140X7RnjOrD7ClczvI1VvyAi5tuJM37h24SqYlk=; b=q5I3U7VT3dcAsl9tlQOKlV02VGNkx91YbD5g28WbYU83NzW/g1f+nHIMCYBlZUfI9S OJJRSCpt9BtUupr+G9aLZYO0CraiEYzOk49hA4bTFRPH5+SdJAbZvj7cdfpaCmakVa1f SmnRN/VQ9JFfYFuSP4xw/itlUoQr42sNs09KXxsff6rAXYkWQS30NPOwyDNlbTOfH79R LfUiV1D6zVpKHTzmAJua9hxgodpzo/fnYz3b2NLKXHuCBtmMxEvVs6HZxPNIYyCJNCr5 O5HvH0g2sD3RrLPxINfkhX8PsI2GtQwoee/gz54LuCF063EJtjY9xAcFdhRJyGsNlYw/ vyOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id e38si4389812edd.259.2019.04.03.07.17.52 for ; Wed, 03 Apr 2019 07:17:52 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 8B354168F; Wed, 3 Apr 2019 07:17:51 -0700 (PDT) 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 2C3A33F68F; Wed, 3 Apr 2019 07:17:48 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 10/20] mm: Add generic p?d_large() macros Date: Wed, 3 Apr 2019 15:16:17 +0100 Message-Id: <20190403141627.11664-11-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 p?d_large() macros, provide generic does nothing defaults. Signed-off-by: Steven Price --- include/asm-generic/pgtable.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index fa782fba51ee..9c5d0f73db67 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -1186,4 +1186,23 @@ static inline bool arch_has_pfn_modify_check(void) #define mm_pmd_folded(mm) __is_defined(__PAGETABLE_PMD_FOLDED) #endif +/* + * p?d_large() - 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. + */ +#ifndef pgd_large +#define pgd_large(x) 0 +#endif +#ifndef p4d_large +#define p4d_large(x) 0 +#endif +#ifndef pud_large +#define pud_large(x) 0 +#endif +#ifndef pmd_large +#define pmd_large(x) 0 +#endif + #endif /* _ASM_GENERIC_PGTABLE_H */ From patchwork Wed Apr 3 14:16:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 36FD617E9 for ; Wed, 3 Apr 2019 14:18:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 211B02858B for ; Wed, 3 Apr 2019 14:18:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1585828952; Wed, 3 Apr 2019 14:18:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EED128A13 for ; Wed, 3 Apr 2019 14:17:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43A0D6B026F; Wed, 3 Apr 2019 10:17:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 410EC6B0272; Wed, 3 Apr 2019 10:17:58 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 300C16B0274; Wed, 3 Apr 2019 10:17:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id D39BF6B026F for ; Wed, 3 Apr 2019 10:17:57 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id j3so7642911edb.14 for ; Wed, 03 Apr 2019 07:17:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ahKSq6BT07JiMm6WJgk15VRtm9UPqW7p0TN43pTC2F8=; b=RSwNtLkHu/2fP4viVN9tshN0GE4dvzQ19aKHti/so1/59YGmbpqj+wBaMnzOafnx2z 3zyE/KFAsEYoBvmU0DLcDsSnKxRiZ1piWxEeuQXvhHz8p9PS5+RHgxX1cPq4Z+eemozn RdAOJs7IoNiMrfCBIDiqy4gCm9n5yAiC3kjVNUFCUDbHFKcQ9ieD30lnJOxy7nITKcwH RynL8KN64xvYLWT1Xldffzz+faxykMKzSGAhwPLDjxRoTMiAL/FqWTwbRxKwtB6tniLe smlDsBEijomrFKSohSXb3adENBF09Emq5QUp9qfkMogJt48NVfA69cDAeQzTNAnvOVr+ 48Pw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAUiI3aJOUx4jYiPICxLtVhca/1OeVBKNFOD4FibdkJrcQasaxii b1kgOpLMiEjZEQaOGTLYabWsM9KM4ifnfhCIRus9LxiqHLnCt/KrUS0ovBzsVXmKkoyLROVSj7D KdY6EeFR4oCqYlhYPCO8VMKWxkAQ8jihZSofaBlQBI9icZZW4qsaUm5DPV6HDI8DFBA== X-Received: by 2002:a50:94aa:: with SMTP id s39mr52978144eda.191.1554301077378; Wed, 03 Apr 2019 07:17:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyui37x9wnzXRrzQphAEuqNZaJCW+Z8TID8rtsbkBgyBqmzOL2B92QIq9o2ke5GBlB6tcL X-Received: by 2002:a50:94aa:: with SMTP id s39mr52978091eda.191.1554301076211; Wed, 03 Apr 2019 07:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301076; cv=none; d=google.com; s=arc-20160816; b=PWaEHOD/qbJQ71sR+DHPSOt5quAIZfPKeS7jO7NYJrJNzxDia+g1iIqgysyqoHTpy/ W2av4IJDCCm7Xtgrw4N+N4yZxuRBEQAsZTnP8AQVamSO2h4He/Rbjspuino5dQWRNRSD vPPc1uCrmUG1TsZkoVoz5JEsmfG4hQrdbDkmWwURSeBOIiiL8ErMXlJBT0myHBduzWKN ep4UKgIHMTycYg6hG9CiPBGb6UFnuTq0PjwkYqkGpUtGaLDP3ZRkVraKgPyE/ZU8arkf lSepmZvKPEtdp8ZKmUzqPQbDbChivom+3ZeUgEnZjBvDI4z7HtGKS4lyLZWAvPyb+w4Y ANBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ahKSq6BT07JiMm6WJgk15VRtm9UPqW7p0TN43pTC2F8=; b=SdSD5DnFZmpwNVzu48bQsw+2uiI7VdlVvhRGGN6Abrm+R/eO0+bKiQhi49vZAczdEU URqiZ1PHHbR8ewCNY+cwLF5jP0Sui0dBQk+xplRr+YmcZsw/FlNhTDyiJN0+yKWoFKwA 3T4xYPr6BPdhS8FADUAHpi7eTEw7KAmQlyMiUemf1YYN6f41lTTkpscGB2Q18k8eqplD C1LP+ZzC2yxI1zMcFpRQCbR9J/tW5fdBK4BICVeoxRSq+O2i37jfh8/f4JoN/oH0kq2t lvsNmvm4LzVAhUlo50nVc6J3V4H88GJj53PYpQvftLtPAEy/u3+KCBMT4KRMWLL5mjBn //YQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id e33si1622709ede.76.2019.04.03.07.17.55 for ; Wed, 03 Apr 2019 07:17:56 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 35F061682; Wed, 3 Apr 2019 07:17:55 -0700 (PDT) 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 C9B353F68F; Wed, 3 Apr 2019 07:17:51 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 11/20] mm: pagewalk: Add p4d_entry() and pgd_entry() Date: Wed, 3 Apr 2019 15:16:18 +0100 Message-Id: <20190403141627.11664-12-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP pgd_entry() and pud_entry() were removed by commit 0b1fbfe50006c410 ("mm/pagewalk: remove pgd_entry() and pud_entry()") because there were no users. We're about to add users so reintroduce them, along with p4d_entry() as we now have 5 levels of tables. Note that commit a00cc7d9dd93d66a ("mm, x86: add support for PUD-sized transparent hugepages") already re-added pud_entry() but with different semantics to the other callbacks. Since there have never been upstream users of this, revert the semantics back to match the other callbacks. This means pud_entry() is called for all entries, not just transparent huge pages. Signed-off-by: Steven Price --- include/linux/mm.h | 15 +++++++++------ mm/pagewalk.c | 27 ++++++++++++++++----------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 76769749b5a5..f6de08c116e6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1367,15 +1367,14 @@ void unmap_vmas(struct mmu_gather *tlb, struct vm_area_struct *start_vma, /** * mm_walk - callbacks for walk_page_range - * @pud_entry: if set, called for each non-empty PUD (2nd-level) entry - * this handler should only handle pud_trans_huge() puds. - * the pmd_entry or pte_entry callbacks will be used for - * regular PUDs. - * @pmd_entry: if set, called for each non-empty PMD (3rd-level) entry + * @pgd_entry: if set, called for each non-empty PGD (top-level) entry + * @p4d_entry: if set, called for each non-empty P4D entry + * @pud_entry: if set, called for each non-empty PUD entry + * @pmd_entry: if set, called for each non-empty PMD entry * this handler is required to be able to handle * pmd_trans_huge() pmds. They may simply choose to * split_huge_page() instead of handling it explicitly. - * @pte_entry: if set, called for each non-empty PTE (4th-level) entry + * @pte_entry: if set, called for each non-empty PTE (lowest-level) entry * @pte_hole: if set, called for each hole at all levels * @hugetlb_entry: if set, called for each hugetlb entry * @test_walk: caller specific callback function to determine whether @@ -1390,6 +1389,10 @@ void unmap_vmas(struct mmu_gather *tlb, struct vm_area_struct *start_vma, * (see the comment on walk_page_range() for more details) */ struct mm_walk { + int (*pgd_entry)(pgd_t *pgd, unsigned long addr, + unsigned long next, struct mm_walk *walk); + int (*p4d_entry)(p4d_t *p4d, unsigned long addr, + unsigned long next, struct mm_walk *walk); int (*pud_entry)(pud_t *pud, unsigned long addr, unsigned long next, struct mm_walk *walk); int (*pmd_entry)(pmd_t *pmd, unsigned long addr, diff --git a/mm/pagewalk.c b/mm/pagewalk.c index c3084ff2569d..98373a9f88b8 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -90,15 +90,9 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, } if (walk->pud_entry) { - spinlock_t *ptl = pud_trans_huge_lock(pud, walk->vma); - - if (ptl) { - err = walk->pud_entry(pud, addr, next, walk); - spin_unlock(ptl); - if (err) - break; - continue; - } + err = walk->pud_entry(pud, addr, next, walk); + if (err) + break; } split_huge_pud(walk->vma, pud, addr); @@ -131,7 +125,12 @@ static int walk_p4d_range(pgd_t *pgd, unsigned long addr, unsigned long end, break; continue; } - if (walk->pmd_entry || walk->pte_entry) + if (walk->p4d_entry) { + err = walk->p4d_entry(p4d, addr, next, walk); + if (err) + break; + } + if (walk->pud_entry || walk->pmd_entry || walk->pte_entry) err = walk_pud_range(p4d, addr, next, walk); if (err) break; @@ -157,7 +156,13 @@ static int walk_pgd_range(unsigned long addr, unsigned long end, break; continue; } - if (walk->pmd_entry || walk->pte_entry) + if (walk->pgd_entry) { + err = walk->pgd_entry(pgd, addr, next, walk); + if (err) + break; + } + if (walk->p4d_entry || walk->pud_entry || walk->pmd_entry || + walk->pte_entry) err = walk_p4d_range(pgd, addr, next, walk); if (err) break; From patchwork Wed Apr 3 14:16:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F46B17E1 for ; Wed, 3 Apr 2019 14:18:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A6081FF7E for ; Wed, 3 Apr 2019 14:18:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DE6C28A12; Wed, 3 Apr 2019 14:18:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4B631FF7E for ; Wed, 3 Apr 2019 14:18:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0491D6B0274; Wed, 3 Apr 2019 10:18:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E71826B0275; Wed, 3 Apr 2019 10:18:01 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D86576B0276; Wed, 3 Apr 2019 10:18:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 7D8546B0274 for ; Wed, 3 Apr 2019 10:18:01 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id s27so7619727eda.16 for ; Wed, 03 Apr 2019 07:18:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NXbLxkVEjkUC98nDqbwMu9XwBnfr8Fy+W9xUz87hsi8=; b=R/2g6wXbQvq0j6YpBbVyNmocexQ59yef+7O8KKz5iJWBKpcDxQQFjss/h/6gNfdNp7 aLWsTdEN1H+obUqZBOOCKj5+gAMogD1kpAeJcY6jXHnwIHRRClKefrp0mn/+b3Mglzxj i41bVkIHLYkKt+/glIkvyDpMBxTEvPOzp6clfgXSipNterpNGWZBNnBS4bqUDrjG0gAC Yq3Hn6g7lfLy4AJVg9o4+Jjc5wOm/QG094ww0Jt2dLlDFoDR00J1qzptwoi7IPusJQxg B4v9d5TwoYrmRDTmdK7SAYibHuRG9CXcAOFA+mNlj8XayylELoasAuCWuRQ7trpbz1ye uNEQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAWYPpzCasXam56bVbnIMpxR+9Z1n0Evnkh7uoo+Ob3JIyaS0xaQ Cmh5StGEXN9YQNVBqHRra1pkTLOqyqJKGPxGfqpp08XrFbT+6olTCJfCunoTmFGaPLbxFGdbW3J +gtLr2aJK+0RPKeFuWWgVMKcVyX1WkhuezC5hNDHuA3stHd84nyhNDhEpJ9WVaI/iZg== X-Received: by 2002:a50:a515:: with SMTP id y21mr35388657edb.135.1554301081016; Wed, 03 Apr 2019 07:18:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOsDBDf3Qlf/LQxJ0avvtDU7E5sR0voVi3ZbDouse6QxqqybjHZxjDeyXttLbKlArK43NQ X-Received: by 2002:a50:a515:: with SMTP id y21mr35388579edb.135.1554301079749; Wed, 03 Apr 2019 07:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301079; cv=none; d=google.com; s=arc-20160816; b=ILRG3r6peTeuJufrqRwp9ygRENz0czXQRfH44XO7n1VWyKx/6Ne+y4ysWz66LqDGD6 V/Zt+Sb+QGeuBLfHi63cSMdAQF+SfOsQXgystRTZV56JhGfI7Xne0cDtOOvg5ygdh1SA 7XBxjbk2L8iYaVY6IhEiTHP/6v/jfl8CZO63namYDPj8hW4LEh5HGjdULKdWvKmkltCr aQVRyxLqUiFJjGM3bNYJkCcb57sBoWtR6qiqHRBLgHcR3ce2WjuUEetzPURpGWVdUbMJ pP5QhVqnbWNFxcLht2lGkHurwNvlNaO0yyEpnsd5sxQUbvsy4lqPWeL9cCQDQuof6o3h yblQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=NXbLxkVEjkUC98nDqbwMu9XwBnfr8Fy+W9xUz87hsi8=; b=wLKVf7v1gKP3qLhW3Ffu2CUlMCOa0OV6BGbqgXwz1sW80+YLHk1ovbjKHG+nnKEzIa J8tbw+YSYIAbT3phe7GlF6CFlMhYh/sU1svx+1arNKJE7Lr9AjeZLDLikVC025oEoCSo i//FKts/pgNP3Y0QpUr50WBAEs8sM8/dfrJx1eeaf7vr59BspKpeTaXulvBryMuD/5lb BLheeBpI6+nR+KSBUjGeXZR98ErazBH0jYtx5luQGUYxkyO9wZLwvjbLy0cjhStn0qAj usayBrdqiHDalE4QlEvC6wDvH2jzSajiZoCHUIyTctDktUNtXFNogCpGFbNzBxeTFEcd CydA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id s39si2088937eda.15.2019.04.03.07.17.59 for ; Wed, 03 Apr 2019 07:17:59 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 D4615169E; Wed, 3 Apr 2019 07:17:58 -0700 (PDT) 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 759873F68F; Wed, 3 Apr 2019 07:17:55 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 12/20] mm: pagewalk: Allow walking without vma Date: Wed, 3 Apr 2019 15:16:19 +0100 Message-Id: <20190403141627.11664-13-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Since 48684a65b4e3: "mm: pagewalk: fix misbehavior of walk_page_range for vma(VM_PFNMAP)", page_table_walk() will report any kernel area as a hole, because it lacks a vma. This means each arch has re-implemented page table walking when needed, for example in the per-arch ptdump walker. Remove the requirement to have a vma except when trying to split huge pages. Signed-off-by: Steven Price --- mm/pagewalk.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/mm/pagewalk.c b/mm/pagewalk.c index 98373a9f88b8..dac0c848b458 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -36,7 +36,7 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, do { again: next = pmd_addr_end(addr, end); - if (pmd_none(*pmd) || !walk->vma) { + if (pmd_none(*pmd)) { if (walk->pte_hole) err = walk->pte_hole(addr, next, walk); if (err) @@ -59,9 +59,14 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, if (!walk->pte_entry) continue; - split_huge_pmd(walk->vma, pmd, addr); - if (pmd_trans_unstable(pmd)) - goto again; + if (walk->vma) { + split_huge_pmd(walk->vma, pmd, addr); + if (pmd_trans_unstable(pmd)) + goto again; + } else if (pmd_large(*pmd)) { + continue; + } + err = walk_pte_range(pmd, addr, next, walk); if (err) break; @@ -81,7 +86,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, do { again: next = pud_addr_end(addr, end); - if (pud_none(*pud) || !walk->vma) { + if (pud_none(*pud)) { if (walk->pte_hole) err = walk->pte_hole(addr, next, walk); if (err) @@ -95,9 +100,13 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, break; } - split_huge_pud(walk->vma, pud, addr); - if (pud_none(*pud)) - goto again; + if (walk->vma) { + split_huge_pud(walk->vma, pud, addr); + if (pud_none(*pud)) + goto again; + } else if (pud_large(*pud)) { + continue; + } if (walk->pmd_entry || walk->pte_entry) err = walk_pmd_range(pud, addr, next, walk); From patchwork Wed Apr 3 14:16:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E93017E1 for ; Wed, 3 Apr 2019 14:18:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5752928A11 for ; Wed, 3 Apr 2019 14:18:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B4C328A21; Wed, 3 Apr 2019 14:18:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC70A1FF7E for ; Wed, 3 Apr 2019 14:18:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BFC66B0275; Wed, 3 Apr 2019 10:18:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 56FFF6B0276; Wed, 3 Apr 2019 10:18:05 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45FC46B0277; Wed, 3 Apr 2019 10:18:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id EBDCD6B0275 for ; Wed, 3 Apr 2019 10:18:04 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id e16so5111523edj.1 for ; Wed, 03 Apr 2019 07:18:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=R0+mDUGg1Ak1pVP4iC7Dj6pIbpcwhG5wwqV4iIviRKc=; b=kE+sVUe0iQaOj1/JeQHzedg2Q96z4A+uPRI/xEn105QmIyZ51NnbaiyGCktgm9ZyVB NDTZltYBC3tpfTkH7uHCB2czxzDs8scTcjO2XCmGNOPmwYs1La3uoOti3qSTykXQD2sl npVM321XMX5nBf/gLoIXWldlNqcNN2cvu5EWPuUi/1i5B+j2pqJ5MceBQH+C6jishPiI gM4S3+fUuB/JKLBXkca5JQSQBD7PmzOsfeKxyShEAVPi0SxWGZJzQjn26AusXqKt5mH4 vDBQ548kviqhrWSiSUvwVjnTHlMdISG40UX5L4s6JSruArBcu6NYhEumy+C6nRAhxJnG WNnw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAU0Ds/siq+L8/KeAW4ZpLSKtUBKSQMpCZIQ2IFf9qrOHQeH+hzG BPRp31RdiEq1vFKPTa/tNxMxco7wwher4UH2pPS+/uTQm87I5Vy+hCKFM/6IpQaoDzz6Rh5CzNG QBn00+2GmIB1GHJduMfatcya1k+CjTMgqkfEPze5FI3SLog291mpMiqObwq/9KId1qw== X-Received: by 2002:a17:906:1984:: with SMTP id g4mr3667701ejd.260.1554301084474; Wed, 03 Apr 2019 07:18:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwj/dP4Xx7y/F/EpOTaoKi6FNbvXUZO/JotaOfpFhXTAx066Cd7sqGCiOrnBnAZVUR8Mr4g X-Received: by 2002:a17:906:1984:: with SMTP id g4mr3667652ejd.260.1554301083540; Wed, 03 Apr 2019 07:18:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301083; cv=none; d=google.com; s=arc-20160816; b=YlSv7i1i7vbmnHn9C6kDMvCTOZFKwrUwQ8GddbG3eoQN7cQPJgImvk9k21CwE/O6a1 gx94KQt2UC3jQ0F0j0pUo8UPr6ZfKXsdH5YFfIsAsKF4fRQEDzMGcRzP67S2Lh/m4SwC Vz7HgQTsk8Apf9O+4m19REXyoCyI8GyAzAK6tNmTT1DL+5a22eyxa+GvvJrf8LBJbS4A wlmmtvqbOu9pVqlY9Q1PRuwOmSUltgOQsQGAZP57va3ufzIv1f1hxwaifO90tYYG+o44 SuHMjotqaHEQDoJAeptH39p8TlwcJ74ZDJfGYlwYGjf484BMFkf3PqzuvMymg2OJtsbS YFTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=R0+mDUGg1Ak1pVP4iC7Dj6pIbpcwhG5wwqV4iIviRKc=; b=iSbGLAx7sXAguuP8Pi8B5GuGkj7T60ehxGk8/hjRfdAla2JHnVYnijoghcHO+3MY5P 6Ai/JsvWqnx8PLF8p3lk/JukStB4rcDVsoZ2mS3hcvW3WVYxP1AbdSGzf8dtl4o7ELSa Z0JRySJwqn7J0oBiLhEfNlP1bVCiaiO/eSQ9sqODtNVxhyWYd+CtX7KuCKz5JDd15LNJ KJbzUECz496kJTa6yNCajby25e6SvzK2AlpoTjf//TXJphZyyIjogOjQbkXA3TIuhuBO StlBL2VAgEWbqkHX0A8lsotToEoLsPXd/uM9vX40wKJ12M35xxEiLPmvlEAsqn7TcAXV gGBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id g12si1185396eda.361.2019.04.03.07.18.03 for ; Wed, 03 Apr 2019 07:18:03 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 804F21682; Wed, 3 Apr 2019 07:18:02 -0700 (PDT) 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 20DDA3F68F; Wed, 3 Apr 2019 07:17:58 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 13/20] mm: pagewalk: Add test_p?d callbacks Date: Wed, 3 Apr 2019 15:16:20 +0100 Message-Id: <20190403141627.11664-14-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP It is useful to be able to skip parts of the page table tree even when walking without VMAs. Add test_p?d callbacks similar to test_walk but which are called just before a table at that level is walked. If the callback returns non-zero then the entire table is skipped. Signed-off-by: Steven Price --- include/linux/mm.h | 11 +++++++++++ mm/pagewalk.c | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index f6de08c116e6..a4c1ed255455 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1382,6 +1382,11 @@ void unmap_vmas(struct mmu_gather *tlb, struct vm_area_struct *start_vma, * value means "do page table walk over the current vma," * and a negative one means "abort current page table walk * right now." 1 means "skip the current vma." + * @test_pmd: similar to test_walk(), but called for every pmd. + * @test_pud: similar to test_walk(), but called for every pud. + * @test_p4d: similar to test_walk(), but called for every p4d. + * Returning 0 means walk this part of the page tables, + * returning 1 means to skip this range. * @mm: mm_struct representing the target process of page table walk * @vma: vma currently walked (NULL if walking outside vmas) * @private: private data for callbacks' usage @@ -1406,6 +1411,12 @@ struct mm_walk { struct mm_walk *walk); int (*test_walk)(unsigned long addr, unsigned long next, struct mm_walk *walk); + int (*test_pmd)(unsigned long addr, unsigned long next, + pmd_t *pmd_start, struct mm_walk *walk); + int (*test_pud)(unsigned long addr, unsigned long next, + pud_t *pud_start, struct mm_walk *walk); + int (*test_p4d)(unsigned long addr, unsigned long next, + p4d_t *p4d_start, struct mm_walk *walk); struct mm_struct *mm; struct vm_area_struct *vma; void *private; diff --git a/mm/pagewalk.c b/mm/pagewalk.c index dac0c848b458..231655db1295 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -32,6 +32,14 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, unsigned long next; int err = 0; + if (walk->test_pmd) { + err = walk->test_pmd(addr, end, pmd_offset(pud, 0), walk); + if (err < 0) + return err; + if (err > 0) + return 0; + } + pmd = pmd_offset(pud, addr); do { again: @@ -82,6 +90,14 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, unsigned long next; int err = 0; + if (walk->test_pud) { + err = walk->test_pud(addr, end, pud_offset(p4d, 0), walk); + if (err < 0) + return err; + if (err > 0) + return 0; + } + pud = pud_offset(p4d, addr); do { again: @@ -124,6 +140,14 @@ static int walk_p4d_range(pgd_t *pgd, unsigned long addr, unsigned long end, unsigned long next; int err = 0; + if (walk->test_p4d) { + err = walk->test_p4d(addr, end, p4d_offset(pgd, 0), walk); + if (err < 0) + return err; + if (err > 0) + return 0; + } + p4d = p4d_offset(pgd, addr); do { next = p4d_addr_end(addr, end); From patchwork Wed Apr 3 14:16:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45E5F17E1 for ; Wed, 3 Apr 2019 14:18:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2925F2896F for ; Wed, 3 Apr 2019 14:18:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D41B28A12; Wed, 3 Apr 2019 14:18:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 867342896F for ; Wed, 3 Apr 2019 14:18:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F140F6B0278; Wed, 3 Apr 2019 10:18:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EC1E86B0279; Wed, 3 Apr 2019 10:18:09 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D88356B027A; Wed, 3 Apr 2019 10:18:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 8231F6B0278 for ; Wed, 3 Apr 2019 10:18:09 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id z98so7701890ede.3 for ; Wed, 03 Apr 2019 07:18:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Z5ii9WWPo9WVfhue9NtkIQuQCcbK0pxcqGqIbiUCEeU=; b=SBWbpvrx2VrPeiGyzl2lNCkfl2xvYY9kYTbhip2Dw5Ao1y+T7b8GIvOSWFtQaOtQCB s51z9OxPx9kzsB8U8/NORxtQfCbtgO2QFVGjuTPhBkyjdaWM2T3bY2K+4iVjLIl0jWvy XTxXN9mx7IcqZ0nZuDfctc9NOfbyGLlngGuR6mvPYB5H2NRY6t+cjqjYTp9HOB1UlKmr pLquLJKy3s5VqC+iK2Nrvm7RFDfh+HMxuGA1PZxCHHLauk6OoxGricILLfA3ovZLa6o0 yV2D4aHaS7u+llbXxXrwWzjdfnHRNxyYxcdyqYdg0Dv5R6ALA+SgbrqwSpTe7Dx3tpme A7bw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAWegNiaP1tNIDzb6rN6eTf3l5jnPYl4Coc+bDYNm4KyubFZV4UW ak0WhSWJDqusksFOMagdXYl9a9Nb2ar39T1+u1wKZQ+6HO3piVKyqnoPwSKu7Imu7UGKSPVk/ca NwlQZOBqNTiIzKfyRoJgF5kSLINohX9JbcwSAAiBqcZIPLI8W93SjuZ1lhEp7EDJm7Q== X-Received: by 2002:a17:906:63ca:: with SMTP id u10mr43958538ejk.127.1554301089017; Wed, 03 Apr 2019 07:18:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBeaxnt50ZSUv+KiMkBRV//IuoLYlC175eXI/py/FiuINOtclV71vNhJUqE+4REdqCSUKF X-Received: by 2002:a17:906:63ca:: with SMTP id u10mr43958452ejk.127.1554301087360; Wed, 03 Apr 2019 07:18:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301087; cv=none; d=google.com; s=arc-20160816; b=vLL7F0U+5210Iq3+/auuTLPk6svxS5tRzjN+NzQlvZsF14ceMQ1oKVhHbeQ45172nr RAC6DUY57Qe+uAthtvGKrUl5Fetr1y2AfDfwyv3hlX0hXwwIYLtSkhL5rQDxYTjRdrU7 eWmH6z7ibgSFs6ClvG2bpS+itj6Ldt3OOg5O/oQdNksgSQEdPSWnCgEReJlHwaMZfPCI RvjzfxU1BCV5fj+5gl2PcM2XlTxt65n3XSQE9FZsGcl+d1NwiARnlpKiJ+/83mPYGph1 Yr/jetrLVWVCdJig1EHrSTgh4u+MDHfuVJzG8pOKG5XhYFoHvJAFhTYYSJGgyuySOya0 HesA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Z5ii9WWPo9WVfhue9NtkIQuQCcbK0pxcqGqIbiUCEeU=; b=KebRNxqQPYOj+X65WWIk5SqTmRKX2vmQzBP6k59gnZmU8XDM8OXzWADNqbhFFbYc3z mPnwvIB1Q8kOcuRDZsS3K6wYmlR1Yz55bVFfOiBrrsQSPlj3dBqelhC0QfuTqzKBzn3w ruNSxJZAvCRSuzoS6jtF6yfCELIt25Acr2wK2mzp8JKSdggzhpaELg1kiuBwA8eI0JOM cSTWl7qtsnWcyxxG2mKrr35I1pt0It0kbjSew+g9EWw97+qglU3aRhuecG9c0XO7R1vb d0ZbZtz/EvJLmFfX+eTy5APt/N7CK/MqvAXGizStGVvak4vFl//U9PPuvR+3SUFaBmmu Zw9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id q2si4217337edn.429.2019.04.03.07.18.06 for ; Wed, 03 Apr 2019 07:18:07 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 2A999EBD; Wed, 3 Apr 2019 07:18:06 -0700 (PDT) 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 BFC9E3F68F; Wed, 3 Apr 2019 07:18:02 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 14/20] arm64: mm: Convert mm/dump.c to use walk_page_range() Date: Wed, 3 Apr 2019 15:16:21 +0100 Message-Id: <20190403141627.11664-15-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Now walk_page_range() can walk kernel page tables, we can switch the arm64 ptdump code over to using it, simplifying the code. Signed-off-by: Steven Price --- arch/arm64/mm/dump.c | 117 ++++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/arch/arm64/mm/dump.c b/arch/arm64/mm/dump.c index 14fe23cd5932..ea20c1213498 100644 --- a/arch/arm64/mm/dump.c +++ b/arch/arm64/mm/dump.c @@ -72,7 +72,7 @@ struct pg_state { struct seq_file *seq; const struct addr_marker *marker; unsigned long start_address; - unsigned level; + int level; u64 current_prot; bool check_wx; unsigned long wx_pages; @@ -234,11 +234,14 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr) st->wx_pages += (addr - st->start_address) / PAGE_SIZE; } -static void note_page(struct pg_state *st, unsigned long addr, unsigned level, +static void note_page(struct pg_state *st, unsigned long addr, int level, u64 val) { static const char units[] = "KMGTPE"; - u64 prot = val & pg_level[level].mask; + u64 prot = 0; + + if (level >= 0) + prot = val & pg_level[level].mask; if (!st->level) { st->level = level; @@ -286,73 +289,71 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level, } -static void walk_pte(struct pg_state *st, pmd_t *pmdp, unsigned long start, - unsigned long end) +static int pud_entry(pud_t *pud, unsigned long addr, + unsigned long next, struct mm_walk *walk) { - unsigned long addr = start; - pte_t *ptep = pte_offset_kernel(pmdp, start); + struct pg_state *st = walk->private; + pud_t val = READ_ONCE(*pud); + + if (pud_table(val)) + return 0; + + note_page(st, addr, 2, pud_val(val)); - do { - note_page(st, addr, 4, READ_ONCE(pte_val(*ptep))); - } while (ptep++, addr += PAGE_SIZE, addr != end); + return 0; } -static void walk_pmd(struct pg_state *st, pud_t *pudp, unsigned long start, - unsigned long end) +static int pmd_entry(pmd_t *pmd, unsigned long addr, + unsigned long next, struct mm_walk *walk) { - unsigned long next, addr = start; - pmd_t *pmdp = pmd_offset(pudp, start); - - do { - pmd_t pmd = READ_ONCE(*pmdp); - next = pmd_addr_end(addr, end); - - if (pmd_none(pmd) || pmd_sect(pmd)) { - note_page(st, addr, 3, pmd_val(pmd)); - } else { - BUG_ON(pmd_bad(pmd)); - walk_pte(st, pmdp, addr, next); - } - } while (pmdp++, addr = next, addr != end); + struct pg_state *st = walk->private; + pmd_t val = READ_ONCE(*pmd); + + if (pmd_table(val)) + return 0; + + note_page(st, addr, 3, pmd_val(val)); + + return 0; } -static void walk_pud(struct pg_state *st, pgd_t *pgdp, unsigned long start, - unsigned long end) +static int pte_entry(pte_t *pte, unsigned long addr, + unsigned long next, struct mm_walk *walk) { - unsigned long next, addr = start; - pud_t *pudp = pud_offset(pgdp, start); - - do { - pud_t pud = READ_ONCE(*pudp); - next = pud_addr_end(addr, end); - - if (pud_none(pud) || pud_sect(pud)) { - note_page(st, addr, 2, pud_val(pud)); - } else { - BUG_ON(pud_bad(pud)); - walk_pmd(st, pudp, addr, next); - } - } while (pudp++, addr = next, addr != end); + struct pg_state *st = walk->private; + pte_t val = READ_ONCE(*pte); + + note_page(st, addr, 4, pte_val(val)); + + return 0; +} + +static int pte_hole(unsigned long addr, unsigned long next, + struct mm_walk *walk) +{ + struct pg_state *st = walk->private; + + note_page(st, addr, -1, 0); + + return 0; } static void walk_pgd(struct pg_state *st, struct mm_struct *mm, - unsigned long start) + unsigned long start) { - unsigned long end = (start < TASK_SIZE_64) ? TASK_SIZE_64 : 0; - unsigned long next, addr = start; - pgd_t *pgdp = pgd_offset(mm, start); - - do { - pgd_t pgd = READ_ONCE(*pgdp); - next = pgd_addr_end(addr, end); - - if (pgd_none(pgd)) { - note_page(st, addr, 1, pgd_val(pgd)); - } else { - BUG_ON(pgd_bad(pgd)); - walk_pud(st, pgdp, addr, next); - } - } while (pgdp++, addr = next, addr != end); + struct mm_walk walk = { + .mm = mm, + .private = st, + .pud_entry = pud_entry, + .pmd_entry = pmd_entry, + .pte_entry = pte_entry, + .pte_hole = pte_hole + }; + down_read(&mm->mmap_sem); + walk_page_range(start, start | (((unsigned long)PTRS_PER_PGD << + PGDIR_SHIFT) - 1), + &walk); + up_read(&mm->mmap_sem); } void ptdump_walk_pgd(struct seq_file *m, struct ptdump_info *info) From patchwork Wed Apr 3 14:16:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFB77184E for ; Wed, 3 Apr 2019 14:18:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6A4928A04 for ; Wed, 3 Apr 2019 14:18:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AD5428A10; Wed, 3 Apr 2019 14:18:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B8C228A1F for ; Wed, 3 Apr 2019 14:18:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD7176B0279; Wed, 3 Apr 2019 10:18:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D87516B027A; Wed, 3 Apr 2019 10:18:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9D6E6B027B; Wed, 3 Apr 2019 10:18:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 7C6C76B0279 for ; Wed, 3 Apr 2019 10:18:12 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id l19so7507090edr.12 for ; Wed, 03 Apr 2019 07:18:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=VefPUADSnZrha76TxVHSwbw6LrT1e+Tmwp23y0+XUXU=; b=c6tdEtk90+74Mj2Vvnv4gUIkJrBoh6pTv1akNEni+kfZlZNStX9QMP6+RRPQLqgpNJ drLjv8natGFpJhtdXbtYdA6wCeU20NegYpohBBg76tORpkxz9crZio4vP4gsVmc/NxHu dKsFe5VIENB/6cKeiDEz83ONRdovndqZCWS5GqxeH8sV8JvKi1GMkkahPDQ1LfCFnKti YqG7NxD16jbZi0258Uk0rzrpYakEUdkEOSbxQRPGK2XftaB4k40GmxO7cFMKECwbD8fh 3ym8iJ/g2qGw8F4/WQYoJ6xjw2cSFDdEdXLSU3y/UXlEDk66vJPPA3DkGAmSutn+j/on UPgg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAVYIO5TqK10tpPNE2JEh0pKfU/fyUESDtSy9bmNgJCnp2uQEe78 QxujQu/hKL/4ZnOKWCRMhU/Q1j5WUpvPd8UO66mUNqkvpobGeLarymD0E8brpnqLYoDi7ybfaQm 4B3gxkEbjGiIP7J9b7fXsw877z5FuB9tsfqCRS/Pj1e5uqW9G4n3JzSNq9NCMO/tHiw== X-Received: by 2002:a17:906:184e:: with SMTP id w14mr5670637eje.209.1554301092032; Wed, 03 Apr 2019 07:18:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjYJWHqp3fsIUP5GLqOmZzy4djlbyCTaXuDqif80NZUkvgLcD1Y+tmNfrGkHFW5L7T2yK0 X-Received: by 2002:a17:906:184e:: with SMTP id w14mr5670567eje.209.1554301090761; Wed, 03 Apr 2019 07:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301090; cv=none; d=google.com; s=arc-20160816; b=uihJhwIIb0XcBW/UFC4CBrL8WSM/LbDgZZuFDe0Iitp5NmMV3TEt8W+nmyaDRvksfK goepzv3k9IWvbD9pJa6GTH9UCBKQa6SJ5WHcrB+mvvohz1ijXDny68qzRoNX6ZfDgv1B pVNrBkrLDr92f3tZg8sREZq6U16l5D/8tS9lACXpCNU1qc5HH5haLNIFq4N6o2v5IuRg JMJzddNudUk1w0l+OS54BLYvxTbLAvTyxdCYYMSsd7i3ZiwNmwbKMMQ7hEgm2sew7zY4 JNAzPUt/LJDQot1k0KVuoYIIe3obv1t4Nc0Rr2IS2zc6hMt8/HPMyxnYTSkvfrsQHMVN 2oCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=VefPUADSnZrha76TxVHSwbw6LrT1e+Tmwp23y0+XUXU=; b=GUjvXoWMQPZXxOA+8yElEzr9gZS5iF8WhkXQtprrHbrvI6fQVomf1eV0QRV/ysYZJm 3aVkuv0p/HbTLjCq4QdUDLkvjpqnnUV1/0OP441Me+x9bBoHHZn+6rZQnW+RlnIy707q qzpx7SnW8T2jfHifyca7cRCAI3jG6S96gsjZ4gn/Up5F0JEKup2j5IFOlQtgfJr5QrXM J2vUyvSoAeQe+tAMpjrk2PbWvEXiZhMthHuNBtD5KwI4/FMD1QeL3qO2NSKapfyfCXql vpXr5Uj1lzVMdEUvEQCaklQc/PzKT1Cl99/1DF4fY1dugIdzRRND9BTPxpHINIy7EmBy IUTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id y24si4362237ejo.327.2019.04.03.07.18.10 for ; Wed, 03 Apr 2019 07:18:10 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 C93351684; Wed, 3 Apr 2019 07:18:09 -0700 (PDT) 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 6A25C3F68F; Wed, 3 Apr 2019 07:18:06 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 15/20] x86: mm: Don't display pages which aren't present in debugfs Date: Wed, 3 Apr 2019 15:16:22 +0100 Message-Id: <20190403141627.11664-16-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP For the /sys/kernel/debug/page_tables/ files, rather than outputing a mostly empty line when a block of memory isn't present just skip the line. This keeps the output shorter and will help with a future change switching to using the generic page walk code as we no longer care about the 'level' that the page table holes are at. Signed-off-by: Steven Price --- arch/x86/mm/dump_pagetables.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index ca270fb00805..e2b53db92c34 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -304,8 +304,8 @@ static void note_page(struct seq_file *m, struct pg_state *st, /* * Now print the actual finished series */ - if (!st->marker->max_lines || - st->lines < st->marker->max_lines) { + if ((cur & _PAGE_PRESENT) && (!st->marker->max_lines || + st->lines < st->marker->max_lines)) { pt_dump_seq_printf(m, st->to_dmesg, "0x%0*lx-0x%0*lx ", width, st->start_address, @@ -321,7 +321,8 @@ static void note_page(struct seq_file *m, struct pg_state *st, printk_prot(m, st->current_prot, st->level, st->to_dmesg); } - st->lines++; + if (cur & _PAGE_PRESENT) + st->lines++; /* * We print markers for special areas of address space, From patchwork Wed Apr 3 14:16:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883927 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D58A17E1 for ; Wed, 3 Apr 2019 14:18:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84F0D2898D for ; Wed, 3 Apr 2019 14:18:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7933228A0E; Wed, 3 Apr 2019 14:18:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6C1B288D2 for ; Wed, 3 Apr 2019 14:18:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E73D46B027B; Wed, 3 Apr 2019 10:18:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E25166B027C; Wed, 3 Apr 2019 10:18:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D13436B027D; Wed, 3 Apr 2019 10:18:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 7A5D56B027B for ; Wed, 3 Apr 2019 10:18:16 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id z98so7702070ede.3 for ; Wed, 03 Apr 2019 07:18:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=EdmI+0I92GKFAd3iMq11M1xz2Gn4jOCXE9cUiL18SLA=; b=Wkl9QOYjq6dnNAt1/0cpgCdXmbmILd6r4ULi7GHBqI385jepQDYcBG53JHpZcGrFhJ Lu3o6W5zHSoNMOQPMW0MJ0XKR7eK2FNJVQ4s2WcqcACgC7mZpQOWasfjqDDVA4oZkhAq vTpqN8nkN/qqzlu+tp69nhREE/ySv4U24+W291FC7/yU6e+I3h70o1eOZV1a/nqf9tLh BbJ2Lpmg82n6Goh0a9e5lYCjxOh/R4a+jhQpXTfcqIDKA27OMbmb29LchhP+6XLwIqxi sb0g7bYcv0+INwgH/ttHt/aaxdj4DiVmGCP2WJRwGiZ+qQIonJzWgRLgV9AdbvoQPhIa I/Pg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAXDjCoz0l0Vtzf4iWuZ24cfeIHbNC3vHkR3ax78C/VGOCmAESwC xAcf8Ac/gE5HQqn68h/UGFK1C0PsP+xWDjt+JUi8k6tFCXq4AGTGox0SwsoT1/WAMqLXO3H6gkn 8vp8oy1Q/PTA/gy34RVIFViaIkbeHwBp/UXXq/vdTMG2L4DCite2BLaNv5UXhyumulA== X-Received: by 2002:a50:b2e1:: with SMTP id p88mr35464418edd.62.1554301095944; Wed, 03 Apr 2019 07:18:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfbq3o9jN4eS4PB4g6H+3K6t/PCjPnesCkwTL7I0DkixqWI3LvlSitvGR3YOIdWc6akOt4 X-Received: by 2002:a50:b2e1:: with SMTP id p88mr35464358edd.62.1554301094710; Wed, 03 Apr 2019 07:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301094; cv=none; d=google.com; s=arc-20160816; b=V6A+jMjWDhkBuctBW2VMnIggep0N9DOCjTx2qp56wRAlwxachNVXD4N5IdFqlLRohk o5iQ8T8SYPDqximjO4vj6WLDbA027VLiDZ4tVLlPED/7sglRqHRiJyNgv1iK1liM3WGM n7TBdgVSHDJ+liLTMxCzEPoCTxieJ13yzvypwUYBcAsvbqRqFG3siavR+7PLrC6l3JXY 7+i2Gn4QZytOwzyP/Zsad3YRLrErH0OjYDQtFZC/wF/3yZPPKI0bQCdDVBN9nBmc31/e LazOWheMBHQd4XQRsHs+V3KczqyZhc/OY5bz8lh6LuPDh+s0w+Gwfb0DjUmCnQg8trcJ dmCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=EdmI+0I92GKFAd3iMq11M1xz2Gn4jOCXE9cUiL18SLA=; b=q4tTejqG84freNWNqMPL7/xXveH1rJbSVOUeQqXdEc05zvcYR7gSKPlXvfAdFGEKS9 yFFvkyfyMFzJolFeG9+r1ovdaYrMozavO4Lw7C2NtRrxO3cRq/J94zMZsF1PrSYRMGcE DwqWOO0ipdZj0KyU7AwhtGOgLWi3XGmAZfTN7LaqbDiDs4wZoP2K5Q1U/iP7R5Mvvmnr lBiksdf3G5gucbDHmCZ3HMJeozFGKBrz5B5xDYK2zo+g4hWfaqzxERNVxnVuGqz6gZG5 goDY5ifRUtH1dks9kXkDbmBwD1uYjK/81gKG6Wy115eIeAgWm2k3HaUG/0n8pRhPXblZ m6Zg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id y7si719180edm.315.2019.04.03.07.18.14 for ; Wed, 03 Apr 2019 07:18:14 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 97F0D16A3; Wed, 3 Apr 2019 07:18:13 -0700 (PDT) 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 14A043F68F; Wed, 3 Apr 2019 07:18:09 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 16/20] x86: mm: Point to struct seq_file from struct pg_state Date: Wed, 3 Apr 2019 15:16:23 +0100 Message-Id: <20190403141627.11664-17-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP mm/dump_pagetables.c passes both struct seq_file and struct pg_state down the chain of walk_*_level() functions to be passed to note_page(). Instead place the struct seq_file in struct pg_state and access it from struct pg_state (which is private to this file) in note_page(). Signed-off-by: Steven Price --- arch/x86/mm/dump_pagetables.c | 69 ++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index e2b53db92c34..3d12ac031144 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -40,6 +40,7 @@ struct pg_state { bool to_dmesg; bool check_wx; unsigned long wx_pages; + struct seq_file *seq; }; struct addr_marker { @@ -268,11 +269,12 @@ static void note_wx(struct pg_state *st) * of PTE entries; the next one is different so we need to * print what we collected so far. */ -static void note_page(struct seq_file *m, struct pg_state *st, - pgprot_t new_prot, pgprotval_t new_eff, int level) +static void note_page(struct pg_state *st, pgprot_t new_prot, + pgprotval_t new_eff, int level) { pgprotval_t prot, cur, eff; static const char units[] = "BKMGTPE"; + struct seq_file *m = st->seq; /* * If we have a "break" in the series, we need to flush the state that @@ -358,8 +360,8 @@ static inline pgprotval_t effective_prot(pgprotval_t prot1, pgprotval_t prot2) ((prot1 | prot2) & _PAGE_NX); } -static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t addr, - pgprotval_t eff_in, unsigned long P) +static void walk_pte_level(struct pg_state *st, pmd_t addr, pgprotval_t eff_in, + unsigned long P) { int i; pte_t *pte; @@ -370,7 +372,7 @@ static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t addr, pte = pte_offset_map(&addr, st->current_address); prot = pte_flags(*pte); eff = effective_prot(eff_in, prot); - note_page(m, st, __pgprot(prot), eff, 5); + note_page(st, __pgprot(prot), eff, 5); pte_unmap(pte); } } @@ -383,22 +385,20 @@ static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t addr, * us dozens of seconds (minutes for 5-level config) while checking for * W+X mapping or reading kernel_page_tables debugfs file. */ -static inline bool kasan_page_table(struct seq_file *m, struct pg_state *st, - void *pt) +static inline bool kasan_page_table(struct pg_state *st, void *pt) { if (__pa(pt) == __pa(kasan_early_shadow_pmd) || (pgtable_l5_enabled() && __pa(pt) == __pa(kasan_early_shadow_p4d)) || __pa(pt) == __pa(kasan_early_shadow_pud)) { pgprotval_t prot = pte_flags(kasan_early_shadow_pte[0]); - note_page(m, st, __pgprot(prot), 0, 5); + note_page(st, __pgprot(prot), 0, 5); return true; } return false; } #else -static inline bool kasan_page_table(struct seq_file *m, struct pg_state *st, - void *pt) +static inline bool kasan_page_table(struct pg_state *st, void *pt) { return false; } @@ -406,7 +406,7 @@ static inline bool kasan_page_table(struct seq_file *m, struct pg_state *st, #if PTRS_PER_PMD > 1 -static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr, +static void walk_pmd_level(struct pg_state *st, pud_t addr, pgprotval_t eff_in, unsigned long P) { int i; @@ -420,19 +420,19 @@ static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr, prot = pmd_flags(*start); eff = effective_prot(eff_in, prot); if (pmd_large(*start) || !pmd_present(*start)) { - note_page(m, st, __pgprot(prot), eff, 4); - } else if (!kasan_page_table(m, st, pmd_start)) { - walk_pte_level(m, st, *start, eff, + note_page(st, __pgprot(prot), eff, 4); + } else if (!kasan_page_table(st, pmd_start)) { + walk_pte_level(st, *start, eff, P + i * PMD_LEVEL_MULT); } } else - note_page(m, st, __pgprot(0), 0, 4); + note_page(st, __pgprot(0), 0, 4); start++; } } #else -#define walk_pmd_level(m,s,a,e,p) walk_pte_level(m,s,__pmd(pud_val(a)),e,p) +#define walk_pmd_level(s,a,e,p) walk_pte_level(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))) @@ -440,8 +440,8 @@ static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr, #if PTRS_PER_PUD > 1 -static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr, - pgprotval_t eff_in, unsigned long P) +static void walk_pud_level(struct pg_state *st, p4d_t addr, pgprotval_t eff_in, + unsigned long P) { int i; pud_t *start, *pud_start; @@ -455,34 +455,34 @@ static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr, prot = pud_flags(*start); eff = effective_prot(eff_in, prot); if (pud_large(*start) || !pud_present(*start)) { - note_page(m, st, __pgprot(prot), eff, 3); - } else if (!kasan_page_table(m, st, pud_start)) { - walk_pmd_level(m, st, *start, eff, + note_page(st, __pgprot(prot), eff, 3); + } else if (!kasan_page_table(st, pud_start)) { + walk_pmd_level(st, *start, eff, P + i * PUD_LEVEL_MULT); } } else - note_page(m, st, __pgprot(0), 0, 3); + note_page(st, __pgprot(0), 0, 3); start++; } } #else -#define walk_pud_level(m,s,a,e,p) walk_pmd_level(m,s,__pud(p4d_val(a)),e,p) +#define walk_pud_level(s,a,e,p) walk_pmd_level(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 -static void walk_p4d_level(struct seq_file *m, struct pg_state *st, pgd_t addr, - pgprotval_t eff_in, unsigned long P) +static void walk_p4d_level(struct pg_state *st, pgd_t addr, pgprotval_t eff_in, + unsigned long P) { int i; p4d_t *start, *p4d_start; pgprotval_t prot, eff; if (PTRS_PER_P4D == 1) - return walk_pud_level(m, st, __p4d(pgd_val(addr)), eff_in, P); + return walk_pud_level(st, __p4d(pgd_val(addr)), eff_in, P); p4d_start = start = (p4d_t *)pgd_page_vaddr(addr); @@ -492,13 +492,13 @@ static void walk_p4d_level(struct seq_file *m, struct pg_state *st, pgd_t addr, prot = p4d_flags(*start); eff = effective_prot(eff_in, prot); if (p4d_large(*start) || !p4d_present(*start)) { - note_page(m, st, __pgprot(prot), eff, 2); - } else if (!kasan_page_table(m, st, p4d_start)) { - walk_pud_level(m, st, *start, eff, + note_page(st, __pgprot(prot), eff, 2); + } else if (!kasan_page_table(st, p4d_start)) { + walk_pud_level(st, *start, eff, P + i * P4D_LEVEL_MULT); } } else - note_page(m, st, __pgprot(0), 0, 2); + note_page(st, __pgprot(0), 0, 2); start++; } @@ -536,6 +536,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, } st.check_wx = checkwx; + st.seq = m; if (checkwx) st.wx_pages = 0; @@ -549,13 +550,13 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, eff = prot; #endif if (pgd_large(*start) || !pgd_present(*start)) { - note_page(m, &st, __pgprot(prot), eff, 1); + note_page(&st, __pgprot(prot), eff, 1); } else { - walk_p4d_level(m, &st, *start, eff, + walk_p4d_level(&st, *start, eff, i * PGD_LEVEL_MULT); } } else - note_page(m, &st, __pgprot(0), 0, 1); + note_page(&st, __pgprot(0), 0, 1); cond_resched(); start++; @@ -563,7 +564,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, /* Flush out the last page */ st.current_address = normalize_addr(PTRS_PER_PGD*PGD_LEVEL_MULT); - note_page(m, &st, __pgprot(0), 0, 0); + note_page(&st, __pgprot(0), 0, 0); if (!checkwx) return; if (st.wx_pages) From patchwork Wed Apr 3 14:16:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C61517E9 for ; Wed, 3 Apr 2019 14:18:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 770E6288E1 for ; Wed, 3 Apr 2019 14:18:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AD702898D; Wed, 3 Apr 2019 14:18:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E96B928A1A for ; Wed, 3 Apr 2019 14:18:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D137C6B027D; Wed, 3 Apr 2019 10:18:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CC5116B027E; Wed, 3 Apr 2019 10:18:20 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3D346B027F; Wed, 3 Apr 2019 10:18:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 651F66B027D for ; Wed, 3 Apr 2019 10:18:20 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id d2so7489539edo.23 for ; Wed, 03 Apr 2019 07:18:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=82GVaLwkCHLAJuw0cg7cs7mz13Kyr233/Gpjb9qS/I0=; b=Cs2NKMw9gg1Mnu0r6oMb5bDIeamFQ0e3m0/nLjPpzQp3GohjOfIfBM6HDzDUGsoiC4 O38BVeM4gtojq2BD7Cyht9HTBtZfq4iDERPgQAYZf12ZZA1KhUhezA3Wrp8iDXUziYP8 FeizyaH6MG8B811F1gIbpDyI2OmHZCkBMgzgznawt7DZmRn84TGiscpCHVAx/qO+yYgg +uH/GprrW7DsLuW4I8zWhtY+6qCex3t5VsFrsCKA3XSlbTC8HgYez+i7hAh2d7XS27do Y72VHWGv6fvFh6o2oFvVuRQaQLp8nK+2sup0t2R0pKVAg8dVPMtV+mE88wvZ6NBEeLc5 wOEg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAUu/+aaMo7uamRcl9/YrRSTGFdkBzK0Ws+dQEwvCznStSbevBtZ EDPPHdw0JyxGG2WlesbXH3rsSZiV0qVhCdhrCEn76aOnXkXzrWqXeO+gT3mvPtfNYdW4EvZ5T94 j46ATvSSmac8Fq9OSI7jO7Tlda26xarvZkyXHvTex1VgCd7FXaoSgLYnlOTMZq5k8mA== X-Received: by 2002:a17:906:4958:: with SMTP id f24mr44255462ejt.77.1554301099919; Wed, 03 Apr 2019 07:18:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8DR6Fb+JK1Hx4D3oCjoi+h1knT8mptG1RH6XDBodB7ZO0FUVYoMk6YyLuXOQd7AytjYwc X-Received: by 2002:a17:906:4958:: with SMTP id f24mr44255380ejt.77.1554301098315; Wed, 03 Apr 2019 07:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301098; cv=none; d=google.com; s=arc-20160816; b=F4pOvFlUL/ijYpP+QTRDbWfksTcyj1ay4+hkkjqqB74Iy3AQjxoYtWkPcCUcyPYsD7 ScjbAkL/d3+cgC53TcAvGXbS5LRJZDsBb2Ql2bjF78TqCm+czi/YAtSJivBg3oybmWtk Ev8xTu//7U54pSsSTdrSb7VOI8RBprUvfKeh+TffZ2AlfXIqF1GPe8UI27P9MnANOCQV LrSdvncTvZWwxttQM0UTHtKp1U3g4v/zYONCU5VM+CwcSE07HCLUKVsQosfiYKeLQfv7 vjaxSJdaW7JSbvbTp0ubYsKHZJ1SWRqFy3YmC5zhyxh0mTkxRxpbhmtOFlBG1xwEY0Dc 0UgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=82GVaLwkCHLAJuw0cg7cs7mz13Kyr233/Gpjb9qS/I0=; b=WyVgLfOU+8VEd/2vgWxaxgh8txc03HQQwNmY1Uq4k/oNFPHQ/hyxkxU8Miioy67umn /7lNJExDxdtI+zocem7J0AJJxP5fVV4ajnksQ9vJM932n9nxNGHULAsPM9mWdtXOLkgp M6R42ETT+piwHZO6YMueJwWQ6qfjT6Sm7upYChzQZsd+rFxIcH8UXl0femrOu9ESlRuL SGN49GpAjbSX7HklJ3b3CcMI8KYai9uHd/+1Xhg645kJFibOInTcz+uXIABVdoSm5FL9 qAlbrqfEkHpjS7uEHXVxGoFIrEUs9WyHyswtv6LGdDi71vTjNsl0kxjxSmTetXhrQHoc Ht4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id t6si3152240eda.289.2019.04.03.07.18.17 for ; Wed, 03 Apr 2019 07:18:18 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 426FF1713; Wed, 3 Apr 2019 07:18:17 -0700 (PDT) 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 D73153F68F; Wed, 3 Apr 2019 07:18:13 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 17/20] x86: mm+efi: Convert ptdump_walk_pgd_level() to take a mm_struct Date: Wed, 3 Apr 2019 15:16:24 +0100 Message-Id: <20190403141627.11664-18-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP To enable x86 to use the generic walk_page_range() function, the callers of ptdump_walk_pgd_level() need to pass an mm_struct rather than the raw pgd_t pointer. Luckily since commit 7e904a91bf60 ("efi: Use efi_mm in x86 as well as ARM") we now have an mm_struct for EFI on x86. Signed-off-by: Steven Price --- arch/x86/include/asm/pgtable.h | 2 +- arch/x86/mm/dump_pagetables.c | 4 ++-- arch/x86/platform/efi/efi_32.c | 2 +- arch/x86/platform/efi/efi_64.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 0dd04cf6ebeb..579959750f34 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -27,7 +27,7 @@ extern pgd_t early_top_pgt[PTRS_PER_PGD]; int __init __early_make_pgtable(unsigned long address, pmdval_t pmd); -void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd); +void ptdump_walk_pgd_level(struct seq_file *m, struct mm_struct *mm); void ptdump_walk_pgd_level_debugfs(struct seq_file *m, pgd_t *pgd, bool user); void ptdump_walk_pgd_level_checkwx(void); void ptdump_walk_user_pgd_level_checkwx(void); diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index 3d12ac031144..ddf8ea6b059d 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -574,9 +574,9 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, pr_info("x86/mm: Checked W+X mappings: passed, no W+X pages found.\n"); } -void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd) +void ptdump_walk_pgd_level(struct seq_file *m, struct mm_struct *mm) { - ptdump_walk_pgd_level_core(m, pgd, false, true); + ptdump_walk_pgd_level_core(m, mm->pgd, false, true); } void ptdump_walk_pgd_level_debugfs(struct seq_file *m, pgd_t *pgd, bool user) diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c index 9959657127f4..9175ceaa6e72 100644 --- a/arch/x86/platform/efi/efi_32.c +++ b/arch/x86/platform/efi/efi_32.c @@ -49,7 +49,7 @@ void efi_sync_low_kernel_mappings(void) {} void __init efi_dump_pagetable(void) { #ifdef CONFIG_EFI_PGT_DUMP - ptdump_walk_pgd_level(NULL, swapper_pg_dir); + ptdump_walk_pgd_level(NULL, init_mm); #endif } diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index cf0347f61b21..a2e0f9800190 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -611,9 +611,9 @@ void __init efi_dump_pagetable(void) { #ifdef CONFIG_EFI_PGT_DUMP if (efi_enabled(EFI_OLD_MEMMAP)) - ptdump_walk_pgd_level(NULL, swapper_pg_dir); + ptdump_walk_pgd_level(NULL, init_mm); else - ptdump_walk_pgd_level(NULL, efi_mm.pgd); + ptdump_walk_pgd_level(NULL, efi_mm); #endif } From patchwork Wed Apr 3 14:16:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C319417E9 for ; Wed, 3 Apr 2019 14:18:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC5C01FF73 for ; Wed, 3 Apr 2019 14:18:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA6C92898D; Wed, 3 Apr 2019 14:18:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 216CB1FF73 for ; Wed, 3 Apr 2019 14:18:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 091DC6B027F; Wed, 3 Apr 2019 10:18:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EE89B6B0280; Wed, 3 Apr 2019 10:18:23 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFD7A6B0281; Wed, 3 Apr 2019 10:18:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 8E8696B027F for ; Wed, 3 Apr 2019 10:18:23 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id m31so7655612edm.4 for ; Wed, 03 Apr 2019 07:18:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QI1ft8uG/6LmqX3YnTkHhfrqxc9+RDV6RJGxqI2lX8w=; b=D8LMM/m8DjtJwFsm/6UV6IOjLs1ZS5wJSo+FosumURwXa2n2OMFY+U8EJShE4bZm/M nM3omECLjXjqJZr56BSXik4vhDhgjIqzwtNKM3niNNK8PzIFsr/UahYYwkhlMak0nRL5 rGMeCJntxn/5QHXcS9hDkMBu2ol3djamp9roMVwnsOgEzju+25Qie+bzDfVQqaTrEY8Q LG2AKMeAiuejWJLAFtse8auQlMtYG8eE68mCiSWlmgRw/azfTdyTbv04/akGaCm6yhzG mzbdYtx4lH5GXh/kvPRg0s04hC1oFwvEnqZs9/Xh5Y/3HJpcvxMHJk1WFufjw4qKuStu XzaA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAV5k2nYujA9QqkNfPq5oTdpzLUZga1I4pDeBAHtCgSbXzpG4nVv +9KsXikGq+TYXlhpd4Hby3+BaW5F9nEsz6JIKuW6bmBZ518tS4lB/zqvPHb2oF88p6CrS1a6YVr /3Zf1alwQrPjMNvALE7GBogNB8nGjIXONHc4FKK34dqqtmtvV7d8RjMffJHxOPBhblw== X-Received: by 2002:a50:f5f8:: with SMTP id x53mr52652195edm.2.1554301103064; Wed, 03 Apr 2019 07:18:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfN5WA0EhZKnyIZ7dIoLc6/CxA23Ub8mW8y0LzSU5uyMxR5UmfAltuv1CzOvJxT1zrdQBw X-Received: by 2002:a50:f5f8:: with SMTP id x53mr52652135edm.2.1554301102021; Wed, 03 Apr 2019 07:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301102; cv=none; d=google.com; s=arc-20160816; b=Oh+Fjs10ZpNeu/sQ5Z+HSyEsdIxjo6+1p5V4zpQ9NXvlb1uUMBOr2DUILBg9237KGs oWGJaQERdxXweSp2XHy+fjOnEgromuMh5ebkncmOTYbNqHB44enFyQm9ocsmCIuYQLAI J6iwBNhDgU+UrgwtdbRlJZsdOLHo7gDx10wE9q1q2QzvZBKrSwPQ2uvbsX50AghgcwX+ NrXP54nWpiGQnXiWUJTkrkO0nafYvzY1iwNIG+Xh1TJe5NDPzDa7wZvwIQHzDX4mzYJX 5IQfIq84xDLwjydKA1NDrI3rQ65DANEp1bMlWdBvIfGXH7t7i7rjsabiH2ETUyRY4zfA ZgYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=QI1ft8uG/6LmqX3YnTkHhfrqxc9+RDV6RJGxqI2lX8w=; b=B1NRivDsdb+ger0tvqoj117Ih739ODN71QToESzCrdp2Pd5oYDXz48pcFDhd0tQEgZ 3u5QpJ3MuKEsq+SsgFXObTRLlzW8/+THy0Dqj7vsgF4vTkHVHTKn8+bDRs0qNgn4cfe2 5BV/mYlARodUE63OhaB4D/V8epR9p+5u4v6k0tobTkqhXOXFg4dgtFFHE9+BTVkzUfbx Dbv60zrKA6+Klj8IwoYgikCznIJnwvhx7HKM0KNjlIYjz3GCYnPHCFdw5Us/pzbHPeCU 8LywPl5CAyVzsNENAGUdbNlhbg0Diu94WPrA41Nr7nvLtryxM05ldr3wvqZUSJoMAw7/ Trsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id k23si2356701edd.387.2019.04.03.07.18.21 for ; Wed, 03 Apr 2019 07:18:22 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 E144C1684; Wed, 3 Apr 2019 07:18:20 -0700 (PDT) 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 81C473F68F; Wed, 3 Apr 2019 07:18:17 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 18/20] x86: mm: Convert ptdump_walk_pgd_level_debugfs() to take an mm_struct Date: Wed, 3 Apr 2019 15:16:25 +0100 Message-Id: <20190403141627.11664-19-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP To enable x86 to use the generic walk_page_range() function, the callers of ptdump_walk_pgd_level_debugfs() need to pass in the mm_struct. This means that ptdump_walk_pgd_level_core() is now always passed a valid pgd, so drop the support for pgd==NULL. Signed-off-by: Steven Price --- arch/x86/include/asm/pgtable.h | 3 ++- arch/x86/mm/debug_pagetables.c | 8 ++++---- arch/x86/mm/dump_pagetables.c | 14 ++++++-------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 579959750f34..5abf693dc9b2 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -28,7 +28,8 @@ extern pgd_t early_top_pgt[PTRS_PER_PGD]; int __init __early_make_pgtable(unsigned long address, pmdval_t pmd); void ptdump_walk_pgd_level(struct seq_file *m, struct mm_struct *mm); -void ptdump_walk_pgd_level_debugfs(struct seq_file *m, pgd_t *pgd, bool user); +void ptdump_walk_pgd_level_debugfs(struct seq_file *m, struct mm_struct *mm, + bool user); void ptdump_walk_pgd_level_checkwx(void); void ptdump_walk_user_pgd_level_checkwx(void); diff --git a/arch/x86/mm/debug_pagetables.c b/arch/x86/mm/debug_pagetables.c index cd84f067e41d..824131052574 100644 --- a/arch/x86/mm/debug_pagetables.c +++ b/arch/x86/mm/debug_pagetables.c @@ -6,7 +6,7 @@ static int ptdump_show(struct seq_file *m, void *v) { - ptdump_walk_pgd_level_debugfs(m, NULL, false); + ptdump_walk_pgd_level_debugfs(m, &init_mm, false); return 0; } @@ -16,7 +16,7 @@ static int ptdump_curknl_show(struct seq_file *m, void *v) { if (current->mm->pgd) { down_read(¤t->mm->mmap_sem); - ptdump_walk_pgd_level_debugfs(m, current->mm->pgd, false); + ptdump_walk_pgd_level_debugfs(m, current->mm, false); up_read(¤t->mm->mmap_sem); } return 0; @@ -31,7 +31,7 @@ static int ptdump_curusr_show(struct seq_file *m, void *v) { if (current->mm->pgd) { down_read(¤t->mm->mmap_sem); - ptdump_walk_pgd_level_debugfs(m, current->mm->pgd, true); + ptdump_walk_pgd_level_debugfs(m, current->mm, true); up_read(¤t->mm->mmap_sem); } return 0; @@ -46,7 +46,7 @@ static struct dentry *pe_efi; static int ptdump_efi_show(struct seq_file *m, void *v) { if (efi_mm.pgd) - ptdump_walk_pgd_level_debugfs(m, efi_mm.pgd, false); + ptdump_walk_pgd_level_debugfs(m, &efi_mm, false); return 0; } diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index ddf8ea6b059d..40b3f1da6e15 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -525,16 +525,12 @@ static inline bool is_hypervisor_range(int idx) static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, bool checkwx, bool dmesg) { - pgd_t *start = INIT_PGD; + pgd_t *start = pgd; pgprotval_t prot, eff; int i; struct pg_state st = {}; - if (pgd) { - start = pgd; - st.to_dmesg = dmesg; - } - + st.to_dmesg = dmesg; st.check_wx = checkwx; st.seq = m; if (checkwx) @@ -579,8 +575,10 @@ void ptdump_walk_pgd_level(struct seq_file *m, struct mm_struct *mm) ptdump_walk_pgd_level_core(m, mm->pgd, false, true); } -void ptdump_walk_pgd_level_debugfs(struct seq_file *m, pgd_t *pgd, bool user) +void ptdump_walk_pgd_level_debugfs(struct seq_file *m, struct mm_struct *mm, + bool user) { + pgd_t *pgd = mm->pgd; #ifdef CONFIG_PAGE_TABLE_ISOLATION if (user && static_cpu_has(X86_FEATURE_PTI)) pgd = kernel_to_user_pgdp(pgd); @@ -606,7 +604,7 @@ void ptdump_walk_user_pgd_level_checkwx(void) void ptdump_walk_pgd_level_checkwx(void) { - ptdump_walk_pgd_level_core(NULL, NULL, true, false); + ptdump_walk_pgd_level_core(NULL, INIT_PGD, true, false); } static int __init pt_dump_init(void) From patchwork Wed Apr 3 14:16:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 477B717E1 for ; Wed, 3 Apr 2019 14:18:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30FAA288EF for ; Wed, 3 Apr 2019 14:18:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2592828A1B; Wed, 3 Apr 2019 14:18:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82743288EF for ; Wed, 3 Apr 2019 14:18:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 683626B0280; Wed, 3 Apr 2019 10:18:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 632E06B0281; Wed, 3 Apr 2019 10:18:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FB9C6B0282; Wed, 3 Apr 2019 10:18:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 0521D6B0280 for ; Wed, 3 Apr 2019 10:18:27 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id n12so7651110edo.5 for ; Wed, 03 Apr 2019 07:18:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0Qu5DM7t7O6eLZ930vwdwyGGSyJREtb45OisMEetzTk=; b=a+LDXYywEoYdECjpsag9Qt4laP7e7zq7kQ2wUEDXGuyKyWX8Pu/4tjhPeHaK1fjVO7 WLXnrYTFfkZ4Bzr5GSrLF2Y9SIv0tPCvXLIin21r5/ChYWWeR6ygjLp9G8m2JsRnJI2u EORmafHexFFEibb3hiWQtjcaDPVMteT+S9DQFyAJXd4X3vwr13d40gnX+nSuSgf6uKdr 4XO3ZinO63SRgujmH5MeRtsCaptjWfqq+Zv96+CKSDadZv5vuve53vRyS3aDwvdf/C1h 1Gco15cCGV49ZpIMBpK/LxcBBYZsbaxh3yvvb61StqNCKM0y1XUPqkDsFzZvxIEFP5Dy j/hw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAWAqbNSptwurKAITv5BPPUloyuWAQQ8n/FNdivdQhhZk2SInpqT Rw/1uW4FyLwJUAIzZHni+4mXXbRedX5LjNuISBf0nfgC/y8EuIQHgXMaX9GLCl8IqLtVbkHFJqJ +UZEZnCfYrDxe28sfUULJznUGJAbrnE+DWiv82/mM67INIAwioyKFBkNAf4u+QsrtDg== X-Received: by 2002:a50:ec89:: with SMTP id e9mr31934559edr.252.1554301106543; Wed, 03 Apr 2019 07:18:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwU1kJo7gGld2UhuMwibGXOAqu3CzYF9oSuTWaov/ACL4kyTxyiDsZ+OguLoyswC11gDWnw X-Received: by 2002:a50:ec89:: with SMTP id e9mr31934508edr.252.1554301105640; Wed, 03 Apr 2019 07:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301105; cv=none; d=google.com; s=arc-20160816; b=M5YSDSnKRtT8LbJBNy+F9ZEA+EzLS7TdtyUIHTAoP1JfAsdSxRLplgxzRzz0bM4Mcw aPEMhsxLl8YmWybaUXMx9TJa3VCklm2PHwlQJdioC8ElcTavzKVW4CQ9+0R3xj+Jep4V U7CAcBhf7Ds61+DxW5EjM1SruH4V08FSYc9uO1DGh6w+C6FomMhN0Pqs3X2QUm87ts3D gHjxTnXK82UGaunrRqAaAHKCW/ySWRzfpAWLCJ7iz5cMrJJ7L/LY8jT6dfFOwH73+zrE 4t526LZidy/eFy80i0OyIQr24YKVzgN3iwXLSWWELp+2DL86t3xM3dBsyaahohZ9N3si 2e+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=0Qu5DM7t7O6eLZ930vwdwyGGSyJREtb45OisMEetzTk=; b=fDjVR6gTdoyZHG6vq274Q5bkq1LLVJFephExXlaMfDBryKZEKwN3P3PF9seR4EKI+j tZYw6qTfR+qsvW0dgBEPw0bx/x/2L7/hzmUDlS+D/v9SATBuOrgv5nTBeOtbheuJeGSB DVYtHBH3EO8GQ8zE5q8dcAXsnf5Nwr+Ox0ojCOhvxIGdon9oG88Yy4g6wjYM3P5zVmcF 7ir4oEfv8ZoiuUv7sQI/HyXRjs7iXUFfr9WsYFduXnIl0pwbfXjlvaADn26QJ5W8MlMA avShZCFc0IF2MQcz+cBofV1T9YywfJY/Yt6czZP7YZ/29lhZ0LRDyMwFn5wtb7O95Z3k UUyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id w48si2420346edc.295.2019.04.03.07.18.25 for ; Wed, 03 Apr 2019 07:18:25 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 8FB1D168F; Wed, 3 Apr 2019 07:18:24 -0700 (PDT) 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 2C9A03F68F; Wed, 3 Apr 2019 07:18:21 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 19/20] x86: mm: Convert ptdump_walk_pgd_level_core() to take an mm_struct Date: Wed, 3 Apr 2019 15:16:26 +0100 Message-Id: <20190403141627.11664-20-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP An mm_struct is needed to enable x86 to use of the generic walk_page_range() function. In the case of walking the user page tables (when CONFIG_PAGE_TABLE_ISOLATION is enabled), it is necessary to create a fake_mm structure because there isn't an mm_struct with a pointer to the pgd of the user page tables. This fake_mm structure is initialised with the minimum necessary for the generic page walk code. Signed-off-by: Steven Price --- arch/x86/mm/dump_pagetables.c | 36 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index 40b3f1da6e15..c0fbb9e5a790 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -111,8 +111,6 @@ static struct addr_marker address_markers[] = { [END_OF_SPACE_NR] = { -1, NULL } }; -#define INIT_PGD ((pgd_t *) &init_top_pgt) - #else /* CONFIG_X86_64 */ enum address_markers_idx { @@ -147,8 +145,6 @@ static struct addr_marker address_markers[] = { [END_OF_SPACE_NR] = { -1, NULL } }; -#define INIT_PGD (swapper_pg_dir) - #endif /* !CONFIG_X86_64 */ /* Multipliers for offsets within the PTEs */ @@ -522,10 +518,10 @@ static inline bool is_hypervisor_range(int idx) #endif } -static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, +static void ptdump_walk_pgd_level_core(struct seq_file *m, struct mm_struct *mm, bool checkwx, bool dmesg) { - pgd_t *start = pgd; + pgd_t *start = mm->pgd; pgprotval_t prot, eff; int i; struct pg_state st = {}; @@ -572,39 +568,49 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, void ptdump_walk_pgd_level(struct seq_file *m, struct mm_struct *mm) { - ptdump_walk_pgd_level_core(m, mm->pgd, false, true); + ptdump_walk_pgd_level_core(m, mm, false, true); } +#ifdef CONFIG_PAGE_TABLE_ISOLATION +static void ptdump_walk_pgd_level_user_core(struct seq_file *m, + struct mm_struct *mm, + bool checkwx, bool dmesg) +{ + struct mm_struct fake_mm = { + .pgd = kernel_to_user_pgdp(mm->pgd) + }; + init_rwsem(&fake_mm.mmap_sem); + ptdump_walk_pgd_level_core(m, &fake_mm, checkwx, dmesg); +} +#endif + void ptdump_walk_pgd_level_debugfs(struct seq_file *m, struct mm_struct *mm, bool user) { - pgd_t *pgd = mm->pgd; #ifdef CONFIG_PAGE_TABLE_ISOLATION if (user && static_cpu_has(X86_FEATURE_PTI)) - pgd = kernel_to_user_pgdp(pgd); + ptdump_walk_pgd_level_user_core(m, mm, false, false); + else #endif - ptdump_walk_pgd_level_core(m, pgd, false, false); + ptdump_walk_pgd_level_core(m, mm, false, false); } EXPORT_SYMBOL_GPL(ptdump_walk_pgd_level_debugfs); void ptdump_walk_user_pgd_level_checkwx(void) { #ifdef CONFIG_PAGE_TABLE_ISOLATION - pgd_t *pgd = INIT_PGD; - if (!(__supported_pte_mask & _PAGE_NX) || !static_cpu_has(X86_FEATURE_PTI)) return; pr_info("x86/mm: Checking user space page tables\n"); - pgd = kernel_to_user_pgdp(pgd); - ptdump_walk_pgd_level_core(NULL, pgd, true, false); + ptdump_walk_pgd_level_user_core(NULL, &init_mm, true, false); #endif } void ptdump_walk_pgd_level_checkwx(void) { - ptdump_walk_pgd_level_core(NULL, INIT_PGD, true, false); + ptdump_walk_pgd_level_core(NULL, &init_mm, true, false); } static int __init pt_dump_init(void) From patchwork Wed Apr 3 14:16:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10883937 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A21C6184E for ; Wed, 3 Apr 2019 14:18:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85C4E2858B for ; Wed, 3 Apr 2019 14:18:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78BFF289BF; Wed, 3 Apr 2019 14:18:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BAA32858B for ; Wed, 3 Apr 2019 14:18:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFDBB6B0282; Wed, 3 Apr 2019 10:18:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D878C6B0283; Wed, 3 Apr 2019 10:18:31 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9B7E6B0284; Wed, 3 Apr 2019 10:18:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 77A216B0282 for ; Wed, 3 Apr 2019 10:18:31 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id f2so7635328edv.15 for ; Wed, 03 Apr 2019 07:18:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kX4dLJraJo092n4y125DLKk3n4IU7HsLifEATF3quag=; b=nSV1uAeNc3vLGxr+7uG4wF4dDDgntR8Jj5SFah6vrSDgffFOj3IKB4RP5MjoRBWtDJ NypckRb77CjBqivkb+aYGtchnclabwT+jyfDxNF+jNViMylhBK3IVSLagmT1WKBTS2ZI +YyUcR+HLsIY6ZocgAatEbWFzuwL79jfnOa/ACl2S1xmFa88F5/Oj/w2Vbm8r9ocibiM wcAILokq4OVCswfrA3pedMiO3rCYu4zJ6b469mQnqnouCEOEmE/hXD46IbfOb4CSa/7x xwRsvrgei4z6v0QWXv6lLsC4BL/VSdXn3xgSo4k+X0UO98jrOsmPh9NiT9nZ1QpWgyHA oYbg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com X-Gm-Message-State: APjAAAWYvCVeaOWxwGQPTBbbdBHiC65FQcNRcaFDgV+mA2nOBkqt/OZL oAD6Om7OKl335Mj1eUnl+XKWsCv/6pcoMtR6wgTVR3tutcpFJcA6kvNp10V6taynXKj4aBWsHHK tu/cLaKGzAGi6tZq8d/xu2AnhPdMfyI/cg+qgzsAmLspV3jnsGTilkpM3tmZ54gXUdA== X-Received: by 2002:a17:906:31cf:: with SMTP id f15mr40010681ejf.246.1554301110961; Wed, 03 Apr 2019 07:18:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpboJh7wfl89AtEw4eVBcaUPhLf+E+UGK7fdPIlVAcqGSmfkx/PDTmxd0GtmQTrj4Um48N X-Received: by 2002:a17:906:31cf:: with SMTP id f15mr40010601ejf.246.1554301109229; Wed, 03 Apr 2019 07:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554301109; cv=none; d=google.com; s=arc-20160816; b=aehmAjdFQvqnTyScsxq1q+s1Gg0/Tq6YdiinmIgWQfH2e/2wicLR8UNWCQFFmaPfz+ YJyX5clMLXCwe3moe/pri/wbXXeGlBrQe3Oc4L46YSAHFxoxAe1hQ15Ws/a7y2apBtnx dS9x2N4mCRgd7GF0sT7LHx8zB7a8eMpIRX3GlPNKQbAU1LfI2BB9bjdFBxVuiqX6lCVX /9iJjVGwldw8DO+8QjsjCzePMn5ha5L3YjbK4EmjTWxaS11Ug342iUeQYOd2vikEszEf YoRCHawMQC0qh2u+ZNyrT2+PfLOUgMMZ70uDlvCGkmiiJayWhuyjAMu7LuvndYOGlXYv KicQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=kX4dLJraJo092n4y125DLKk3n4IU7HsLifEATF3quag=; b=jg7fRhMEdObJIw6w2yRXekIpcW/vuDCKWc1wVzNp6ad+XoWD5f7TAjNXl8x00MdR/5 dLxodmmKxqYpjqXmOM7nZOlh+rfQo5IjqQCJugbTzojy1ynjoHDd8hIr7sEhX/80KOkE JIJ/maoSJRrcKM6jCmWYLL+meaKOe0A6kwo4t2QM5HSujqf/BIU5QqhzKwiYYT1PxGnc tpXoJGZPoboWzTpAVAGiY8U6mly0Lf+HyqX2pL+oRbIIbWVO6OxT7lA12c3kf/GL2/6d tuO+mCwBXAJE6BAHnF+0Ex/9i3tmq9aWsqltT6gSBqgcmDho48NAUqy4BSYiwYrHIqeX UKRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id e1si2162944edy.366.2019.04.03.07.18.28 for ; Wed, 03 Apr 2019 07:18:29 -0700 (PDT) Received-SPF: pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steven.price@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steven.price@arm.com 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 3968D169E; Wed, 3 Apr 2019 07:18:28 -0700 (PDT) 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 CF37D3F68F; Wed, 3 Apr 2019 07:18:24 -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?b?SsOpcsO0bWUgR2xpc3Nl?= , 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 v8 20/20] x86: mm: Convert dump_pagetables to use walk_page_range Date: Wed, 3 Apr 2019 15:16:27 +0100 Message-Id: <20190403141627.11664-21-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403141627.11664-1-steven.price@arm.com> References: <20190403141627.11664-1-steven.price@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Make use of the new functionality in walk_page_range to remove the arch page walking code and use the generic code to walk the page tables. The effective permissions are passed down the chain using new fields in struct pg_state. The KASAN optimisation is implemented by including test_p?d callbacks which can decide to skip an entire tree of entries Signed-off-by: Steven Price --- arch/x86/mm/dump_pagetables.c | 280 ++++++++++++++++++---------------- 1 file changed, 146 insertions(+), 134 deletions(-) diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index c0fbb9e5a790..f6b814aaddf7 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -33,6 +33,10 @@ struct pg_state { int level; pgprot_t current_prot; pgprotval_t effective_prot; + pgprotval_t effective_prot_pgd; + pgprotval_t effective_prot_p4d; + pgprotval_t effective_prot_pud; + pgprotval_t effective_prot_pmd; unsigned long start_address; unsigned long current_address; const struct addr_marker *marker; @@ -356,22 +360,21 @@ static inline pgprotval_t effective_prot(pgprotval_t prot1, pgprotval_t prot2) ((prot1 | prot2) & _PAGE_NX); } -static void walk_pte_level(struct pg_state *st, pmd_t addr, pgprotval_t eff_in, - unsigned long P) +static int ptdump_pte_entry(pte_t *pte, unsigned long addr, + unsigned long next, struct mm_walk *walk) { - int i; - pte_t *pte; - pgprotval_t prot, eff; - - for (i = 0; i < PTRS_PER_PTE; i++) { - st->current_address = normalize_addr(P + i * PTE_LEVEL_MULT); - pte = pte_offset_map(&addr, st->current_address); - prot = pte_flags(*pte); - eff = effective_prot(eff_in, prot); - note_page(st, __pgprot(prot), eff, 5); - pte_unmap(pte); - } + struct pg_state *st = walk->private; + pgprotval_t eff, prot; + + st->current_address = normalize_addr(addr); + + prot = pte_flags(*pte); + eff = effective_prot(st->effective_prot_pmd, prot); + note_page(st, __pgprot(prot), eff, 5); + + return 0; } + #ifdef CONFIG_KASAN /* @@ -400,131 +403,152 @@ static inline bool kasan_page_table(struct pg_state *st, void *pt) } #endif -#if PTRS_PER_PMD > 1 - -static void walk_pmd_level(struct pg_state *st, pud_t addr, - pgprotval_t eff_in, unsigned long P) +static int ptdump_test_pmd(unsigned long addr, unsigned long next, + pmd_t *pmd, struct mm_walk *walk) { - int i; - pmd_t *start, *pmd_start; - pgprotval_t prot, eff; - - pmd_start = start = (pmd_t *)pud_page_vaddr(addr); - for (i = 0; i < PTRS_PER_PMD; i++) { - st->current_address = normalize_addr(P + i * PMD_LEVEL_MULT); - if (!pmd_none(*start)) { - prot = pmd_flags(*start); - eff = effective_prot(eff_in, prot); - if (pmd_large(*start) || !pmd_present(*start)) { - note_page(st, __pgprot(prot), eff, 4); - } else if (!kasan_page_table(st, pmd_start)) { - walk_pte_level(st, *start, eff, - P + i * PMD_LEVEL_MULT); - } - } else - note_page(st, __pgprot(0), 0, 4); - start++; - } + struct pg_state *st = walk->private; + + st->current_address = normalize_addr(addr); + + if (kasan_page_table(st, pmd)) + return 1; + return 0; } -#else -#define walk_pmd_level(s,a,e,p) walk_pte_level(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 +static int ptdump_pmd_entry(pmd_t *pmd, unsigned long addr, + unsigned long next, struct mm_walk *walk) +{ + struct pg_state *st = walk->private; + pgprotval_t eff, prot; + + prot = pmd_flags(*pmd); + eff = effective_prot(st->effective_prot_pud, prot); + + st->current_address = normalize_addr(addr); + + if (pmd_large(*pmd)) + note_page(st, __pgprot(prot), eff, 4); -#if PTRS_PER_PUD > 1 + st->effective_prot_pmd = eff; -static void walk_pud_level(struct pg_state *st, p4d_t addr, pgprotval_t eff_in, - unsigned long P) + return 0; +} + +static int ptdump_test_pud(unsigned long addr, unsigned long next, + pud_t *pud, struct mm_walk *walk) { - int i; - pud_t *start, *pud_start; - pgprotval_t prot, eff; - - pud_start = start = (pud_t *)p4d_page_vaddr(addr); - - for (i = 0; i < PTRS_PER_PUD; i++) { - st->current_address = normalize_addr(P + i * PUD_LEVEL_MULT); - if (!pud_none(*start)) { - prot = pud_flags(*start); - eff = effective_prot(eff_in, prot); - if (pud_large(*start) || !pud_present(*start)) { - note_page(st, __pgprot(prot), eff, 3); - } else if (!kasan_page_table(st, pud_start)) { - walk_pmd_level(st, *start, eff, - P + i * PUD_LEVEL_MULT); - } - } else - note_page(st, __pgprot(0), 0, 3); + struct pg_state *st = walk->private; - start++; - } + st->current_address = normalize_addr(addr); + + if (kasan_page_table(st, pud)) + return 1; + return 0; } -#else -#define walk_pud_level(s,a,e,p) walk_pmd_level(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 +static int ptdump_pud_entry(pud_t *pud, unsigned long addr, + unsigned long next, struct mm_walk *walk) +{ + struct pg_state *st = walk->private; + pgprotval_t eff, prot; + + prot = pud_flags(*pud); + eff = effective_prot(st->effective_prot_p4d, prot); + + st->current_address = normalize_addr(addr); + + if (pud_large(*pud)) + note_page(st, __pgprot(prot), eff, 3); + + st->effective_prot_pud = eff; -static void walk_p4d_level(struct pg_state *st, pgd_t addr, pgprotval_t eff_in, - unsigned long P) + return 0; +} + +static int ptdump_test_p4d(unsigned long addr, unsigned long next, + p4d_t *p4d, struct mm_walk *walk) { - int i; - p4d_t *start, *p4d_start; - pgprotval_t prot, eff; - - if (PTRS_PER_P4D == 1) - return walk_pud_level(st, __p4d(pgd_val(addr)), eff_in, P); - - p4d_start = start = (p4d_t *)pgd_page_vaddr(addr); - - for (i = 0; i < PTRS_PER_P4D; i++) { - st->current_address = normalize_addr(P + i * P4D_LEVEL_MULT); - if (!p4d_none(*start)) { - prot = p4d_flags(*start); - eff = effective_prot(eff_in, prot); - if (p4d_large(*start) || !p4d_present(*start)) { - note_page(st, __pgprot(prot), eff, 2); - } else if (!kasan_page_table(st, p4d_start)) { - walk_pud_level(st, *start, eff, - P + i * P4D_LEVEL_MULT); - } - } else - note_page(st, __pgprot(0), 0, 2); + struct pg_state *st = walk->private; - start++; - } + st->current_address = normalize_addr(addr); + + if (kasan_page_table(st, p4d)) + return 1; + return 0; } -#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)))) +static int ptdump_p4d_entry(p4d_t *p4d, unsigned long addr, + unsigned long next, struct mm_walk *walk) +{ + struct pg_state *st = walk->private; + pgprotval_t eff, prot; + + prot = p4d_flags(*p4d); + eff = effective_prot(st->effective_prot_pgd, prot); + + st->current_address = normalize_addr(addr); + + if (p4d_large(*p4d)) + note_page(st, __pgprot(prot), eff, 2); + + st->effective_prot_p4d = eff; + + return 0; +} -static inline bool is_hypervisor_range(int idx) +static int ptdump_pgd_entry(pgd_t *pgd, unsigned long addr, + unsigned long next, struct mm_walk *walk) { -#ifdef CONFIG_X86_64 - /* - * A hole in the beginning of kernel address space reserved - * for a hypervisor. - */ - return (idx >= pgd_index(GUARD_HOLE_BASE_ADDR)) && - (idx < pgd_index(GUARD_HOLE_END_ADDR)); + struct pg_state *st = walk->private; + pgprotval_t eff, prot; + + prot = pgd_flags(*pgd); + +#ifdef CONFIG_X86_PAE + eff = _PAGE_USER | _PAGE_RW; #else - return false; + eff = prot; #endif + + st->current_address = normalize_addr(addr); + + if (pgd_large(*pgd)) + note_page(st, __pgprot(prot), eff, 1); + + st->effective_prot_pgd = eff; + + return 0; +} + +static int ptdump_hole(unsigned long addr, unsigned long next, + struct mm_walk *walk) +{ + struct pg_state *st = walk->private; + + st->current_address = normalize_addr(addr); + + note_page(st, __pgprot(0), 0, -1); + + return 0; } static void ptdump_walk_pgd_level_core(struct seq_file *m, struct mm_struct *mm, bool checkwx, bool dmesg) { - pgd_t *start = mm->pgd; - pgprotval_t prot, eff; - int i; struct pg_state st = {}; + struct mm_walk walk = { + .mm = mm, + .pgd_entry = ptdump_pgd_entry, + .p4d_entry = ptdump_p4d_entry, + .pud_entry = ptdump_pud_entry, + .pmd_entry = ptdump_pmd_entry, + .pte_entry = ptdump_pte_entry, + .test_p4d = ptdump_test_p4d, + .test_pud = ptdump_test_pud, + .test_pmd = ptdump_test_pmd, + .pte_hole = ptdump_hole, + .private = &st + }; st.to_dmesg = dmesg; st.check_wx = checkwx; @@ -532,27 +556,15 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, struct mm_struct *mm, if (checkwx) st.wx_pages = 0; - for (i = 0; i < PTRS_PER_PGD; i++) { - st.current_address = normalize_addr(i * PGD_LEVEL_MULT); - if (!pgd_none(*start) && !is_hypervisor_range(i)) { - prot = pgd_flags(*start); -#ifdef CONFIG_X86_PAE - eff = _PAGE_USER | _PAGE_RW; + down_read(&mm->mmap_sem); +#ifdef CONFIG_X86_64 + walk_page_range(0, PTRS_PER_PGD*PGD_LEVEL_MULT/2, &walk); + walk_page_range(normalize_addr(PTRS_PER_PGD*PGD_LEVEL_MULT/2), ~0, + &walk); #else - eff = prot; + walk_page_range(0, ~0, &walk); #endif - if (pgd_large(*start) || !pgd_present(*start)) { - note_page(&st, __pgprot(prot), eff, 1); - } else { - walk_p4d_level(&st, *start, eff, - i * PGD_LEVEL_MULT); - } - } else - note_page(&st, __pgprot(0), 0, 1); - - cond_resched(); - start++; - } + up_read(&mm->mmap_sem); /* Flush out the last page */ st.current_address = normalize_addr(PTRS_PER_PGD*PGD_LEVEL_MULT);