Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4696424iob; Sun, 8 May 2022 22:21:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkf/5HwBD/q+L+yLCMxjep1PavMpfqqSFfu+2ixXBg4AVivplxzt7hfMXyZgVUkq/7ET51 X-Received: by 2002:a05:6a00:b56:b0:510:8107:5cf8 with SMTP id p22-20020a056a000b5600b0051081075cf8mr13882026pfo.2.1652073684126; Sun, 08 May 2022 22:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652073684; cv=none; d=google.com; s=arc-20160816; b=tjYXbpyU70vsxaa1K6DQjoUSvwieL7JecASYFp1RlycugpTFf+ltUm9U+inJ/zXYpt fqz/k7YTt7KJu26l5/+8BlBeHA82Zg27X9TTAF2P3jnelIP7vA22W4mZujaBtAvKKnku Unlj8+qVLJf/AfhQmXrKBU5vZmnkIZS9lIQo7l6SC22/vT3JyG4J3g17L9MYm/NKqRAb R7o9raTCeOgwJrKCmnwyWVKqyIbJjlWP8nNex1wz538xHdQQFI27D+1hxPs40aAhf1kA sisAsGx7LBBu9KQ3x0xvmcp1aDUFxPVMNXiqfHG4vJiJ4MgGo1Q34jCPru6ROH3bORAZ vmWQ== 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=RL0fsymuWZ2ZCqvyX6J6eN6eXhWGcNLsMwSIN1Un5k8=; b=qYGWejIMJ4e8g2pgGt0cz3z4aXR78yCgiPD7H/x1VKdzQIJLT4KVhRZK/mEeLmrL1x pPI7SVupk/rDiOnrpWbM8uAEZ+yvUiULlNsmSLCeChaati2Mqj5f7+xucahm+enizJpr tPgkcfG0A1jfqKgBCFzozj1YpabQkHF2ESqHjN8cJyxqYZBTIfnfULP/VslBaT/77jai KRu8tvHTfGjMthJWUDw85VDJVDZvHcmXU3P99B5hlq8zEfDD1SCE6WZznXR+9UbuNJrP AFMKvutU1o+yzpXz2LY9kHUDCe2XZ+5p/UjmX94Eavs22rfQH9boYgZOez4CLO7ORo+Z 1mfg== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v31-20020a63465f000000b0039d94389fe6si13582789pgk.599.2022.05.08.22.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 22:21:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 087D514B640; Sun, 8 May 2022 22:19:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384463AbiEGKqe (ORCPT + 99 others); Sat, 7 May 2022 06:46:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236372AbiEGKq3 (ORCPT ); Sat, 7 May 2022 06:46:29 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F03F53732 for ; Sat, 7 May 2022 03:42:41 -0700 (PDT) Received: from kwepemi100022.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KwPBt5NknzhYxX; Sat, 7 May 2022 18:42:14 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi100022.china.huawei.com (7.221.188.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 7 May 2022 18:42:38 +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; Sat, 7 May 2022 18:42:37 +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 v7 0/6]mm: page_table_check: add support on arm64 and riscv Date: Sat, 7 May 2022 11:01:08 +0000 Message-ID: <20220507110114.4128854-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: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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/ v6 -> v7: According to Anshuman and Catalin's suggestion, optimized code implementation: 1. __set_pte_at() code specification modification. 2. pmdp_huge_get_and_clear() implementation optimization. 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 | 61 ++++++++++++++++++++++++--- 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, 156 insertions(+), 51 deletions(-) -- 2.25.1