From patchwork Tue Feb 28 21:37:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13155241 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 51611C64EC4 for ; Tue, 28 Feb 2023 21:38:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DA116B008A; Tue, 28 Feb 2023 16:37:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B24C6B0089; Tue, 28 Feb 2023 16:37:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C512E6B008A; Tue, 28 Feb 2023 16:37:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6AFB16B0083 for ; Tue, 28 Feb 2023 16:37:46 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 45F661C641A for ; Tue, 28 Feb 2023 21:37:46 +0000 (UTC) X-FDA: 80518012932.05.CC6666E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id 97A4C100012 for ; Tue, 28 Feb 2023 21:37:44 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=C4l9hofg; dmarc=none; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677620264; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ohh0hBicoR9cEJC1f0QXvtIvk3E2NGoKfRsPDD6eKkI=; b=VMv7AcIyWrEHSDhDtfzFi6xZza79kF5TsC97scJq921o4gh+hzRO4oBEAp96h2qoSlO+6c QYWx95PhelXwPlkMF05O8KD31qsCKsH0ZByWtM+02wM58LpsyYbX4mOo47dqYk9nAe50VX dQ5IluvsEYvuh2lcYlbu5L4rxAQjI7o= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=C4l9hofg; dmarc=none; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677620264; a=rsa-sha256; cv=none; b=UK4B6WwGLIZ/Q0TQXYtrj88tkddt1fzIDgl4yZ1uHa44JoOdzVtCvF8yqFSDSQ4fAfp9U2 sDRqdVG74JCVKHt6sXPZy0CQwJ8V+idhRsTDwcgieAFGxC4Mq1pliJJ0kRtNcRTc6GqFgX +ap+43rAHdQhIaQml09S9qwBKGOAHXk= 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=ohh0hBicoR9cEJC1f0QXvtIvk3E2NGoKfRsPDD6eKkI=; b=C4l9hofg4rXftyXEerYvPHhQWb dfQB5LKm+FDa6C47uGBFnFC3zM3BryxXu8sj/gjDOY2O+D49YhfYWpVTZxEV/shabx37cO1Dva5zN D3mCsa9NIAKTpB7OrGAFf8e+244BialSZcSfy1ocAy27AG1DniLnfMQPg8aRpFWr/OMM6UK1Mkpxv W0As55hUkjr87Ho6l/vHOgFkeKR8CsjU1Un3j625SmEIZ3v+hTCZK+nvQnTAQOlaNV29QcYwvG8zF YfTNGdH3SPPddEAtGGWqWC+fugeAGBF4tEhu7ueNcMRAbblnJOP5ra5PWDQ3HUsUpBnaOyHqPvSza PlHdlyag==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pX7fH-0018oU-J8; Tue, 28 Feb 2023 21:37:39 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, linux-arch@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org Subject: [PATCH v3 01/34] mm: Convert page_table_check_pte_set() to page_table_check_ptes_set() Date: Tue, 28 Feb 2023 21:37:04 +0000 Message-Id: <20230228213738.272178-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230228213738.272178-1-willy@infradead.org> References: <20230228213738.272178-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 97A4C100012 X-Stat-Signature: jk7yeox5f3aq7xipyohg7356g8mytiyz X-HE-Tag: 1677620264-297445 X-HE-Meta: U2FsdGVkX1/DpMVIb1H4tilnU2plDTr0+5+ZNtaTS2VZ8f6nlIrBNpw8wxrRDMD5N8jb+wMS9j9YGfAbtBPdPeXWiwWF4c+TsrkqYoyDZhk9E+JTPugUqVX7WfBjXiBgKrYdaCjHtv654u7jF8W7lqkq/i4UjEQfXVWhvsDoZyiMdnTcinc8fwjfMW/GSSq0+1udj5dGtkVn5c67RQAwlyirQpqU2Xy4pN2WVMjuRKgL/cyz5/czLBWb/nUq9ZcH1YSSCtGHdq7Nj5PAwK77MbEKP8PySyAIkszURCKFQi8rH224wVtM7coCeoTP7Gc4ZjpoSTV3IJZ51h5IWBbaKNRIQTVmccORXMZwzJTu5PUk6yo9Yv+pmY2IeO/ZgJ6NQ9PWNhKkxUNpzJW0TMJW70LSGgvnyXMlq5rZJ39ZGETKH4H5tUwpYMENDTMG2CkFa1X9HcWsHmXzgQ2chWMxz60mPT7Ehdtx1/pogt7P6xWQnqNX10Tq/Q8jn4MBXVdShNq2LvB2al+sgKezL5uoIwcOvabAzDKsvXPtr2v9BJdT7NacHfZhQxowe/qZEK3c6MhLJSbWUST8mkORJCJ36AaKxHFIb99AnnvNQlSAypVqRxyoErUKFctdIDwnb4FiCKYPs7dPMq54Xif5MImPb9i3Agg+toGNv3bT7yVDlL2u2HggcRFjPRkvovtP8cbFzBewdGF9h+qvnikjUrPdmeRUJsHf1CbbWHxR5aWhrsWodg2EUvSdI/WjLtpWuaEelUyj+dwqMJi4i24bi/6Vub8SGyVZZfSgLCEe4KFs9Nvq3L3wr8NwmLw7uWU9YIme2QSaMUwHiBY5FxJUfkqAzdCXQOq/pwpO7MO+JstMlkcAPFrgzqWyQVvxquUSCHetAw0ioNGnkKrzwKxt4/2EN2IaXhtMOx96TBgL9M+T4mHWvK9yno/lT5lfFKXyYr0kWUsjbTjL83BqM3/qhUx Ij7IMqj2 Lhiy4fdQI9OHhqJtVqjGII082rSl0iMGggzLSCe2aUwtPYEfQl9Ahnfn/RRHT5esJkYS+kyfFAMCYJt1ijJKLXRaXTwfdsCY2s4tPdrU36xvtbVADtqSMXWUO+ibN4Qp5xdgqt5D+WH0bd7y/MkFe6aWJlXoyjW9bQKHA5HNJ6HPZzDN7hlKmYqZ6kIqNF3G5kXid1Pr2TXkTVcixqmbv8/vquBGoIoWrh14IFEv0xVtEaXN5zw7HcSFoxQ== 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: Tell the page table check how many PTEs & PFNs we want it to check. Signed-off-by: Matthew Wilcox (Oracle) --- 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 | 14 +++++++------- mm/page_table_check.c | 14 ++++++++------ 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index b6ba466e2e8a..69765dc697af 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -358,7 +358,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, addr, ptep, pte); + page_table_check_ptes_set(mm, addr, 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 ab05f892d317..b516f3b59616 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -459,7 +459,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, addr, ptep, pteval); + page_table_check_ptes_set(mm, addr, 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 7425f32e5293..84be3e07b112 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1022,7 +1022,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, addr, ptep, pte); + page_table_check_ptes_set(mm, addr, ptep, pte, 1); set_pte(ptep, pte); } diff --git a/include/linux/page_table_check.h b/include/linux/page_table_check.h index 01e16c7696ec..ba269c7009e4 100644 --- a/include/linux/page_table_check.h +++ b/include/linux/page_table_check.h @@ -20,8 +20,8 @@ void __page_table_check_pmd_clear(struct mm_struct *mm, unsigned long addr, pmd_t pmd); void __page_table_check_pud_clear(struct mm_struct *mm, unsigned long addr, pud_t pud); -void __page_table_check_pte_set(struct mm_struct *mm, unsigned long addr, - pte_t *ptep, pte_t pte); +void __page_table_check_ptes_set(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte, unsigned int nr); void __page_table_check_pmd_set(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd); void __page_table_check_pud_set(struct mm_struct *mm, unsigned long addr, @@ -73,14 +73,14 @@ static inline void page_table_check_pud_clear(struct mm_struct *mm, __page_table_check_pud_clear(mm, addr, pud); } -static inline void page_table_check_pte_set(struct mm_struct *mm, +static inline void page_table_check_ptes_set(struct mm_struct *mm, unsigned long addr, pte_t *ptep, - pte_t pte) + pte_t pte, unsigned int nr) { if (static_branch_likely(&page_table_check_disabled)) return; - __page_table_check_pte_set(mm, addr, ptep, pte); + __page_table_check_ptes_set(mm, addr, ptep, pte, nr); } static inline void page_table_check_pmd_set(struct mm_struct *mm, @@ -138,9 +138,9 @@ static inline void page_table_check_pud_clear(struct mm_struct *mm, { } -static inline void page_table_check_pte_set(struct mm_struct *mm, +static inline void page_table_check_ptes_set(struct mm_struct *mm, unsigned long addr, pte_t *ptep, - pte_t pte) + pte_t pte, unsigned int nr) { } diff --git a/mm/page_table_check.c b/mm/page_table_check.c index 25d8610c0042..e6f4d40caaa2 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -184,20 +184,22 @@ void __page_table_check_pud_clear(struct mm_struct *mm, unsigned long addr, } EXPORT_SYMBOL(__page_table_check_pud_clear); -void __page_table_check_pte_set(struct mm_struct *mm, unsigned long addr, - pte_t *ptep, pte_t pte) +void __page_table_check_ptes_set(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte, unsigned int nr) { + unsigned int i; + if (&init_mm == mm) return; - __page_table_check_pte_clear(mm, addr, *ptep); + for (i = 0; i < nr; i++) + __page_table_check_pte_clear(mm, addr, ptep[i]); if (pte_user_accessible_page(pte)) { - page_table_check_set(mm, addr, pte_pfn(pte), - PAGE_SIZE >> PAGE_SHIFT, + page_table_check_set(mm, addr, 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, unsigned long addr, pmd_t *pmdp, pmd_t pmd)