[PATCH v2] Add static_key_feature_checks_initialized flag

2024-04-07 Thread Nicholas Miehlbradt
this by the call to jump_label_init() in early_init_devtree(). This creates a window in which JUMP_LABEL_FEATURE_CHECK_DEBUG will not detect misuse and report errors. Add a flag specifically to indicate when {cpu,mmu}_has_feature() is safe to use. Signed-off-by: Nicholas Miehlbradt --- v2: Reword commit message

Re: [PATCH] Add static_key_feature_checks_initialized flag

2024-04-01 Thread Nicholas Miehlbradt
On 28/3/2024 2:20 am, Christophe Leroy wrote: Le 27/03/2024 à 05:59, Nicholas Miehlbradt a écrit : JUMP_LABEL_FEATURE_CHECK_DEBUG used static_key_initialized to determine whether {cpu,mmu}_has_feature() was used before static keys were initialized. However, {cpu,mmu}_has_feature() should

Re: [PATCH] Add static_key_feature_checks_initialized flag

2024-04-01 Thread Nicholas Miehlbradt
On 28/3/2024 2:20 am, Christophe Leroy wrote: Le 27/03/2024 à 05:59, Nicholas Miehlbradt a écrit : JUMP_LABEL_FEATURE_CHECK_DEBUG used static_key_initialized to determine whether {cpu,mmu}_has_feature() was used before static keys were initialized. However, {cpu,mmu}_has_feature() should

[PATCH] Add static_key_feature_checks_initialized flag

2024-03-26 Thread Nicholas Miehlbradt
there is a window in which JUMP_LABEL_FEATURE_CHECK_DEBUG will not report errors. Add a flag specifically to indicate when {cpu,mmu}_has_feature() is safe to use. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/include/asm/cpu_has_feature.h | 2 +- arch/powerpc/include/asm/feature-fixups.h

Re: [PATCH 09/13] powerpc: Disable KMSAN checks on functions which walk the stack

2024-01-09 Thread Nicholas Miehlbradt
On 14/12/2023 8:00 pm, Christophe Leroy wrote: Le 14/12/2023 à 06:55, Nicholas Miehlbradt a écrit : Functions which walk the stack read parts of the stack which cannot be instrumented by KMSAN e.g. the backchain. Disable KMSAN sanitization of these functions to prevent false positives

Re: [PATCH 12/13] powerpc/string: Add KMSAN support

2024-01-09 Thread Nicholas Miehlbradt
On 14/12/2023 8:25 pm, Christophe Leroy wrote: Le 14/12/2023 à 06:55, Nicholas Miehlbradt a écrit : KMSAN expects functions __mem{set,cpy,move} so add aliases pointing to the respective functions. Disable use of architecture specific memset{16,32,64} to ensure that metadata is correctly

Re: [PATCH 10/13] powerpc: Define KMSAN metadata address ranges for vmalloc and ioremap

2024-01-09 Thread Nicholas Miehlbradt
On 14/12/2023 8:17 pm, Christophe Leroy wrote: Le 14/12/2023 à 06:55, Nicholas Miehlbradt a écrit : Splits the vmalloc region into four. The first quarter is the new vmalloc region, the second is used to store shadow metadata and the third is used to store origin metadata. The fourth

[PATCH 01/13] kmsan: Export kmsan_handle_dma

2023-12-13 Thread Nicholas Miehlbradt
kmsan_handle_dma is required by virtio drivers. Export kmsan_handle_dma so that the drivers can be compiled as modules. Signed-off-by: Nicholas Miehlbradt --- mm/kmsan/hooks.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/kmsan/hooks.c b/mm/kmsan/hooks.c index 7a30274b893c

[PATCH 05/13] powerpc: Unpoison buffers populated by hcalls

2023-12-13 Thread Nicholas Miehlbradt
plpar_hcall provides to the hypervisor a buffer where return data should be placed. The hypervisor initializes the buffers which is not visible to KMSAN so unpoison them manually. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/platforms/pseries/hvconsole.c | 2 ++ arch/powerpc/sysdev/xive

[PATCH 07/13] powerpc/kprobes: Unpoison instruction in kprobe struct

2023-12-13 Thread Nicholas Miehlbradt
KMSAN does not unpoison the ainsn field of a kprobe struct correctly. Manually unpoison it to prevent false positives. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/kernel/kprobes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel

[PATCH 10/13] powerpc: Define KMSAN metadata address ranges for vmalloc and ioremap

2023-12-13 Thread Nicholas Miehlbradt
(CONFIG_PPC32). Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/include/asm/book3s/64/pgtable.h | 42 arch/powerpc/kernel/module.c | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch

[PATCH 11/13] powerpc: Implement architecture specific KMSAN interface

2023-12-13 Thread Nicholas Miehlbradt
higher than this. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/include/asm/kmsan.h | 44 1 file changed, 44 insertions(+) create mode 100644 arch/powerpc/include/asm/kmsan.h diff --git a/arch/powerpc/include/asm/kmsan.h b/arch/powerpc/include/asm/kmsan.h new

[PATCH 06/13] powerpc/pseries/nvram: Unpoison buffer populated by rtas_call

2023-12-13 Thread Nicholas Miehlbradt
rtas_call provides a buffer where the return data should be placed. Rtas initializes the buffer which is not visible to KMSAN so unpoison it manually. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/platforms/pseries/nvram.c | 4 1 file changed, 4 insertions(+) diff --git a/arch

[PATCH 12/13] powerpc/string: Add KMSAN support

2023-12-13 Thread Nicholas Miehlbradt
be instrumented to propagate/check metadata. Alias calls to mem{set,cpy,move} to __msan_mem{set,cpy,move} in instrumented code to correctly propagate metadata. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/include/asm/kmsan.h | 7 +++ arch/powerpc/include/asm/string.h

[PATCH 13/13] powerpc: Enable KMSAN on powerpc

2023-12-13 Thread Nicholas Miehlbradt
Enable KMSAN in the Kconfig. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index e33e3250c478..71cc7d2a0a72 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -217,6 +217,7

[PATCH 08/13] powerpc: Unpoison pt_regs

2023-12-13 Thread Nicholas Miehlbradt
pt_regs is initialized ppc_save_regs which is implemented in assembly and therefore does not mark the struct as initialized. Unpoison it so that it will not generate false positives. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/include/asm/interrupt.h | 2 ++ arch/powerpc/kernel/irq_64.c

[PATCH 09/13] powerpc: Disable KMSAN checks on functions which walk the stack

2023-12-13 Thread Nicholas Miehlbradt
Functions which walk the stack read parts of the stack which cannot be instrumented by KMSAN e.g. the backchain. Disable KMSAN sanitization of these functions to prevent false positives. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/kernel/process.c| 6 +++--- arch/powerpc/kernel

[PATCH 00/13] kmsan: Enable on powerpc

2023-12-13 Thread Nicholas Miehlbradt
] https://lore.kernel.org/linux-mm/20231121220155.1217090-1-...@linux.ibm.com/ [3] https://lore.kernel.org/linux-rtc/20231129073647.2624497-1-nicho...@linux.ibm.com/ Nicholas Miehlbradt (13): kmsan: Export kmsan_handle_dma hvc: Fix use of uninitialized array in udbg_hvc_putc powerpc: Disable

[PATCH 02/13] hvc: Fix use of uninitialized array in udbg_hvc_putc

2023-12-13 Thread Nicholas Miehlbradt
All elements of bounce_buffer are eventually read and passed to the hypervisor so it should probably be fully initialized. Signed-off-by: Nicholas Miehlbradt --- drivers/tty/hvc/hvc_vio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/hvc/hvc_vio.c b/drivers/tty

[PATCH 03/13] powerpc: Disable KMSAN santitization for prom_init, vdso and purgatory

2023-12-13 Thread Nicholas Miehlbradt
Other sanitizers are disabled for these, disable KMSAN too. prom_init.o can only reference a limited set of external symbols. KMSAN adds additional references which are not permitted so disable sanitization. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/kernel/Makefile | 2 ++ arch

[PATCH 04/13] powerpc: Disable CONFIG_DCACHE_WORD_ACCESS when KMSAN is enabled

2023-12-13 Thread Nicholas Miehlbradt
Word sized accesses may read uninitialized data when optimizing loads. Disable this optimization when KMSAN is enabled to prevent false positives. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/Kconfig

[PATCH v3] powerpc: Implement arch_within_stack_frames

2023-02-27 Thread Nicholas Miehlbradt
boundaries. Signed-off-by: Nicholas Miehlbradt --- v3: Move STACK_FRAME_PARAMS macros to ppc_asm.h Add diagram in comments to show position of pointers into the stack during execution v2: Rename PARAMETER_SAVE_OFFSET to STACK_FRAME_PARAMS Add definitions of STACK_FRAME_PARAMS for PPC32

[PATCH v2] powerpc: Implement arch_within_stack_frames

2023-01-18 Thread Nicholas Miehlbradt
-by: Nicholas Miehlbradt --- v2: Rename PARAMETER_SAVE_OFFSET to STACK_FRAME_PARAMS Add definitions of STACK_FRAME_PARAMS for PPC32 and remove dependancy on PPC64 Ignore the current stack frame and start with it's parent, similar to x86 v1: https://lore.kernel.org/linuxppc-dev

Re: [PATCH] powerpc/64: Implement arch_within_stack_frames

2022-12-18 Thread Nicholas Miehlbradt
On 14/12/2022 10:39 pm, Nicholas Piggin wrote: On Wed Dec 14, 2022 at 6:39 PM AEST, Christophe Leroy wrote: Le 14/12/2022 à 05:42, Nicholas Miehlbradt a écrit : Walks the stack when copy_{to,from}_user address is in the stack to ensure that the object being copied is entirely within

[PATCH] powerpc/64: Implement arch_within_stack_frames

2022-12-13 Thread Nicholas Miehlbradt
-by: Nicholas Miehlbradt --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/thread_info.h | 38 ++ 2 files changed, 39 insertions(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 2ca5418457ed..4c59d139ea83 100644 --- a/arch/powerpc

[PATCH v3 2/4] powerpc/64s: Remove unneeded #ifdef CONFIG_DEBUG_PAGEALLOC in hash_utils

2022-09-26 Thread Nicholas Miehlbradt
-by: Christophe Leroy Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/mm/book3s64/hash_utils.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index fc92613dc2bf..e63ff401a6ea 100644

[PATCH v3 4/4] powerpc/64s: Enable KFENCE on book3s64

2022-09-26 Thread Nicholas Miehlbradt
NCE memory is initially allocated using memblock but is later marked as SLAB allocated. This necessitates the change to __pud_free to ensure that the KFENCE pages are freed appropriately. Based on previous work by Christophe Leroy and Jordan Niethe. Signed-off-by: Nicholas Miehlbradt --- v2: Refactor v3:

[PATCH v3 3/4] powerpc/64s: Allow double call of kernel_[un]map_linear_page()

2022-09-26 Thread Nicholas Miehlbradt
From: Christophe Leroy If the page is already mapped resp. already unmapped, bail out. Signed-off-by: Christophe Leroy Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/mm/book3s64/hash_utils.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm

[PATCH v3 1/4] powerpc/64s: Add DEBUG_PAGEALLOC for radix

2022-09-26 Thread Nicholas Miehlbradt
There is support for DEBUG_PAGEALLOC on hash but not on radix. Add support on radix. Signed-off-by: Nicholas Miehlbradt --- v2: Revert change to radix_memory_block_size, instead set the size in radix_init_pgtable and radix__create_section_mapping directly. v3: Remove max_mapping_size argument

[PATCH v2 3/4] powerpc/64s: Allow double call of kernel_[un]map_linear_page()

2022-09-20 Thread Nicholas Miehlbradt
From: Christophe Leroy If the page is already mapped resp. already unmapped, bail out. Signed-off-by: Christophe Leroy Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/mm/book3s64/hash_utils.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm

[PATCH v2 4/4] powerpc/64s: Enable KFENCE on book3s64

2022-09-20 Thread Nicholas Miehlbradt
NCE memory is initially allocated using memblock but is later marked as SLAB allocated. This necessitates the change to __pud_free to ensure that the KFENCE pages are freed appropriately. Based on previous work by Christophe Leroy and Jordan Niethe. Signed-off-by: Nicholas Miehlbradt --- v2: Refactor

[PATCH v2 2/4] powerpc/64s: Remove unneeded #ifdef CONFIG_DEBUG_PAGEALLOC in hash_utils

2022-09-20 Thread Nicholas Miehlbradt
-by: Christophe Leroy Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/mm/book3s64/hash_utils.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index fc92613dc2bf..e63ff401a6ea 100644

[PATCH v2 1/4] powerpc/64s: Add DEBUG_PAGEALLOC for radix

2022-09-20 Thread Nicholas Miehlbradt
There is support for DEBUG_PAGEALLOC on hash but not on radix. Add support on radix. Signed-off-by: Nicholas Miehlbradt --- v2: Revert change to radix_memory_block_size, instead set the size in radix_init_pgtable and radix__create_section_mapping directly. --- arch/powerpc/mm/book3s64

[PATCH 3/4] powerpc/64s: Allow double call of kernel_[un]map_linear_page()

2022-09-18 Thread Nicholas Miehlbradt
From: Christophe Leroy If the page is already mapped resp. already unmapped, bail out. Signed-off-by: Christophe Leroy Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/mm/book3s64/hash_utils.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm

[PATCH 2/4] powerpc/64s: Remove unneeded #ifdef CONFIG_DEBUG_PAGEALLOC in hash_utils

2022-09-18 Thread Nicholas Miehlbradt
-by: Christophe Leroy Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/mm/book3s64/hash_utils.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index fc92613dc2bf..e63ff401a6ea 100644

[PATCH 4/4] powerpc/64s: Enable KFENCE on book3s64

2022-09-18 Thread Nicholas Miehlbradt
NCE memory is initially allocated using memblock but is later marked as SLAB allocated. This necessitates the change to __pud_free to ensure that the KFENCE pages are freed appropriately. Based on previous work by Christophe Leroy and Jordan Niethe. Signed-off-by: Nicholas Miehlbradt --- arch/power

[PATCH 1/4] powerpc/64s: Add DEBUG_PAGEALLOC for radix

2022-09-18 Thread Nicholas Miehlbradt
There is support for DEBUG_PAGEALLOC on hash but not on radix. Add support on radix. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/mm/book3s64/radix_pgtable.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b

Re: [PATCH v4 2/2] selftests/powerpc: Add a test for execute-only memory

2022-08-18 Thread Nicholas Miehlbradt
On 17/8/2022 4:15 pm, Jordan Niethe wrote: On Wed, 2022-08-17 at 15:06 +1000, Russell Currey wrote: From: Nicholas Miehlbradt This selftest is designed to cover execute-only protections on the Radix MMU but will also work with Hash. The tests are based on those found in pkey_exec_test

[PATCH] docs: powerpc: add POWER9 and POWER10 to CPU families

2022-08-09 Thread Nicholas Miehlbradt
Add POWER9 and POWER10 to CPU families and list Radix MMU. Signed-off-by: Nicholas Miehlbradt --- Documentation/powerpc/cpu_families.rst | 13 + 1 file changed, 13 insertions(+) diff --git a/Documentation/powerpc/cpu_families.rst b/Documentation/powerpc/cpu_families.rst index