mbox series

[v8,0/7] Support page table check

Message ID 20230215231153.2147454-1-rmclure@linux.ibm.com (mailing list archive)
Headers show
Series Support page table check | expand

Message

Rohan McLure Feb. 15, 2023, 11:11 p.m. UTC
Support the page table check sanitiser on all PowerPC platforms. This
sanitiser 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, to allow for internal, uninstrumented mappings.

v8:
 * Fix linux/page_table_check.h include in asm/pgtable.h breaking
   32-bit.

v7:
 * Remove use of extern in set_pte prototypes
 * Clean up pmdp_collapse_flush macro
 * Replace set_pte_at with static inline function
 * Fix commit message for patch 7
Link: https://lore.kernel.org/linuxppc-dev/20230215020155.1969194-1-rmclure@linux.ibm.com/

v6:
 * Support huge pages and p{m,u}d accounting.
 * Remove instrumentation from set_pte from kernel internal pages.
 * 64s: Implement pmdp_collapse_flush in terms of __pmdp_collapse_flush
   as access to the mm_struct * is required.
Link: https://lore.kernel.org/linuxppc-dev/20230214015939.1853438-1-rmclure@linux.ibm.com/

v5:
Link: https://lore.kernel.org/linuxppc-dev/20221118002146.25979-1-rmclure@linux.ibm.com/

Rohan McLure (7):
  powerpc: mm: Separate set_pte, set_pte_at for internal, external use
  powerpc/64s: mm: Introduce __pmdp_collapse_flush with mm_struct
    argument
  powerpc: mm: Replace p{u,m,4}d_is_leaf with p{u,m,4}_leaf
  powerpc: mm: Implement p{m,u,4}d_leaf on all platforms
  powerpc: mm: Add common pud_pfn stub for all platforms
  powerpc: mm: Add p{te,md,ud}_user_accessible_page helpers
  powerpc: mm: Support page table check

 arch/powerpc/Kconfig                         |  1 +
 arch/powerpc/include/asm/book3s/32/pgtable.h | 17 +++-
 arch/powerpc/include/asm/book3s/64/pgtable.h | 85 +++++++++++++-------
 arch/powerpc/include/asm/book3s/pgtable.h    |  3 +-
 arch/powerpc/include/asm/nohash/32/pgtable.h | 12 ++-
 arch/powerpc/include/asm/nohash/64/pgtable.h | 24 +++++-
 arch/powerpc/include/asm/nohash/pgtable.h    |  9 ++-
 arch/powerpc/include/asm/pgtable.h           | 60 +++++++++-----
 arch/powerpc/kvm/book3s_64_mmu_radix.c       | 12 +--
 arch/powerpc/mm/book3s64/hash_pgtable.c      |  2 +-
 arch/powerpc/mm/book3s64/pgtable.c           | 16 ++--
 arch/powerpc/mm/book3s64/radix_pgtable.c     | 24 +++---
 arch/powerpc/mm/nohash/book3e_pgtable.c      |  2 +-
 arch/powerpc/mm/pgtable.c                    |  9 +--
 arch/powerpc/mm/pgtable_32.c                 |  2 +-
 arch/powerpc/mm/pgtable_64.c                 |  6 +-
 arch/powerpc/xmon/xmon.c                     |  6 +-
 17 files changed, 197 insertions(+), 93 deletions(-)

Comments

Rohan McLure March 30, 2023, 2:11 a.m. UTC | #1
Anyone got time to review this one?

> On 16 Feb 2023, at 10:11 am, Rohan McLure <rmclure@linux.ibm.com> wrote:
> 
> Support the page table check sanitiser on all PowerPC platforms. This
> sanitiser 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, to allow for internal, uninstrumented mappings.
> 
> v8:
> * Fix linux/page_table_check.h include in asm/pgtable.h breaking
>   32-bit.
> 
> v7:
> * Remove use of extern in set_pte prototypes
> * Clean up pmdp_collapse_flush macro
> * Replace set_pte_at with static inline function
> * Fix commit message for patch 7
> Link: https://lore.kernel.org/linuxppc-dev/20230215020155.1969194-1-rmclure@linux.ibm.com/
> 
> v6:
> * Support huge pages and p{m,u}d accounting.
> * Remove instrumentation from set_pte from kernel internal pages.
> * 64s: Implement pmdp_collapse_flush in terms of __pmdp_collapse_flush
>   as access to the mm_struct * is required.
> Link: https://lore.kernel.org/linuxppc-dev/20230214015939.1853438-1-rmclure@linux.ibm.com/
> 
> v5:
> Link: https://lore.kernel.org/linuxppc-dev/20221118002146.25979-1-rmclure@linux.ibm.com/
> 
> Rohan McLure (7):
>  powerpc: mm: Separate set_pte, set_pte_at for internal, external use
>  powerpc/64s: mm: Introduce __pmdp_collapse_flush with mm_struct
>    argument
>  powerpc: mm: Replace p{u,m,4}d_is_leaf with p{u,m,4}_leaf
>  powerpc: mm: Implement p{m,u,4}d_leaf on all platforms
>  powerpc: mm: Add common pud_pfn stub for all platforms
>  powerpc: mm: Add p{te,md,ud}_user_accessible_page helpers
>  powerpc: mm: Support page table check
> 
> arch/powerpc/Kconfig                         |  1 +
> arch/powerpc/include/asm/book3s/32/pgtable.h | 17 +++-
> arch/powerpc/include/asm/book3s/64/pgtable.h | 85 +++++++++++++-------
> arch/powerpc/include/asm/book3s/pgtable.h    |  3 +-
> arch/powerpc/include/asm/nohash/32/pgtable.h | 12 ++-
> arch/powerpc/include/asm/nohash/64/pgtable.h | 24 +++++-
> arch/powerpc/include/asm/nohash/pgtable.h    |  9 ++-
> arch/powerpc/include/asm/pgtable.h           | 60 +++++++++-----
> arch/powerpc/kvm/book3s_64_mmu_radix.c       | 12 +--
> arch/powerpc/mm/book3s64/hash_pgtable.c      |  2 +-
> arch/powerpc/mm/book3s64/pgtable.c           | 16 ++--
> arch/powerpc/mm/book3s64/radix_pgtable.c     | 24 +++---
> arch/powerpc/mm/nohash/book3e_pgtable.c      |  2 +-
> arch/powerpc/mm/pgtable.c                    |  9 +--
> arch/powerpc/mm/pgtable_32.c                 |  2 +-
> arch/powerpc/mm/pgtable_64.c                 |  6 +-
> arch/powerpc/xmon/xmon.c                     |  6 +-
> 17 files changed, 197 insertions(+), 93 deletions(-)
> 
> -- 
> 2.37.2
>
Michael Ellerman March 31, 2023, 12:25 a.m. UTC | #2
Rohan McLure <rmclure@linux.ibm.com> writes:
> Anyone got time to review this one?

I was planning to pick it up, but it's going to conflict badly with the
set_ptes() series:

  https://lore.kernel.org/all/20230315051444.3229621-1-willy@infradead.org/

I thought that series was likely to go in soon, but I see it's still not
in linux-next.

Hopefully there'll be a v5 of that series soon and we can try and work
out the conflicts. I might need to create a topic branch, or have this
series go via -mm.

cheers


>> On 16 Feb 2023, at 10:11 am, Rohan McLure <rmclure@linux.ibm.com> wrote:
>> 
>> Support the page table check sanitiser on all PowerPC platforms. This
>> sanitiser 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, to allow for internal, uninstrumented mappings.
>> 
>> v8:
>> * Fix linux/page_table_check.h include in asm/pgtable.h breaking
>>   32-bit.
>> 
>> v7:
>> * Remove use of extern in set_pte prototypes
>> * Clean up pmdp_collapse_flush macro
>> * Replace set_pte_at with static inline function
>> * Fix commit message for patch 7
>> Link: https://lore.kernel.org/linuxppc-dev/20230215020155.1969194-1-rmclure@linux.ibm.com/
>> 
>> v6:
>> * Support huge pages and p{m,u}d accounting.
>> * Remove instrumentation from set_pte from kernel internal pages.
>> * 64s: Implement pmdp_collapse_flush in terms of __pmdp_collapse_flush
>>   as access to the mm_struct * is required.
>> Link: https://lore.kernel.org/linuxppc-dev/20230214015939.1853438-1-rmclure@linux.ibm.com/
>> 
>> v5:
>> Link: https://lore.kernel.org/linuxppc-dev/20221118002146.25979-1-rmclure@linux.ibm.com/
>> 
>> Rohan McLure (7):
>>  powerpc: mm: Separate set_pte, set_pte_at for internal, external use
>>  powerpc/64s: mm: Introduce __pmdp_collapse_flush with mm_struct
>>    argument
>>  powerpc: mm: Replace p{u,m,4}d_is_leaf with p{u,m,4}_leaf
>>  powerpc: mm: Implement p{m,u,4}d_leaf on all platforms
>>  powerpc: mm: Add common pud_pfn stub for all platforms
>>  powerpc: mm: Add p{te,md,ud}_user_accessible_page helpers
>>  powerpc: mm: Support page table check
>> 
>> arch/powerpc/Kconfig                         |  1 +
>> arch/powerpc/include/asm/book3s/32/pgtable.h | 17 +++-
>> arch/powerpc/include/asm/book3s/64/pgtable.h | 85 +++++++++++++-------
>> arch/powerpc/include/asm/book3s/pgtable.h    |  3 +-
>> arch/powerpc/include/asm/nohash/32/pgtable.h | 12 ++-
>> arch/powerpc/include/asm/nohash/64/pgtable.h | 24 +++++-
>> arch/powerpc/include/asm/nohash/pgtable.h    |  9 ++-
>> arch/powerpc/include/asm/pgtable.h           | 60 +++++++++-----
>> arch/powerpc/kvm/book3s_64_mmu_radix.c       | 12 +--
>> arch/powerpc/mm/book3s64/hash_pgtable.c      |  2 +-
>> arch/powerpc/mm/book3s64/pgtable.c           | 16 ++--
>> arch/powerpc/mm/book3s64/radix_pgtable.c     | 24 +++---
>> arch/powerpc/mm/nohash/book3e_pgtable.c      |  2 +-
>> arch/powerpc/mm/pgtable.c                    |  9 +--
>> arch/powerpc/mm/pgtable_32.c                 |  2 +-
>> arch/powerpc/mm/pgtable_64.c                 |  6 +-
>> arch/powerpc/xmon/xmon.c                     |  6 +-
>> 17 files changed, 197 insertions(+), 93 deletions(-)
>> 
>> -- 
>> 2.37.2
>>
Christophe Leroy Oct. 13, 2023, 10:56 a.m. UTC | #3
Le 16/02/2023 à 00:11, Rohan McLure a écrit :
> Support the page table check sanitiser on all PowerPC platforms. This
> sanitiser 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, to allow for internal, uninstrumented mappings.

This series doesn't apply, can you rebase if still applicable ?

Thanks
Christophe

> 
> v8:
>   * Fix linux/page_table_check.h include in asm/pgtable.h breaking
>     32-bit.
> 
> v7:
>   * Remove use of extern in set_pte prototypes
>   * Clean up pmdp_collapse_flush macro
>   * Replace set_pte_at with static inline function
>   * Fix commit message for patch 7
> Link: https://lore.kernel.org/linuxppc-dev/20230215020155.1969194-1-rmclure@linux.ibm.com/
> 
> v6:
>   * Support huge pages and p{m,u}d accounting.
>   * Remove instrumentation from set_pte from kernel internal pages.
>   * 64s: Implement pmdp_collapse_flush in terms of __pmdp_collapse_flush
>     as access to the mm_struct * is required.
> Link: https://lore.kernel.org/linuxppc-dev/20230214015939.1853438-1-rmclure@linux.ibm.com/
> 
> v5:
> Link: https://lore.kernel.org/linuxppc-dev/20221118002146.25979-1-rmclure@linux.ibm.com/
> 
> Rohan McLure (7):
>    powerpc: mm: Separate set_pte, set_pte_at for internal, external use
>    powerpc/64s: mm: Introduce __pmdp_collapse_flush with mm_struct
>      argument
>    powerpc: mm: Replace p{u,m,4}d_is_leaf with p{u,m,4}_leaf
>    powerpc: mm: Implement p{m,u,4}d_leaf on all platforms
>    powerpc: mm: Add common pud_pfn stub for all platforms
>    powerpc: mm: Add p{te,md,ud}_user_accessible_page helpers
>    powerpc: mm: Support page table check
> 
>   arch/powerpc/Kconfig                         |  1 +
>   arch/powerpc/include/asm/book3s/32/pgtable.h | 17 +++-
>   arch/powerpc/include/asm/book3s/64/pgtable.h | 85 +++++++++++++-------
>   arch/powerpc/include/asm/book3s/pgtable.h    |  3 +-
>   arch/powerpc/include/asm/nohash/32/pgtable.h | 12 ++-
>   arch/powerpc/include/asm/nohash/64/pgtable.h | 24 +++++-
>   arch/powerpc/include/asm/nohash/pgtable.h    |  9 ++-
>   arch/powerpc/include/asm/pgtable.h           | 60 +++++++++-----
>   arch/powerpc/kvm/book3s_64_mmu_radix.c       | 12 +--
>   arch/powerpc/mm/book3s64/hash_pgtable.c      |  2 +-
>   arch/powerpc/mm/book3s64/pgtable.c           | 16 ++--
>   arch/powerpc/mm/book3s64/radix_pgtable.c     | 24 +++---
>   arch/powerpc/mm/nohash/book3e_pgtable.c      |  2 +-
>   arch/powerpc/mm/pgtable.c                    |  9 +--
>   arch/powerpc/mm/pgtable_32.c                 |  2 +-
>   arch/powerpc/mm/pgtable_64.c                 |  6 +-
>   arch/powerpc/xmon/xmon.c                     |  6 +-
>   17 files changed, 197 insertions(+), 93 deletions(-)
>