linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/2] mm: fix some page table check related issues
@ 2022-05-17  7:45 Tong Tiangen
  2022-05-17  7:45 ` [PATCH -next 1/2] riscv/mm: fix two " Tong Tiangen
  2022-05-17  7:45 ` [PATCH -next 2/2] arm64/mm: fix page table check compile error for CONFIG_PGTABLE_LEVELS=2 Tong Tiangen
  0 siblings, 2 replies; 5+ messages in thread
From: Tong Tiangen @ 2022-05-17  7:45 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Paul Walmsley, Palmer Dabbelt,
	Palmer Dabbelt, Albert Ou, Arnd Bergmann
  Cc: linux-arm-kernel, linux-riscv, linux-arch, linux-kernel,
	Tong Tiangen, wangkefeng.wang, Guohanjun, Xie XiuQi

This patchset solves some ptc-related issues found recently.

Tong Tiangen (2):
  riscv/mm: fix two page table check related issues
  arm64/mm: fix page table check compile error for
    CONFIG_PGTABLE_LEVELS=2

 arch/arm64/include/asm/pgtable.h    | 33 +++++++++++++++--------------
 arch/riscv/include/asm/pgtable-64.h |  5 +++++
 arch/riscv/include/asm/pgtable.h    |  5 -----
 include/asm-generic/pgtable-nopmd.h |  2 ++
 4 files changed, 24 insertions(+), 21 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH -next 1/2] riscv/mm: fix two page table check related issues
  2022-05-17  7:45 [PATCH -next 0/2] mm: fix some page table check related issues Tong Tiangen
@ 2022-05-17  7:45 ` Tong Tiangen
  2022-05-17  7:45 ` [PATCH -next 2/2] arm64/mm: fix page table check compile error for CONFIG_PGTABLE_LEVELS=2 Tong Tiangen
  1 sibling, 0 replies; 5+ messages in thread
From: Tong Tiangen @ 2022-05-17  7:45 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Paul Walmsley, Palmer Dabbelt,
	Palmer Dabbelt, Albert Ou, Arnd Bergmann
  Cc: linux-arm-kernel, linux-riscv, linux-arch, linux-kernel,
	Tong Tiangen, wangkefeng.wang, Guohanjun, Xie XiuQi

Two page table check related issues have been fixed here.

1. Open CONFIG_PAGE_TABLE_CHECK in riscv32, we got a compile error[1]:

   error: implicit declaration of function 'pud_leaf'

   Add pud_leaf() definition to incluce/asm-generic/pgtable-nopmd.h to fix
   this issue.

2. Keep consistent with other pud_xxx() helpers, move pud_user() to
   pgtable-64.h and add pud_user() to pgtable-nopmd.h.

[1]https://lore.kernel.org/linux-mm/202205161811.2nLxmN2O-lkp@intel.com/T/

Fixes: 856eed79f8d3 ("riscv/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
---
 arch/riscv/include/asm/pgtable-64.h | 5 +++++
 arch/riscv/include/asm/pgtable.h    | 5 -----
 include/asm-generic/pgtable-nopmd.h | 2 ++
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h
index 7e246e9f8d70..ba2494cbc24f 100644
--- a/arch/riscv/include/asm/pgtable-64.h
+++ b/arch/riscv/include/asm/pgtable-64.h
@@ -86,6 +86,11 @@ static inline int pud_leaf(pud_t pud)
 	return pud_present(pud) && (pud_val(pud) & _PAGE_LEAF);
 }
 
+static inline int pud_user(pud_t pud)
+{
+	return pud_val(pud) & _PAGE_USER;
+}
+
 static inline void set_pud(pud_t *pudp, pud_t pud)
 {
 	*pudp = pud;
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 62e733c85836..4200ddede880 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -634,11 +634,6 @@ static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
 	return __set_pte_at(mm, addr, (pte_t *)pmdp, pmd_pte(pmd));
 }
 
-static inline int pud_user(pud_t pud)
-{
-	return pte_user(pud_pte(pud));
-}
-
 static inline void set_pud_at(struct mm_struct *mm, unsigned long addr,
 				pud_t *pudp, pud_t pud)
 {
diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
index 10789cf51d16..8ffd64e7a24c 100644
--- a/include/asm-generic/pgtable-nopmd.h
+++ b/include/asm-generic/pgtable-nopmd.h
@@ -30,6 +30,8 @@ typedef struct { pud_t pud; } pmd_t;
 static inline int pud_none(pud_t pud)		{ return 0; }
 static inline int pud_bad(pud_t pud)		{ return 0; }
 static inline int pud_present(pud_t pud)	{ return 1; }
+static inline int pud_user(pud_t pud)		{ return 0; }
+static inline int pud_leaf(pud_t pud)		{ return 0; }
 static inline void pud_clear(pud_t *pud)	{ }
 #define pmd_ERROR(pmd)				(pud_ERROR((pmd).pud))
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH -next 2/2] arm64/mm: fix page table check compile error for CONFIG_PGTABLE_LEVELS=2
  2022-05-17  7:45 [PATCH -next 0/2] mm: fix some page table check related issues Tong Tiangen
  2022-05-17  7:45 ` [PATCH -next 1/2] riscv/mm: fix two " Tong Tiangen
@ 2022-05-17  7:45 ` Tong Tiangen
  2022-05-18 16:28   ` Catalin Marinas
  1 sibling, 1 reply; 5+ messages in thread
From: Tong Tiangen @ 2022-05-17  7:45 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Paul Walmsley, Palmer Dabbelt,
	Palmer Dabbelt, Albert Ou, Arnd Bergmann
  Cc: linux-arm-kernel, linux-riscv, linux-arch, linux-kernel,
	Tong Tiangen, wangkefeng.wang, Guohanjun, Xie XiuQi

If CONFIG_PGTABLE_LEVELS=2 and CONFIG_ARCH_SUPPORTS_PAGE_TABLE_CHECK=y,
then we trigger a compile error:

  error: implicit declaration of function 'pte_user_accessible_page'

Move the definition of page table check helper out of branch
CONFIG_PGTABLE_LEVELS > 2

Fixes: daf214c14dbe ("arm64/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK")
Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
---
 arch/arm64/include/asm/pgtable.h | 33 ++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 4e61cde27f9f..979601528f1e 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -667,22 +667,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
 #define pud_valid(pud)		pte_valid(pud_pte(pud))
 #define pud_user(pud)		pte_user(pud_pte(pud))
 
-#ifdef CONFIG_PAGE_TABLE_CHECK
-static inline bool pte_user_accessible_page(pte_t pte)
-{
-	return pte_present(pte) && (pte_user(pte) || pte_user_exec(pte));
-}
-
-static inline bool pmd_user_accessible_page(pmd_t pmd)
-{
-	return pmd_present(pmd) && (pmd_user(pmd) || pmd_user_exec(pmd));
-}
-
-static inline bool pud_user_accessible_page(pud_t pud)
-{
-	return pud_present(pud) && pud_user(pud);
-}
-#endif
 
 static inline void set_pud(pud_t *pudp, pud_t pud)
 {
@@ -855,6 +839,23 @@ static inline int pgd_devmap(pgd_t pgd)
 }
 #endif
 
+#ifdef CONFIG_PAGE_TABLE_CHECK
+static inline bool pte_user_accessible_page(pte_t pte)
+{
+	return pte_present(pte) && (pte_user(pte) || pte_user_exec(pte));
+}
+
+static inline bool pmd_user_accessible_page(pmd_t pmd)
+{
+	return pmd_present(pmd) && (pmd_user(pmd) || pmd_user_exec(pmd));
+}
+
+static inline bool pud_user_accessible_page(pud_t pud)
+{
+	return pud_present(pud) && pud_user(pud);
+}
+#endif
+
 /*
  * Atomic pte/pmd modifications.
  */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH -next 2/2] arm64/mm: fix page table check compile error for CONFIG_PGTABLE_LEVELS=2
  2022-05-17  7:45 ` [PATCH -next 2/2] arm64/mm: fix page table check compile error for CONFIG_PGTABLE_LEVELS=2 Tong Tiangen
@ 2022-05-18 16:28   ` Catalin Marinas
  2022-05-18 17:13     ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Catalin Marinas @ 2022-05-18 16:28 UTC (permalink / raw)
  To: Tong Tiangen
  Cc: Will Deacon, Paul Walmsley, Palmer Dabbelt, Palmer Dabbelt,
	Albert Ou, Arnd Bergmann, linux-arm-kernel, linux-riscv,
	linux-arch, linux-kernel, wangkefeng.wang, Guohanjun, Xie XiuQi,
	linux-mm, Andrew Morton

On Tue, May 17, 2022 at 07:45:48AM +0000, Tong Tiangen wrote:
> If CONFIG_PGTABLE_LEVELS=2 and CONFIG_ARCH_SUPPORTS_PAGE_TABLE_CHECK=y,
> then we trigger a compile error:
> 
>   error: implicit declaration of function 'pte_user_accessible_page'
> 
> Move the definition of page table check helper out of branch
> CONFIG_PGTABLE_LEVELS > 2
> 
> Fixes: daf214c14dbe ("arm64/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK")
> Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>

I'd drop the fixes tag here since the patch is queued in the mm tree and
AFAIK that one doesn't have stable git commit ids. Otherwise:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

(I cc'ed Andrew and linux-mm as Andrew queued the original patches)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next 2/2] arm64/mm: fix page table check compile error for CONFIG_PGTABLE_LEVELS=2
  2022-05-18 16:28   ` Catalin Marinas
@ 2022-05-18 17:13     ` Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2022-05-18 17:13 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Tong Tiangen, Will Deacon, Paul Walmsley, Palmer Dabbelt,
	Palmer Dabbelt, Albert Ou, Arnd Bergmann, linux-arm-kernel,
	linux-riscv, linux-arch, linux-kernel, wangkefeng.wang,
	Guohanjun, Xie XiuQi, linux-mm

On Wed, 18 May 2022 17:28:38 +0100 Catalin Marinas <catalin.marinas@arm.com> wrote:

> On Tue, May 17, 2022 at 07:45:48AM +0000, Tong Tiangen wrote:
> > If CONFIG_PGTABLE_LEVELS=2 and CONFIG_ARCH_SUPPORTS_PAGE_TABLE_CHECK=y,
> > then we trigger a compile error:
> > 
> >   error: implicit declaration of function 'pte_user_accessible_page'
> > 
> > Move the definition of page table check helper out of branch
> > CONFIG_PGTABLE_LEVELS > 2
> > 
> > Fixes: daf214c14dbe ("arm64/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK")
> > Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
> 
> I'd drop the fixes tag here since the patch is queued in the mm tree and
> AFAIK that one doesn't have stable git commit ids.

MM tree is at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Commit ID's are stable if a commit is in the mm-hotfixes-stable,
mm-stable or mm-nonmm-stable branch.

Commit ID's are unstable if a commit is still in the
mm-hotfixes-unstable, mm-unstable or mm-unnonmm-stable.

I move patches from -unstable to -stable after they're considered ready
for it.  The delay is very variable, depends on how things are coming
along with that patch(set).



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-18 17:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17  7:45 [PATCH -next 0/2] mm: fix some page table check related issues Tong Tiangen
2022-05-17  7:45 ` [PATCH -next 1/2] riscv/mm: fix two " Tong Tiangen
2022-05-17  7:45 ` [PATCH -next 2/2] arm64/mm: fix page table check compile error for CONFIG_PGTABLE_LEVELS=2 Tong Tiangen
2022-05-18 16:28   ` Catalin Marinas
2022-05-18 17:13     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).