linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/8] powerpc/32s: Allocate modules outside of vmalloc space for STRICT_KERNEL_RWX
@ 2020-06-19 15:06 Christophe Leroy
  2020-06-19 15:06 ` [PATCH v1 1/8] powerpc/ptdump: Refactor update of st->last_pa Christophe Leroy
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Christophe Leroy @ 2020-06-19 15:06 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

On book3s32 (hash), exec protection is set per 256Mb segments with NX bit.
Instead of clearing NX bit on vmalloc space when CONFIG_MODULES is selected,
allocate modules in a dedicated segment (0xb0000000-0xbfffffff by default).
This allows to keep exec protection on vmalloc space while allowing exec
on modules.

Christophe Leroy (8):
  powerpc/ptdump: Refactor update of st->last_pa
  powerpc/ptdump: Refactor update of pg_state
  powerpc: Set user/kernel boundary at TASK_SIZE instead of PAGE_OFFSET
  powerpc/lib: Prepare code-patching for modules allocated outside
    vmalloc space
  powerpc: Use MODULES_VADDR if defined
  powerpc/32s: Only leave NX unset on segments used for modules
  powerpc/32s: Kernel space starts at TASK_SIZE
  powerpc/32s: Use dedicated segment for modules with STRICT_KERNEL_RWX

 arch/powerpc/Kconfig                         |  1 +
 arch/powerpc/include/asm/book3s/32/pgtable.h | 15 ++----
 arch/powerpc/include/asm/page.h              |  2 +-
 arch/powerpc/kernel/head_32.S                | 12 ++---
 arch/powerpc/kernel/module.c                 | 11 ++++
 arch/powerpc/lib/code-patching.c             |  2 +-
 arch/powerpc/mm/book3s32/hash_low.S          |  2 +-
 arch/powerpc/mm/book3s32/mmu.c               | 17 +++++--
 arch/powerpc/mm/kasan/kasan_init_32.c        |  6 +++
 arch/powerpc/mm/ptdump/ptdump.c              | 53 ++++++++++++--------
 10 files changed, 78 insertions(+), 43 deletions(-)

-- 
2.25.0


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

* [PATCH v1 1/8] powerpc/ptdump: Refactor update of st->last_pa
  2020-06-19 15:06 [PATCH v1 0/8] powerpc/32s: Allocate modules outside of vmalloc space for STRICT_KERNEL_RWX Christophe Leroy
@ 2020-06-19 15:06 ` Christophe Leroy
  2020-06-19 15:06 ` [PATCH v1 2/8] powerpc/ptdump: Refactor update of pg_state Christophe Leroy
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2020-06-19 15:06 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

st->last_pa is always updated in note_page() so it can
be done outside the if/elseif/else block.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/mm/ptdump/ptdump.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdump.c
index de6e05ef871c..d5e42b958e86 100644
--- a/arch/powerpc/mm/ptdump/ptdump.c
+++ b/arch/powerpc/mm/ptdump/ptdump.c
@@ -207,7 +207,6 @@ static void note_page(struct pg_state *st, unsigned long addr,
 		st->current_flags = flag;
 		st->start_address = addr;
 		st->start_pa = pa;
-		st->last_pa = pa;
 		st->page_size = page_size;
 		pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
 	/*
@@ -247,13 +246,11 @@ static void note_page(struct pg_state *st, unsigned long addr,
 		}
 		st->start_address = addr;
 		st->start_pa = pa;
-		st->last_pa = pa;
 		st->page_size = page_size;
 		st->current_flags = flag;
 		st->level = level;
-	} else {
-		st->last_pa = pa;
 	}
+	st->last_pa = pa;
 }
 
 static void walk_pte(struct pg_state *st, pmd_t *pmd, unsigned long start)
-- 
2.25.0


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

* [PATCH v1 2/8] powerpc/ptdump: Refactor update of pg_state
  2020-06-19 15:06 [PATCH v1 0/8] powerpc/32s: Allocate modules outside of vmalloc space for STRICT_KERNEL_RWX Christophe Leroy
  2020-06-19 15:06 ` [PATCH v1 1/8] powerpc/ptdump: Refactor update of st->last_pa Christophe Leroy
@ 2020-06-19 15:06 ` Christophe Leroy
  2020-06-19 15:06 ` [PATCH v1 3/8] powerpc: Set user/kernel boundary at TASK_SIZE instead of PAGE_OFFSET Christophe Leroy
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2020-06-19 15:06 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

In note_page(), the pg_state is updated the same way in two places.

Add note_page_update_state() to do it.

Also include the display of boundary markers there as it is missing
"no level" leg, leading to a mismatch when the first two markers
are at the same address and the first displayed area uses that
address.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/mm/ptdump/ptdump.c | 34 +++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdump.c
index d5e42b958e86..b71cc628facd 100644
--- a/arch/powerpc/mm/ptdump/ptdump.c
+++ b/arch/powerpc/mm/ptdump/ptdump.c
@@ -195,6 +195,24 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr)
 	st->wx_pages += (addr - st->start_address) / PAGE_SIZE;
 }
 
+static void note_page_update_state(struct pg_state *st, unsigned long addr,
+				   unsigned int level, u64 val, unsigned long page_size)
+{
+	u64 flag = val & pg_level[level].mask;
+	u64 pa = val & PTE_RPN_MASK;
+
+	st->level = level;
+	st->current_flags = flag;
+	st->start_address = addr;
+	st->start_pa = pa;
+	st->page_size = page_size;
+
+	while (addr >= st->marker[1].start_address) {
+		st->marker++;
+		pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
+	}
+}
+
 static void note_page(struct pg_state *st, unsigned long addr,
 	       unsigned int level, u64 val, unsigned long page_size)
 {
@@ -203,12 +221,8 @@ static void note_page(struct pg_state *st, unsigned long addr,
 
 	/* At first no level is set */
 	if (!st->level) {
-		st->level = level;
-		st->current_flags = flag;
-		st->start_address = addr;
-		st->start_pa = pa;
-		st->page_size = page_size;
 		pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
+		note_page_update_state(st, addr, level, val, page_size);
 	/*
 	 * Dump the section of virtual memory when:
 	 *   - the PTE flags from one entry to the next differs.
@@ -240,15 +254,7 @@ static void note_page(struct pg_state *st, unsigned long addr,
 		 * Address indicates we have passed the end of the
 		 * current section of virtual memory
 		 */
-		while (addr >= st->marker[1].start_address) {
-			st->marker++;
-			pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
-		}
-		st->start_address = addr;
-		st->start_pa = pa;
-		st->page_size = page_size;
-		st->current_flags = flag;
-		st->level = level;
+		note_page_update_state(st, addr, level, val, page_size);
 	}
 	st->last_pa = pa;
 }
-- 
2.25.0


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

* [PATCH v1 3/8] powerpc: Set user/kernel boundary at TASK_SIZE instead of PAGE_OFFSET
  2020-06-19 15:06 [PATCH v1 0/8] powerpc/32s: Allocate modules outside of vmalloc space for STRICT_KERNEL_RWX Christophe Leroy
  2020-06-19 15:06 ` [PATCH v1 1/8] powerpc/ptdump: Refactor update of st->last_pa Christophe Leroy
  2020-06-19 15:06 ` [PATCH v1 2/8] powerpc/ptdump: Refactor update of pg_state Christophe Leroy
@ 2020-06-19 15:06 ` Christophe Leroy
  2020-06-20 11:25   ` kernel test robot
  2020-06-20 11:33   ` kernel test robot
  2020-06-19 15:06 ` [PATCH v1 4/8] powerpc/lib: Prepare code-patching for modules allocated outside vmalloc space Christophe Leroy
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 11+ messages in thread
From: Christophe Leroy @ 2020-06-19 15:06 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

User space stops at TASK_SIZE. At the moment, kernel space starts
at PAGE_OFFSET.

In order to use space between TASK_SIZE and PAGE_OFFSET for modules,
make TASK_SIZE the limit between user and kernel space.

Note that fault.c already considers TASK_SIZE as the boundary between
user and kernel space.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/include/asm/page.h | 2 +-
 arch/powerpc/mm/ptdump/ptdump.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index a63fe6f3a0ff..352a2b80d505 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -256,7 +256,7 @@ static inline bool pfn_valid(unsigned long pfn)
 #ifdef CONFIG_PPC_BOOK3E_64
 #define is_kernel_addr(x)	((x) >= 0x8000000000000000ul)
 #else
-#define is_kernel_addr(x)	((x) >= PAGE_OFFSET)
+#define is_kernel_addr(x)	((x) >= TASK_SIZE)
 #endif
 
 #ifndef CONFIG_PPC_BOOK3S_64
diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdump.c
index b71cc628facd..e995f2e9e9f7 100644
--- a/arch/powerpc/mm/ptdump/ptdump.c
+++ b/arch/powerpc/mm/ptdump/ptdump.c
@@ -351,7 +351,7 @@ static void populate_markers(void)
 {
 	int i = 0;
 
-	address_markers[i++].start_address = PAGE_OFFSET;
+	address_markers[i++].start_address = TASK_SIZE;
 	address_markers[i++].start_address = VMALLOC_START;
 	address_markers[i++].start_address = VMALLOC_END;
 #ifdef CONFIG_PPC64
@@ -388,7 +388,7 @@ static int ptdump_show(struct seq_file *m, void *v)
 	struct pg_state st = {
 		.seq = m,
 		.marker = address_markers,
-		.start_address = PAGE_OFFSET,
+		.start_address = TASK_SIZE,
 	};
 
 #ifdef CONFIG_PPC64
@@ -432,7 +432,7 @@ void ptdump_check_wx(void)
 		.seq = NULL,
 		.marker = address_markers,
 		.check_wx = true,
-		.start_address = PAGE_OFFSET,
+		.start_address = TASK_SIZE,
 	};
 
 #ifdef CONFIG_PPC64
-- 
2.25.0


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

* [PATCH v1 4/8] powerpc/lib: Prepare code-patching for modules allocated outside vmalloc space
  2020-06-19 15:06 [PATCH v1 0/8] powerpc/32s: Allocate modules outside of vmalloc space for STRICT_KERNEL_RWX Christophe Leroy
                   ` (2 preceding siblings ...)
  2020-06-19 15:06 ` [PATCH v1 3/8] powerpc: Set user/kernel boundary at TASK_SIZE instead of PAGE_OFFSET Christophe Leroy
@ 2020-06-19 15:06 ` Christophe Leroy
  2020-06-19 15:06 ` [PATCH v1 5/8] powerpc: Use MODULES_VADDR if defined Christophe Leroy
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2020-06-19 15:06 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

Use is_vmalloc_or_module_addr() instead of is_vmalloc_addr()

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/lib/code-patching.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index 0a051dfeb177..8c3934ea6220 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -93,7 +93,7 @@ static int map_patch_area(void *addr, unsigned long text_poke_addr)
 	unsigned long pfn;
 	int err;
 
-	if (is_vmalloc_addr(addr))
+	if (is_vmalloc_or_module_addr(addr))
 		pfn = vmalloc_to_pfn(addr);
 	else
 		pfn = __pa_symbol(addr) >> PAGE_SHIFT;
-- 
2.25.0


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

* [PATCH v1 5/8] powerpc: Use MODULES_VADDR if defined
  2020-06-19 15:06 [PATCH v1 0/8] powerpc/32s: Allocate modules outside of vmalloc space for STRICT_KERNEL_RWX Christophe Leroy
                   ` (3 preceding siblings ...)
  2020-06-19 15:06 ` [PATCH v1 4/8] powerpc/lib: Prepare code-patching for modules allocated outside vmalloc space Christophe Leroy
@ 2020-06-19 15:06 ` Christophe Leroy
  2020-06-19 15:06 ` [PATCH v1 6/8] powerpc/32s: Only leave NX unset on segments used for modules Christophe Leroy
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2020-06-19 15:06 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

In order to allow allocation of modules outside of vmalloc space,
use MODULES_VADDR and MODULES_END when MODULES_VADDR is defined.

Redefine module_alloc() when MODULES_VADDR defined.
Unmap corresponding KASAN shadow memory.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/kernel/module.c          | 11 +++++++++++
 arch/powerpc/mm/kasan/kasan_init_32.c |  6 ++++++
 2 files changed, 17 insertions(+)

diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c
index df649acb5631..a211b0253cdb 100644
--- a/arch/powerpc/kernel/module.c
+++ b/arch/powerpc/kernel/module.c
@@ -86,3 +86,14 @@ int module_finalize(const Elf_Ehdr *hdr,
 
 	return 0;
 }
+
+#ifdef MODULES_VADDR
+void *module_alloc(unsigned long size)
+{
+	BUILD_BUG_ON(TASK_SIZE > MODULES_VADDR);
+
+	return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, GFP_KERNEL,
+				    PAGE_KERNEL_EXEC, VM_FLUSH_RESET_PERMS, NUMA_NO_NODE,
+				    __builtin_return_address(0));
+}
+#endif
diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c
index 0760e1e754e4..f1bc267d42af 100644
--- a/arch/powerpc/mm/kasan/kasan_init_32.c
+++ b/arch/powerpc/mm/kasan/kasan_init_32.c
@@ -115,6 +115,12 @@ static void __init kasan_unmap_early_shadow_vmalloc(void)
 	unsigned long k_end = (unsigned long)kasan_mem_to_shadow((void *)VMALLOC_END);
 
 	kasan_update_early_region(k_start, k_end, __pte(0));
+
+#ifdef MODULES_VADDR
+	k_start = (unsigned long)kasan_mem_to_shadow((void *)MODULES_VADDR);
+	k_end = (unsigned long)kasan_mem_to_shadow((void *)MODULES_END);
+	kasan_update_early_region(k_start, k_end, __pte(0));
+#endif
 }
 
 static void __init kasan_mmu_init(void)
-- 
2.25.0


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

* [PATCH v1 6/8] powerpc/32s: Only leave NX unset on segments used for modules
  2020-06-19 15:06 [PATCH v1 0/8] powerpc/32s: Allocate modules outside of vmalloc space for STRICT_KERNEL_RWX Christophe Leroy
                   ` (4 preceding siblings ...)
  2020-06-19 15:06 ` [PATCH v1 5/8] powerpc: Use MODULES_VADDR if defined Christophe Leroy
@ 2020-06-19 15:06 ` Christophe Leroy
  2020-06-19 15:06 ` [PATCH v1 7/8] powerpc/32s: Kernel space starts at TASK_SIZE Christophe Leroy
  2020-06-19 15:06 ` [PATCH v1 8/8] powerpc/32s: Use dedicated segment for modules with STRICT_KERNEL_RWX Christophe Leroy
  7 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2020-06-19 15:06 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

Instead of leaving NX unset on all segments above the start
of vmalloc space, only leave NX unset on segments used for
modules.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/mm/book3s32/mmu.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/mm/book3s32/mmu.c b/arch/powerpc/mm/book3s32/mmu.c
index 03b6ba54460e..c0162911f6cb 100644
--- a/arch/powerpc/mm/book3s32/mmu.c
+++ b/arch/powerpc/mm/book3s32/mmu.c
@@ -187,6 +187,17 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)
 	return __mmu_mapin_ram(border, top);
 }
 
+static bool is_module_segment(unsigned long addr)
+{
+	if (!IS_ENABLED(CONFIG_MODULES))
+		return false;
+	if (addr < ALIGN_DOWN(VMALLOC_START, SZ_256M))
+		return false;
+	if (addr >= ALIGN(VMALLOC_END, SZ_256M))
+		return false;
+	return true;
+}
+
 void mmu_mark_initmem_nx(void)
 {
 	int nb = mmu_has_feature(MMU_FTR_USE_HIGH_BATS) ? 8 : 4;
@@ -223,9 +234,9 @@ void mmu_mark_initmem_nx(void)
 
 	for (i = TASK_SIZE >> 28; i < 16; i++) {
 		/* Do not set NX on VM space for modules */
-		if (IS_ENABLED(CONFIG_MODULES) &&
-		    (VMALLOC_START & 0xf0000000) == i << 28)
-			break;
+		if (is_module_segment(i << 28))
+			continue;
+
 		mtsrin(mfsrin(i << 28) | 0x10000000, i << 28);
 	}
 }
-- 
2.25.0


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

* [PATCH v1 7/8] powerpc/32s: Kernel space starts at TASK_SIZE
  2020-06-19 15:06 [PATCH v1 0/8] powerpc/32s: Allocate modules outside of vmalloc space for STRICT_KERNEL_RWX Christophe Leroy
                   ` (5 preceding siblings ...)
  2020-06-19 15:06 ` [PATCH v1 6/8] powerpc/32s: Only leave NX unset on segments used for modules Christophe Leroy
@ 2020-06-19 15:06 ` Christophe Leroy
  2020-06-19 15:06 ` [PATCH v1 8/8] powerpc/32s: Use dedicated segment for modules with STRICT_KERNEL_RWX Christophe Leroy
  7 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2020-06-19 15:06 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

Kernel space starts at TASK_SIZE. Select kernel page table
when address is over TASK_SIZE.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/kernel/head_32.S       | 12 ++++++------
 arch/powerpc/mm/book3s32/hash_low.S |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index 705c042309d8..bbef6ce8322b 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -474,7 +474,7 @@ InstructionTLBMiss:
 	/* Get PTE (linux-style) and check access */
 	mfspr	r3,SPRN_IMISS
 #if defined(CONFIG_MODULES) || defined(CONFIG_DEBUG_PAGEALLOC)
-	lis	r1,PAGE_OFFSET@h		/* check if kernel address */
+	lis	r1, TASK_SIZE@h		/* check if kernel address */
 	cmplw	0,r1,r3
 #endif
 	mfspr	r2, SPRN_SPRG_PGDIR
@@ -484,7 +484,7 @@ InstructionTLBMiss:
 	li	r1,_PAGE_PRESENT | _PAGE_EXEC
 #endif
 #if defined(CONFIG_MODULES) || defined(CONFIG_DEBUG_PAGEALLOC)
-	bge-	112f
+	bgt-	112f
 	lis	r2, (swapper_pg_dir - PAGE_OFFSET)@ha	/* if kernel address, use */
 	addi	r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l	/* kernel page table */
 #endif
@@ -541,7 +541,7 @@ DataLoadTLBMiss:
  */
 	/* Get PTE (linux-style) and check access */
 	mfspr	r3,SPRN_DMISS
-	lis	r1,PAGE_OFFSET@h		/* check if kernel address */
+	lis	r1, TASK_SIZE@h		/* check if kernel address */
 	cmplw	0,r1,r3
 	mfspr	r2, SPRN_SPRG_PGDIR
 #ifdef CONFIG_SWAP
@@ -549,7 +549,7 @@ DataLoadTLBMiss:
 #else
 	li	r1, _PAGE_PRESENT
 #endif
-	bge-	112f
+	bgt-	112f
 	lis	r2, (swapper_pg_dir - PAGE_OFFSET)@ha	/* if kernel address, use */
 	addi	r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l	/* kernel page table */
 112:	rlwimi	r2,r3,12,20,29		/* insert top 10 bits of address */
@@ -621,7 +621,7 @@ DataStoreTLBMiss:
  */
 	/* Get PTE (linux-style) and check access */
 	mfspr	r3,SPRN_DMISS
-	lis	r1,PAGE_OFFSET@h		/* check if kernel address */
+	lis	r1, TASK_SIZE@h		/* check if kernel address */
 	cmplw	0,r1,r3
 	mfspr	r2, SPRN_SPRG_PGDIR
 #ifdef CONFIG_SWAP
@@ -629,7 +629,7 @@ DataStoreTLBMiss:
 #else
 	li	r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT
 #endif
-	bge-	112f
+	bgt-	112f
 	lis	r2, (swapper_pg_dir - PAGE_OFFSET)@ha	/* if kernel address, use */
 	addi	r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l	/* kernel page table */
 112:	rlwimi	r2,r3,12,20,29		/* insert top 10 bits of address */
diff --git a/arch/powerpc/mm/book3s32/hash_low.S b/arch/powerpc/mm/book3s32/hash_low.S
index 923ad8f374eb..1690d369688b 100644
--- a/arch/powerpc/mm/book3s32/hash_low.S
+++ b/arch/powerpc/mm/book3s32/hash_low.S
@@ -62,7 +62,7 @@ _GLOBAL(hash_page)
 	isync
 #endif
 	/* Get PTE (linux-style) and check access */
-	lis	r0,KERNELBASE@h		/* check if kernel address */
+	lis	r0, TASK_SIZE@h		/* check if kernel address */
 	cmplw	0,r4,r0
 	ori	r3,r3,_PAGE_USER|_PAGE_PRESENT /* test low addresses as user */
 	mfspr	r5, SPRN_SPRG_PGDIR	/* phys page-table root */
-- 
2.25.0


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

* [PATCH v1 8/8] powerpc/32s: Use dedicated segment for modules with STRICT_KERNEL_RWX
  2020-06-19 15:06 [PATCH v1 0/8] powerpc/32s: Allocate modules outside of vmalloc space for STRICT_KERNEL_RWX Christophe Leroy
                   ` (6 preceding siblings ...)
  2020-06-19 15:06 ` [PATCH v1 7/8] powerpc/32s: Kernel space starts at TASK_SIZE Christophe Leroy
@ 2020-06-19 15:06 ` Christophe Leroy
  7 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2020-06-19 15:06 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

When STRICT_KERNEL_RWX is set, we want to set NX bit on vmalloc
segments. But modules require exec.

Use a dedicated segment for modules. There is not much space
above kernel, and we don't waste vmalloc space to do alignment.
Therefore, we take the segment before PAGE_OFFSET for modules.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/Kconfig                         |  1 +
 arch/powerpc/include/asm/book3s/32/pgtable.h | 15 +++++----------
 arch/powerpc/mm/ptdump/ptdump.c              |  8 ++++++++
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 9fa23eb320ff..2ba6ac9da46f 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -1198,6 +1198,7 @@ config TASK_SIZE_BOOL
 config TASK_SIZE
 	hex "Size of user task space" if TASK_SIZE_BOOL
 	default "0x80000000" if PPC_8xx
+	default "0xb0000000" if PPC_BOOK3S_32 && STRICT_KERNEL_RWX
 	default "0xc0000000"
 endmenu
 
diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h
index 224912432821..36443cda8dcf 100644
--- a/arch/powerpc/include/asm/book3s/32/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/32/pgtable.h
@@ -184,17 +184,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
  */
 #define VMALLOC_OFFSET (0x1000000) /* 16M */
 
-/*
- * With CONFIG_STRICT_KERNEL_RWX, kernel segments are set NX. But when modules
- * are used, NX cannot be set on VMALLOC space. So vmalloc VM space and linear
- * memory shall not share segments.
- */
-#if defined(CONFIG_STRICT_KERNEL_RWX) && defined(CONFIG_MODULES)
-#define VMALLOC_START ((ALIGN((long)high_memory, 256L << 20) + VMALLOC_OFFSET) & \
-		       ~(VMALLOC_OFFSET - 1))
-#else
 #define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
-#endif
 
 #ifdef CONFIG_KASAN_VMALLOC
 #define VMALLOC_END	ALIGN_DOWN(ioremap_bot, PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
@@ -202,6 +192,11 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
 #define VMALLOC_END	ioremap_bot
 #endif
 
+#ifdef CONFIG_STRICT_KERNEL_RWX
+#define MODULES_END	ALIGN_DOWN(PAGE_OFFSET, SZ_256M)
+#define MODULES_VADDR	(MODULES_END - SZ_256M)
+#endif
+
 #ifndef __ASSEMBLY__
 #include <linux/sched.h>
 #include <linux/threads.h>
diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdump.c
index e995f2e9e9f7..51aab1b7be31 100644
--- a/arch/powerpc/mm/ptdump/ptdump.c
+++ b/arch/powerpc/mm/ptdump/ptdump.c
@@ -74,6 +74,10 @@ struct addr_marker {
 
 static struct addr_marker address_markers[] = {
 	{ 0,	"Start of kernel VM" },
+#ifdef MODULES_VADDR
+	{ 0,	"modules start" },
+	{ 0,	"modules end" },
+#endif
 	{ 0,	"vmalloc() Area" },
 	{ 0,	"vmalloc() End" },
 #ifdef CONFIG_PPC64
@@ -352,6 +356,10 @@ static void populate_markers(void)
 	int i = 0;
 
 	address_markers[i++].start_address = TASK_SIZE;
+#ifdef MODULES_VADDR
+	address_markers[i++].start_address = MODULES_VADDR;
+	address_markers[i++].start_address = MODULES_END;
+#endif
 	address_markers[i++].start_address = VMALLOC_START;
 	address_markers[i++].start_address = VMALLOC_END;
 #ifdef CONFIG_PPC64
-- 
2.25.0


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

* Re: [PATCH v1 3/8] powerpc: Set user/kernel boundary at TASK_SIZE instead of PAGE_OFFSET
  2020-06-19 15:06 ` [PATCH v1 3/8] powerpc: Set user/kernel boundary at TASK_SIZE instead of PAGE_OFFSET Christophe Leroy
@ 2020-06-20 11:25   ` kernel test robot
  2020-06-20 11:33   ` kernel test robot
  1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2020-06-20 11:25 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman
  Cc: kbuild-all, linux-kernel, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 8599 bytes --]

Hi Christophe,

I love your patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.8-rc1 next-20200618]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-32s-Allocate-modules-outside-of-vmalloc-space-for-STRICT_KERNEL_RWX/20200620-001346
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc64-randconfig-r023-20200619 (attached as .config)
compiler: powerpc64le-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=powerpc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from arch/powerpc/include/asm/book3s/64/mmu-hash.h:22,
                    from arch/powerpc/include/asm/book3s/64/mmu.h:46,
                    from arch/powerpc/include/asm/mmu.h:348,
                    from arch/powerpc/include/asm/lppaca.h:47,
                    from arch/powerpc/include/asm/paca.h:17,
                    from arch/powerpc/include/asm/current.h:13,
                    from include/linux/thread_info.h:21,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/powerpc/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/seqlock.h:36,
                    from include/linux/time.h:6,
                    from include/linux/compat.h:10,
                    from arch/powerpc/kernel/asm-offsets.c:14:
   arch/powerpc/include/asm/book3s/64/mmu-hash.h: In function 'get_kernel_vsid':
>> arch/powerpc/include/asm/task_size_64.h:48:3: error: implicit declaration of function 'test_tsk_thread_flag' [-Werror=implicit-function-declaration]
      48 |  (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 : \
         |   ^~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/task_size_64.h:51:19: note: in expansion of macro 'TASK_SIZE_OF'
      51 | #define TASK_SIZE TASK_SIZE_OF(current)
         |                   ^~~~~~~~~~~~
>> arch/powerpc/include/asm/page.h:259:35: note: in expansion of macro 'TASK_SIZE'
     259 | #define is_kernel_addr(x) ((x) >= TASK_SIZE)
         |                                   ^~~~~~~~~
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:836:7: note: in expansion of macro 'is_kernel_addr'
     836 |  if (!is_kernel_addr(ea))
         |       ^~~~~~~~~~~~~~
>> arch/powerpc/include/asm/task_size_64.h:51:32: error: 'current' undeclared (first use in this function)
      51 | #define TASK_SIZE TASK_SIZE_OF(current)
         |                                ^~~~~~~
   arch/powerpc/include/asm/task_size_64.h:48:24: note: in definition of macro 'TASK_SIZE_OF'
      48 |  (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 : \
         |                        ^~~
>> arch/powerpc/include/asm/page.h:259:35: note: in expansion of macro 'TASK_SIZE'
     259 | #define is_kernel_addr(x) ((x) >= TASK_SIZE)
         |                                   ^~~~~~~~~
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:836:7: note: in expansion of macro 'is_kernel_addr'
     836 |  if (!is_kernel_addr(ea))
         |       ^~~~~~~~~~~~~~
   arch/powerpc/include/asm/task_size_64.h:51:32: note: each undeclared identifier is reported only once for each function it appears in
      51 | #define TASK_SIZE TASK_SIZE_OF(current)
         |                                ^~~~~~~
   arch/powerpc/include/asm/task_size_64.h:48:24: note: in definition of macro 'TASK_SIZE_OF'
      48 |  (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 : \
         |                        ^~~
>> arch/powerpc/include/asm/page.h:259:35: note: in expansion of macro 'TASK_SIZE'
     259 | #define is_kernel_addr(x) ((x) >= TASK_SIZE)
         |                                   ^~~~~~~~~
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:836:7: note: in expansion of macro 'is_kernel_addr'
     836 |  if (!is_kernel_addr(ea))
         |       ^~~~~~~~~~~~~~
>> arch/powerpc/include/asm/task_size_64.h:48:29: error: 'TIF_32BIT' undeclared (first use in this function)
      48 |  (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 : \
         |                             ^~~~~~~~~
>> arch/powerpc/include/asm/task_size_64.h:51:19: note: in expansion of macro 'TASK_SIZE_OF'
      51 | #define TASK_SIZE TASK_SIZE_OF(current)
         |                   ^~~~~~~~~~~~
>> arch/powerpc/include/asm/page.h:259:35: note: in expansion of macro 'TASK_SIZE'
     259 | #define is_kernel_addr(x) ((x) >= TASK_SIZE)
         |                                   ^~~~~~~~~
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:836:7: note: in expansion of macro 'is_kernel_addr'
     836 |  if (!is_kernel_addr(ea))
         |       ^~~~~~~~~~~~~~
   In file included from include/linux/uaccess.h:5,
                    from include/linux/crypto.h:21,
                    from include/crypto/hash.h:11,
                    from include/linux/uio.h:10,
                    from include/linux/socket.h:8,
                    from include/linux/compat.h:15,
                    from arch/powerpc/kernel/asm-offsets.c:14:
   include/linux/sched.h: At top level:
>> include/linux/sched.h:1786:19: error: static declaration of 'test_tsk_thread_flag' follows non-static declaration
    1786 | static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag)
         |                   ^~~~~~~~~~~~~~~~~~~~
   In file included from arch/powerpc/include/asm/book3s/64/mmu-hash.h:22,
                    from arch/powerpc/include/asm/book3s/64/mmu.h:46,
                    from arch/powerpc/include/asm/mmu.h:348,
                    from arch/powerpc/include/asm/lppaca.h:47,
                    from arch/powerpc/include/asm/paca.h:17,
                    from arch/powerpc/include/asm/current.h:13,
                    from include/linux/thread_info.h:21,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/powerpc/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/seqlock.h:36,
                    from include/linux/time.h:6,
                    from include/linux/compat.h:10,
                    from arch/powerpc/kernel/asm-offsets.c:14:
   arch/powerpc/include/asm/task_size_64.h:48:3: note: previous implicit declaration of 'test_tsk_thread_flag' was here
      48 |  (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 : \
         |   ^~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/task_size_64.h:51:19: note: in expansion of macro 'TASK_SIZE_OF'
      51 | #define TASK_SIZE TASK_SIZE_OF(current)
         |                   ^~~~~~~~~~~~
>> arch/powerpc/include/asm/page.h:259:35: note: in expansion of macro 'TASK_SIZE'
     259 | #define is_kernel_addr(x) ((x) >= TASK_SIZE)
         |                                   ^~~~~~~~~
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:836:7: note: in expansion of macro 'is_kernel_addr'
     836 |  if (!is_kernel_addr(ea))
         |       ^~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
   make[2]: *** [scripts/Makefile.build:114: arch/powerpc/kernel/asm-offsets.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [Makefile:1188: prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:185: __sub-make] Error 2
   make: Target 'prepare' not remade because of errors.

vim +/TASK_SIZE +259 arch/powerpc/include/asm/page.h

   251	
   252	/*
   253	 * Don't compare things with KERNELBASE or PAGE_OFFSET to test for
   254	 * "kernelness", use is_kernel_addr() - it should do what you want.
   255	 */
   256	#ifdef CONFIG_PPC_BOOK3E_64
   257	#define is_kernel_addr(x)	((x) >= 0x8000000000000000ul)
   258	#else
 > 259	#define is_kernel_addr(x)	((x) >= TASK_SIZE)
   260	#endif
   261	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34730 bytes --]

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

* Re: [PATCH v1 3/8] powerpc: Set user/kernel boundary at TASK_SIZE instead of PAGE_OFFSET
  2020-06-19 15:06 ` [PATCH v1 3/8] powerpc: Set user/kernel boundary at TASK_SIZE instead of PAGE_OFFSET Christophe Leroy
  2020-06-20 11:25   ` kernel test robot
@ 2020-06-20 11:33   ` kernel test robot
  1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2020-06-20 11:33 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman
  Cc: kbuild-all, clang-built-linux, linux-kernel, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 10067 bytes --]

Hi Christophe,

I love your patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.8-rc1 next-20200618]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-32s-Allocate-modules-outside-of-vmalloc-space-for-STRICT_KERNEL_RWX/20200620-001346
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-randconfig-r006-20200619 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 63700971ac9cdf198faa4a3a7c226fa579e49206)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install powerpc cross compiling tool for clang build
        # apt-get install binutils-powerpc-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from arch/powerpc/kernel/asm-offsets.c:14:
   In file included from include/linux/compat.h:10:
   In file included from include/linux/time.h:6:
   In file included from include/linux/seqlock.h:36:
   In file included from include/linux/spinlock.h:51:
   In file included from include/linux/preempt.h:78:
   In file included from ./arch/powerpc/include/generated/asm/preempt.h:1:
   In file included from include/asm-generic/preempt.h:5:
   In file included from include/linux/thread_info.h:21:
   In file included from arch/powerpc/include/asm/current.h:13:
   In file included from arch/powerpc/include/asm/paca.h:17:
   In file included from arch/powerpc/include/asm/lppaca.h:47:
   In file included from arch/powerpc/include/asm/mmu.h:348:
   In file included from arch/powerpc/include/asm/book3s/64/mmu.h:46:
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:836:7: error: implicit declaration of function 'test_tsk_thread_flag' [-Werror,-Wimplicit-function-declaration]
           if (!is_kernel_addr(ea))
                ^
   arch/powerpc/include/asm/page.h:259:35: note: expanded from macro 'is_kernel_addr'
   #define is_kernel_addr(x)       ((x) >= TASK_SIZE)
                                           ^
   arch/powerpc/include/asm/task_size_64.h:51:19: note: expanded from macro 'TASK_SIZE'
   #define TASK_SIZE TASK_SIZE_OF(current)
                     ^
   arch/powerpc/include/asm/task_size_64.h:48:3: note: expanded from macro 'TASK_SIZE_OF'
           (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 :      \
            ^
   In file included from arch/powerpc/kernel/asm-offsets.c:14:
   In file included from include/linux/compat.h:10:
   In file included from include/linux/time.h:6:
   In file included from include/linux/seqlock.h:36:
   In file included from include/linux/spinlock.h:51:
   In file included from include/linux/preempt.h:78:
   In file included from ./arch/powerpc/include/generated/asm/preempt.h:1:
   In file included from include/asm-generic/preempt.h:5:
   In file included from include/linux/thread_info.h:21:
   In file included from arch/powerpc/include/asm/current.h:13:
   In file included from arch/powerpc/include/asm/paca.h:17:
   In file included from arch/powerpc/include/asm/lppaca.h:47:
   In file included from arch/powerpc/include/asm/mmu.h:348:
   In file included from arch/powerpc/include/asm/book3s/64/mmu.h:46:
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:836:7: error: use of undeclared identifier 'current'
   arch/powerpc/include/asm/page.h:259:35: note: expanded from macro 'is_kernel_addr'
   #define is_kernel_addr(x)       ((x) >= TASK_SIZE)
                                           ^
   arch/powerpc/include/asm/task_size_64.h:51:32: note: expanded from macro 'TASK_SIZE'
   #define TASK_SIZE TASK_SIZE_OF(current)
                                  ^
   In file included from arch/powerpc/kernel/asm-offsets.c:14:
   In file included from include/linux/compat.h:10:
   In file included from include/linux/time.h:6:
   In file included from include/linux/seqlock.h:36:
   In file included from include/linux/spinlock.h:51:
   In file included from include/linux/preempt.h:78:
   In file included from ./arch/powerpc/include/generated/asm/preempt.h:1:
   In file included from include/asm-generic/preempt.h:5:
   In file included from include/linux/thread_info.h:21:
   In file included from arch/powerpc/include/asm/current.h:13:
   In file included from arch/powerpc/include/asm/paca.h:17:
   In file included from arch/powerpc/include/asm/lppaca.h:47:
   In file included from arch/powerpc/include/asm/mmu.h:348:
   In file included from arch/powerpc/include/asm/book3s/64/mmu.h:46:
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:836:7: error: use of undeclared identifier 'TIF_32BIT'
   arch/powerpc/include/asm/page.h:259:35: note: expanded from macro 'is_kernel_addr'
   #define is_kernel_addr(x)       ((x) >= TASK_SIZE)
                                           ^
   arch/powerpc/include/asm/task_size_64.h:51:19: note: expanded from macro 'TASK_SIZE'
   #define TASK_SIZE TASK_SIZE_OF(current)
                     ^
   arch/powerpc/include/asm/task_size_64.h:48:29: note: expanded from macro 'TASK_SIZE_OF'
           (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 :      \
                                      ^
   In file included from arch/powerpc/kernel/asm-offsets.c:14:
   In file included from include/linux/compat.h:15:
   In file included from include/linux/socket.h:8:
   In file included from include/linux/uio.h:10:
   In file included from include/crypto/hash.h:11:
   In file included from include/linux/crypto.h:21:
   In file included from include/linux/uaccess.h:5:
>> include/linux/sched.h:1786:19: error: static declaration of 'test_tsk_thread_flag' follows non-static declaration
   static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag)
                     ^
   arch/powerpc/include/asm/book3s/64/mmu-hash.h:836:7: note: previous implicit declaration is here
           if (!is_kernel_addr(ea))
                ^
   arch/powerpc/include/asm/page.h:259:35: note: expanded from macro 'is_kernel_addr'
   #define is_kernel_addr(x)       ((x) >= TASK_SIZE)
                                           ^
   arch/powerpc/include/asm/task_size_64.h:51:19: note: expanded from macro 'TASK_SIZE'
   #define TASK_SIZE TASK_SIZE_OF(current)
                     ^
   arch/powerpc/include/asm/task_size_64.h:48:3: note: expanded from macro 'TASK_SIZE_OF'
           (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 :      \
            ^
   In file included from arch/powerpc/kernel/asm-offsets.c:21:
   include/linux/mman.h:133:9: warning: division by zero is undefined [-Wdivision-by-zero]
                  _calc_vm_trans(flags, MAP_LOCKED,     VM_LOCKED    ) |
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/mman.h:111:21: note: expanded from macro '_calc_vm_trans'
      : ((x) & (bit1)) / ((bit1) / (bit2))))
                       ^ ~~~~~~~~~~~~~~~~~
   include/linux/mman.h:134:9: warning: division by zero is undefined [-Wdivision-by-zero]
                  _calc_vm_trans(flags, MAP_SYNC,       VM_SYNC      );
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/mman.h:111:21: note: expanded from macro '_calc_vm_trans'
      : ((x) & (bit1)) / ((bit1) / (bit2))))
                       ^ ~~~~~~~~~~~~~~~~~
   2 warnings and 4 errors generated.
   make[2]: *** [scripts/Makefile.build:114: arch/powerpc/kernel/asm-offsets.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [Makefile:1188: prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:185: __sub-make] Error 2
   make: Target 'prepare' not remade because of errors.

vim +/test_tsk_thread_flag +836 arch/powerpc/include/asm/book3s/64/mmu-hash.h

4ffe713b7587b1 arch/powerpc/include/asm/book3s/64/mmu-hash.h Aneesh Kumar K.V 2018-09-20  828  
c60ac5693c47df arch/powerpc/include/asm/mmu-hash64.h         Aneesh Kumar K.V 2013-03-13  829  /*
c60ac5693c47df arch/powerpc/include/asm/mmu-hash64.h         Aneesh Kumar K.V 2013-03-13  830   * This is only valid for addresses >= PAGE_OFFSET
c60ac5693c47df arch/powerpc/include/asm/mmu-hash64.h         Aneesh Kumar K.V 2013-03-13  831   */
c60ac5693c47df arch/powerpc/include/asm/mmu-hash64.h         Aneesh Kumar K.V 2013-03-13  832  static inline unsigned long get_kernel_vsid(unsigned long ea, int ssize)
c60ac5693c47df arch/powerpc/include/asm/mmu-hash64.h         Aneesh Kumar K.V 2013-03-13  833  {
c60ac5693c47df arch/powerpc/include/asm/mmu-hash64.h         Aneesh Kumar K.V 2013-03-13  834  	unsigned long context;
c60ac5693c47df arch/powerpc/include/asm/mmu-hash64.h         Aneesh Kumar K.V 2013-03-13  835  
85beb1c486df76 arch/powerpc/include/asm/book3s/64/mmu-hash.h Michael Ellerman 2017-03-29 @836  	if (!is_kernel_addr(ea))
85beb1c486df76 arch/powerpc/include/asm/book3s/64/mmu-hash.h Michael Ellerman 2017-03-29  837  		return 0;
85beb1c486df76 arch/powerpc/include/asm/book3s/64/mmu-hash.h Michael Ellerman 2017-03-29  838  
4ffe713b7587b1 arch/powerpc/include/asm/book3s/64/mmu-hash.h Aneesh Kumar K.V 2018-09-20  839  	context = get_kernel_context(ea);
c60ac5693c47df arch/powerpc/include/asm/mmu-hash64.h         Aneesh Kumar K.V 2013-03-13  840  	return get_vsid(context, ea, ssize);
c60ac5693c47df arch/powerpc/include/asm/mmu-hash64.h         Aneesh Kumar K.V 2013-03-13  841  }
5c3c7ede2bdcb8 arch/powerpc/include/asm/mmu-hash64.h         David Gibson     2016-02-09  842  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 37346 bytes --]

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

end of thread, other threads:[~2020-06-20 12:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-19 15:06 [PATCH v1 0/8] powerpc/32s: Allocate modules outside of vmalloc space for STRICT_KERNEL_RWX Christophe Leroy
2020-06-19 15:06 ` [PATCH v1 1/8] powerpc/ptdump: Refactor update of st->last_pa Christophe Leroy
2020-06-19 15:06 ` [PATCH v1 2/8] powerpc/ptdump: Refactor update of pg_state Christophe Leroy
2020-06-19 15:06 ` [PATCH v1 3/8] powerpc: Set user/kernel boundary at TASK_SIZE instead of PAGE_OFFSET Christophe Leroy
2020-06-20 11:25   ` kernel test robot
2020-06-20 11:33   ` kernel test robot
2020-06-19 15:06 ` [PATCH v1 4/8] powerpc/lib: Prepare code-patching for modules allocated outside vmalloc space Christophe Leroy
2020-06-19 15:06 ` [PATCH v1 5/8] powerpc: Use MODULES_VADDR if defined Christophe Leroy
2020-06-19 15:06 ` [PATCH v1 6/8] powerpc/32s: Only leave NX unset on segments used for modules Christophe Leroy
2020-06-19 15:06 ` [PATCH v1 7/8] powerpc/32s: Kernel space starts at TASK_SIZE Christophe Leroy
2020-06-19 15:06 ` [PATCH v1 8/8] powerpc/32s: Use dedicated segment for modules with STRICT_KERNEL_RWX Christophe Leroy

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).