Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4706922iob; Sun, 8 May 2022 22:44:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdiwz4HvdEqirBUc0uSiTHggjUkdXeUIoiE9+1C0536cMpdrXDcfAi2TtvM1Q68IqJxUCq X-Received: by 2002:a17:902:ec92:b0:15e:9c61:2acb with SMTP id x18-20020a170902ec9200b0015e9c612acbmr14934694plg.141.1652075069760; Sun, 08 May 2022 22:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652075069; cv=none; d=google.com; s=arc-20160816; b=HWp85G7wzGeahpmyMe1spUAoW4jDCGYCvAV7q7/MFrDMyn8Y/tD5dMRykJiGMzGKfN Q/ZFoHkGzCeqKyRYiqFdKJ6eF+6yuG91wxp3RQWHzDsZNkzxV0sOSXEeesNQCSdBXQVN HrFcZMy0t3KiXr/a/px3A0oHUV/N+ebvkedyzEY7TUefTUXx6boa9JViZkufv8Vzd/yh NMdkQUFZBzZDIlLh7DjUG8+3giff6MeLoredp0oiK5ayUSvZ9Yk+idMlfQT2UptsCenI B2I0Cgnkgz7dQs/6GjdA6I6Z5yUSUgYnUw4Hx7LFqlLNW4GgHVG7LfrFGY35I0+dI4Z3 +EfA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=AqTWEmCAq43Ps5MGFZbg3l43HSGk35ei95VJbCx1xQo=; b=zg6fY+EnUEc0r9Gv2Al3iNOdJBsVrvEakPzDhID4g5+c51WaqJV6/1U2FXMKKcbHMH V4ZKFYL/vJsASUxy1khumWd5ESyXYZhPg9Gn2AkTCRUwXbBFYsSoV7iV2J5HGAW4rIc1 AVuzVxJ42d/EvaSNhyAdUHozfATz6MvFSd7U+T5F6BKvb/RajYpcSO9WUCLDNp9hSt6z V9kcpdfBHjkBUy6IGKa2oIv7aTgs0w4pBcol+J4uHE5vs+om/LnHdUPGIVU9u2RJ9/po maAqN9FmBrygb7VlSb089NbTAQ/nVzEHIuiDSfKzoGnlHJdm4tVXpnqiBTn9wd0GfIaT 4+Bg== 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 p13-20020a056a000b4d00b0051076cfcf29si12756642pfo.153.2022.05.08.22.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 22:44:29 -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 88CDB15EE70; Sun, 8 May 2022 22:43:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384480AbiEGKqh (ORCPT + 99 others); Sat, 7 May 2022 06:46:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384400AbiEGKqa (ORCPT ); Sat, 7 May 2022 06:46:30 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8975F53A70 for ; Sat, 7 May 2022 03:42:43 -0700 (PDT) Received: from kwepemi100025.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KwPBx2j6dzhYxp; Sat, 7 May 2022 18:42:17 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi100025.china.huawei.com (7.221.188.158) 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:41 +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:40 +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 2/6] mm: page_table_check: move pxx_user_accessible_page into x86 Date: Sat, 7 May 2022 11:01:10 +0000 Message-ID: <20220507110114.4128854-3-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507110114.4128854-1-tongtiangen@huawei.com> References: <20220507110114.4128854-1-tongtiangen@huawei.com> 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 From: Kefeng Wang The pxx_user_accessible_page() checks the PTE bit, it's architecture-specific code, move them into x86's pgtable.h. These helpers are being moved out to make the page table check framework platform independent. Signed-off-by: Kefeng Wang Signed-off-by: Tong Tiangen Acked-by: Pasha Tatashin Reviewed-by: Anshuman Khandual --- arch/x86/include/asm/pgtable.h | 17 +++++++++++++++++ mm/page_table_check.c | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 0821f87d495f..46fa65d818bd 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1447,6 +1447,23 @@ static inline bool arch_faults_on_old_pte(void) return false; } +#ifdef CONFIG_PAGE_TABLE_CHECK +static inline bool pte_user_accessible_page(pte_t pte) +{ + return (pte_val(pte) & _PAGE_PRESENT) && (pte_val(pte) & _PAGE_USER); +} + +static inline bool pmd_user_accessible_page(pmd_t pmd) +{ + return pmd_leaf(pmd) && (pmd_val(pmd) & _PAGE_PRESENT) && (pmd_val(pmd) & _PAGE_USER); +} + +static inline bool pud_user_accessible_page(pud_t pud) +{ + return pud_leaf(pud) && (pud_val(pud) & _PAGE_PRESENT) && (pud_val(pud) & _PAGE_USER); +} +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_PGTABLE_H */ diff --git a/mm/page_table_check.c b/mm/page_table_check.c index eb0d0b71cdf6..3692bea2ea2c 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -52,23 +52,6 @@ static struct page_table_check *get_page_table_check(struct page_ext *page_ext) return (void *)(page_ext) + page_table_check_ops.offset; } -static inline bool pte_user_accessible_page(pte_t pte) -{ - return (pte_val(pte) & _PAGE_PRESENT) && (pte_val(pte) & _PAGE_USER); -} - -static inline bool pmd_user_accessible_page(pmd_t pmd) -{ - return pmd_leaf(pmd) && (pmd_val(pmd) & _PAGE_PRESENT) && - (pmd_val(pmd) & _PAGE_USER); -} - -static inline bool pud_user_accessible_page(pud_t pud) -{ - return pud_leaf(pud) && (pud_val(pud) & _PAGE_PRESENT) && - (pud_val(pud) & _PAGE_USER); -} - /* * An enty is removed from the page table, decrement the counters for that page * verify that it is of correct type and counters do not become negative. -- 2.25.1