From patchwork Tue Apr 26 08:10:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tong Tiangen X-Patchwork-Id: 12826598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 161C9C433F5 for ; Tue, 26 Apr 2022 07:52:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D74C06B0073; Tue, 26 Apr 2022 03:52:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BADD86B007B; Tue, 26 Apr 2022 03:52:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 962F76B0075; Tue, 26 Apr 2022 03:52:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 781696B0074 for ; Tue, 26 Apr 2022 03:52:04 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4D5E060AC9 for ; Tue, 26 Apr 2022 07:52:04 +0000 (UTC) X-FDA: 79398261768.27.C1AEF57 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf15.hostedemail.com (Postfix) with ESMTP id C1F31A0040 for ; Tue, 26 Apr 2022 07:51:58 +0000 (UTC) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KnYxG5z5HzhYs7; Tue, 26 Apr 2022 15:51:46 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 26 Apr 2022 15:51:59 +0800 Received: from localhost.localdomain (10.175.112.125) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 26 Apr 2022 15:51:57 +0800 From: Tong Tiangen To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , "H. Peter Anvin" , Pasha Tatashin , Anshuman Khandual , Andrew Morton , Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou CC: , , , , Tong Tiangen , Kefeng Wang , Guohanjun Subject: [PATCH -next v6 0/6]mm: page_table_check: add support on arm64 and riscv Date: Tue, 26 Apr 2022 08:10:30 +0000 Message-ID: <20220426081036.1374452-1-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Stat-Signature: m55qxwcb919afmksqzcx3mrs7fqpjmyg X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C1F31A0040 Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-HE-Tag: 1650959518-338003 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: Page table check performs extra verifications at the time when new pages become accessible from the userspace by getting their page table entries (PTEs PMDs etc.) added into the table. It is supported on X86[1]. This patchset made some simple changes and make it easier to support new architecture, then we support this feature on ARM64 and RISCV. [1]https://lore.kernel.org/lkml/20211123214814.3756047-1-pasha.tatashin@soleen.com/ v5 -> v6: According to Anshuman's suggestion, optimized partial implementation and commit message: 1. Remove redundant IS_ENABLED() in ptep_clear(). 2. Remove redundant __HAVE_ARCH_PTEP_CLEAR usage in pgtable.h. 3. Remove redundant __ptep_get_and_clear() on arm64 and riscv. v4 -> v5: According to Anshuman's suggestion, using PxD_SIZE instead of PxD_PAGE_SIZE in mm/page_table_check.c and it is checked by Pasha. v3 -> v4: Adapt to next-20220414 v2 -> v3: Modify ptep_clear() in include/linux/pgtable.h, using IS_ENABLED according to the suggestions of Pasha. v1 -> v2: 1. Fix arm64's pte/pmd/pud_user_accessible_page() according to the suggestions of Catalin. 2. Also fix riscv's pte_pmd_pud_user_accessible_page(). Kefeng Wang (2): mm: page_table_check: move pxx_user_accessible_page into x86 arm64/mm: Enable ARCH_SUPPORTS_PAGE_TABLE_CHECK Tong Tiangen (4): mm: page_table_check: using PxD_SIZE instead of PxD_PAGE_SIZE mm: page_table_check: add hooks to public helpers mm: remove __HAVE_ARCH_PTEP_CLEAR in pgtable.h riscv/mm: Enable ARCH_SUPPORTS_PAGE_TABLE_CHECK arch/arm64/Kconfig | 1 + arch/arm64/include/asm/pgtable.h | 59 +++++++++++++++++++++++--- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/pgtable.h | 71 +++++++++++++++++++++++++++++--- arch/x86/include/asm/pgtable.h | 27 +++++++----- include/linux/pgtable.h | 21 ++++++---- mm/page_table_check.c | 25 ++--------- 7 files changed, 155 insertions(+), 50 deletions(-)