Re: [PATCH 2/2] powerpc/64: Only warn for kuap locked when KCSAN not present

2024-04-10 Thread Rohan McLure
On Thu, 2024-04-04 at 06:14 +, Christophe Leroy wrote: > > > Le 04/04/2024 à 06:45, Rohan McLure a écrit : > > Arbitrary instrumented locations, including syscall handlers, can > > call > > arch_local_irq_restore() transitively when KCSAN is enable

[PATCH 2/2] powerpc/64: Only warn for kuap locked when KCSAN not present

2024-04-03 Thread Rohan McLure
-off-by: Rohan McLure --- arch/powerpc/kernel/irq_64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/irq_64.c b/arch/powerpc/kernel/irq_64.c index d5c48d1b0a31..18b2048389a2 100644 --- a/arch/powerpc/kernel/irq_64.c +++ b/arch/powerpc/kernel/irq_64.c

[PATCH 1/2] powerpc: Apply __always_inline to interrupt_{enter,exit}_prepare()

2024-04-03 Thread Rohan McLure
observed to compile without inlining these routines, which would lead to grief on NMI handlers. Signed-off-by: Rohan McLure --- arch/powerpc/include/asm/interrupt.h | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc

[PATCH] asm-generic/mmiowb: Mark accesses to fix KCSAN warnings

2024-04-03 Thread Rohan McLure
to correct behaviour. Signed-off-by: Rohan McLure Reported-by: Michael Ellerman Reported-by: Gautam Menghani Tested-by: Gautam Menghani Acked-by: Arnd Bergmann --- Previously discussed here: https://lore.kernel.org/linuxppc-dev/20230510033117.1395895-4-rmcl...@linux.ibm.com/ But pushed back

[PATCH v12 11/11] powerpc: mm: Support page table check

2024-04-01 Thread Rohan McLure
support in commit 3fee229a8eb9 ("riscv/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") arm64 in commit 42b2547137f5 ("arm64/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") x86_64 in commit d283d422c6c4 ("x86: mm: add x86_64 support for page table check") Reviewed-by: Christophe Lero

[PATCH v12 04/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_clear()

2024-04-01 Thread Rohan McLure
ut instead in the address of the access. Signed-off-by: Rohan McLure --- arch/x86/include/asm/pgtable.h | 2 +- include/linux/page_table_check.h | 11 +++ include/linux/pgtable.h | 2 +- mm/page_table_check.c| 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-)

[PATCH v12 10/11] powerpc: mm: Use set_pte_at_unchecked() for early-boot / internal usages

2024-04-01 Thread Rohan McLure
() in early-boot usages which should not be instrumented. Signed-off-by: Rohan McLure --- v9: New patch v10: don't reuse __set_pte_at(), as that will not apply filters. Instead use new set_pte_at_unchecked(). v11: Include the assertion that hwvalid => !protnone. It is possible that some of these calls

[PATCH v12 09/11] poweprc: mm: Implement *_user_accessible_page() for ptes

2024-04-01 Thread Rohan McLure
r required to be present on all platforms as it may be equivalent to or implied by pte_read(). Hence implementations of pte_user_accessible_page() are specialised. Signed-off-by: Rohan McLure --- v9: New implementation v10: Let book3s/64 use pte_user(), but otherwise default other platform

[PATCH v12 08/11] powerpc: mm: Add pud_pfn() stub

2024-04-01 Thread Rohan McLure
as a BUILD_BUG(). Signed-off-by: Rohan McLure --- v11: pud_pfn() stub has been removed upstream as it has valid users now in transparent hugepages. Create a BUG_ON() for other, non Book3S64 platforms. v12: Add missing return line to stub. --- arch/powerpc/include/asm/pgtable.h | 9 + 1 file

[PATCH v12 07/11] mm: Provide address parameter to p{te,md,ud}_user_accessible_page()

2024-04-01 Thread Rohan McLure
table check on powerpc. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 6 +++--- arch/riscv/include/asm/pgtable.h | 6 +++--- arch/x86/include/asm/pgtable.h | 6 +++--- mm/page_table_check.c| 12 ++-- 4 files changed, 15 insertions(+), 15 deletions

[PATCH v12 06/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pte_clear()

2024-04-01 Thread Rohan McLure
ut instead in the address of the access. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 2 +- arch/riscv/include/asm/pgtable.h | 2 +- arch/x86/include/asm/pgtable.h | 4 ++-- include/linux/page_table_check.h | 11 +++ include/linux/pgtable.h | 2 +- mm/page_tab

[PATCH v12 03/11] mm/page_table_check: Provide addr parameter to page_table_check_pte_set()

2024-04-01 Thread Rohan McLure
. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 2 +- arch/riscv/include/asm/pgtable.h | 2 +- include/linux/page_table_check.h | 12 +++- include/linux/pgtable.h | 2 +- mm/page_table_check.c| 4 ++-- 5 files changed, 12 insertions(+), 10

[PATCH v12 05/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd_clear()

2024-04-01 Thread Rohan McLure
ut instead in the address of the access. Signed-off-by: Rohan McLure --- 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 | 11 +++ include/linux/pgtable.h | 2 +- mm/page_tab

[PATCH v12 01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()

2024-04-01 Thread Rohan McLure
Signed-off-by: Rohan McLure --- 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 | 11 +++ mm/page_table_check.c| 3 ++- 5 files changed, 12 insertions(+), 8 deletion

[PATCH v12 00/11] Support page table check PowerPC

2024-04-01 Thread Rohan McLure
/linuxppc-dev/20230214015939.1853438-1-rmcl...@linux.ibm.com/ v5: Link: https://lore.kernel.org/linuxppc-dev/20221118002146.25979-1-rmcl...@linux.ibm.com/ Rohan McLure (11): mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set() mm/page_table_check: Reinstate

[PATCH v12 02/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd_set()

2024-04-01 Thread Rohan McLure
Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 4 ++-- arch/riscv/include/asm/pgtable.h | 4 ++-- arch/x86/include/asm/pgtable.h | 4 ++-- include/linux/page_table_check.h | 11 +++ mm/page_table_check.c| 3 ++- 5 files changed, 15 insertions(+), 11

Re: [PATCH v11 00/11] Support page table check PowerPC

2024-04-01 Thread Rohan McLure
On Thu, 2024-03-28 at 10:28 +0100, Ingo Molnar wrote: > > * Rohan McLure wrote: > > > Rohan McLure (11): > >   Revert "mm/page_table_check: remove unused parameter in > > [__]page_table_check_pud_set" > >   Revert "mm/page_table_check: remove unus

Re: [PATCH v11 09/11] poweprc: mm: Implement *_user_accessible_page() for ptes

2024-03-27 Thread Rohan McLure
On Thu, 2024-03-28 at 05:40 +, Christophe Leroy wrote: > > > Le 28/03/2024 à 05:55, Rohan McLure a écrit : > > Page table checking depends on architectures providing an > > implementation of p{te,md,ud}_user_accessible_page. With > > refactor

[PATCH v11 02/11] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set"

2024-03-27 Thread Rohan McLure
, addr parameters from __set_pte_at() This commit also changed calls to __set_pte_at() to use fewer parameters on riscv. Keep that change rather than reverting it, as the signature of __set_pte_at() is changed in a different commit. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h

[PATCH v11 08/11] powerpc: mm: Add pud_pfn() stub

2024-03-27 Thread Rohan McLure
as a BUILD_BUG(). Signed-off-by: Rohan McLure --- v11: pud_pfn() stub has been removed upstream as it has valid users now in transparent hugepages. Create a BUG_ON() for other, non Book3S64 platforms. --- arch/powerpc/include/asm/pgtable.h | 8 1 file changed, 8 insertions(+) diff --git

[PATCH v11 03/11] mm: Provide addr parameter to page_table_check_pte_set()

2024-03-27 Thread Rohan McLure
. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 2 +- arch/riscv/include/asm/pgtable.h | 2 +- include/linux/page_table_check.h | 12 +++- include/linux/pgtable.h | 2 +- mm/page_table_check.c| 4 ++-- 5 files changed, 12 insertions(+), 10

[PATCH v11 11/11] powerpc: mm: Support page table check

2024-03-27 Thread Rohan McLure
support in commit 3fee229a8eb9 ("riscv/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") arm64 in commit 42b2547137f5 ("arm64/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") x86_64 in commit d283d422c6c4 ("x86: mm: add x86_64 support for page table check") Reviewed-by: Christophe Lero

[PATCH v11 09/11] poweprc: mm: Implement *_user_accessible_page() for ptes

2024-03-27 Thread Rohan McLure
r required to be present on all platforms as it may be equivalent to or implied by pte_read(). Hence implementations of pte_user_accessible_page() are specialised. Signed-off-by: Rohan McLure --- v9: New implementation v10: Let book3s/64 use pte_user(), but otherwise default other platform

[PATCH v11 10/11] powerpc: mm: Use set_pte_at_unchecked() for early-boot / internal usages

2024-03-27 Thread Rohan McLure
() in early-boot usages which should not be instrumented. Signed-off-by: Rohan McLure --- v9: New patch v10: don't reuse __set_pte_at(), as that will not apply filters. Instead use new set_pte_at_unchecked(). v11: Include the assertion that hwvalid => !protnone. It is possible that some of these calls

[PATCH v11 07/11] mm: Provide address parameter to p{te,md,ud}_user_accessible_page()

2024-03-27 Thread Rohan McLure
table check on powerpc. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 6 +++--- arch/riscv/include/asm/pgtable.h | 6 +++--- arch/x86/include/asm/pgtable.h | 6 +++--- mm/page_table_check.c| 12 ++-- 4 files changed, 15 insertions(+), 15 deletions

[PATCH v11 06/11] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pte_clear"

2024-03-27 Thread Rohan McLure
This reverts commit aa232204c4689427cefa55fe975692b57291523a. Reinstate previously unused parameters for the purpose of supporting powerpc platforms, as many do not encode user/kernel ownership of the page in the pte, but instead in the address of the access. Signed-off-by: Rohan McLure

[PATCH v11 05/11] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_clear"

2024-03-27 Thread Rohan McLure
This reverts commit 1831414cd729a34af937d56ad684a66599de6344. Reinstate previously unused parameters for the purpose of supporting powerpc platforms, as many do not encode user/kernel ownership of the page in the pte, but instead in the address of the access. Signed-off-by: Rohan McLure

[PATCH v11 04/11] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_clear"

2024-03-27 Thread Rohan McLure
This reverts commit 931c38e16499a057e30a3033f4d6a9c242f0f156. Reinstate previously unused parameters for the purpose of supporting powerpc platforms, as many do not encode user/kernel ownership of the page in the pte, but instead in the address of the access. Signed-off-by: Rohan McLure

[PATCH v11 00/11] Support page table check PowerPC

2024-03-27 Thread Rohan McLure
/20230214015939.1853438-1-rmcl...@linux.ibm.com/ v5: Link: https://lore.kernel.org/linuxppc-dev/20221118002146.25979-1-rmcl...@linux.ibm.com/ Rohan McLure (11): Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set" Revert "mm/page_table_check

[PATCH v11 01/11] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set"

2024-03-27 Thread Rohan McLure
, addr parameters from __set_pte_at() This commit also changed calls to __set_pte_at() to use fewer parameters on riscv. Keep that change rather than reverting it, as the signature of __set_pte_at() is changed in a different commit. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h

[PATCH v10 07/12] mm: Provide address parameter to p{te,md,ud}_user_accessible_page()

2024-03-12 Thread Rohan McLure
table check on powerpc. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 6 +++--- arch/riscv/include/asm/pgtable.h | 6 +++--- arch/x86/include/asm/pgtable.h | 6 +++--- mm/page_table_check.c| 12 ++-- 4 files changed, 15 insertions(+), 15 deletions

[PATCH v10 03/12] mm: Provide addr parameter to page_table_check_pte_set()

2024-03-12 Thread Rohan McLure
parameter. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 2 +- arch/riscv/include/asm/pgtable.h | 2 +- include/linux/page_table_check.h | 12 +++- include/linux/pgtable.h | 2 +- mm/page_table_check.c| 4 ++-- 5 files changed, 12 insertions(+), 10

[PATCH v10 05/12] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_clear"

2024-03-12 Thread Rohan McLure
This reverts commit 1831414cd729a34af937d56ad684a66599de6344. Reinstate previously unused parameters for the purpose of supporting powerpc platforms, as many do not encode user/kernel ownership of the page in the pte, but instead in the address of the access. Signed-off-by: Rohan McLure

[PATCH v10 00/12] Support page table check PowerPC

2024-03-12 Thread Rohan McLure
/linuxppc-dev/20221118002146.25979-1-rmcl...@linux.ibm.com/ Rohan McLure (12): Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set" Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set" mm: Pr

[PATCH v10 08/12] powerpc: mm: Replace p{u,m,4}d_is_leaf with p{u,m,4}_leaf

2024-03-12 Thread Rohan McLure
Replace occurrences of p{u,m,4}d_is_leaf with p{u,m,4}_leaf, as the latter is the name given to checking that a higher-level entry in multi-level paging contains a page translation entry (pte) throughout all other archs. Reviewed-by: Christophe Leroy Signed-off-by: Rohan McLure --- v9

[PATCH v10 12/12] powerpc: mm: Support page table check

2024-03-12 Thread Rohan McLure
support in commit 3fee229a8eb9 ("riscv/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") arm64 in commit 42b2547137f5 ("arm64/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") x86_64 in commit d283d422c6c4 ("x86: mm: add x86_64 support for page table check") Reviewed-by: Christophe Lero

[PATCH v10 02/12] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set"

2024-03-12 Thread Rohan McLure
, addr parameters from __set_pte_at() This commit also changed calls to __set_pte_at() to use fewer parameters on riscv. Keep that change rather than reverting it, as the signature of __set_pte_at() is changed in a different commit. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h

[PATCH v10 10/12] poweprc: mm: Implement *_user_accessible_page() for ptes

2024-03-12 Thread Rohan McLure
r required to be present on all platforms as it may be equivalent to or implied by pte_read(). Hence implementations are specialised. Signed-off-by: Rohan McLure --- v9: New implementation v10: Let book3s/64 use pte_user(), but otherwise default other platforms to using the address provided wit

[PATCH v10 11/12] powerpc: mm: Use set_pte_at_unchecked() for early-boot / internal usages

2024-03-12 Thread Rohan McLure
() in early-boot usages which should not be instrumented. Signed-off-by: Rohan McLure --- v9: New patch v10: don't reuse __set_pte_at(), as that will not apply filters. Instead use new set_pte_at_unchecked(). --- arch/powerpc/include/asm/pgtable.h | 2 ++ arch/powerpc/mm/book3s64/hash_pgtable.c | 2

[PATCH v10 06/12] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pte_clear"

2024-03-12 Thread Rohan McLure
This reverts commit aa232204c4689427cefa55fe975692b57291523a. Reinstate previously unused parameters for the purpose of supporting powerpc platforms, as many do not encode user/kernel ownership of the page in the pte, but instead in the address of the access. Signed-off-by: Rohan McLure

[PATCH v10 04/12] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_clear"

2024-03-12 Thread Rohan McLure
This reverts commit 931c38e16499a057e30a3033f4d6a9c242f0f156. Reinstate previously unused parameters for the purpose of supporting powerpc platforms, as many do not encode user/kernel ownership of the page in the pte, but instead in the address of the access. Signed-off-by: Rohan McLure

[PATCH v10 01/12] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set"

2024-03-12 Thread Rohan McLure
, addr parameters from __set_pte_at() This commit also changed calls to __set_pte_at() to use fewer parameters on riscv. Keep that change rather than reverting it, as the signature of __set_pte_at() is changed in a different commit. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h

[PATCH v10 09/12] powerpc: mm: Add common pud_pfn stub for all platforms

2024-03-12 Thread Rohan McLure
. Signed-off-by: Rohan McLure --- arch/powerpc/include/asm/pgtable.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 0c0ffbe7a3b5..13f661831333 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b

Re: [PATCH v9 4/7] powerpc: mm: Default p{m,u}d_pte implementations

2023-12-10 Thread Rohan McLure
On 11/30/23 18:35, Christophe Leroy wrote: > > Le 30/11/2023 à 03:53, Rohan McLure a écrit : >> For 32-bit systems which have no usecases for p{m,u}d_pte() prior to >> page table checking, implement default stubs. > Is that the best solution ? > > If I understand c

[PATCH v9 6/7] powerpc: mm: Use __set_pte_at() for early-boot / internal usages

2023-11-29 Thread Rohan McLure
uninstrumented by page table check. set_ptes() is itself implemented by calls to __set_pte_at(), so this eliminates redundant code. Also prefer __set_pte_at() in early-boot usages which should not be instrumented. Signed-off-by: Rohan McLure --- v9: New patch --- arch/powerpc/mm/book3s64/hash_pgtable.c

[PATCH v9 2/7] powerpc: mm: Implement p{m,u,4}d_leaf on all platforms

2023-11-29 Thread Rohan McLure
. Reviewed-by: Christophe Leroy Signed-off-by: Rohan McLure --- v9: No longer required in order implement page table check, just refactoring. --- arch/powerpc/include/asm/book3s/32/pgtable.h | 5 + arch/powerpc/include/asm/book3s/64/pgtable.h | 10 - arch/powerpc/include/asm/nohash/64

[PATCH v9 3/7] powerpc: mm: Add common pud_pfn stub for all platforms

2023-11-29 Thread Rohan McLure
. Signed-off-by: Rohan McLure --- arch/powerpc/include/asm/pgtable.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index db0231afca9d..9c0f2151f08f 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b

[PATCH v9 1/7] powerpc: mm: Replace p{u,m,4}d_is_leaf with p{u,m,4}_leaf

2023-11-29 Thread Rohan McLure
that they may be referenced in generic code. Reviewed-by: Christophe Leroy Signed-off-by: Rohan McLure --- v9: No longer required in order to implement page table check, just a refactor. --- arch/powerpc/kvm/book3s_64_mmu_radix.c | 12 ++-- arch/powerpc/mm/book3s64/radix_pgtable.c | 14

[PATCH v9 7/7] powerpc: mm: Support page table check

2023-11-29 Thread Rohan McLure
support in commit 3fee229a8eb9 ("riscv/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") arm64 in commit 42b2547137f5 ("arm64/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") x86_64 in commit d283d422c6c4 ("x86: mm: add x86_64 support for page table check") Reviewed-by: Christophe Lero

[PATCH v9 5/7] poweprc: mm: Implement *_user_accessible_page() for ptes

2023-11-29 Thread Rohan McLure
r required to be present on all platforms as it may be equivalent to or implied by pte_read(). Hence implementations are specialised. Signed-off-by: Rohan McLure --- v9: New implementation --- arch/powerpc/include/asm/book3s/32/pgtable.h | 5 + arch/powerpc/include/asm/book3s/64/pgta

[PATCH v9 4/7] powerpc: mm: Default p{m,u}d_pte implementations

2023-11-29 Thread Rohan McLure
For 32-bit systems which have no usecases for p{m,u}d_pte() prior to page table checking, implement default stubs. Signed-off-by: Rohan McLure --- v9: New patch --- arch/powerpc/include/asm/book3s/64/pgtable.h | 3 +++ arch/powerpc/include/asm/nohash/64/pgtable.h | 2 ++ arch/powerpc/include

[PATCH v9 0/7] Support page table check

2023-11-29 Thread Rohan McLure
-dev/20221118002146.25979-1-rmcl...@linux.ibm.com/ Rohan McLure (7): 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: Default p{m,u}d_pte implementations

[PATCH 3/3] powerpc/64: Only warn for kuap locked when KCSAN not present

2023-11-26 Thread Rohan McLure
-off-by: Rohan McLure --- arch/powerpc/kernel/irq_64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/irq_64.c b/arch/powerpc/kernel/irq_64.c index 938e66829eae..1b7e8ebb052a 100644 --- a/arch/powerpc/kernel/irq_64.c +++ b/arch/powerpc/kernel/irq_64.c

[PATCH 2/3] powerpc: Apply __always_inline to interrupt_{enter,exit}_prepare()

2023-11-26 Thread Rohan McLure
observed to compile without inlining these routines, which would lead to grief on NMI handlers. Signed-off-by: Rohan McLure --- arch/powerpc/include/asm/interrupt.h | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc

[PATCH 1/3] asm-generic/mmiowb: Mark accesses to fix KCSAN warnings

2023-11-26 Thread Rohan McLure
to correct behaviour. Signed-off-by: Rohan McLure Reported-by: Michael Ellerman Reported-by: Gautam Menghani Tested-by: Gautam Menghani Acked-by: Arnd Bergmann --- Previously discussed here: https://lore.kernel.org/linuxppc-dev/20230510033117.1395895-4-rmcl...@linux.ibm.com/ But pushed back

Re: [PATCH v2 03/11] asm-generic/mmiowb: Mark accesses to fix KCSAN warnings

2023-05-22 Thread Rohan McLure
On Wed May 10, 2023 at 1:31 PM AEST, Rohan McLure wrote: > Prior to this patch, data races are detectable by KCSAN of the following > forms: > > [1] Asynchronous calls to mmiowb_set_pending() from an interrupt context >or otherwise outside of a critical section > [2] In

Re: [PATCH v2 03/11] asm-generic/mmiowb: Mark accesses to fix KCSAN warnings

2023-05-22 Thread Rohan McLure
On 23 May 2023, at 10:28 am, Rohan McLure wrote: > > On Wed May 10, 2023 at 1:31 PM AEST, Rohan McLure wrote: >> Prior to this patch, data races are detectable by KCSAN of the following >> forms: >> >> [1] Asynchronous calls to mmiowb_set_pending() from an interr

Re: [PATCH v2 05/11] powerpc: Mark accesses to power_save callback in arch_cpu_idle

2023-05-15 Thread Rohan McLure
> On 15 May 2023, at 3:50 pm, Nicholas Piggin wrote: > > On Wed May 10, 2023 at 1:31 PM AEST, Rohan McLure wrote: >> The power_save callback can be overwritten by another core at boot time. >> Specifically, null values will be replaced exactly once with the

Re: [PATCH v2 08/11] powerpc: Mark writes registering ipi to host cpu through kvm and polling

2023-05-15 Thread Rohan McLure
> On 15 May 2023, at 3:53 pm, Nicholas Piggin wrote: > > On Wed May 10, 2023 at 1:31 PM AEST, Rohan McLure wrote: >> Mark writes to hypervisor ipi state so that KCSAN recognises these >> asynchronous issue of kvmppc_{set,clear}_host_ipi to be intended, with >> atomi

[PATCH v2 09/11] powerpc: powernv: Annotate data races in opal events

2023-05-09 Thread Rohan McLure
it is aware of when it is scheduled. Also removes extraneous KCSAN warnings. Signed-off-by: Rohan McLure Reviewed-by: Nicholas Piggin --- arch/powerpc/platforms/powernv/opal-irqchip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/powernv/opal

[PATCH v2 11/11] powerpc: Mark asynchronous accesses to irq_data

2023-05-09 Thread Rohan McLure
ngs. Signed-off-by: Rohan McLure --- arch/powerpc/kernel/irq.c | 2 +- arch/powerpc/platforms/powernv/pci-ioda.c | 12 ++-- include/linux/irq.h | 2 +- kernel/irq/irqdomain.c| 4 ++-- 4 files changed, 10 insertions(+), 10 deleti

[PATCH v2 04/11] powerpc: Mark [h]ssr_valid accesses in check_return_regs_valid

2023-05-09 Thread Rohan McLure
and writes, but annotate with data_race. Signed-off-by: Rohan McLure Reported-by: Michael Ellerman Reviewed-by: Nicholas Piggin --- arch/powerpc/include/asm/ptrace.h | 4 ++-- arch/powerpc/kernel/interrupt.c | 14 ++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/arch

[PATCH v2 08/11] powerpc: Mark writes registering ipi to host cpu through kvm and polling

2023-05-09 Thread Rohan McLure
Mark writes to hypervisor ipi state so that KCSAN recognises these asynchronous issue of kvmppc_{set,clear}_host_ipi to be intended, with atomic writes. Mark asynchronous polls to this variable in kvm_ppc_read_one_intr(). Signed-off-by: Rohan McLure --- v2: Add read-side annotations to both

[PATCH v2 03/11] asm-generic/mmiowb: Mark accesses to fix KCSAN warnings

2023-05-09 Thread Rohan McLure
memory accesses with READ_ONCE or WRITE_ONCE, including increments and decrements to nesting_count. This has the effect of removing KCSAN warnings at consumer's callsites. Signed-off-by: Rohan McLure Reported-by: Michael Ellerman Reported-by: Gautam Menghani Tested-by: Gautam Menghani Acked-by: Arnd

[PATCH v2 07/11] powerpc: Annotate accesses to ipi message flags

2023-05-09 Thread Rohan McLure
is expected. Mark write for message source in smp_muxed_ipi_set_message(). Signed-off-by: Rohan McLure --- v2: Add missing WRITE_ONCE() in smp_muxed_ipi_set_message(). --- arch/powerpc/kernel/smp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/smp.c b

[PATCH v2 06/11] powerpc: powernv: Fix KCSAN datarace warnings on idle_state contention

2023-05-09 Thread Rohan McLure
-by: Rohan McLure --- v2: Remove extraneous WRITE_ONCE on paca thread_idle_state, which are only read diagnostically. --- arch/powerpc/include/asm/paca.h | 1 + arch/powerpc/platforms/powernv/idle.c | 16 +--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/arch

[PATCH v2 05/11] powerpc: Mark accesses to power_save callback in arch_cpu_idle

2023-05-09 Thread Rohan McLure
sees unmarked reads to the callback variable, and notices that unfortunate compiler reorderings could lead to distinct function pointers being read. In reality this is impossible, so don't instrument at this read. Signed-off-by: Rohan McLure --- v2: Mark instances at init where the callback

[PATCH v2 01/11] powerpc: qspinlock: Mark accesses to qnode lock checks

2023-05-09 Thread Rohan McLure
The powerpc implemenation of qspinlocks will both poll and spin on the bitlock guarding a qnode. Mark these accesses with READ_ONCE to convey to KCSAN that polling is intentional here. Signed-off-by: Rohan McLure Reviewed-by: Nicholas Piggin --- arch/powerpc/lib/qspinlock.c | 4 ++-- 1 file

[PATCH v2 10/11] powerpc: powernv: Annotate asynchronous access to opal tokens

2023-05-09 Thread Rohan McLure
The opal-async.c unit contains code for polling event sources, which implies intentional data races. Ensure that the compiler will atomically access such variables by means of {READ,WRITE}_ONCE calls, which in turn inform KCSAN that polling behaviour is intended. Signed-off-by: Rohan McLure

[PATCH v2 02/11] powerpc: qspinlock: Enforce qnode writes prior to publishing to queue

2023-05-09 Thread Rohan McLure
' attribute is guaranteed to terminate prior to the node being visible, KCSAN still complains that the write is reorderable by the compiler. Issue a kcsan_release() to inform KCSAN of the release barrier contained in publish_tail_cpu(). Signed-off-by: Rohan McLure --- v2: Remove extraneous compiler

[PATCH v2 00/11] powerpc: KCSAN fix warnings and mark accesses

2023-05-09 Thread Rohan McLure
ower_save callback to remove instrumentation, as there is no real data race Rohan McLure (11): powerpc: qspinlock: Mark accesses to qnode lock checks powerpc: qspinlock: Enforce qnode writes prior to publishing to queue asm-generic/mmiowb: Mark accesses to fix KCSAN warnings powerpc: Mark [h]

Re: [PATCH 07/12] powerpc: powernv: Fix KCSAN datarace warnings on idle_state contention

2023-05-09 Thread Rohan McLure
> On 9 May 2023, at 12:26 pm, Nicholas Piggin wrote: > > On Mon May 8, 2023 at 12:01 PM AEST, Rohan McLure wrote: >> The idle_state entry in the PACA on PowerNV features a bit which is >> atomically tested and set through ldarx/stdcx. to be used as a spinlock. >> T

Re: [PATCH 03/12] powerpc: qspinlock: Enforce qnode writes prior to publishing to queue

2023-05-08 Thread Rohan McLure
> On 9 May 2023, at 12:04 pm, Nicholas Piggin wrote: > > On Mon May 8, 2023 at 12:01 PM AEST, Rohan McLure wrote: >> Use a compiler barrier to enforce that all fields of a new struct qnode >> be written to (especially the lock value) before publishing the qnod

Re: [PATCH 01/12] powerpc: qspinlock: Fix qnode->locked value interpretation

2023-05-08 Thread Rohan McLure
> On 9 May 2023, at 12:01 pm, Nicholas Piggin wrote: > > On Mon May 8, 2023 at 12:01 PM AEST, Rohan McLure wrote: >> A comment accompanying the locked attribute of a qnode assigns a value >> of 1 to mean that the lock has been acquired. The usages of this >> varia

[PATCH 10/12] powerpc: powernv: Annotate data races in opal events

2023-05-07 Thread Rohan McLure
it is aware of when it is scheduled. Also removes extraneous KCSAN warnings. Signed-off-by: Rohan McLure --- arch/powerpc/platforms/powernv/opal-irqchip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/powernv/opal-irqchip.c b/arch/powerpc/platforms

[PATCH 02/12] powerpc: qspinlock: Mark accesses to qnode lock checks

2023-05-07 Thread Rohan McLure
The powerpc implemenation of qspinlocks will both poll and spin on the bitlock guarding a qnode. Mark these accesses with READ_ONCE to convey to KCSAN that polling is intentional here. Signed-off-by: Rohan McLure --- arch/powerpc/lib/qspinlock.c | 4 ++-- 1 file changed, 2 insertions(+), 2

[PATCH 06/12] powerpc: Mark accesses to power_save callback in arch_cpu_idle

2023-05-07 Thread Rohan McLure
is acceptable, as well as to rule-out the possibility for compiler reorderings leading to calling a null pointer. Signed-off-by: Rohan McLure --- arch/powerpc/kernel/idle.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c

[PATCH 11/12] powerpc: powernv: Annotate asynchronous access to opal tokens

2023-05-07 Thread Rohan McLure
The opal-async.c unit contains code for polling event sources, which implies intentional data races. Ensure that the compiler will atomically access such variables by means of {READ,WRITE}_ONCE calls, which in turn inform KCSAN that polling behaviour is intended. Signed-off-by: Rohan McLure

[PATCH 05/12] powerpc: Mark [h]ssr_valid accesses in check_return_regs_valid

2023-05-07 Thread Rohan McLure
and writes, but annotate with data_race. Signed-off-by: Rohan McLure Reported-by: Michael Ellerman --- arch/powerpc/include/asm/ptrace.h | 4 ++-- arch/powerpc/kernel/interrupt.c | 14 ++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/include/asm/ptrace.h b

[PATCH 12/12] powerpc: Mark asynchronous accesses to irq_data

2023-05-07 Thread Rohan McLure
ngs. Signed-off-by: Rohan McLure --- arch/powerpc/kernel/irq.c | 2 +- arch/powerpc/platforms/powernv/pci-ioda.c | 12 ++-- include/linux/irq.h | 2 +- kernel/irq/irqdomain.c| 4 ++-- 4 files changed, 10 insertions(+), 10 deleti

[PATCH 08/12] powerpc: Annotate accesses to ipi message flags

2023-05-07 Thread Rohan McLure
is expected. Signed-off-by: Rohan McLure --- arch/powerpc/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 6b90f10a6c81..00b74d66b771 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c

[PATCH 00/12] powerpc: KCSAN fix warnings and mark accesses

2023-05-07 Thread Rohan McLure
qspinlock interpretation to reflect the comment beside this field Rohan McLure (12): powerpc: qspinlock: Fix qnode->locked value interpretation powerpc: qspinlock: Mark accesses to qnode lock checks powerpc: qspinlock: Enforce qnode writes prior to publishing to queue asm-generic/

[PATCH 09/12] powerpc: Mark writes registering ipi to host cpu through kvm

2023-05-07 Thread Rohan McLure
Mark writes to hypervisor ipi state so that KCSAN recognises these asynchronous issue of kvmppc_{set,clear}_host_ipi to be intended, with atomic writes. Signed-off-by: Rohan McLure --- arch/powerpc/include/asm/kvm_ppc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git

[PATCH 07/12] powerpc: powernv: Fix KCSAN datarace warnings on idle_state contention

2023-05-07 Thread Rohan McLure
-by: Rohan McLure --- arch/powerpc/include/asm/paca.h | 1 + arch/powerpc/platforms/powernv/idle.c | 20 +++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h index da0377f46597..cb325938766a

[PATCH 03/12] powerpc: qspinlock: Enforce qnode writes prior to publishing to queue

2023-05-07 Thread Rohan McLure
Use a compiler barrier to enforce that all fields of a new struct qnode be written to (especially the lock value) before publishing the qnode to the waitqueue. Signed-off-by: Rohan McLure --- arch/powerpc/lib/qspinlock.c | 4 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/lib

[PATCH 04/12] asm-generic/mmiowb: Mark accesses to fix KCSAN warnings

2023-05-07 Thread Rohan McLure
memory accesses with READ_ONCE or WRITE_ONCE, including increments and decrements to nesting_count. This has the effect of removing KCSAN warnings at consumer's callsites. Signed-off-by: Rohan McLure Reported-by: Michael Ellerman Reported-by: Gautam Menghani --- include/asm-generic/mmiowb.h | 17

[PATCH 01/12] powerpc: qspinlock: Fix qnode->locked value interpretation

2023-05-07 Thread Rohan McLure
A comment accompanying the locked attribute of a qnode assigns a value of 1 to mean that the lock has been acquired. The usages of this variable however assume opposite semantics. Update usages so that the assertions of this comment are reflected in this file. Signed-off-by: Rohan McLure

Re: [PATCH v8 0/7] Support page table check

2023-03-29 Thread Rohan McLure
Anyone got time to review this one? > On 16 Feb 2023, at 10:11 am, Rohan McLure 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

Re: [PATCH 1/2] kcsan: xtensa: Add atomic builtin stubs for 32-bit systems

2023-02-16 Thread Rohan McLure
> On 16 Feb 2023, at 7:09 pm, Marco Elver wrote: > > On Thu, Feb 16, 2023 at 07:12AM +, Christophe Leroy wrote: >> >> >> Le 16/02/2023 à 06:09, Rohan McLure a écrit : >>> KCSAN instruments calls to atomic builtins, and will in turn call these >>

Re: [PATCH 2/2] powerpc/{32,book3e}: kcsan: Extend KCSAN Support

2023-02-16 Thread Rohan McLure
> On 16 Feb 2023, at 6:14 pm, Christophe Leroy > wrote: > > > > Le 16/02/2023 à 06:09, Rohan McLure a écrit : >> Enable HAVE_ARCH_KCSAN on all powerpc platforms, permitting use of the >> kernel concurrency sanitiser through the CONFIG_KCSAN_* kconfig options. >

[PATCH 1/2] kcsan: xtensa: Add atomic builtin stubs for 32-bit systems

2023-02-15 Thread Rohan McLure
, and use BUG() to assert unreachability. In commit 725aea873261 ("xtensa: enable KCSAN"), xtensa implements these locally. Move these definitions to be accessible to all 32-bit architectures that do not provide the necessary builtins, with opt in for PowerPC and xtensa. Signed-off-by: Ro

[PATCH 2/2] powerpc/{32,book3e}: kcsan: Extend KCSAN Support

2023-02-15 Thread Rohan McLure
-by: Rohan McLure --- New patch --- arch/powerpc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 2c9cdf1d8761..45771448d47a 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -197,7 +197,7 @@ config PPC

[PATCH v8 7/7] powerpc: mm: Support page table check

2023-02-15 Thread Rohan McLure
rm64/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") x86_64 in commit d283d422c6c4 ("x86: mm: add x86_64 support for page table check") Reviewed-by: Christophe Leroy Signed-off-by: Rohan McLure --- V2: Update spacing and types assigned to pte_update calls. V3: Update one last pte_update call

[PATCH v8 6/7] powerpc: mm: Add p{te,md,ud}_user_accessible_page helpers

2023-02-15 Thread Rohan McLure
for Book3S/nohash 32-bit systems. Reviewed-by: Christophe Leroy Signed-off-by: Rohan McLure --- V2: Provide missing pud_user implementations, use p{u,m}d_is_leaf. V3: Provide missing pmd_user implementations as stubs in 32-bit. V4: Use pmd_leaf, pud_leaf, and define pmd_user for 32 Book3E with static

[PATCH v8 5/7] powerpc: mm: Add common pud_pfn stub for all platforms

2023-02-15 Thread Rohan McLure
. Signed-off-by: Rohan McLure --- V2: Remove conditional BUILD_BUG and BUG. Instead warn on usage. V3: Replace WARN with WARN_ONCE, which should suffice to demonstrate misuse of puds. --- arch/powerpc/include/asm/book3s/64/pgtable.h | 10 -- arch/powerpc/include/asm/pgtable.h | 14

[PATCH v8 4/7] powerpc: mm: Implement p{m,u,4}d_leaf on all platforms

2023-02-15 Thread Rohan McLure
. Reviewed-by: Christophe Leroy Signed-off-by: Rohan McLure --- v5: Split patch that replaces p{m,u,4}d_is_leaf into two patches, first replacing callsites and afterward providing generic definition. Remove ifndef-defines implementing p{m,u}d_leaf in favour of implementing stubs in headers

[PATCH v8 3/7] powerpc: mm: Replace p{u,m,4}d_is_leaf with p{u,m,4}_leaf

2023-02-15 Thread Rohan McLure
that they may be referenced in generic code. Reviewed-by: Christophe Leroy Signed-off-by: Rohan McLure --- V4: New patch V5: Previously replaced stub definition for *_is_leaf with *_leaf. Do that in a later patch --- arch/powerpc/kvm/book3s_64_mmu_radix.c | 12 ++-- arch/powerpc/mm/book3s64

[PATCH v8 2/7] powerpc/64s: mm: Introduce __pmdp_collapse_flush with mm_struct argument

2023-02-15 Thread Rohan McLure
the vma and calls __pmdp_collapse_flush. The mm_struct * parameter is needed in a future patch providing Page Table Check support, which is defined in terms of mm context objects. Signed-off-by: Rohan McLure --- v6: New patch v7: Remove explicit `return' in macro. Prefix macro args with __ --- arch

[PATCH v8 1/7] powerpc: mm: Separate set_pte, set_pte_at for internal, external use

2023-02-15 Thread Rohan McLure
not to be, permitting for uninstrumented internal mappings. This distinction in names is also present in x86. Reviewed-by: Christophe Leroy Signed-off-by: Rohan McLure --- v6: new patch v7: Remove extern, move set_pte args to be in a single line. --- arch/powerpc/include/asm/book3s/pgtable.h | 3

[PATCH v8 0/7] Support page table check

2023-02-15 Thread Rohan McLure
...@linux.ibm.com/ v5: Link: https://lore.kernel.org/linuxppc-dev/20221118002146.25979-1-rmcl...@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

  1   2   3   4   >