linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pasha Tatashin <pasha.tatashin@soleen.com>
To: Tong Tiangen <tongtiangen@huawei.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	 Dave Hansen <dave.hansen@linux.intel.com>,
	 "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
	<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	 Will Deacon <will@kernel.org>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	 LKML <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>,
	 Linux ARM <linux-arm-kernel@lists.infradead.org>,
	linux-riscv@lists.infradead.org
Subject: Re: [PATCH -next v2 2/4] mm: page_table_check: add hooks to public helpers
Date: Wed, 23 Mar 2022 13:42:16 -0400	[thread overview]
Message-ID: <CA+CK2bAa96oE0FbtJUjAJ=vpuzQsW3R60K9SUhca6mZ3BL1f8w@mail.gmail.com> (raw)
In-Reply-To: <20220322144447.3563146-3-tongtiangen@huawei.com>

On Tue, Mar 22, 2022 at 10:25 AM Tong Tiangen <tongtiangen@huawei.com> wrote:
>
> Move ptep_clear() to the include/linux/pgtable.h and add page table check
> relate hooks to some helpers, it's prepare for support page table check
> feature on new architecture.
>
> Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
> ---
>  arch/x86/include/asm/pgtable.h | 10 ----------
>  include/linux/pgtable.h        | 27 +++++++++++++++++++--------
>  2 files changed, 19 insertions(+), 18 deletions(-)
>
> diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
> index 8cd6514e3052..8c85f2eabbaa 100644
> --- a/arch/x86/include/asm/pgtable.h
> +++ b/arch/x86/include/asm/pgtable.h
> @@ -1077,16 +1077,6 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm,
>         return pte;
>  }
>
> -#define __HAVE_ARCH_PTEP_CLEAR
> -static inline void ptep_clear(struct mm_struct *mm, unsigned long addr,
> -                             pte_t *ptep)
> -{
> -       if (IS_ENABLED(CONFIG_PAGE_TABLE_CHECK))
> -               ptep_get_and_clear(mm, addr, ptep);
> -       else
> -               pte_clear(mm, addr, ptep);
> -}
> -
>  #define __HAVE_ARCH_PTEP_SET_WRPROTECT
>  static inline void ptep_set_wrprotect(struct mm_struct *mm,
>                                       unsigned long addr, pte_t *ptep)
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index f4f4077b97aa..d27fd0ed84a9 100644
> --- a/include/linux/pgtable.h
> +++ b/include/linux/pgtable.h
> @@ -12,6 +12,7 @@
>  #include <linux/bug.h>
>  #include <linux/errno.h>
>  #include <asm-generic/pgtable_uffd.h>
> +#include <linux/page_table_check.h>
>
>  #if 5 - defined(__PAGETABLE_P4D_FOLDED) - defined(__PAGETABLE_PUD_FOLDED) - \
>         defined(__PAGETABLE_PMD_FOLDED) != CONFIG_PGTABLE_LEVELS
> @@ -259,14 +260,6 @@ static inline int pmdp_clear_flush_young(struct vm_area_struct *vma,
>  #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
>  #endif
>
> -#ifndef __HAVE_ARCH_PTEP_CLEAR
> -static inline void ptep_clear(struct mm_struct *mm, unsigned long addr,
> -                             pte_t *ptep)
> -{
> -       pte_clear(mm, addr, ptep);
> -}
> -#endif
> -
>  #ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR
>  static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
>                                        unsigned long address,
> @@ -274,10 +267,23 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
>  {
>         pte_t pte = *ptep;
>         pte_clear(mm, address, ptep);
> +       page_table_check_pte_clear(mm, address, pte);
>         return pte;
>  }
>  #endif
>
> +#ifndef __HAVE_ARCH_PTEP_CLEAR
> +static inline void ptep_clear(struct mm_struct *mm, unsigned long addr,
> +                             pte_t *ptep)
> +{
> +#ifdef CONFIG_PAGE_TABLE_CHECK
> +       ptep_get_and_clear(mm, addr, ptep);
> +#else
> +       pte_clear(mm, addr, ptep);
> +#endif

I have a preference to use if (IS_ENABLED(CONFIG_PAGE_TABLE_CHECK))
instead of #ifdef. The end result is the same. Otherwise it looks
good.

Thanks,
Pasha


  reply	other threads:[~2022-03-23 17:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22 14:44 [PATCH -next v2 0/4]mm: page_table_check: add support on arm64 and riscv Tong Tiangen
2022-03-22 14:44 ` [PATCH -next v2 1/4] mm: page_table_check: move pxx_user_accessible_page into x86 Tong Tiangen
2022-03-23 17:34   ` Pasha Tatashin
2022-03-22 14:44 ` [PATCH -next v2 2/4] mm: page_table_check: add hooks to public helpers Tong Tiangen
2022-03-23 17:42   ` Pasha Tatashin [this message]
2022-03-24  2:07     ` Tong Tiangen
2022-03-24  2:12       ` Pasha Tatashin
2022-03-24  2:44         ` Tong Tiangen
2022-03-22 14:44 ` [PATCH -next v2 3/4] arm64: mm: add support for page table check Tong Tiangen
2022-03-23 18:35   ` Pasha Tatashin
2022-03-22 14:44 ` [PATCH -next v2 4/4] riscv: " Tong Tiangen
2022-03-23 18:37   ` Pasha Tatashin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+CK2bAa96oE0FbtJUjAJ=vpuzQsW3R60K9SUhca6mZ3BL1f8w@mail.gmail.com' \
    --to=pasha.tatashin@soleen.com \
    --cc=akpm@linux-foundation.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mingo@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=tglx@linutronix.de \
    --cc=tongtiangen@huawei.com \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox