Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1208872rwo; Wed, 2 Aug 2023 10:13:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlHACPU7ULYTPVEI2NCxUeYibdXtMIUYz23U4CdeQZue1mtH3FbDgLLmIKjjykFwqUlDnSLP X-Received: by 2002:a17:902:8a95:b0:1b3:9d13:34b3 with SMTP id p21-20020a1709028a9500b001b39d1334b3mr14705221plo.37.1690996423487; Wed, 02 Aug 2023 10:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690996423; cv=none; d=google.com; s=arc-20160816; b=OR0jv0Rjx0QRMm/8vYliGQ0R91DZftK4OJMhXFXFD3eO3Wqz4r88fn6IHqd8rIDc9T uryVioKis6znu/2J5SgHmpZdkPHHESQ5Q3+2gjiuwwGMYdbNtMJv57Tk+0hVTAWQPZVZ u+rMpm8whwhilz7Yc97ljmPjRsbjZaNrSL0YLYYlI9s58v/zd5TEweruyom1vzJ4uJ9M jDO8JUcQ9j5P4PdK+YymklcxO9i1heWAdNeLsszS/u6hbnFgpCmoVM9OnDFZ87w/deC7 PH7IRXRTzpnkmFPLTX1arjddrQsPFLXq8fvBTCFx7mCVYxPgteSiuBoclmdi1zP7X80K KQWA== 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 :dkim-signature; bh=5otL2xfi5fq8beqcNQO018MOMk9VZAnogawmcQkO95A=; fh=o5Gq1WLGnnFTlNdb8t4YCP7HM0H9d2hN3YCEdtj1R/Q=; b=RiXc7B73RcZ7n9vMl5p5LLrktdWJJyotxKfipVpsEL4xzb4aXtA09x+L5DnZZKGyai izv4xxNX6FumiqXwrUOz0IzlaKfwlX7vDVRoxopOCKQOnAbX3K3ntxbeKwD0deQs6vFb kv5Ttyk3dSZcQNxmZjMgL4aAOvaf8I7Y1bg9484g1AtK5YA2JklKmKnES+2iE3LnwgHu EM9Y5gEA7HewxeKDywgcLfrr3jjcE3zGF3a5WIwIc6i2paWLRd8NHz+c7B8ShP3TJiYD G6ur/yLhBh/LDPMpR4wQJp73C8fngXPodvrng2pxAAFazwZaFvoP2THcgoLcJpTDyQ6x lJvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=W9UdzekK; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb3-20020a170902fa4300b001bbc138af0dsi1472836plb.163.2023.08.02.10.13.30; Wed, 02 Aug 2023 10:13:43 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=W9UdzekK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235050AbjHBPO4 (ORCPT + 99 others); Wed, 2 Aug 2023 11:14:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234714AbjHBPOT (ORCPT ); Wed, 2 Aug 2023 11:14:19 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4A652D6A; Wed, 2 Aug 2023 08:14:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5otL2xfi5fq8beqcNQO018MOMk9VZAnogawmcQkO95A=; b=W9UdzekKdA4eNBMudYVz4/3g59 eFMFALpM104qYTLYM3rs/SU/i4NE8rLpF7TKGXeBJ/H7hsL3eblOQjHX/wwFdSitbk5kgfTH0ijy3 Q5zhEC9UeW+wWJgexOrM+ndfv/tCsTOOfejOmyj4Uw1mK8YV6ShnWWhKRd8uCiAcq/0OPX//HRByZ AA72KqfC4oIWt+KiHcehLjK7+QmMJcl+qaTRfRpBCcqIkkg1ofYbMjFMdgx2AcUhXRw4LUvbwtTB0 PE0kPwYjf4pflBECZryuEsv97ccMioO81DH+r3PO25wFt397UVl+sst7znklIhzsRRP0RTFZ+rEta QO4KxADA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qRDY8-00Ffie-3z; Wed, 02 Aug 2023 15:14:08 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport , Pasha Tatashin , Anshuman Khandual Subject: [PATCH v6 02/38] mm: Convert page_table_check_pte_set() to page_table_check_ptes_set() Date: Wed, 2 Aug 2023 16:13:30 +0100 Message-Id: <20230802151406.3735276-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230802151406.3735276-1-willy@infradead.org> References: <20230802151406.3735276-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Tell the page table check how many PTEs & PFNs we want it to check. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Mike Rapoport (IBM) Acked-by: Pasha Tatashin Reviewed-by: Anshuman Khandual --- arch/arm64/include/asm/pgtable.h | 2 +- arch/riscv/include/asm/pgtable.h | 2 +- arch/x86/include/asm/pgtable.h | 2 +- include/linux/page_table_check.h | 13 +++++++------ mm/page_table_check.c | 16 +++++++++------- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index fe4b913589ee..445b18d7a47c 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -348,7 +348,7 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr, static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte) { - page_table_check_pte_set(mm, ptep, pte); + page_table_check_ptes_set(mm, ptep, pte, 1); return __set_pte_at(mm, addr, ptep, pte); } diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 44377f0d7c35..01e4aabc8898 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -499,7 +499,7 @@ static inline void __set_pte_at(struct mm_struct *mm, static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval) { - page_table_check_pte_set(mm, ptep, pteval); + page_table_check_ptes_set(mm, ptep, pteval, 1); __set_pte_at(mm, addr, ptep, pteval); } diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index ada1bbf12961..cd0b6337d03c 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1023,7 +1023,7 @@ static inline pud_t native_local_pudp_get_and_clear(pud_t *pudp) static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte) { - page_table_check_pte_set(mm, ptep, pte); + page_table_check_ptes_set(mm, ptep, pte, 1); set_pte(ptep, pte); } diff --git a/include/linux/page_table_check.h b/include/linux/page_table_check.h index 7f6b9bf926c5..6722941c7cb8 100644 --- a/include/linux/page_table_check.h +++ b/include/linux/page_table_check.h @@ -17,7 +17,8 @@ void __page_table_check_zero(struct page *page, unsigned int order); void __page_table_check_pte_clear(struct mm_struct *mm, pte_t pte); void __page_table_check_pmd_clear(struct mm_struct *mm, pmd_t pmd); void __page_table_check_pud_clear(struct mm_struct *mm, pud_t pud); -void __page_table_check_pte_set(struct mm_struct *mm, pte_t *ptep, pte_t pte); +void __page_table_check_ptes_set(struct mm_struct *mm, pte_t *ptep, pte_t pte, + unsigned int nr); void __page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, pmd_t pmd); void __page_table_check_pud_set(struct mm_struct *mm, pud_t *pudp, pud_t pud); void __page_table_check_pte_clear_range(struct mm_struct *mm, @@ -64,13 +65,13 @@ static inline void page_table_check_pud_clear(struct mm_struct *mm, pud_t pud) __page_table_check_pud_clear(mm, pud); } -static inline void page_table_check_pte_set(struct mm_struct *mm, pte_t *ptep, - pte_t pte) +static inline void page_table_check_ptes_set(struct mm_struct *mm, + pte_t *ptep, pte_t pte, unsigned int nr) { if (static_branch_likely(&page_table_check_disabled)) return; - __page_table_check_pte_set(mm, ptep, pte); + __page_table_check_ptes_set(mm, ptep, pte, nr); } static inline void page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, @@ -123,8 +124,8 @@ static inline void page_table_check_pud_clear(struct mm_struct *mm, pud_t pud) { } -static inline void page_table_check_pte_set(struct mm_struct *mm, pte_t *ptep, - pte_t pte) +static inline void page_table_check_ptes_set(struct mm_struct *mm, + pte_t *ptep, pte_t pte, unsigned int nr) { } diff --git a/mm/page_table_check.c b/mm/page_table_check.c index 46e77c12c81e..af69c3c8f7c2 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -182,18 +182,20 @@ void __page_table_check_pud_clear(struct mm_struct *mm, pud_t pud) } EXPORT_SYMBOL(__page_table_check_pud_clear); -void __page_table_check_pte_set(struct mm_struct *mm, pte_t *ptep, pte_t pte) +void __page_table_check_ptes_set(struct mm_struct *mm, pte_t *ptep, pte_t pte, + unsigned int nr) { + unsigned int i; + if (&init_mm == mm) return; - __page_table_check_pte_clear(mm, ptep_get(ptep)); - if (pte_user_accessible_page(pte)) { - page_table_check_set(pte_pfn(pte), PAGE_SIZE >> PAGE_SHIFT, - pte_write(pte)); - } + for (i = 0; i < nr; i++) + __page_table_check_pte_clear(mm, ptep_get(ptep + i)); + if (pte_user_accessible_page(pte)) + page_table_check_set(pte_pfn(pte), nr, pte_write(pte)); } -EXPORT_SYMBOL(__page_table_check_pte_set); +EXPORT_SYMBOL(__page_table_check_ptes_set); void __page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, pmd_t pmd) { -- 2.40.1