All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Rohan McLure <rmclure@linux.ibm.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: "mpe@ellerman.id.au" <mpe@ellerman.id.au>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH v11 00/11] Support page table check PowerPC
Date: Fri, 29 Mar 2024 08:29:59 +0000	[thread overview]
Message-ID: <02ab19a2-cd5d-4205-8be5-d642f277c75d@csgroup.eu> (raw)
In-Reply-To: <eb906bc3-b372-449b-a351-eb739ffa7418@csgroup.eu>



Le 28/03/2024 à 08:57, Christophe Leroy a écrit :
> 
> 
> Le 28/03/2024 à 07:52, Christophe Leroy a écrit :
>>
>>
>> Le 28/03/2024 à 05:55, Rohan McLure a écrit :
>>> Support page table check on all PowerPC platforms. This works by
>>> serialising assignments, reassignments and clears of page table
>>> entries at each level in order to ensure that anonymous mappings
>>> have at most one writable consumer, and likewise that file-backed
>>> mappings are not simultaneously also anonymous mappings.
>>>
>>> In order to support this infrastructure, a number of stubs must be
>>> defined for all powerpc platforms. Additionally, seperate set_pte_at()
>>> and set_pte_at_unchecked(), to allow for internal, uninstrumented 
>>> mappings.
>>
>> I gave it a try on QEMU e500 (64 bits), and get the following Oops. 
>> What do I have to look for ?
>>
>> Freeing unused kernel image (initmem) memory: 2588K
>> This architecture does not have kernel memory protection.
>> Run /init as init process
>> ------------[ cut here ]------------
>> kernel BUG at mm/page_table_check.c:119!
>> Oops: Exception in kernel mode, sig: 5 [#1]
>> BE PAGE_SIZE=4K SMP NR_CPUS=32 QEMU e500
> 
> Same problem on my 8xx board:
> 
> [    7.358146] Freeing unused kernel image (initmem) memory: 448K
> [    7.363957] Run /init as init process
> [    7.370955] ------------[ cut here ]------------
> [    7.375411] kernel BUG at mm/page_table_check.c:119!
> [    7.380393] Oops: Exception in kernel mode, sig: 5 [#1]
> [    7.385621] BE PAGE_SIZE=16K PREEMPT CMPC885

Both problems are fixed by following change:

diff --git a/arch/powerpc/include/asm/nohash/pgtable.h 
b/arch/powerpc/include/asm/nohash/pgtable.h
index 413d01a51e6f..5b932632a5d7 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h
@@ -29,6 +29,8 @@ static inline pte_basic_t pte_update(struct mm_struct 
*mm, unsigned long addr, p

  #ifndef __ASSEMBLY__

+#include <linux/page_table_check.h>
+
  extern int icache_44x_need_flush;

  /*
@@ -92,7 +94,11 @@ static inline void ptep_set_wrprotect(struct 
mm_struct *mm, unsigned long addr,
  static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned 
long addr,
  				       pte_t *ptep)
  {
-	return __pte(pte_update(mm, addr, ptep, ~0UL, 0, 0));
+	pte_t old_pte = __pte(pte_update(mm, addr, ptep, ~0UL, 0, 0));
+
+	page_table_check_pte_clear(mm, addr, old_pte);
+
+	return old_pte;
  }
  #define __HAVE_ARCH_PTEP_GET_AND_CLEAR


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Rohan McLure <rmclure@linux.ibm.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: "mpe@ellerman.id.au" <mpe@ellerman.id.au>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH v11 00/11] Support page table check PowerPC
Date: Fri, 29 Mar 2024 08:29:59 +0000	[thread overview]
Message-ID: <02ab19a2-cd5d-4205-8be5-d642f277c75d@csgroup.eu> (raw)
In-Reply-To: <eb906bc3-b372-449b-a351-eb739ffa7418@csgroup.eu>



Le 28/03/2024 à 08:57, Christophe Leroy a écrit :
> 
> 
> Le 28/03/2024 à 07:52, Christophe Leroy a écrit :
>>
>>
>> Le 28/03/2024 à 05:55, Rohan McLure a écrit :
>>> Support page table check on all PowerPC platforms. This works by
>>> serialising assignments, reassignments and clears of page table
>>> entries at each level in order to ensure that anonymous mappings
>>> have at most one writable consumer, and likewise that file-backed
>>> mappings are not simultaneously also anonymous mappings.
>>>
>>> In order to support this infrastructure, a number of stubs must be
>>> defined for all powerpc platforms. Additionally, seperate set_pte_at()
>>> and set_pte_at_unchecked(), to allow for internal, uninstrumented 
>>> mappings.
>>
>> I gave it a try on QEMU e500 (64 bits), and get the following Oops. 
>> What do I have to look for ?
>>
>> Freeing unused kernel image (initmem) memory: 2588K
>> This architecture does not have kernel memory protection.
>> Run /init as init process
>> ------------[ cut here ]------------
>> kernel BUG at mm/page_table_check.c:119!
>> Oops: Exception in kernel mode, sig: 5 [#1]
>> BE PAGE_SIZE=4K SMP NR_CPUS=32 QEMU e500
> 
> Same problem on my 8xx board:
> 
> [    7.358146] Freeing unused kernel image (initmem) memory: 448K
> [    7.363957] Run /init as init process
> [    7.370955] ------------[ cut here ]------------
> [    7.375411] kernel BUG at mm/page_table_check.c:119!
> [    7.380393] Oops: Exception in kernel mode, sig: 5 [#1]
> [    7.385621] BE PAGE_SIZE=16K PREEMPT CMPC885

Both problems are fixed by following change:

diff --git a/arch/powerpc/include/asm/nohash/pgtable.h 
b/arch/powerpc/include/asm/nohash/pgtable.h
index 413d01a51e6f..5b932632a5d7 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h
@@ -29,6 +29,8 @@ static inline pte_basic_t pte_update(struct mm_struct 
*mm, unsigned long addr, p

  #ifndef __ASSEMBLY__

+#include <linux/page_table_check.h>
+
  extern int icache_44x_need_flush;

  /*
@@ -92,7 +94,11 @@ static inline void ptep_set_wrprotect(struct 
mm_struct *mm, unsigned long addr,
  static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned 
long addr,
  				       pte_t *ptep)
  {
-	return __pte(pte_update(mm, addr, ptep, ~0UL, 0, 0));
+	pte_t old_pte = __pte(pte_update(mm, addr, ptep, ~0UL, 0, 0));
+
+	page_table_check_pte_clear(mm, addr, old_pte);
+
+	return old_pte;
  }
  #define __HAVE_ARCH_PTEP_GET_AND_CLEAR



WARNING: multiple messages have this Message-ID (diff)
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Rohan McLure <rmclure@linux.ibm.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: "mpe@ellerman.id.au" <mpe@ellerman.id.au>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH v11 00/11] Support page table check PowerPC
Date: Fri, 29 Mar 2024 08:29:59 +0000	[thread overview]
Message-ID: <02ab19a2-cd5d-4205-8be5-d642f277c75d@csgroup.eu> (raw)
In-Reply-To: <eb906bc3-b372-449b-a351-eb739ffa7418@csgroup.eu>



Le 28/03/2024 à 08:57, Christophe Leroy a écrit :
> 
> 
> Le 28/03/2024 à 07:52, Christophe Leroy a écrit :
>>
>>
>> Le 28/03/2024 à 05:55, Rohan McLure a écrit :
>>> Support page table check on all PowerPC platforms. This works by
>>> serialising assignments, reassignments and clears of page table
>>> entries at each level in order to ensure that anonymous mappings
>>> have at most one writable consumer, and likewise that file-backed
>>> mappings are not simultaneously also anonymous mappings.
>>>
>>> In order to support this infrastructure, a number of stubs must be
>>> defined for all powerpc platforms. Additionally, seperate set_pte_at()
>>> and set_pte_at_unchecked(), to allow for internal, uninstrumented 
>>> mappings.
>>
>> I gave it a try on QEMU e500 (64 bits), and get the following Oops. 
>> What do I have to look for ?
>>
>> Freeing unused kernel image (initmem) memory: 2588K
>> This architecture does not have kernel memory protection.
>> Run /init as init process
>> ------------[ cut here ]------------
>> kernel BUG at mm/page_table_check.c:119!
>> Oops: Exception in kernel mode, sig: 5 [#1]
>> BE PAGE_SIZE=4K SMP NR_CPUS=32 QEMU e500
> 
> Same problem on my 8xx board:
> 
> [    7.358146] Freeing unused kernel image (initmem) memory: 448K
> [    7.363957] Run /init as init process
> [    7.370955] ------------[ cut here ]------------
> [    7.375411] kernel BUG at mm/page_table_check.c:119!
> [    7.380393] Oops: Exception in kernel mode, sig: 5 [#1]
> [    7.385621] BE PAGE_SIZE=16K PREEMPT CMPC885

Both problems are fixed by following change:

diff --git a/arch/powerpc/include/asm/nohash/pgtable.h 
b/arch/powerpc/include/asm/nohash/pgtable.h
index 413d01a51e6f..5b932632a5d7 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h
@@ -29,6 +29,8 @@ static inline pte_basic_t pte_update(struct mm_struct 
*mm, unsigned long addr, p

  #ifndef __ASSEMBLY__

+#include <linux/page_table_check.h>
+
  extern int icache_44x_need_flush;

  /*
@@ -92,7 +94,11 @@ static inline void ptep_set_wrprotect(struct 
mm_struct *mm, unsigned long addr,
  static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned 
long addr,
  				       pte_t *ptep)
  {
-	return __pte(pte_update(mm, addr, ptep, ~0UL, 0, 0));
+	pte_t old_pte = __pte(pte_update(mm, addr, ptep, ~0UL, 0, 0));
+
+	page_table_check_pte_clear(mm, addr, old_pte);
+
+	return old_pte;
  }
  #define __HAVE_ARCH_PTEP_GET_AND_CLEAR


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Rohan McLure <rmclure@linux.ibm.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: "linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	"x86@kernel.org" <x86@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH v11 00/11] Support page table check PowerPC
Date: Fri, 29 Mar 2024 08:29:59 +0000	[thread overview]
Message-ID: <02ab19a2-cd5d-4205-8be5-d642f277c75d@csgroup.eu> (raw)
In-Reply-To: <eb906bc3-b372-449b-a351-eb739ffa7418@csgroup.eu>



Le 28/03/2024 à 08:57, Christophe Leroy a écrit :
> 
> 
> Le 28/03/2024 à 07:52, Christophe Leroy a écrit :
>>
>>
>> Le 28/03/2024 à 05:55, Rohan McLure a écrit :
>>> Support page table check on all PowerPC platforms. This works by
>>> serialising assignments, reassignments and clears of page table
>>> entries at each level in order to ensure that anonymous mappings
>>> have at most one writable consumer, and likewise that file-backed
>>> mappings are not simultaneously also anonymous mappings.
>>>
>>> In order to support this infrastructure, a number of stubs must be
>>> defined for all powerpc platforms. Additionally, seperate set_pte_at()
>>> and set_pte_at_unchecked(), to allow for internal, uninstrumented 
>>> mappings.
>>
>> I gave it a try on QEMU e500 (64 bits), and get the following Oops. 
>> What do I have to look for ?
>>
>> Freeing unused kernel image (initmem) memory: 2588K
>> This architecture does not have kernel memory protection.
>> Run /init as init process
>> ------------[ cut here ]------------
>> kernel BUG at mm/page_table_check.c:119!
>> Oops: Exception in kernel mode, sig: 5 [#1]
>> BE PAGE_SIZE=4K SMP NR_CPUS=32 QEMU e500
> 
> Same problem on my 8xx board:
> 
> [    7.358146] Freeing unused kernel image (initmem) memory: 448K
> [    7.363957] Run /init as init process
> [    7.370955] ------------[ cut here ]------------
> [    7.375411] kernel BUG at mm/page_table_check.c:119!
> [    7.380393] Oops: Exception in kernel mode, sig: 5 [#1]
> [    7.385621] BE PAGE_SIZE=16K PREEMPT CMPC885

Both problems are fixed by following change:

diff --git a/arch/powerpc/include/asm/nohash/pgtable.h 
b/arch/powerpc/include/asm/nohash/pgtable.h
index 413d01a51e6f..5b932632a5d7 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h
@@ -29,6 +29,8 @@ static inline pte_basic_t pte_update(struct mm_struct 
*mm, unsigned long addr, p

  #ifndef __ASSEMBLY__

+#include <linux/page_table_check.h>
+
  extern int icache_44x_need_flush;

  /*
@@ -92,7 +94,11 @@ static inline void ptep_set_wrprotect(struct 
mm_struct *mm, unsigned long addr,
  static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned 
long addr,
  				       pte_t *ptep)
  {
-	return __pte(pte_update(mm, addr, ptep, ~0UL, 0, 0));
+	pte_t old_pte = __pte(pte_update(mm, addr, ptep, ~0UL, 0, 0));
+
+	page_table_check_pte_clear(mm, addr, old_pte);
+
+	return old_pte;
  }
  #define __HAVE_ARCH_PTEP_GET_AND_CLEAR



  reply	other threads:[~2024-03-29  8:30 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28  4:55 [PATCH v11 00/11] Support page table check PowerPC Rohan McLure
2024-03-28  4:55 ` Rohan McLure
2024-03-28  4:55 ` Rohan McLure
2024-03-28  4:55 ` Rohan McLure
2024-03-28  4:55 ` [PATCH v11 01/11] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set" Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55 ` [PATCH v11 02/11] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set" Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55 ` [PATCH v11 03/11] mm: Provide addr parameter to page_table_check_pte_set() Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55 ` [PATCH v11 04/11] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_clear" Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55 ` [PATCH v11 05/11] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_clear" Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55 ` [PATCH v11 06/11] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pte_clear" Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55 ` [PATCH v11 07/11] mm: Provide address parameter to p{te,md,ud}_user_accessible_page() Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55 ` [PATCH v11 08/11] powerpc: mm: Add pud_pfn() stub Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  5:33   ` Christophe Leroy
2024-03-28  5:33     ` Christophe Leroy
2024-03-28  5:33     ` Christophe Leroy
2024-03-28  5:33     ` Christophe Leroy
2024-03-28  4:55 ` [PATCH v11 09/11] poweprc: mm: Implement *_user_accessible_page() for ptes Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  5:40   ` Christophe Leroy
2024-03-28  5:40     ` Christophe Leroy
2024-03-28  5:40     ` Christophe Leroy
2024-03-28  5:40     ` Christophe Leroy
2024-03-28  5:44     ` Rohan McLure
2024-03-28  5:44       ` Rohan McLure
2024-03-28  5:44       ` Rohan McLure
2024-03-28  5:44       ` Rohan McLure
2024-03-28  4:55 ` [PATCH v11 10/11] powerpc: mm: Use set_pte_at_unchecked() for early-boot / internal usages Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55 ` [PATCH v11 11/11] powerpc: mm: Support page table check Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  4:55   ` Rohan McLure
2024-03-28  6:52 ` [PATCH v11 00/11] Support page table check PowerPC Christophe Leroy
2024-03-28  6:52   ` Christophe Leroy
2024-03-28  6:52   ` Christophe Leroy
2024-03-28  6:52   ` Christophe Leroy
2024-03-28  7:57   ` Christophe Leroy
2024-03-28  7:57     ` Christophe Leroy
2024-03-28  7:57     ` Christophe Leroy
2024-03-28  7:57     ` Christophe Leroy
2024-03-29  8:29     ` Christophe Leroy [this message]
2024-03-29  8:29       ` Christophe Leroy
2024-03-29  8:29       ` Christophe Leroy
2024-03-29  8:29       ` Christophe Leroy
2024-03-28  9:28 ` Ingo Molnar
2024-03-28  9:28   ` Ingo Molnar
2024-03-28  9:28   ` Ingo Molnar
2024-03-28  9:28   ` Ingo Molnar
2024-04-02  3:00   ` Rohan McLure
2024-04-02  3:00     ` Rohan McLure
2024-04-02  3:00     ` Rohan McLure
2024-04-02  3:00     ` Rohan McLure

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=02ab19a2-cd5d-4205-8be5-d642f277c75d@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=rmclure@linux.ibm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.