From patchwork Wed Mar 6 15:50: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: 10841329 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 0477D17E0 for ; Wed, 6 Mar 2019 15:50:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3A272E72F for ; Wed, 6 Mar 2019 15:50:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E14172E72C; Wed, 6 Mar 2019 15:50:54 +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 4D48F2E72F for ; Wed, 6 Mar 2019 15:50:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DD138E0005; Wed, 6 Mar 2019 10:50:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 163338E0002; Wed, 6 Mar 2019 10:50:53 -0500 (EST) 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 02A6C8E0005; Wed, 6 Mar 2019 10:50:52 -0500 (EST) 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 A15F28E0002 for ; Wed, 6 Mar 2019 10:50:52 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id f2so6455863edm.18 for ; Wed, 06 Mar 2019 07:50:52 -0800 (PST) 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=bB851xJ1+m2w22NkSVyX5FgghjYTjVedZadvQ3/k8dJP89m0iZ94Gq2ID1QQvk3A/0 aCT2LTCpVoUsJe++CXPYTSz9uAa3Xi62tBh3z0JFsuLhsBHmvtAlH8OQjAGn3zyItfa8 pS5CTT1+0EIuy7SCE4x5sMCKkKfoSjxDRCBt+5pQW2mUc0TU+Zev/DLDcsfCXlJiFbUo pab+2Xd7QoEmEFsHHJacMUfpt4tHavfVVI7/KPcRjbdewvX9qAIoPTNu+nr5qL4roDVZ 0y11LLQxWWjxQUuNML0x8TLPgj48qi9iVsaFGUpo18g20126ia0wpG6Fep0iqyrTWlDm /0Rw== 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: APjAAAWt+U6xfCXwWQWZWai4qOPLos0egefY1PCwyJxSG1LPvaE5ELJt dfqagKnuGTJEAj4ujC8Zpd1VU7vFXqQV/esmkvAqLyLtJBqdDvn8xwJYe9RWhAUGjWks2Pn0t1/ /62QGFF+mUqDx5HkeCBTaqxoP/ylLKA4m/y9l6G+lECk8CurbUtw7rnME/6DZG5qTsw== X-Received: by 2002:a17:906:4ad9:: with SMTP id u25mr4446041ejt.176.1551887451885; Wed, 06 Mar 2019 07:50:51 -0800 (PST) X-Google-Smtp-Source: APXvYqwMrt/S98k2uu5Pkn3ONiffGcOLV5uNWTtC580591jiYl2ufV9sa0boHE6SS1jSdy2uarer X-Received: by 2002:a17:906:4ad9:: with SMTP id u25mr4445968ejt.176.1551887450577; Wed, 06 Mar 2019 07:50:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887450; cv=none; d=google.com; s=arc-20160816; b=xu/5GkBeEacBk9l6fSwt4s6vWTDUa58PRW0KslCic6m2Q6WQFJQA1SKJVk/GTcAUuk Jrw6G4bAaKBHUQvvLPd+kmN6aTCLhPtd5aH7S4GKFLziNc2AsuJbOV/OKjuxr15qMonC M0zJMdPWmFvUynqNqWzMnEjWIeEV2AT7FnA7QPNsuY5uhwFIeDmbz36Kte7HV366dKR1 eOxvZHI27ZVGMN0EOMzStVDsix5CUAlBQEvnLhs4MEkGaIqQ81yQDi42gzZLbGtD78sX dI8csGB+Tasb2/BrdljHTEDoFPNNbvqO3uRwviwr96TEQofPh/Pm3FCdsBgh7yjmemYV AdCg== 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=jhaG1+7nNm5hJyc+6aad36+bVWUzfkBJGkiUhSt1N+abN9MCvECY1DxShmjOJcsC6l oD0rHz/iB5SiN7Vhqr5tR44/1dinQ1HiVtUjQiy3ziW34qL/YQPO9fOnZBT9kK7stNG2 kzU6p/TXUt8K2tgyuAI+tJaQ68S1aj9i59FISyh7+cFwrAoppCYQi6d95svswjvlBf7E ljJvZGONGaJLWoK3+F1YBTV97qoIebhF4Sp0iqxDt/979lNAlaVFFegUSeAEoIuqFXL8 nbBIKOPafkJpbPj7TWZUtyfqeeFR1F8uTotEjlMT2D/Vd0f1aUR26MIQHI+hdp/VKgzS gOZg== 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 p21si184204eda.281.2019.03.06.07.50.50 for ; Wed, 06 Mar 2019 07:50:50 -0800 (PST) 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 8FBC91596; Wed, 6 Mar 2019 07:50:49 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E1EB3F703; Wed, 6 Mar 2019 07:50:45 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" , Vineet Gupta , linux-snps-arc@lists.infradead.org Subject: [PATCH v4 01/19] arc: mm: Add p?d_large() definitions Date: Wed, 6 Mar 2019 15:50:13 +0000 Message-Id: <20190306155031.4291-2-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 Mar 6 15:50: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: 10841331 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 A810E1515 for ; Wed, 6 Mar 2019 15:50:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90CE92E733 for ; Wed, 6 Mar 2019 15:50:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CE0B2E73C; Wed, 6 Mar 2019 15:50:58 +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 0BF512E73D for ; Wed, 6 Mar 2019 15:50:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB3358E0006; Wed, 6 Mar 2019 10:50:56 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A3BFF8E0002; Wed, 6 Mar 2019 10:50:56 -0500 (EST) 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 92AF48E0006; Wed, 6 Mar 2019 10:50:56 -0500 (EST) 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 3AE1C8E0002 for ; Wed, 6 Mar 2019 10:50:56 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id f2so6456184edm.18 for ; Wed, 06 Mar 2019 07:50:56 -0800 (PST) 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=BRz1fLaVHJrWps04LeU/9kcyNHUo1yfdaodtNUtdXHA=; b=qF5Rl+9HdODZowxwei5NAUla67PNplkDMtrQOyH+7dbBDsEo6FzHkAmX3dri510s9Q tkkIOhMp9vE6tOY0pk3+0jOa+FM1pKFD7pWlrR4hqS6ZIrpq/eD95dt9muoJbqbSO0pG WxkYYwedAKWE5BxFuIh4XA+/YpeQXkAiTxTuPvgTMYb75jNL0tbH9lEnNpD/9br09Rl7 oj9eTV5yJZ8W72X/qAE+pqEuAIM+NEM5MtXhIqY3H0gbNKTckmfTrUevuKW/YPuseSOF 2qcOe/7yTdr0spnZlz6OgOMOHwANMYi3BCVfWpsh2MaBAcVfWMitLk8z676SJeVMKUny qJtA== 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: APjAAAV75hvVoKjJKbsnLnfJJW+eugRl/mqFcvWAofolTFaB/WyCiC3i i9LQp3f4uyzAtYzhQMteVV4BZZtVfGxUX60M/d6x4qL7ZdRrvWzhtNR88EpR7kQNFFC/HxU7alf WBLkchww9+bo8Yxn7acyCVYyWvlj5DcUHiM5osWUS+ovUos0zy3Cc4s87vokmgzHwuw== X-Received: by 2002:a17:906:1b10:: with SMTP id o16mr4349027ejg.184.1551887455470; Wed, 06 Mar 2019 07:50:55 -0800 (PST) X-Google-Smtp-Source: APXvYqw5PY5iX0vBxzenuxfEpGSQe8p7MrWdyvJB90iIWkK0Bn2UKdm0N99XkVwfqaCyb6jzyNUP X-Received: by 2002:a17:906:1b10:: with SMTP id o16mr4348955ejg.184.1551887454115; Wed, 06 Mar 2019 07:50:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887454; cv=none; d=google.com; s=arc-20160816; b=FTno8MxPKMP1dVa8ZboXg2f3MkFbG9gcw6YuNr43lnbFSOcT9DDYhTvaH84vKrMqvG R1OQPp/q7cNL3eEByyWw3NU5NDSaurharA99hiMlq5khtmjWQK82tTfud0WFIOCanJZb F3PpPKsL9s/3QiPt7Jo8ARhAWSD+1WGgs0rWO5eUtUCOCSKoasagFdb4X91my8QmJciZ 5Q2n7x3f7yJRbpwH3+2CirmRQJOOm7TP+bFl7KnObgvu7eBSAauehHgiI03QPKvx9zB8 wUoMEDDrWrZTATDkV4DOXnq3BQMN+KguXnPegfDweXg4P0fVfiPs5W72XKP6ufA2G3/X PGFA== 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=BRz1fLaVHJrWps04LeU/9kcyNHUo1yfdaodtNUtdXHA=; b=jYzqQ9IZ/PD6FR75YrWDgnqcFvQXt++t1FFih7UH6trSL0TMPSG5pJlgsRe97tH9NC JkbJXTwecf9re2l3+LomsDm8CmSoYMKz+u3ZfSekrB4zpZjdMA2+QKXt12nVfW0KqW1r 9cJAfEc81GxzVREkg1WVviGTvmgJtuG4hrU2O0s5lkSVzGaJXGbKI0o605wp1HIOD9fS 4bvm01oa6RKlNMCywOE6gUaeJzLd5yQJw7K0t8JqBQR4wxyX56TTs9rvGk+wjJdeJzbp jyineMyF8tN+4GQO6MecIbHM1/vuQZA9zlPwNzqWiWH8ah8ykFOCOgEJzEaX7Ua3ovEB XE3Q== 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 jr13si751296ejb.235.2019.03.06.07.50.53 for ; Wed, 06 Mar 2019 07:50:54 -0800 (PST) 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 1612C165C; Wed, 6 Mar 2019 07:50:53 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CF75B3F703; Wed, 6 Mar 2019 07:50:49 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 02/19] arm64: mm: Add p?d_large() definitions Date: Wed, 6 Mar 2019 15:50:14 +0000 Message-Id: <20190306155031.4291-3-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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(). CC: Catalin Marinas CC: Will Deacon Signed-off-by: Steven Price --- arch/arm64/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 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 Mar 6 15:50: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: 10841337 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 ADFF21515 for ; Wed, 6 Mar 2019 15:51:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B4642E66E for ; Wed, 6 Mar 2019 15:51:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96B712E6DF; Wed, 6 Mar 2019 15:51:02 +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 D6A7A2E722 for ; Wed, 6 Mar 2019 15:51:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BA838E0007; Wed, 6 Mar 2019 10:51:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 866BB8E0002; Wed, 6 Mar 2019 10:51:00 -0500 (EST) 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 72FDD8E0007; Wed, 6 Mar 2019 10:51:00 -0500 (EST) 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 1E4CF8E0002 for ; Wed, 6 Mar 2019 10:51:00 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id k32so6452150edc.23 for ; Wed, 06 Mar 2019 07:51:00 -0800 (PST) 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=cPKBnLK8oZvB2lWO7ABGhCwqW0QzKgUdLTrWIxZALpE=; b=BhNwqyf3QDO1vjeMwm9T2Rfxfpjjo2XJjs4fALvGNZ5wTMBjdK5+KETTcXom9KTUlI NBOepAuzMpR2pnRv84n2k/YkyJoaVxSSQ0c03WEUWxBnBxAM6sf/7ZzxU0BzSoF/Paz/ lndRS2aHj0Ab0TWNvFkBe4Y2hEmbG9Me0Wr/PUADSHmZC/gmauefXhNXvML9U/3XZUqO eHxJLNeZIXKFaiZC2e2vtegtOl9C7R5UiaK92LiNd+mizKEJLAXuDsdseefdtRXjp4Ye iDP0LCGX3jFCayt5DVvmBZELW+fTGvLjwvXVxaLnc/h7YKKER0i1CcbMMHzr8R43pfql OLBA== 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: APjAAAU68E9YGjS5qVXgLIWljzmvCDxFy2+fcfsSXw5iToZyKwvNl86r wFmAMUij3LS+HWXOUO9dfspbV8sBlIODcTCrI2TlPFfG8p9GIZT2CmZ/v1oyUnVEham0om0Jpt8 5EBNvn/fg1voveI48d7adsGUbNKNr+SkEhbRxrjlUKIH4wsYO6A6NeZ5evdUZfjXiAA== X-Received: by 2002:a50:ac55:: with SMTP id w21mr24526117edc.121.1551887459492; Wed, 06 Mar 2019 07:50:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwQ5YFSDM3CxFDOEI88nEXldDoWQDNnTon2Ccrl4D+sQQ9r6dtxMmMhdyqYNN3EGHllVIhY X-Received: by 2002:a50:ac55:: with SMTP id w21mr24526030edc.121.1551887458176; Wed, 06 Mar 2019 07:50:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887458; cv=none; d=google.com; s=arc-20160816; b=w1p5KHRlHHFKGsZwkPPLhbGao2A4h3lRYuX/VrQ/PEhwU9pecpvDSQ2F9gQQ4YTTUF qXZAPGvnhUICH0hyniYPGvS4IdOnz4b0LIDlt+pMWwWA9GNZPPQHQF27kbOo9r3hFMa6 6odbNe3OR+Kvcskq4aFcqAacKj4mRpITYKRc/HuSLONDftiEZctKno7WKXVuMDQjmu5g 0pPV95LS43zNbrfhouc3kPT+HGO4s8Vkw3U6QYudLvpSHWVjv4NJJSrQKKyDeaaUOTDV 9uc6Ohrl9JM8oWZT7sTwg4fjAoiTTM7NLjcJ/ZsKWBqANOKjNAvntI06uyjJIYbE+8RU V/sg== 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=cPKBnLK8oZvB2lWO7ABGhCwqW0QzKgUdLTrWIxZALpE=; b=Pv9qSWA+GMjL9PqcI6lltjMIWWqPfVqLXcePu/eN5HKxvLCbAGVRika0dj9HK02imQ YSuDzyn6TaZMNAw854nXYxiD5zuj+inp2RyGad3MfPol+12hTL0dpZ4z6Rf8yWbm0YHN 1GUdWk13jnYbbWik1etVpEFo4SA/Q6rbbxRir7qRcfxr9+yEVbkOsdr7aKGc9kQblt/e q5YvkTvXu0a0t9RHXLXAvIQM5cbPMRFHLfIvw33JEh6pKt4Vr1sYmvD/1/O+e617YcY+ XNVZVLCyyJTrGz1FiXVyHuCcU9ZVBW9djDQKe1rSA72rbBQ7J8bKXn/SCTvhVWTu3jxp ulJQ== 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 n15si742321ejk.117.2019.03.06.07.50.57 for ; Wed, 06 Mar 2019 07:50:58 -0800 (PST) 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 2A69C80D; Wed, 6 Mar 2019 07:50:57 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 567923F703; Wed, 6 Mar 2019 07:50:53 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" , Ralf Baechle , Paul Burton , James Hogan , linux-mips@vger.kernel.org Subject: [PATCH v4 03/19] mips: mm: Add p?d_large() definitions Date: Wed, 6 Mar 2019 15:50:15 +0000 Message-Id: <20190306155031.4291-4-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 Mar 6 15:50: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: 10841341 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 693561803 for ; Wed, 6 Mar 2019 15:51:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5504F2E389 for ; Wed, 6 Mar 2019 15:51:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52F3E2E6F7; Wed, 6 Mar 2019 15:51:09 +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 166EF2E721 for ; Wed, 6 Mar 2019 15:51:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 078A28E0003; Wed, 6 Mar 2019 10:51:06 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 02A2A8E0002; Wed, 6 Mar 2019 10:51:05 -0500 (EST) 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 E5C718E0003; Wed, 6 Mar 2019 10:51:05 -0500 (EST) 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 8D2C08E0002 for ; Wed, 6 Mar 2019 10:51:05 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id o27so6570482edc.14 for ; Wed, 06 Mar 2019 07:51:05 -0800 (PST) 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=jPV2QhL324pMmsFwCL76K/pZK2wary4s770HvasTlro=; b=mfDwCyUMCrsuCdYTdNocQben+q7tftNtEBTVZhSANUXZ1MCXi7JF8JabKWL1gZlnbF 014G1DPB9TZplXw2b2Mir3a/xAeTP8RddX8KIvcAD2JwXaiVPAXnn6vZMr7SbgBZwKEB WtcYNpENcWicPwHC7Y47cn9hGdCSBPwZ2aWjFgPY3HSK2tjx/Upxj5cCMt5FOpCRq0Sj 0AAn15W52g8sQ6gG5V7YY48i8IopROoETKGLj4T+g+MXBnt/TRoqPtAuESoH5sOTYuor Fy/2woi+h6iejTgaiIELCIKjk4qVEcDfs3EiIjJWKG5LJH/5F5iw9crPXEj+oFCcIey4 Ifng== 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: APjAAAVftBzyVnalaDsx+jYkX75CiGa1KuIebEpCbg8f912eBY9xkKYe PlGDyWAL7lrEzt9cs+GMTt2V5wdIYGDPnSju7V8yQzDrmK2CcrFf/KfW3mFpLk1pmedzKr4Nt1X KYb0N8C2te2Ny687elFp88hH1zahCk0nFUIyaEBFkjWh+LxF9jNWkkwFvpf4/oOqefg== X-Received: by 2002:a17:906:2a86:: with SMTP id l6mr4382305eje.186.1551887464774; Wed, 06 Mar 2019 07:51:04 -0800 (PST) X-Google-Smtp-Source: APXvYqzxjZtfTOgvqq3sHmHmVujHMmuHbz2Biv5ylg4TPD1+Y1E1v9lqZypqUoriNZhWe6Ox9Ogg X-Received: by 2002:a17:906:2a86:: with SMTP id l6mr4382187eje.186.1551887462551; Wed, 06 Mar 2019 07:51:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887462; cv=none; d=google.com; s=arc-20160816; b=t5CxRLpYcydFCEreh5S1UWQt7oyu5khsX7pKo1szqxVJzeAIOSSwash/qDxEDJsp40 aOxIG+NI7QUAA7qptLq7M28HORszU/sGj6Mef6MNpya94fKOTwE3Juy6ymf6NNtZPBjL uNmcUi0kNmlv2DgybTyPgXLaLc9bO1Pl55E7IpfPTr+BbiHqKM6/qT82jY2ym9Jmsw71 geRMicgcizemUq+1favWloKOnvNPr9mSrFUf4G9pvWkF/K5mYA/fuzxXzP+bjikT8fBM WcBYUaFfWWt7vAcYm702t6Wp96P1YWwWn5sJ56T8NYx0O/zYZKT+a5tw2q1n3zwNfRbA IAiA== 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=jPV2QhL324pMmsFwCL76K/pZK2wary4s770HvasTlro=; b=YalLPn4+qzKZK4a9JkwRu98kiaDmsePBGUBoSPC/dIotjxvfaHvmMh6NYuc4mQmmub s6ODHbxEgvuC4718y7H3FJNWqHddV/4EBLw5aBKJODd/XONMA28zF+VzrTwxjZdagNqo pbnG/iE0rwsaYERpz276bEnOzyUpg+kZ/X4/bO5W/I2WHKoOl/56bNbMJ5MT5GhE3jT+ RjKgXtZhgUPFm/LW8RCXmEiyRR2fk+FOwoEYoeE5yIoN2Vdi1uWkA/Ixya1zGVnUhFT5 nqOK55Neoysj4QTaDKEnfMMioZdwGThQdQ7xvq/FZK48N75n28VBoxBMkzrcPPTGNM0Y aLNg== 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 r15si749714edd.284.2019.03.06.07.51.02 for ; Wed, 06 Mar 2019 07:51:02 -0800 (PST) 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 6361C1596; Wed, 6 Mar 2019 07:51:01 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6AC853F703; Wed, 6 Mar 2019 07:50:57 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org Subject: [PATCH v4 04/19] powerpc: mm: Add p?d_large() definitions Date: Wed, 6 Mar 2019 15:50:16 +0000 Message-Id: <20190306155031.4291-5-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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. Also since we now have a pmd_large always implemented we can drop the pmd_is_leaf() function. 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 ++++++++++++++------ arch/powerpc/kvm/book3s_64_mmu_radix.c | 12 ++------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index c9bfe526ca9d..c4b29caf2a3b 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -907,6 +907,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) @@ -954,6 +960,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)); @@ -1107,6 +1119,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); @@ -1133,15 +1154,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); diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c index 1b821c6efdef..040db20ac2ab 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); @@ -455,7 +449,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 { @@ -588,7 +582,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 */ @@ -657,7 +651,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 Mar 6 15:50: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: 10841343 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 2AD1117E0 for ; Wed, 6 Mar 2019 15:51:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 146312E6EA for ; Wed, 6 Mar 2019 15:51:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 122EA2E721; Wed, 6 Mar 2019 15:51:11 +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 88DED2E704 for ; Wed, 6 Mar 2019 15:51:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9534F8E0008; Wed, 6 Mar 2019 10:51:08 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 904538E0002; Wed, 6 Mar 2019 10:51:08 -0500 (EST) 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 759328E0008; Wed, 6 Mar 2019 10:51:08 -0500 (EST) 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 1EDA28E0002 for ; Wed, 6 Mar 2019 10:51:08 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id y26so6584827edb.4 for ; Wed, 06 Mar 2019 07:51:08 -0800 (PST) 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=HeBpJ/5/E/W6YLustewMuJne+7VmLrz2+1cQ19OBNYE=; b=VX9hU4A+L6Vl+FXMLILiQjO9v6UwuTpOerKVPPJx1EXiN0E3p6i3P63EwDV0/ds/Rw dlV2yTZ/TM9xl0hSiiUccFMk5jrFYSpuPqXnpiKLfY2d/UKNEi1RnnEbFge4Rd0yL4o5 HzTrMNTEAduBR8NKlhqaH4VNUIZQkssGfun85YooH+A6ghll4IzGeckMW1SZ6U4kAqsX KbMpSVPSQNFrJdTrEfsMnYZ+GrGtAgrnyqygAici+m95fnXJCIKNn6alN6Zf9/OHFtTs 9gNUVXws09OyEiNvhcjKq9WDdFN79UaNrOscy+9NBruY4oVOnCzPPgksqzr14hTrWiry OsEw== 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: APjAAAW8sSXLKwPQj70R1RK7xID6Eoqw7lzS/jrSuUnLw9KJZ2UW1nrY Adp4hosOcdAgtbdIhtqch0xOWiU9fKYZNoT3uyd2IQqib9nNhPTZML+CBNyyVDpXrfCtaHX6iUc QBQGZudMzmdKo6KsxqiJ+SzweOjXJ/M6FpcsYH8WvuW5bpZsZfaiQq5l+IN8EbgyQig== X-Received: by 2002:a50:ad45:: with SMTP id z5mr24093513edc.61.1551887467368; Wed, 06 Mar 2019 07:51:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwpU9x0p3uNcKzogjkzmfoQY7kxandjDFwLL4o0n2clcis/N47EXoxDwX+Wcroeh/NJed4H X-Received: by 2002:a50:ad45:: with SMTP id z5mr24093440edc.61.1551887466311; Wed, 06 Mar 2019 07:51:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887466; cv=none; d=google.com; s=arc-20160816; b=JcBp5QQZ3GZsJeGwgLiqz55HJ6i3whybBXtMkFLuN+1Co0gCPyWKtH3UYXf2tFduzb yh6UGrIFl3ELBghij4QMQfIAe4e5+e0yVURSU9Xb5qSZR8fFZha6qhtCGy5voEHcsHT9 rLcFe/U+DvGQNZ/o2XMuUXWGPqsKwS2/avDijjuBYcxrEa4psGc0UBgK+MdCkNTrzzzi EW+vcc94qzquW8NAAfNBRfFtUs+k+PK/cxZOiqZvdGHR2FndBEycj40ooYteFsnRe/Y+ SczUfJRUQJRyf1vkDXtyLOrbob4hairpJkvpl9SqUHkSxw/2vV8k3h3+8vmN6JwsOYXk 77OQ== 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=HeBpJ/5/E/W6YLustewMuJne+7VmLrz2+1cQ19OBNYE=; b=0ukJlzUs0MvOrIUcykW2f+v689NY1RMUEhTjlIoD5RxtJr+gEPj0eucZOjuB+x3JI1 0sdPSdLEfsxK+tKo6U77RYWqDpiRKDzf2JL89B538fYqSomJ3O68tpRyI/U/BOJM91NW kKamtkB9mEcX7XuDNI8ewdJ5A9vfgCDg4s1LH2+JMW5T2htpO//uiK1ELkGh3F/YKY2B 8CohJc/KTbYSRWTIWASI8gT+k/TusYZX42uYYxyTpNnEg0mVRwVgfdEFWkOBT9TLkyFI wqj0ZDLYUx0v715KgX6xUMlWIauzpRaruVxUCU/htGyS/xOwUAsoqkUnwMi2prltDcy0 kaZw== 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 i22si752281edv.214.2019.03.06.07.51.06 for ; Wed, 06 Mar 2019 07:51:06 -0800 (PST) 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 54ABF165C; Wed, 6 Mar 2019 07:51:05 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A34033F703; Wed, 6 Mar 2019 07:51:01 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org Subject: [PATCH v4 05/19] riscv: mm: Add p?d_large() definitions Date: Wed, 6 Mar 2019 15:50:17 +0000 Message-Id: <20190306155031.4291-6-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 --- 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 16301966d65b..c66e2a69215f 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 Mar 6 15:50: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: 10841351 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 38D421515 for ; Wed, 6 Mar 2019 15:51:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 233F52E6E3 for ; Wed, 6 Mar 2019 15:51:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 214B32E732; Wed, 6 Mar 2019 15:51:18 +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 A6AFE2E73A for ; Wed, 6 Mar 2019 15:51:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B75C38E0009; Wed, 6 Mar 2019 10:51:12 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B4DBF8E0002; Wed, 6 Mar 2019 10:51:12 -0500 (EST) 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 A1B4B8E000B; Wed, 6 Mar 2019 10:51:12 -0500 (EST) 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 39F698E0002 for ; Wed, 6 Mar 2019 10:51:12 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id f2so6456789edm.18 for ; Wed, 06 Mar 2019 07:51:12 -0800 (PST) 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=FbmI8H/LDLwwCfkSNCFyqL30B69VDCB+cT3TXJ207I8=; b=GXbTa+mmmNXYgx5uWqFJp1I7/QxjSXeF5ray8lLSHSoZWWKKUsMpUBI6UyxpPuOGTF DVGLx2ka13H1RB9yr+i5PpDjVOKedQfQdwsD4xLOnppmcebPzzixFwTasjRRkz4/MwLC linpcvwyxqiVdPSDYrUzb9Kde/jEJ2B7E5zQwNklnTUeNVp2Vi9TA+6MSavsHvvUPuU3 QpCaXzxpvMnyi/vzio3n7D2nTGyNIt8BGTH1f07l62EhP7BUUenjTl8dHWBerNRnzIv7 BFAAcHL23kOzKMeL6wO0ehasm0r59VpaD3ICRzuEO2qKqXTQRn4rNsMtgUWghRbw8V1W RRlg== 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: APjAAAUewThDso6FNnSrRbm8qoEkifjjxCK+IcN9+MkV7zU1vk9kB5LI dE+FAPPsW1UgCfnzZUEiZGeLEIKHKwOIVhOBWE0fmov3ux2ZOxph+XIwBJ9bAFLvrxhY1Mh/tFl bx1tpFI/FIMfSKvNOuFUhmP6mPX+pBQ1ijhn09FVl8uvdhWKJP5tmekji5/a7qLkFQA== X-Received: by 2002:aa7:db14:: with SMTP id t20mr23906858eds.231.1551887471484; Wed, 06 Mar 2019 07:51:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyiLtwa3olOJ27DEGKDs6T7LVT6+cB+sjWA7jwyhywQw1Pdpd1V11kTxju87e++LNTBbZ5w X-Received: by 2002:aa7:db14:: with SMTP id t20mr23906777eds.231.1551887470269; Wed, 06 Mar 2019 07:51:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887470; cv=none; d=google.com; s=arc-20160816; b=kxH83nkLKX4XrwqQSijdpyJ33ILWLdzm5RxLgCG6ih9D20NlFpHXpbkOOr5BnHsZxB 5nwQZTxDAarsrnEFDWFwWR0dAFL0RTTikkKO+NMdHk/yd6XO8bTM/kYCYJaYWqEX2/ho ozHyXgq57vq4yVDCJkAjxFeTxWJCq/Ecr0jZuSTiAT7A8zwyt2sYz3QDnb5nqgGbZKME ojWfw6iEBmN32+RdW+Dm+72nWmzEI2ZKCd5wD9jfdENglEEHuceuulfIqVDj8Bb1/5qV 2vvHCM4Q/WZvdcrtzhQZz1X33ztNPLCk82tmkm5JUF7m+Np29jwoUnnl7aeNc9DURUKE DiSg== 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=FbmI8H/LDLwwCfkSNCFyqL30B69VDCB+cT3TXJ207I8=; b=E7OG9sAPcnCOOPAubxLzZh7m6jAKPTtIzqAZu6/04CRrMrLJOVkZxJnWUXFIeHkR4w PXWWmjOisRz2dIZaRw9soim4enedheSLcsfA2XVwxeRe07PXCg3d/q6xBnzqTUmf9IeS i7LLx5BtY4fF/ppZy0O/L84K84RINPq1oKea+SXRojaEG/PuxBJDpgczgIACBFhaCG3J TqdKeyf0/VJsCuqm/4X3cYl76m0Hc2aAxVpqKIeEgKRXnAlk32+boSSRIunKrNAhMGIL C1x5qoB0BF/q28QgwVsbXErqX1CKPSXi8BRqtraPWltpmUK5dy4YX0tG+4G53xKgq4Rv mvww== 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 22si767445edu.228.2019.03.06.07.51.09 for ; Wed, 06 Mar 2019 07:51:10 -0800 (PST) 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 4631D80D; Wed, 6 Mar 2019 07:51:09 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 94F673F703; Wed, 6 Mar 2019 07:51:05 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" , Martin Schwidefsky , Heiko Carstens , linux-s390@vger.kernel.org Subject: [PATCH v4 06/19] s390: mm: Add p?d_large() definitions Date: Wed, 6 Mar 2019 15:50:18 +0000 Message-Id: <20190306155031.4291-7-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 063732414dfb..1f188004ba95 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 Mar 6 15:50: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: 10841357 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 8165F17E0 for ; Wed, 6 Mar 2019 15:51:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BBAB2E756 for ; Wed, 6 Mar 2019 15:51:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 698E12E71D; Wed, 6 Mar 2019 15:51:25 +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 C8D682E605 for ; Wed, 6 Mar 2019 15:51:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 70F8D8E000C; Wed, 6 Mar 2019 10:51:16 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 693708E0002; Wed, 6 Mar 2019 10:51:16 -0500 (EST) 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 537B08E000C; Wed, 6 Mar 2019 10:51:16 -0500 (EST) 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 F09268E0002 for ; Wed, 6 Mar 2019 10:51:15 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id j5so6551319edt.17 for ; Wed, 06 Mar 2019 07:51:15 -0800 (PST) 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=5THteukl9LjchCZjOSfwp3HvyVvejyfMSn/dfz+5mKg=; b=MMb2CJITT9gBkeqmhu+MiCChrskTDMLgUFh0NEX43NETCKemgpl3mPybT+H710OBPT F031bziGkvLdg3n6tbpIsUQL7PWa6eGHS57pCh6XDHVQwll7TmKlQf6VsbVMthd3i4Q2 WbviynohICAAy6oJdDSAuqy4c3aK2c5qkk2Pr97paWjFtquhVVXhFH5TdgrO1TTmhBRS uKX0zzQuQgnZj7q8csjaUbLhrxQVactEEhGVDZZqXWadnU/t7/vqew+FEO/hSkDHakgt iegSljusoK4dPGFI9HQVrfmKpPuppcm5lTxu5C3fT30467x1K5j1s1RWsnnNoLW2dGYn 7WHg== 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: APjAAAUOEla94tPePDrINVmH7HWIQIPydCNxBC9O/sLhjQGkZskr7Pak kbB1sX4DxaNycXOU2jC7hn6rauSgickSPrTRU45D6bNfKrhn/gQxiXs5v5gvuE9mxKL5iuFt5w7 u2Hs+PJIO/86KpFj6xt38KTXgkMK+jJLEnj5ESGocZWla8ToJce179w/eeBeAqRTxtg== X-Received: by 2002:a50:97b3:: with SMTP id e48mr24500671edb.159.1551887475191; Wed, 06 Mar 2019 07:51:15 -0800 (PST) X-Google-Smtp-Source: APXvYqzEQn+yv1N6YMz3y5Zm3b8437s6OgXCPmuw/TVdzJxh4FIVd5rYtAcbjr4bTG3AKHy857cD X-Received: by 2002:a50:97b3:: with SMTP id e48mr24500587edb.159.1551887473986; Wed, 06 Mar 2019 07:51:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887473; cv=none; d=google.com; s=arc-20160816; b=yF6GsVzWTcfirxYNDvxs5R4j1vtnrzwmYycUmF1T4hAsxHxC4MCaLRbFxk3/4xZfEQ VYXtOQEhL+X2jz1SDaG0d+FPzT1YFYmmPmqsvttIlnSZK18ahI6f21+eUSP/i5D4fW6E /XOATNVayU56oB70UFULXvfDvJ6cgFQDRNGeSw/b6wqrZP8wFJR0F+mFwlDomgmge9eF UAeYDLwA5ztM++w4CtZ8H/yxkqYlGFDtq21CTqGrwiqzD76bvlDKTtjpQpV/LHdQtt/W 7k4b83EP0rO/Ie1jOoW8GZeEpb9J6oywEyzS6oYqh/ohwlX0icWvo+sGDRcFDNU7EzBy YiJg== 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=5THteukl9LjchCZjOSfwp3HvyVvejyfMSn/dfz+5mKg=; b=VzGlNatfSqcLzBrsyPLTS2GW/rAdYRquJYcZld+o8yCL0OIN7dlWuxO5w2rMHz+flu nYwXCB/iDn4oNMvMgg+9g84cceATOy0Rf9o9qTH/4Fp0RjFgsaEoi35pKa3+al2/3x0t d2IbRRymLLBZTNnJ4V7nNfnsvoNlWaHyi8zqlyS9mvZp06BGeEtGd1YvObOMvpZmb09Z LDO7/eImJjM/znn99shfonsXVQUZB6rPz1TgtulAbhHE0e30iroAXiRtwM8UatzxL6mD i0QrmLcupLY/9j8uLIPTMzqLkRxaPVlVy9d4YlEEvKSR8Gkl6DBcIETv/mqJqXX+GtdO djgA== 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 z37si742759edd.282.2019.03.06.07.51.13 for ; Wed, 06 Mar 2019 07:51:13 -0800 (PST) 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 142FE1684; Wed, 6 Mar 2019 07:51:13 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8609E3F703; Wed, 6 Mar 2019 07:51:09 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" , "David S. Miller" , sparclinux@vger.kernel.org Subject: [PATCH v4 07/19] sparc: mm: Add p?d_large() definitions Date: Wed, 6 Mar 2019 15:50:19 +0000 Message-Id: <20190306155031.4291-8-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 Mar 6 15:50: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: 10841363 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 543B717E0 for ; Wed, 6 Mar 2019 15:51:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A8572E73C for ; Wed, 6 Mar 2019 15:51:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 387D12E776; Wed, 6 Mar 2019 15:51:33 +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 A65A42E775 for ; Wed, 6 Mar 2019 15:51:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 164828E000E; Wed, 6 Mar 2019 10:51:20 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 115AF8E0002; Wed, 6 Mar 2019 10:51:20 -0500 (EST) 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 031398E000E; Wed, 6 Mar 2019 10:51:19 -0500 (EST) 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 9992F8E0002 for ; Wed, 6 Mar 2019 10:51:19 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id u12so6583024edo.5 for ; Wed, 06 Mar 2019 07:51:19 -0800 (PST) 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=w/JFdsJDPYSKc00MKHrpcbCJk0SkUKoK6gsDYp4bqCg=; b=fuZt9xFrKM9FEH9Y+Nd1R8LYFGQ2lDye0/UsU0iAS3weVYtnYQMakUzVMd+hE1+M/O dEfHiW2DEusKHyxKm/mrLVHmfzuegrsbSKCVeV1BM3YX4t4dybo/y3LocJTOmYrTnX/V jpPN4UsO1Zi5LYCGzWCPL4VG8xzIeFnevv0Qe+OIRpeMK5WAhl88+BOjd/axav2m25eo UFFYEP+VgEjxZ/aOvyOHgkk+BtVx3ySdKUzqYOPw//+OyI87OJVZV3jOgraFrWqumNHt wqzq+R165gTOqxuWHvLls7msdKGrWicAHxWl15ngoPLWhWMYfhTK/m0vsBMhw9pZY3ao 9M2A== 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: APjAAAW7Yp5GyuBogtnWoa2q5r71wSpAPvCHVAoG0Z8RGq3iDhqfAZt/ 1cxplzrbEAZw4zSjd87TZ7bx7oeqAfoxBol3eL8khQ7BynbVq4tbnEfKj5bTfgrjlgO50XOIbLv Fy7FgegpOeWdamtv72e4cZlGSFmD7fRuKuXYfkGyBzr2rKmQZgBUf/izEJm4WFylMQQ== X-Received: by 2002:a50:9908:: with SMTP id k8mr23141137edb.246.1551887478858; Wed, 06 Mar 2019 07:51:18 -0800 (PST) X-Google-Smtp-Source: APXvYqyQiTVJAIbppigMTvpVTTNriThB9j0hryLjPGc6d/iIT90T4OKPFKgV/W5/6QgjjY9FGqlM X-Received: by 2002:a50:9908:: with SMTP id k8mr23141066edb.246.1551887477718; Wed, 06 Mar 2019 07:51:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887477; cv=none; d=google.com; s=arc-20160816; b=uGGoPPdrRMhlnpe9uLMsXLm3HLPvu8g659w5gGwgjXffyBn4fKiT3W+8nr6D7gMvT0 mW31+9st2e+Qz6qkG9erkNfegQwOg0MExFno1O4S71qb+k21Xb9CJkUMw/DzSLMvwe7w llVEWAdw/XybIkACWqe8nJen7BKw6Yn6I+BvrbZMTByVyNcgnnfsUErUMPIq4XygC05b dqs3J3UI0c32nM5IXhUf8RxSztc/XtXRsJWU/M5afm6+5+Zc7c+Rvvau3bEmNzMXWJ5F YBN/9ogl01EIEfENsQzLp4l6Cm2jD0sg8+ah3JH1ZPei55b68ySi8tX9fHNhYarr6U6D v81g== 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=w/JFdsJDPYSKc00MKHrpcbCJk0SkUKoK6gsDYp4bqCg=; b=uP90hjGzNLI7Vf5k68gi9IRzGJKquj2l9ehnjpoNnznd7u8BvhqA8rTFPel7T3/ktS 8yTlGMkCYy0vBjpq24RI8g1bDyicBfs09YPzCYNNZ+ZHmI2AH3AxREMj1yiZ3c2bUmrI ZAMLooDgQgripwBh926v/0wW7svVQK8rwYe/NfTFrXp6WWfgXK44fYo4VbquO72t1A7Y mwXVSzJ0RqiPDiWMyU8Qo3nifzQKj1iiQWHzQLQlegVH6qV9glS4rwXGuDdrTt4ZofSS jnrmUUQRLVIkqeKluJ5mtAOIDIONYXOkk9ZZ8lRg+x3OvM17wzjtz1YjL7rqJC4AwD+z woDw== 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 x4si802153edm.451.2019.03.06.07.51.17 for ; Wed, 06 Mar 2019 07:51:17 -0800 (PST) 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 8F9B41713; Wed, 6 Mar 2019 07:51:16 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 54A923F703; Wed, 6 Mar 2019 07:51:13 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 08/19] x86: mm: Add p?d_large() definitions Date: Wed, 6 Mar 2019 15:50:20 +0000 Message-Id: <20190306155031.4291-9-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 e3cdc85ce5b6..cf37abc0f58a 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -432,6 +432,7 @@ static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr, #else #define walk_pmd_level(m,s,a,e,p) walk_pte_level(m,s,__pmd(pud_val(a)),e,p) +#undef pud_large #define pud_large(a) pmd_large(__pmd(pud_val(a))) #define pud_none(a) pmd_none(__pmd(pud_val(a))) #endif @@ -469,6 +470,7 @@ static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr, #else #define walk_pud_level(m,s,a,e,p) walk_pmd_level(m,s,__pud(p4d_val(a)),e,p) +#undef p4d_large #define p4d_large(a) pud_large(__pud(p4d_val(a))) #define p4d_none(a) pud_none(__pud(p4d_val(a))) #endif @@ -503,6 +505,7 @@ static void walk_p4d_level(struct seq_file *m, struct pg_state *st, pgd_t addr, } } +#undef pgd_large #define pgd_large(a) (pgtable_l5_enabled() ? pgd_large(a) : p4d_large(__p4d(pgd_val(a)))) #define pgd_none(a) (pgtable_l5_enabled() ? pgd_none(a) : p4d_none(__p4d(pgd_val(a)))) From patchwork Wed Mar 6 15:50: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: 10841365 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 B41061515 for ; Wed, 6 Mar 2019 15:51:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FA082E76D for ; Wed, 6 Mar 2019 15:51:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CE0C2E775; Wed, 6 Mar 2019 15:51:36 +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 298D02E775 for ; Wed, 6 Mar 2019 15:51:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8D098E000F; Wed, 6 Mar 2019 10:51:23 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A3CCF8E0002; Wed, 6 Mar 2019 10:51:23 -0500 (EST) 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 93D278E000F; Wed, 6 Mar 2019 10:51:23 -0500 (EST) 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 3ADA98E0002 for ; Wed, 6 Mar 2019 10:51:23 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id o27so6570854edc.14 for ; Wed, 06 Mar 2019 07:51:23 -0800 (PST) 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=qsXQmPprpxmuBeYVH9lG+Xt4hLaFoJ/AyXxwtZbC41E=; b=gCZ3elKmVHBaOgncHgUg3wRaG9actA6Wxtflx+Zq7ba6YRdq/oMZL+AdfwnldN00T6 ybrw2H3v89+x/TBS534QrBOhFtxmVqaD4RdPsmjNynz+5tJ3+VCXzl6m1m/i+ohSIRYn v0kcB8QRmG7N+NOQOXne9Tfo0adkkImrXYmkHNR141qRtghRnOyKa3JtdOfw8qs65lO1 ngSEhmwDm/PaNz1jBgGQ+yrFndfZvXe+P1i81Jr8z0P+EugZ8Gl4WKtUELV06JJddSVO HKk4NfRsTCeHQSBc0v6yJJESKGqz3kxGLYvuGXhqFTuv4lw3CGgvg8M3aps6nCvNuU52 ta7A== 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: APjAAAXqX03qSUrGVapBMz4l5Byi2j/3GherISSLFkCQE0xvG26F2x7c lzC4eVlynMkkvdtUFVj9XgEGDEnRAnV/3zK5bi2cy0BRdor9b6FIsnXn4yRKcnxllvx0qRc7QpR +YVVlzkfOf+OTnN7UNWSbZp2VWr9Sjtl2LjtkrwMSXcN4FMAQIm+D3N07yP+4K9GM3g== X-Received: by 2002:a17:906:4692:: with SMTP id a18mr4389774ejr.96.1551887482425; Wed, 06 Mar 2019 07:51:22 -0800 (PST) X-Google-Smtp-Source: APXvYqz0nT49JRCWl9XjczbWHdABBwsVlciQN7J+8OidGwkgFvdTlfH6J2lMukaKy2rJ+x3813IJ X-Received: by 2002:a17:906:4692:: with SMTP id a18mr4389695ejr.96.1551887480971; Wed, 06 Mar 2019 07:51:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887480; cv=none; d=google.com; s=arc-20160816; b=y1P1YVE88/FEriFubiRWgMLq/yWxQEv/w6KaSX9Xc16fVRTfcy1FMp78HmdhBahoVE cN1Y6K8oRsGGvQM14IRF7B4ubtFTnLctfUsivt6Xj2VAY0JY1wmMjJgx6Lzl9YwbRpSz bpf61EdDOHO7pkfiHMnZgBE71JAS2sSvhP3WyhvgJo8mCVl2MiZIFbzg4HF2pGkPzQkc jSXRHr8hYjW9c5zSmcw3vmq3ccDqy111yMHIhhZWJzptvg19ioM45ts6o/4ZCYguCkaD H1t3/kSSED1FZcuIrrNy78/v4qBFgueO9l9ut+XmHJ9Xhb4npSRaL41TKGg9Va6acFNH RcwA== 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=qsXQmPprpxmuBeYVH9lG+Xt4hLaFoJ/AyXxwtZbC41E=; b=FwhorZYKGBBdtVTRoiPZO9/DuideTzJNZ8qdWxj+38Xt3RKPPzy0nVnvS38VsXicOD 0sRKSi/AoivMMcUle2H2uvEqfJe6/rzj0fLIif+0xpjJr2+sok+fuxxQdEq82rkAKYlu BcvOZPW8g6Z7Sd+gcxY3mgY69Hh/iwaL3X5Ch7Sslr4p52phtGakOIwGdt89Y2EU2N2Y lU8+aeSoO8k5hVygH5JZ/1Kht307y/6BaskeMXF/jcQOvcWBQ7baK7DyeZaxbCp8HMK/ 4r+ZaZ+ryZ4T0vyAFedJeP6aY00tLIlcM5BJ8mDDMMrFC6VlYEhlPhsWSc8lE4yM++xw hGgQ== 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 m15si781444edm.144.2019.03.06.07.51.20 for ; Wed, 06 Mar 2019 07:51:20 -0800 (PST) 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 15C1B165C; Wed, 6 Mar 2019 07:51:20 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CF1BD3F703; Wed, 6 Mar 2019 07:51:16 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 09/19] mm: Add generic p?d_large() macros Date: Wed, 6 Mar 2019 15:50:21 +0000 Message-Id: <20190306155031.4291-10-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 05e61e6c843f..f0de24100ac6 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 Mar 6 15:50: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: 10841369 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 03F9317E0 for ; Wed, 6 Mar 2019 15:51:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3A032E770 for ; Wed, 6 Mar 2019 15:51:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0BE72E782; Wed, 6 Mar 2019 15:51:43 +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 54C002E784 for ; Wed, 6 Mar 2019 15:51:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5368C8E0011; Wed, 6 Mar 2019 10:51:27 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 50CA38E0002; Wed, 6 Mar 2019 10:51:27 -0500 (EST) 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 3B0238E0011; Wed, 6 Mar 2019 10:51:27 -0500 (EST) 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 D18548E0002 for ; Wed, 6 Mar 2019 10:51:26 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id o9so6554638edh.10 for ; Wed, 06 Mar 2019 07:51:26 -0800 (PST) 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=HrdRugGr2uKHHo/TiR13vk3LQ/wnulW6YNAfJqdWS6g=; b=Wn2QlhgETdDm74tHABXwcp0K811oUlajnhNPMj1/ZeLIY9vDQ9J4s72MhxoCpluC1H e+AEC6SVikkuiYiRvvVwKRiAjDTkC59SLrUEjjpFL0O0CLvRQcU+tfAJnnwirSito0vA mlGVqQmPvw2CJnmqFflL62oTj124BA56jtSGYr3TF7nExVrJlvh3Vq+XST8Qbky5uMN0 /oGA3mZhdkea8m62jJk10RMpmZ84j6MuLYBwMl7WzO//TN8FLsAo2Gzph6c/18YSUrUu XrEVFFXB+PZKaUvm/sgazAsODX883BNeGPY1OymjcoXbfrMfzQj2MU/SnnWwLX8pdnpW WOkA== 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: APjAAAUyT9xBfXv1yIfAZZl02a941m5aeIcI6WdkTl0RVc7ZNZePD+DP hoCvaFNsRbnB0yV3+abTX9vJlw4Xbc7EFdc2F6N5wDngyjr5xtKhXacaRcEEepJUKxrCcqiwk8f s/islXMUsh8Oqpjh7ilsZKFmbmiJaQ6aHva+qqd5+jMHzTvVSZtOtXb69NqtssT/8XQ== X-Received: by 2002:a17:906:3fd1:: with SMTP id k17mr4389844ejj.87.1551887486084; Wed, 06 Mar 2019 07:51:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzsgDepq6DqlPpUVSeGQvbyGlQ30Zk3tRTnu8xDrk//uZrwOO7K0jqnTozc5SBWDuWAouIa X-Received: by 2002:a17:906:3fd1:: with SMTP id k17mr4389768ejj.87.1551887484791; Wed, 06 Mar 2019 07:51:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887484; cv=none; d=google.com; s=arc-20160816; b=bTQRp2ZsT5d8wu0oB7TzuDcIyj7gtBUgpfyJLqsMIsOCrxh5U6kb+xXKNe+H0+MEAw KTZMg9rjhZsJwmJE7YPM8WMjcowRuJI50Vvwd3TLGDgbfcEkk5K1zJyy0sdiKSSOVMPD YMwO34YeKxERr3/8RwyBYZth1b+q8r0DPGbXmcKB8YNhSR2anxwT01FZHrc8OFOs2Yyc 7d1grk+JXOAPjxuTELTl4lIw++VXIntEtCWPzc9IXgFpGN57FxflEZMY6i0VmkElUjNZ NiqWRduAA23Zj125yvGV3VhSiqDzH6i7r+tE2z2rQBR/Yhi3+/TM3eW92Ln3mo6hvF96 X+Ew== 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=HrdRugGr2uKHHo/TiR13vk3LQ/wnulW6YNAfJqdWS6g=; b=zomZ5nLBvawLg0HI/Pmt/VJhCQjm5igD9XkeS+JgA28yjlvjlVkUxZ+o4ythzwYu3e VWQfCTVRZwwxjb9JjtSH/XbKqLOgQJ4PGyZRsAOqnU1Cu5N110gowhOOC9aB7rpEQckr xuqLmFNbyox4FanpQ630yB3Sw7VsxLoXghD9fyAt6a0PMGqwRp4fHijR2kmpGjW0Osv4 C+BObF3g4RxNScneZLUL8GIL4Hs/PwFIrifsvgUDS/SplZR4abWDH/3BWJljxzruL+fJ NgZFCbNWypAOqhcS/fcSO5E4E39wjTM+VrmBg/5+N9Ad4UdZrgvkK5wqrZX8U0tiD0gA tusQ== 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 d19si724078ejk.294.2019.03.06.07.51.24 for ; Wed, 06 Mar 2019 07:51:24 -0800 (PST) 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 90991174E; Wed, 6 Mar 2019 07:51:23 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 559333F703; Wed, 6 Mar 2019 07:51:20 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 10/19] mm: pagewalk: Add p4d_entry() and pgd_entry() Date: Wed, 6 Mar 2019 15:50:22 +0000 Message-Id: <20190306155031.4291-11-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 | 9 ++++++--- mm/pagewalk.c | 27 ++++++++++++++++----------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 80bb6408fe73..1a4b1615d012 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1412,10 +1412,9 @@ void unmap_vmas(struct mmu_gather *tlb, struct vm_area_struct *start_vma, /** * mm_walk - callbacks for walk_page_range + * @pgd_entry: if set, called for each non-empty PGD (top-level) entry + * @p4d_entry: if set, called for each non-empty P4D (1st-level) entry * @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 * this handler is required to be able to handle * pmd_trans_huge() pmds. They may simply choose to @@ -1435,6 +1434,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 Mar 6 15:50: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: 10841375 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 1441817E0 for ; Wed, 6 Mar 2019 15:51:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFE032E793 for ; Wed, 6 Mar 2019 15:51:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDBCC2E783; Wed, 6 Mar 2019 15:51: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 6A8F42E789 for ; Wed, 6 Mar 2019 15:51:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9EAB8E0013; Wed, 6 Mar 2019 10:51:30 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B76E18E0002; Wed, 6 Mar 2019 10:51:30 -0500 (EST) 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 A156A8E0013; Wed, 6 Mar 2019 10:51:30 -0500 (EST) 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 485D98E0002 for ; Wed, 6 Mar 2019 10:51:30 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id m25so6553359edd.6 for ; Wed, 06 Mar 2019 07:51:30 -0800 (PST) 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=RWGP8MQSkVeoeLICm8a+huNeS+QgLG9x4b8zbJ3u22Q0Od5cSZLMyNXtDmD5XJnK2K UstEu7e7ygrqx3G1qX7CWkuJu8pbhSTrx+rYlM/dfv/HsV9gsGM2ObDat5IKFkj26A/y LXH9ggj/uAY0+KGxL/1VV9sPutygGhNRnkjagec0IjPTA4w5EfIUcVl2G/1FZ+Xss4en 5BX5yGNJjn8wBd/ShH9Mjeb+CekGgmkmXZIfnIg6PCf2Ko67NTHoOoTYiFGF9u3scfOJ g7yOXjIJSVe50wlfWY9Qb/SGIYXLgccxQbccZhDh1lTFH3G37MJnsBVI2WobXI8oDCwW uElg== 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: APjAAAVVbyu8b8NzISMaTiwIqw8UnAbsCIgtnl8oHZMS04W9rQGhajbp 6C+sIIsHzFaqOspF04LLzs1G+3wi0/6iRzAR8r1xRg42c4ATaDDr5SambjvQKpMtkjL/I4gYvy4 R3xcDO63bwRO1l3m0rdVd4/5QAUXXsctVnoZTfnhO1zuIi3IxtOTWNK56yK2M3Ky0xw== X-Received: by 2002:a50:8eab:: with SMTP id w40mr24985888edw.172.1551887489515; Wed, 06 Mar 2019 07:51:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwk9yH1bT3T7hC8Tl+StBsl9D2vekfGpdFU6gKha8/VtRTVeSftgJQJWM7hmzXmbPQAm9XC X-Received: by 2002:a50:8eab:: with SMTP id w40mr24985784edw.172.1551887487981; Wed, 06 Mar 2019 07:51:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887487; cv=none; d=google.com; s=arc-20160816; b=JEilWf5TWxO7eo0C3g7xNWZiOdhHMfehKQoM4PGNMmOt3dSfAgK2T1Qw5CEnfCT03T tcGbt/LBl0WqZOwscduGX92OKu+d4VejNzipAjeZ/n0fPh1PMqLiyYevsgl7oQDAkUnm WKAELDkU/8pd1uyUoV/ngVNchQIcfdPKqBZkwrsbaR7tp7QA5qSmzyxIEqU8H4JH+5oN joiGm2NcI23irmpAQrGMMlj/Af0uy7h4IQakH64OO8/1rvMqq/qo2I6zjymMFZ6mrEX7 U6gZWS6zo0J/W3yUGD2RdWQKJAk6uUB7K/5l1P8LyltQPuJoOfBzL7+bZCFhsYckLjdF PJ4w== 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=DFHihknwM89do0+VIBn+dxBxbnUsigVuyvfjYgwl6DRk/c83vUPLlnO7lNT/VG6OMY fiqh59Bfk3C/j90QJHx5p7d4QwC8161avN24X9daUNmBMR8Xg/wVsTT+EYrfHpiFUofj hPkvOGqgrJrnLnCuVgOlp8RtViAowpffML3rxIA4bvMegIDO0tKHZ8ECuR831rM8+rqm zY89B5gGCEUnITOhkl04FLP681WMUfbM11yxl7Yv5lSuY6/2miJtM87ZiQsShAqfXjn5 8a+qxJiRRR2wO+6Xf1yKSVe3lc0WOcQPmVLISXjEkGNWrfgXTwhJ99D+yn1W8xAayWwt J99w== 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 p18si725435ejz.318.2019.03.06.07.51.27 for ; Wed, 06 Mar 2019 07:51:27 -0800 (PST) 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 1760F1993; Wed, 6 Mar 2019 07:51:27 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D017A3F703; Wed, 6 Mar 2019 07:51:23 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 11/19] mm: pagewalk: Allow walking without vma Date: Wed, 6 Mar 2019 15:50:23 +0000 Message-Id: <20190306155031.4291-12-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 Mar 6 15:50: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: 10841381 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 D6B6817E0 for ; Wed, 6 Mar 2019 15:51:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9A732E792 for ; Wed, 6 Mar 2019 15:51:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6EA62E779; Wed, 6 Mar 2019 15:51:58 +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 1F3D62E6F1 for ; Wed, 6 Mar 2019 15:51:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 227F68E0002; Wed, 6 Mar 2019 10:51:34 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1D75C8E0015; Wed, 6 Mar 2019 10:51:34 -0500 (EST) 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 0C7E98E0002; Wed, 6 Mar 2019 10:51:34 -0500 (EST) 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 A27E58E0015 for ; Wed, 6 Mar 2019 10:51:33 -0500 (EST) Received: by mail-ed1-f69.google.com with SMTP id f11so6578197edd.2 for ; Wed, 06 Mar 2019 07:51:33 -0800 (PST) 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=ZLiKvIskeL3Cb4PQg+kE/Z5W0NNrB9xArSrGZLY/bh0=; b=C/2o3JLFH87b4fledh8PXiqRq78r/FHaTDoITKjGO8e7YTCVSPRH9Kj6BX8pfPHNPk rEuHFt0D7VhWvm/7gSLf+GeW2gU1jnpq4GFWJR1aNF8ifUMPDuftLnFHWxoRJxa8hi29 0e/lZPGVkpjodpSnQWdov984lG4kMfjKanfkDa/v1+y2RH7ATXIcpCQMmWpCUFsNfBJ4 kedpw1pcO4V/Nxe08mDo1Ex2uZmubxAPtIcgviR7IS/ZJeepUSr6VQgdet1Dp343C1i/ vww4TRXf3vRU+iinTsiqyFZFm3D4FcfVz0TO32ZaFp4qmomN2y/1dkwSqLxOyXlin5Ra OrKg== 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: APjAAAWBBN09L4R2uaGgYoBNGS0osUM7K8RhB6N6z9jyxQd72QHzOH9w W2CVCZieoLLJR7mTc76yRlCVJ5hqnih2gUfrcQhOtWdKYuYGEJyXCBN8Xm/j6raCO1JdvRC3zyh KkrRXpTnwykacmhK4p8c+m9Jlu9PGzzW8mWQhgpe352NQPfcTLOWvGVrx2bZMCr+dxw== X-Received: by 2002:a50:ac58:: with SMTP id w24mr23492446edc.287.1551887492882; Wed, 06 Mar 2019 07:51:32 -0800 (PST) X-Google-Smtp-Source: APXvYqw5SjIb9/xQiskG6frMkd72eJUi+kTYqevabfa2aF086ahp6QHI9lkSkjbMPzrIQCr37KBh X-Received: by 2002:a50:ac58:: with SMTP id w24mr23492378edc.287.1551887491740; Wed, 06 Mar 2019 07:51:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887491; cv=none; d=google.com; s=arc-20160816; b=AkqG8CA2FS2hwz8V6zl0X7MBNdxxytLtz7m3xVYzGFBXgVbHUyb2STqTOSYNWljJVy 2nmveIK5Sx5DzmtQiAQW8B/AyF/89PnwYDJXXCkiEihnt5Eoi/Ki5vnfx6h8boGY1V+N 0nv8dGG+I7mjQugmphqWzE8M0srgkO/6+ujBu2NDpNvfvtb7y7zLhNVbh6CWAPOlzKst DA3N/39F91kerhLyzEFyS5unyQaISlaGmwp4q6JgDOsqfnHonCqysKoC3vjNJjv1isFY Z3VJSOPOgymm5ymNgfCJHd3cVaUKKema2j5Me9X9EbH7BXYi1JehT0PjI3WWeR8oDuZk ILJA== 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=ZLiKvIskeL3Cb4PQg+kE/Z5W0NNrB9xArSrGZLY/bh0=; b=qMgdcirqLDzNDpJW9uKJef26sCGUtUDd9KaqX8pSnm/vIQ1fo/8cvGSPzx8p+xdfqy tKXZrsuwO8gDey5wNh+11KhPMY6c7oiaCElCvgj32lWLLzIKJ2yx7aJaM+uZdluYF1pg TXH+Mvrjh51L0Um2GtMxNEnDNGbEyJX2DQ4xfMaBKFTb9FQO8+ErSNJtXUa4OlPPvWar 1VixiF33geOaGfevv9MFuXlieCopGdpR60fqZDYF/W/EFAarYU7IxXPelXkraPeaIpaI PhvqPM9pj3eCq5AyH76QXa0OhL6apiHYr9+KE/hvjkRwEPA9iOpDkwGcn2hoBcJvFPDX zk4w== 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 34si751077edu.306.2019.03.06.07.51.31 for ; Wed, 06 Mar 2019 07:51:31 -0800 (PST) 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 91B1E1596; Wed, 6 Mar 2019 07:51:30 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 572193F738; Wed, 6 Mar 2019 07:51:27 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 12/19] mm: pagewalk: Add test_p?d callbacks Date: Wed, 6 Mar 2019 15:50:24 +0000 Message-Id: <20190306155031.4291-13-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 1a4b1615d012..4755af1779f6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1427,6 +1427,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 @@ -1451,6 +1456,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 Mar 6 15:50: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: 10841387 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 CC4AA17E0 for ; Wed, 6 Mar 2019 15:52:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B35602E78A for ; Wed, 6 Mar 2019 15:52:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B149A2E790; Wed, 6 Mar 2019 15:52:04 +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 227DF2E7A7 for ; Wed, 6 Mar 2019 15:52:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50D3E8E0018; Wed, 6 Mar 2019 10:51:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4BF638E0015; Wed, 6 Mar 2019 10:51:38 -0500 (EST) 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 3D3658E0018; Wed, 6 Mar 2019 10:51:38 -0500 (EST) 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 D7EC98E0015 for ; Wed, 6 Mar 2019 10:51:37 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id k21so6652130eds.19 for ; Wed, 06 Mar 2019 07:51:37 -0800 (PST) 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=3se5x9e60F5pHicDwQ8/uBQi1VomgQ/cYp+w07wEFJ4=; b=uYghR9V7Spxq0D6Ws00vi+rPROuvAAh9yXKBbYephqUpD1ebzksqeHsHzSi4d36OD3 aInEHV+icVTiPuJNK6ez9c+oWFpto2Pt+9wHG5c+C1SGFIOK5bz1EzefqV41hK+DQIVN c/7JgVUUDcZ6Jqi4v8FkJuZB7BA7VvpEG9H2VCBaP0Mn/Mg/lYEX73a9zEfbMBh88MoF +CCNyZXkT6XS+jS78sfymTELAj/0NKnwhVGmY1SHr6yLjfg7eQgiKzrZhOE7lwK01TE9 hnQUb1XgbHsvb24YMs6YKpRX3QERH3xFC0z5kaJq8dPbzdRd1Ghan/QdBhd9K0Yt1V0x wdOg== 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: APjAAAXX1CObRVhZb+pnOAg4cW/28BG8d5b6CC0pYtS/PFQ4ATyfZNJI yKiCA+T6cDWWLCq8RvjY1mVskO1wnfCgkRcPORt8tzA5Ta9mHzlxr/t7pkAemqFyRnQeIEyWj9X 1JKVasKzS6zFrx6JaipWrkSmm9Yq+G00l9auhSeTdKVkTDK3gOU+BeGoUm/lm3hp5Gw== X-Received: by 2002:a17:906:81d7:: with SMTP id e23mr4364750ejx.207.1551887497028; Wed, 06 Mar 2019 07:51:37 -0800 (PST) X-Google-Smtp-Source: APXvYqwchvPIdhOtPdhV1k67LRezjmS0vVURhJz5gIO6/PCPtUqpY2D24gLhIt+X24TuGXN5GHnD X-Received: by 2002:a17:906:81d7:: with SMTP id e23mr4364650ejx.207.1551887495091; Wed, 06 Mar 2019 07:51:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887495; cv=none; d=google.com; s=arc-20160816; b=z5qktZlc7f/Va2k0tq6avG9lgRxut4NqibtnD1eJX2rBDifTfI0PRAc5PynsbJR9Xs xfD0tOAQyNWvdj6sXpkYt2ojf9DpxGTJtEnvt10fI8O6GLfIQBNoLu5bM0BfT/HTZgzY 751zT3RsXbq8jjvy0O2Ht+qUuJHNypcP4eunsL1OzCBgOHypR0RGspH58kMMuu/KRXX1 eI5S3sjtOjd7/9xvDU3/Xfu95XPvWeP3HS1MeFnK+ij+sat+IRgqcZc77HG7I6a97tNa VbK9qse5BrCrkTiXjs8s2zyxJUGON/lmzS8ap/Es9fpsHn6sXneSFDaTc+x2gMP8HeCu t6qg== 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=3se5x9e60F5pHicDwQ8/uBQi1VomgQ/cYp+w07wEFJ4=; b=0HsPkYFhkv6/igTA83mxEQ2jb8+XMr1OVC8rVdOHUrEv3qkw3zO6ItWWNRgWMuU0hq pocDcBmNuBIi2/WP56qqhfK27fd6fXWRY9Ghwu7JLHQ592Xf3gwArXUxBKivjG90Anzj 3ihUX7AOEzdszeXI9Y0w+m3ydTDfos1Th99UgM94ChGjuVvxYooSGXWAWq/t4U7o7MH4 sLRdhMpbv9u8jNv4Spzu+CIB0aGqkrBYIR9XbqhTfS3BcL3lXlEuIxcw9vtshwUp01Kp Ubw8gLU7oYethLvBIh/NmXf4yIKO7PdApBQVOxq9zosPL3+GRydQx1uOV+oW/P6C43+r sYEQ== 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 g26si756333ejd.14.2019.03.06.07.51.34 for ; Wed, 06 Mar 2019 07:51:35 -0800 (PST) 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 18012174E; Wed, 6 Mar 2019 07:51:34 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D0D233F738; Wed, 6 Mar 2019 07:51:30 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 13/19] arm64: mm: Convert mm/dump.c to use walk_page_range() Date: Wed, 6 Mar 2019 15:50:25 +0000 Message-Id: <20190306155031.4291-14-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 99bb8facb5cb..c5e936507565 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 Mar 6 15:50: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: 10841391 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 6EE8B1515 for ; Wed, 6 Mar 2019 15:52:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5804F2E7AA for ; Wed, 6 Mar 2019 15:52:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5575F2E7B5; Wed, 6 Mar 2019 15:52:07 +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 D9F332E7AA for ; Wed, 6 Mar 2019 15:52:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C88578E0019; Wed, 6 Mar 2019 10:51:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C10D38E0015; Wed, 6 Mar 2019 10:51:40 -0500 (EST) 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 A630B8E0019; Wed, 6 Mar 2019 10:51:40 -0500 (EST) 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 4B2C78E0015 for ; Wed, 6 Mar 2019 10:51:40 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id f9so6561277edf.20 for ; Wed, 06 Mar 2019 07:51:40 -0800 (PST) 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=Z2xmHlQRnW0/E7tQW5e32ucEvBkvUl11M26FOjZx8LI=; b=jtGbQenQ12dUjl5hY1agQdmmXdQbGwsi4Kim6J0MQQHNYBBw2AcqpxA08LqBQpC4U6 IIP6yntN1RoE8liqNkH7kEaHd26+XTt74rs1lo53wElXc4EAPapKazrW3aIhlWSqVCZF YVzwFI/8IN2GZd3XqmR0fzTMeSZDFDEI0cZoOQGJ3/C4VqsGynLwcHLLV63USKEbaQ7z iu+SMdqKmkdnCub8wGpkF6Wq6NSq4aS4qkLnbnSaKJRshdgCC/W/sT+ufsV3JzYHp+ig XJpamdcsTWVx+Mt+yqGIEtZuscmXle0Lmr4AKq67VJsXyZ0UmIlUhQI/N0VEW+ELYu5X aPLA== 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: APjAAAXpbp1E4MFf8D37QYjC9olIrz9gD9uJDESZiUgZKuBxcQbRz4tc tshzlw9k9wFkjhzTgm5kjgUQo9lkiutuQqRpxXGynUrn5ClMoDki5sGK9awb/G7KguhlIrtHzIc URK3Q0H+dcWBQ9Ga1UhY7lrmmCz9JlYHrFijTsnT9Q8h1+XEeD/5mIRZq9bcTRHs2sg== X-Received: by 2002:a50:ac6d:: with SMTP id w42mr24572050edc.122.1551887499520; Wed, 06 Mar 2019 07:51:39 -0800 (PST) X-Google-Smtp-Source: APXvYqwVegd6ZMYiH804QwkJn/puu92DDd6E4Xc+6EHK5fH1JM4mliaugeROY/fn4jAFax8I4fJv X-Received: by 2002:a50:ac6d:: with SMTP id w42mr24571977edc.122.1551887498479; Wed, 06 Mar 2019 07:51:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887498; cv=none; d=google.com; s=arc-20160816; b=DwWzjTQCG4CjyiXZ7PQLyewXhbbOknH5qjy3lGNCN9wiywz+6so7C4BZ+8O1VZouwP lNbe4SWKUeaOR6UYZKrueIOvFK7G7SvZRyFYKnv6Mc7J//k3NwGi6kY8jtNFF5rEOiht t5jfZR0aYk8OORSEpu4tP0J2xH+C1LvMMRMAeJtyjzAMVlK848CYSW7PN1bC8EPOlDEw s1CbKNPnDTEe44hVVJjeH5Ahmqfe+kZo+fC1Pxs7KShHTSrXGh2iH46eXrlbx7GFylF0 MiLwcSD6j23rdj3X09fcll8Oo/hFB1thNcuwoFCFXuAOt4Ys/bYXAPPp8dlC4daQr5Wn 4kug== 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=Z2xmHlQRnW0/E7tQW5e32ucEvBkvUl11M26FOjZx8LI=; b=GIObzHUjctFDYBi0iNRFbkUFu8cSFkJBpKPT46f9qBpZVm//flx6sqYJjCcm9nN1mv J91niaDOHPDnsszHM1PsS0Xjsmb6PUC9oAn9Z+bsC1+/O1sFwWMiNTQU4pbx65jyhO1d 2iKSn6z+G3M7zWcPV1p/ZUHcoNTRU4xNAuWZOdWWzQ49yfedUjZv7U9xJ83+sO6OfwQH jmvW5AcKY9h5UtkF6OyugazH0rSOLfROoHJyVaMgNj3vmtYW+LpZm8L040H24b0DD7wx KXk7Ysi2ecxSJozMOBXD+XrFAs7GusSIqhdX0Vm4+Aq11RTh4PtUh5JroImfahc1IylM 5rOQ== 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 24si758826edu.392.2019.03.06.07.51.38 for ; Wed, 06 Mar 2019 07:51:38 -0800 (PST) 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 9261F80D; Wed, 6 Mar 2019 07:51:37 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 573AC3F703; Wed, 6 Mar 2019 07:51:34 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 14/19] x86: mm: Don't display pages which aren't present in debugfs Date: Wed, 6 Mar 2019 15:50:26 +0000 Message-Id: <20190306155031.4291-15-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 cf37abc0f58a..f9eb25dd3766 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 Mar 6 15:50: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: 10841393 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 B380B17E0 for ; Wed, 6 Mar 2019 15:52:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BB702E7AC for ; Wed, 6 Mar 2019 15:52:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 982522E7A6; Wed, 6 Mar 2019 15:52: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 C4F6A2E6E7 for ; Wed, 6 Mar 2019 15:52:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 38AE68E001A; Wed, 6 Mar 2019 10:51:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1FF9E8E0015; Wed, 6 Mar 2019 10:51:45 -0500 (EST) 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 EFABF8E001A; Wed, 6 Mar 2019 10:51:44 -0500 (EST) 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 84A7D8E0015 for ; Wed, 6 Mar 2019 10:51:44 -0500 (EST) Received: by mail-ed1-f69.google.com with SMTP id f2so6457534edm.18 for ; Wed, 06 Mar 2019 07:51:44 -0800 (PST) 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=AkvggREiF8avTQvXMF9m1CKYPzMfajgNOKSO3I/i4V0=; b=O7wKvfPT/FnYXE10rCufPa0a7HTgoO18IcSRRHdSqRGGUXqwu9hMi5mhmNnFjlMxpk nAHqwpCqA2Guiudfay/02/rPC88pOYWZ8neoN1VLOCMbi1sK7wXyijihL2U5aUfZDdGC YgTxWKzjpCx8SshBLg61yi2Z/aw4Z2rN5S2S85uPs3Wd4Mrc0MeXb1Dt3n8PJP6Mc6Ts dxqSKsotb0yhLTULKtyz6wb2wuzn0D7Xwh0QzSKnTVoYYVGPt8LKV2NBwa4KX2GmgDaX 5eBb5G5lNQRoLzcgy7thNyvm2W6yHcA6TtTu9qKqAaL20bwH1+N273KmGi4NHaexRWcA uKew== 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: APjAAAWT7oBCQKpFfoASJOJxSj7O1umOhn34VHvmsS4ldXoqcUv5k8LQ Jy8Jhojst1cPBdMu+sDC90DePA7j3u5zmZA1Mjxu6FbiVCgoT4T5GK7+CzMHv1gVc2p9VJP/QJL Ty14IVp3sXj9UB3177L3mr6o1olKLM0jf8gv6bod4+sMH8p65FQr3jCZRNjJ5/5DAxw== X-Received: by 2002:a05:6402:1817:: with SMTP id g23mr23932839edy.295.1551887503749; Wed, 06 Mar 2019 07:51:43 -0800 (PST) X-Google-Smtp-Source: APXvYqy2cLOeqez8aL4n4ZE43+N87fDI7EktfEAFgR8Yj4ZApSKRycvfGlQItUeA3CEFy/31irWx X-Received: by 2002:a05:6402:1817:: with SMTP id g23mr23932746edy.295.1551887502233; Wed, 06 Mar 2019 07:51:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887502; cv=none; d=google.com; s=arc-20160816; b=WV8TxeBxn85qeztBOcV/XTYVkHokXARX1EFk7dFuCF5+PZVGFJEspeMxYArw3EK1rv kVMDanxYU4isSoPzG+M6VM0uXOg0nLstyH0KMX0/23Is/8MZxIeSZ57ZKJvo+2hLBYva Z4t0AvRg+Y+hmlSUNd6BVqpxd3k0XHO6sPMdtxXIxL9NzLStpVfb3TRJQunpBakuPupy nP785/lWCqF9ZhFhXDBy9JN8ApYxYm/Tp+WC92D065HgymAe6RQz2qJZJtAw1kOW8sNl g2sBJjJppa/zo7BRc02OAgO8uBwIkF6WDZM2ReB+Km8aXMa7oRMhoEbJEVoL8GZ1bpq8 /8Ug== 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=AkvggREiF8avTQvXMF9m1CKYPzMfajgNOKSO3I/i4V0=; b=qIOUVLeI+erwJCeaGK3PqzrM7Vt//vUa31MuHjVonekClIMeG8KdhwsIEgQfRSxAhC Gd8F5zb/YXr/eXyUIO6safhSBfkBDQ2BMDS7UumOw1IOvihFM6TND58UhMejDqAMwkDs jfnKEgeQB+PsBdU8TyuC1yk7c7GwTL703CQcRBzlIfA6ymM+khFWH6ROm17jxK4KTITF 2YWcioix69VvSDdx6fxxv0DMsi+xNe5+fKeZMB/oZQ7GYgG83l3/F72I/znogQwNs+yf 0nnAMZkWrB3vA7QN9H62uaaoze4KUsMAT51esLmJQb9POqj0n8X4UqNtmhzPbr2OGoxt SpGg== 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 cw8si729544ejb.176.2019.03.06.07.51.41 for ; Wed, 06 Mar 2019 07:51:42 -0800 (PST) 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 3C59C1993; Wed, 6 Mar 2019 07:51:41 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D20823F703; Wed, 6 Mar 2019 07:51:37 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 15/19] x86: mm: Point to struct seq_file from struct pg_state Date: Wed, 6 Mar 2019 15:50:27 +0000 Message-Id: <20190306155031.4291-16-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 f9eb25dd3766..b448546277f4 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; @@ -456,13 +456,13 @@ 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); prev_pud = start; start++; @@ -470,21 +470,21 @@ 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) +#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); @@ -494,13 +494,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++; } @@ -538,6 +538,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; @@ -551,13 +552,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++; @@ -565,7 +566,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 Mar 6 15:50:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10841395 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 9DA1817E0 for ; Wed, 6 Mar 2019 15:52:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89D3C2E79E for ; Wed, 6 Mar 2019 15:52:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 874882E4C0; Wed, 6 Mar 2019 15:52: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 019322E72F for ; Wed, 6 Mar 2019 15:52:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 312AB8E001B; Wed, 6 Mar 2019 10:51:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1FF538E0015; Wed, 6 Mar 2019 10:51:48 -0500 (EST) 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 EF7978E001B; Wed, 6 Mar 2019 10:51:47 -0500 (EST) 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 8DEFC8E0015 for ; Wed, 6 Mar 2019 10:51:47 -0500 (EST) Received: by mail-ed1-f69.google.com with SMTP id m25so6553693edd.6 for ; Wed, 06 Mar 2019 07:51:47 -0800 (PST) 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=OBlZRFK1RAUwn4DmMmPrReWAd+klq5PpYKB/ASjab+c=; b=Rxvd0LTshOtTgozNcxbgn4eb9G7GHmxwEVf/AMueTzsyylsOvRAJ9kqUOqGeMrzf39 ragyvmwWV0GpJ9Q8DkahrvhHic6c+myaO2aU1WpLfVGiwSDlqPmSOH4TO9V117rwdTb2 tvn4zKAUC9kj65B8yl+PylCG+7q6pEH+CPLvkqc7yjiyg7jWZQz/dQcKcCCVRY/ZxgYM 0OViCKTzlpGeBZ+REDG//e3yM3yUu9lgIReo6eq7fX8Ooqe4cdpyRJCP5vRdThqtiMWI xatV7IUfhr4ECqi1/T0JTywhKTtr8EvTemu6RrEZwqYQpSoLBR1YY4oAx+WapEJyPJ3Q 8jqw== 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: APjAAAXYC24SMk3jI8L9xRX77hUY1vXjY0XHWLpYxJAHLsuRG7CVDyMo W9uDyowls+ETSA4zlS3XJUaX7HEA34UORCFh19Z6STrosKu3DAWQdwljfs4FvqIYm6lLtaKVCn4 QgSBYq9a+J/MvvURKgmgRaVZOqtk6BRV3nHfx8LHhIOhpnYmew2w0NCcGiGXgcMn9+A== X-Received: by 2002:a50:9094:: with SMTP id c20mr23788835eda.126.1551887506930; Wed, 06 Mar 2019 07:51:46 -0800 (PST) X-Google-Smtp-Source: APXvYqzfceMWs6ipEpW5PLGc+ibivGWeifaXpyR2CibBJZ60fo5c9AIbvNIrRqx7FmnyM3saezeM X-Received: by 2002:a50:9094:: with SMTP id c20mr23788768eda.126.1551887505813; Wed, 06 Mar 2019 07:51:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887505; cv=none; d=google.com; s=arc-20160816; b=lpn65QQQUfhm82o5jyDeMd4EGIwRyxJb//JuRBx+jx5QEpYqnjJ7E2jaW2UpcuQWJb 1jfEiVYyfJRET6m3imnwnKUhJf3a+PYZxpUbU2L8MUbxBRhKxwj1ALUCAjSsBT/96XY+ ee0JhNKnppezvVBX8rv+TsXJJ2B+aByfRfddB44Mu+C1RZaD00wXTI3BEMBtdHvn/M0K jeqXsf0hZxIY95Tqa1txjVHYaKrZLQAas8VSl7I1ixjLq/CsthfEjqkkKR/EXrqLAtkT NeXe2pv0hvMr+MJhrky7qV0fmWxmPXO8hRsAS99+pQhI6lE09DD3tPdepypHDZW0EWxU YWnA== 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=OBlZRFK1RAUwn4DmMmPrReWAd+klq5PpYKB/ASjab+c=; b=JhWhIK3ks2JyH74fQ1xapE8wQnN3qnvqR1kw78AKpQ26tmAxUNbQJbPVQ58JBExOPg sQkBIx7eYVs4bq9OD4aLmNAXltM+C+ya0BCThYnGSFotueixTUXd7FMzUSTwMAoAUBsY Px5T0Z6vE6+dbdjwsr93lmbcvtW8VZxFRqrKtn5fmd+L9gaqfCBKTkSZq7sjspuivEKs LIFeZ0c+H0PWG6fhkfudh7IDVA/T6snDlGcpg7F/K9b8NcmJSDGudBaKAHQusfsPjiyc 5sfKpnAG1CRtnx2/8c9iqEqYrV9wx9w5zK2s3YiCzdcy7elvyfVaU/It8cMiw3HounnB Nkew== 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 b37si761992edb.447.2019.03.06.07.51.45 for ; Wed, 06 Mar 2019 07:51:45 -0800 (PST) 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 B6EE1174E; Wed, 6 Mar 2019 07:51:44 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7BB333F703; Wed, 6 Mar 2019 07:51:41 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 16/19] x86: mm+efi: Convert ptdump_walk_pgd_level() to take a mm_struct Date: Wed, 6 Mar 2019 15:50:28 +0000 Message-Id: <20190306155031.4291-17-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 b448546277f4..f3663c5e8c6a 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -576,9 +576,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 Mar 6 15:50:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10841399 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 312D81515 for ; Wed, 6 Mar 2019 15:52:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 193C92E78B for ; Wed, 6 Mar 2019 15:52:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 163862E7B6; Wed, 6 Mar 2019 15:52:17 +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 4D9F32E7BB for ; Wed, 6 Mar 2019 15:52:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D26078E001C; Wed, 6 Mar 2019 10:51:51 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C11B28E0015; Wed, 6 Mar 2019 10:51:51 -0500 (EST) 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 9C7468E001C; Wed, 6 Mar 2019 10:51:51 -0500 (EST) 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 3FECE8E0015 for ; Wed, 6 Mar 2019 10:51:51 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id o9so6555194edh.10 for ; Wed, 06 Mar 2019 07:51:51 -0800 (PST) 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=kfrPCNXIG3FQ3lVFQr7+l/G0hifye/sreV+W8dKJJ+E=; b=kApVEtIUeecg+9fPv03rDb+9cM5fXd5TEf4HcI5qnAaHcxkAp0XCdZyxLyCKX/DWGt U72zoX7tmJX1WSlScSFUq+QBSbyUTm/pStR4Tm7hAF8eTPimct/MV1kkwxmtBOb26mgS jAWqVEbK9GAvj9i1Cs0yrmQEFpAM6yVyGozr6IfIOFQBcGtalU/FM2vor9VnGuepFoiK 1Qpo/4nvv7AXCESnh0eXP7CirTJdF+F8gtsOsOVqoKW8ymDYTkZX6QkHSpa7oRx+F72F 5EwbXbDXmQDoloaRsQj9hzGEEkaAFP4dueVvWmAkDyLTRjWQdQWAIeRBC/Sg3j27Mf0F 1Fbg== 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+kLrjpr4VfbpTtGzadUUP04yFBiDKDu8FPAj5c2MsyOt2XkVW dxraRt8qoaKemPBn95c7d5fJhDfIYQmqdzqCzCM8Jix/7q0XE2PlgdoK1W3CzuSLm/Ss8GF/E1A dui0R/ZKtdZDA6Qqbs/JUAFwofG2XoUeTLZfmFkpmPQhE1luj53VyMuc+7LnOE1myrg== X-Received: by 2002:a50:aee3:: with SMTP id f32mr23341566edd.108.1551887510516; Wed, 06 Mar 2019 07:51:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxskWx3NeqBu4n8YiNzBu9xJiwQkdbq+VqqLjxHV/4eHyA4FEV1MnqImAMdXn1ukShRtQqY X-Received: by 2002:a50:aee3:: with SMTP id f32mr23341496edd.108.1551887509292; Wed, 06 Mar 2019 07:51:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887509; cv=none; d=google.com; s=arc-20160816; b=cQ47xechF2Mv5CYxscw39VbYGa2pUJ/UFkSZTCTj86v0d71jVKhpfaIjbBaV041pZY qjzFd0dZkB4tl5YZzc+KxGXUjcfSn23JLh0nWwJnriwug+Vqa8F2HwMyGgCV7QH/Y7x1 3ntFfwequNWZ/VonQk9Gs6rf9VxfvLSOoELecTcz1qPNmDWZ1tcwZ2Yv92GDMcOTrt8H GbG78qrpUhDkkUoC9f3J6tc/8FkjadYM4XlqPqJQnwaHfkqFO8Q5XBsAZgovf15828KD B3H4I20GZ6Bf10Dpq0bifSfQy+XHruJ3mRrTAZaP6GJ9tGleHjQ2QSPBwsSol/YmE92Y eztA== 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=kfrPCNXIG3FQ3lVFQr7+l/G0hifye/sreV+W8dKJJ+E=; b=rZcAieS1pmR/W6okVFZDtEIA3W3oq6yxfssRQaEYzt4bN/V84A6KwPPyNcNZKJBfCh XyqyUioqoFiSp0PYPac1VSUEklnA9NCCf5BUZ57Cy20mj2T6J2/XVv4xA3Hnvml5d46f 4qU25z2bW8/2PwjEdy/2x4W7BIAMyPyaExHwIQvdpTuitZYtJ863rnU3D8AfIgzFJuHu tEZgJG0QJQqP+aLpuLOt18vK/U7PQEF8ypfjlScCrsnqDbnoOgEgGi/mbhZVnzzERd1Z fHY4fidKEUVitjt4x84ukbcrnpwedp8QywppKd+xEQcrmxKCvPuNF6PxQNFTUhyWMC8i 9YMw== 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 s14si12741edb.49.2019.03.06.07.51.48 for ; Wed, 06 Mar 2019 07:51:49 -0800 (PST) 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 3E3CE1684; Wed, 6 Mar 2019 07:51:48 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 029223F703; Wed, 6 Mar 2019 07:51:44 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 17/19] x86: mm: Convert ptdump_walk_pgd_level_debugfs() to take an mm_struct Date: Wed, 6 Mar 2019 15:50:29 +0000 Message-Id: <20190306155031.4291-18-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 f3663c5e8c6a..1c1b37c32787 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -527,16 +527,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) @@ -581,8 +577,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); @@ -608,7 +606,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 Mar 6 15:50:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10841401 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 7C84917E0 for ; Wed, 6 Mar 2019 15:52:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E49E2E77F for ; Wed, 6 Mar 2019 15:52:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C5862E794; Wed, 6 Mar 2019 15:52: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 A0E3D2E6E7 for ; Wed, 6 Mar 2019 15:52:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81C568E001D; Wed, 6 Mar 2019 10:51:55 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7AC7A8E0015; Wed, 6 Mar 2019 10:51:55 -0500 (EST) 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 5FBA28E001D; Wed, 6 Mar 2019 10:51:55 -0500 (EST) 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 F19708E0015 for ; Wed, 6 Mar 2019 10:51:54 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id o25so6588660edr.0 for ; Wed, 06 Mar 2019 07:51:54 -0800 (PST) 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=2coDtKUAAHa6O24jio+8J0JOqtELt/lHMje4085swNg=; b=IzAzlDQv1fsfZISEOPN5BmSSrbGgciBq/orvtugc2zCil8kq4yhEyxM1GS6lyGvnN4 RhDTJNiQG5rIxpFbk587eyx6fgVonW+eg/3x52rjeLFRta0/tVQbHQw2kXn2V6hCJxxh wlAEw/IoXAuhFd0TNG2tLhJGqmp/+pqAZJAEFoObM2vL8xTIPb6VIi7ucP8nwwwLfk8k iKM9dQyurkOvHGAbhEVC8WzEipT3OxgbeRHlVeBOpe9zw9oZMz+ad3QZ0g/WPiZQWIyX 3FXX2aybYBKPAWaOFeDQTihDIx8fYG68nfFAoeMmDxxvcDU5U8pGjBh47ww8RtZjLUu6 Zauw== 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: APjAAAUX/ThrZtnn6lUnMtniu6xIrSlCiB1XPsoq1GiAeGurtvL5Q8hw Q/PFBNmiC8v/h3YQkqpz8Mc52FTeOTvWQnZLDQGqOjcCdvSjBVE3AbG69V+Dh4iSofEvNQ7jvWq P5adUJyyCvYNFS207lh+fguAY9duwPN9VOFj6aAn8pLoLL6aYEHwLu9vXkjaWHY/BbQ== X-Received: by 2002:a17:906:6a43:: with SMTP id n3mr4482308ejs.0.1551887514131; Wed, 06 Mar 2019 07:51:54 -0800 (PST) X-Google-Smtp-Source: APXvYqw79tVSbBoa/I4p7RYai83s1QrZQN7TckPizVkMhEWr0fXeg6f1Pyjo+9bhRpHVSS41GgwG X-Received: by 2002:a17:906:6a43:: with SMTP id n3mr4482239ejs.0.1551887512766; Wed, 06 Mar 2019 07:51:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887512; cv=none; d=google.com; s=arc-20160816; b=Ib7ZGaO7pSmM049s4cJcanwtaEsXnwkAfzeJeeR7BouOagm1cZyGjP9Wyoux2Ssk+j b3C8dIePNz4Izr9VkVIoASza9jAxPY7uLlA62RdDxrKZuPEFexxLPcy4MiidH97dWnX7 2lOfmp9cjVKaHPnCuG4jpCSklOwd4Kc3I4WdNqXQT2+jV5DtQerU6NI2YVEFAgIqsHol O6Za91hi1vWQXrpbFg5ik1aytTtiqKqMgENsdvzH4/ho14E2NmW6bYqN0LilR8MUVXQ5 xucgi17J/DNnI/izfDqcbIwLfM2FOsgdD52lr68G8hClckxCnSdr+ZU0aRUWgJkVRnp5 0z2A== 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=2coDtKUAAHa6O24jio+8J0JOqtELt/lHMje4085swNg=; b=p2v36ELZDZVDsGhTfHY22DJQ1cN9fdAyKiVnerlhazKzqUdevQ5le1c1m6Gl5uIKEB NGZrpq/Ieg4MJ4wGIwuakSjN954vZPeCWJzTnqm5JPmljq91bEB6Cu965p9NtLPDsrDH CpyG60/1mp00t1JjE6O3KGXMc1I4mr1exZbZL0IolqpE0q7y9PW38HSzhcQKIYY9l1ha X+dl13AZPeRyniAudni8vDgYHAMXMqUZ+YKs/D6e8mzfztqjX73nJZw+0EaQBLp5QTIB F+WaBQq8A3Qk82IbRhZIOFtCGv7/cgMlXOpxpCuFzULVahVf/ZVXQd0N3CCjnXE/LrbO Q8bg== 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 w10si777608edc.303.2019.03.06.07.51.52 for ; Wed, 06 Mar 2019 07:51:52 -0800 (PST) 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 B8DE91A25; Wed, 6 Mar 2019 07:51:51 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7D6503F703; Wed, 6 Mar 2019 07:51:48 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 18/19] x86: mm: Convert ptdump_walk_pgd_level_core() to take an mm_struct Date: Wed, 6 Mar 2019 15:50:30 +0000 Message-Id: <20190306155031.4291-19-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 1c1b37c32787..b1c04ecc18cc 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 */ @@ -524,10 +520,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 = {}; @@ -574,39 +570,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 Mar 6 15:50:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10841405 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 A7FF11515 for ; Wed, 6 Mar 2019 15:52:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 873CF2E7A8 for ; Wed, 6 Mar 2019 15:52:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84EAB2E7AE; Wed, 6 Mar 2019 15:52:24 +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 81B462E7BB for ; Wed, 6 Mar 2019 15:52:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 424098E001E; Wed, 6 Mar 2019 10:51:59 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3ACF58E0015; Wed, 6 Mar 2019 10:51:59 -0500 (EST) 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 24F8D8E001E; Wed, 6 Mar 2019 10:51:59 -0500 (EST) 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 B27E38E0015 for ; Wed, 6 Mar 2019 10:51:58 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id f2so6457863edm.18 for ; Wed, 06 Mar 2019 07:51:58 -0800 (PST) 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=vb4bmP8Fo2cBijSAZJ9Hj0yAo2JYFPjw5BmoHVJKNV8=; b=ZRYD6gpq9ZqQ9tgFa4N3qxgeybJ294eR3yNkn8Owmtj3zMAUHL+8v0suPXLtV7ObCD yVL3AfxNumAL7t45hfwbtEQo0MaO1wrtRX+e1aH59ienlqLu5aIt2L8PZJu2yyS3+VB6 03OLIRD9vR7WR2cbjYdsQSSgREualC4l0p68ZMFH+3RkDL8KA0zi6V6IMI0dSVVUhkE2 mJKxEKROSnoDd0UskwTmIdQ3jKSOuml8HQKqg2J9xPH+tBNTapoCuqVEpnWI7ThoSfhG D/oppdePUgaQWqlbQGfYufYgvZqwUVL0YlbZojgj9DEChx4pBNNIep5+GexOpenZmZja vEjw== 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: APjAAAVw+SrnJiM29mNmQuLimML+RcFJXouaTwDGw9fOn55em2cG/qEK U+0T/BE8YUlTZ0I+E5tmQ2JyNlLvOduieKqXXeRNpyBqzuDzo30NdBK57h8K+me6waJvLmatPsC iRv1479aKsGq0kwxhbhAF/3LCKUUQP/JuV/EMaWp34xczVDgon4fuGsLmDMjtK1scbA== X-Received: by 2002:a50:ae63:: with SMTP id c90mr23726444edd.285.1551887517904; Wed, 06 Mar 2019 07:51:57 -0800 (PST) X-Google-Smtp-Source: APXvYqz3SVxqM8KbsTV9tWx5Vtdeum38npToFdiahx+XCMbCAH6tiDAXlOrF1Y/Pf2a8lKjwR7Ud X-Received: by 2002:a50:ae63:: with SMTP id c90mr23726364edd.285.1551887516469; Wed, 06 Mar 2019 07:51:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551887516; cv=none; d=google.com; s=arc-20160816; b=JhC/ZWfaC+Ug8/OhZJV97fC3nucEiWLmnGlCSLv0mInJaZT/kUBqKsUeAlD7YVbTfk HbFEpAbffKHfC/zonQokT54eLegtXX+uasd+A8K5KzKu6stWw+O3OTDDtYriIjOPyIwu 93OzMb9vhUbee+uB+JpnDRo5xAki5Qo9DhZWd3ueEkhUW8ehggIkivabyWsgwlZlGvQ+ XyylP+esAKzRdrKvFG6EZBbeSF4CFqog6dYmfsRcgi8UMU2lsVlVtckeqC5l3NR2q4Wf IAxmDiAvOKsrwGTUO/T3eRPdrYyN3nwr7jIKrX46H+qTt+4LX5vXcnhWo+95v9K9CgWL OVjg== 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=vb4bmP8Fo2cBijSAZJ9Hj0yAo2JYFPjw5BmoHVJKNV8=; b=JRLBP+Hj/TMSHlPxQpyS02NYoKVJLR4+YeO9Idzn+vVR95EibOlwD409ruJXMpjEoh s9pAmjyOXip5bfd7o5YNguPgpGeatn9vcmk9em+LKxkyEk9gCGnTNCNw8iupuT5ZAfh8 yJ8GBD7Q2S3bF2vNGU5ahLma6lZ/fARTc16ipxpmzFKJepjl2bjkboJqfmh+ZE1TS9JS 8NZfM6N4QB/q76WekV/gaQMOHcB0TppzVKEnFRrkeuT2+Xl8haucxdy93cf/wQS+3d2h b26QBT+G2LkpNs0l2CqI/zsMafAVDhUzYCkG5ttupNoQZ4XgdTY/7bCB2OhnGBrdClc5 xZ2g== 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 z5si725710ejp.73.2019.03.06.07.51.55 for ; Wed, 06 Mar 2019 07:51:56 -0800 (PST) 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 3FC02165C; Wed, 6 Mar 2019 07:51:55 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 04C0D3F703; Wed, 6 Mar 2019 07:51:51 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?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" Subject: [PATCH v4 19/19] x86: mm: Convert dump_pagetables to use walk_page_range Date: Wed, 6 Mar 2019 15:50:31 +0000 Message-Id: <20190306155031.4291-20-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306155031.4291-1-steven.price@arm.com> References: <20190306155031.4291-1-steven.price@arm.com> MIME-Version: 1.0 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 | 282 ++++++++++++++++++---------------- 1 file changed, 146 insertions(+), 136 deletions(-) diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index b1c04ecc18cc..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,133 +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_t *prev_pud = NULL; - - 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; - prev_pud = start; - 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; @@ -534,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);