Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3374243ioa; Tue, 26 Apr 2022 02:14:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyanJWtmlBmKy0r9NqypIdFJsnbSgGlTNkKNCuuWlkUy2KAhcZo4Mzc4Dp/BVT+LGs1mv1s X-Received: by 2002:a17:907:7b9d:b0:6df:fb8f:fe82 with SMTP id ne29-20020a1709077b9d00b006dffb8ffe82mr20229163ejc.652.1650964489599; Tue, 26 Apr 2022 02:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650964489; cv=none; d=google.com; s=arc-20160816; b=0mv8ehTo1S8/7DvIX1iTNYOSRe3OH083nzLdsz6dXHUYljt1gHyfXpUgKrZqFrxi2d 2UY4DLV3ccovnG7zULe43M4cD5zTRjuHgDiSPZoSvfyC2ww6bQgNtVSP02YnoQh1+41g HSfuV+mIJ5VmPR4f+8iosUsQJTbdW2OJzf6koQqxCcwND40HgdgjwjCsBjBnBdwxF/g3 L4fxD85f4IOvdVEkT4CyjWWJZE1vwdbCCJjk/p61cLsjowfhraV4Zn40aCp18mhIbjRJ 4p4eFPvneCuNh+LSkWNaIKsnKfZruYZV8ZmbS6rKdJ4ct550rgq9mI5H7N7CPm+oZU9+ d35w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=zGLWk2EzlkABVNatwHPVz1Vn0vsGEu/44Z7NUerzkHs=; b=UJ9zNnNW8BPv4k19ewjAvlPjYZUj2xgbj21OYRRw989DFcAGqknfopJHJTqvTgswWO UJ8XY4eHqPoBl/cSvfwFnZn3sKPk/dgdu6vSuFJtH9g5RqBQKAlO516mftcv3MbKAMvw NCFks06CYrKGeqrRRm/qV7MczVz92jeXlQG4QHOLPDCnVXGFYvDs6H589+ZSKu1Mrrcj ERCmiVBNnR2RtQUdgir7QaQZ+Q9nkvkkWOtu3xJNBNdxSzId0uMsl5Hzqc4ToWEHBUDY S0jZUtyZrVaYdI1tGwngx6tPcNivfeJKYDVl8hpvsumgLqbrdSoArMienQYAVJKZhmFy XCCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jo26-20020a170906f6da00b006e8c0b19a42si987138ejb.294.2022.04.26.02.14.25; Tue, 26 Apr 2022 02:14:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239599AbiDZHzR (ORCPT + 99 others); Tue, 26 Apr 2022 03:55:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243960AbiDZHzJ (ORCPT ); Tue, 26 Apr 2022 03:55:09 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AB6B6479 for ; Tue, 26 Apr 2022 00:52:01 -0700 (PDT) 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.25.1