powerpc/32s: Use BATs/LTLBs for STRICT_KERNEL_RWX
v2 cover powerpc/32s: Use BATs/LTLBs for STRICT_KERNEL_RWX
The purpose of this serie is to:
- use BATs with STRICT_KERNEL_RWX on book3s (See patch 12 for details.)
- use LTLBs with STRICT_KERNEL_RWX on 8xx (See patch 14 for a few details.)
v2:
- Fix patch 2 (was patch 3 in v1) based on feedback from Jonathan.
- Added support for 8xx with LTLBs.
- Added systematic population of pagetables for Abatron BDI.
Christophe Leroy (15):
powerpc/mm/32: add base address to mmu_mapin_ram() powerpc/mm/32s: rework mmu_mapin_ram()
powerpc/mm/32s: use generic mmu_mapin_ram() for all blocks. powerpc/32: always populate page tables for Abatron BDI. powerpc/wii: remove wii_mmu_mapin_mem2()
powerpc/mm/32s: use _PAGE_EXEC in setbat()
powerpc/mm/32s: add setibat() clearibat() and update_bats() powerpc/32: add helper to write into segment registers powerpc/mmu: add is_strict_kernel_rwx() helper powerpc/kconfig: define PAGE_SHIFT inside Kconfig powerpc/kconfig: define CONFIG_DATA_SHIFT and CONFIG_ETEXT_SHIFT powerpc/mm/32s: Use BATs for STRICT_KERNEL_RWX powerpc/kconfig: make _etext and data areas alignment configurable on
Book3s 32
powerpc/8xx: don't disable large TLBs with CONFIG_STRICT_KERNEL_RWX
powerpc/kconfig: make _etext and data areas alignment configurable on
8xxarch/powerpc/Kconfig | 60 +++++++++ arch/powerpc/include/asm/book3s/32/mmu-hash.h | 2 + arch/powerpc/include/asm/book3s/32/pgtable.h | 11 ++ arch/powerpc/include/asm/mmu.h | 11 ++ arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 3 +- arch/powerpc/include/asm/page.h | 13 +- arch/powerpc/include/asm/reg.h | 5 + arch/powerpc/kernel/head_32.S | 35 +++++ arch/powerpc/kernel/head_8xx.S | 33 ++++- arch/powerpc/kernel/vmlinux.lds.S | 9 +- arch/powerpc/mm/40x_mmu.c | 2 +- arch/powerpc/mm/44x_mmu.c | 2 +- arch/powerpc/mm/8xx_mmu.c | 33 ++++- arch/powerpc/mm/fsl_booke_mmu.c | 2 +- arch/powerpc/mm/init_32.c | 6 +- arch/powerpc/mm/mmu_decl.h | 10 +- arch/powerpc/mm/pgtable_32.c | 38 +++--- arch/powerpc/mm/ppc_mmu_32.c | 178 ++++++++++++++++++++++---- arch/powerpc/platforms/embedded6xx/wii.c | 24 ---- 19 files changed, 378 insertions(+), 99 deletions(-)
Signature · 1 line
2.13.3
PATCH v2 1/15 powerpc/mm/32: add base address to mmu_mapin_ram()
At the time being, mmu_mapin_ram() always maps RAM from the beginning. But some platforms like the WII have to map a second block of RAM.
This patch adds to mmu_mapin_ram() the base address of the block. At the moment, only base address 0 is supported.
--- arch/powerpc/mm/40x_mmu.c | 2 +- arch/powerpc/mm/44x_mmu.c | 2 +- arch/powerpc/mm/8xx_mmu.c | 2 +- arch/powerpc/mm/fsl_booke_mmu.c | 2 +- arch/powerpc/mm/mmu_decl.h | 2 +- arch/powerpc/mm/pgtable_32.c | 6 +++--- arch/powerpc/mm/ppc_mmu_32.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-)
arch/powerpc/mm/40x_mmu.c +1 -1
@@ -93,7 +93,7 @@ void __init MMU_init_hw(void)#define LARGE_PAGE_SIZE_16M (1<<24)#define LARGE_PAGE_SIZE_4M (1<<22) -unsigned long __init mmu_mapin_ram (unsigned long top) +unsigned long __init mmu_mapin_ram (unsigned long base,unsigned long top) {unsigned long v, s, mapped;phys_addr_t p;
arch/powerpc/mm/44x_mmu.c +1 -1
@@ -170,7 +170,7 @@ void __init MMU_init_hw(void)flush_instruction_cache (); } -unsigned long __init mmu_mapin_ram (unsigned long top) +unsigned long __init mmu_mapin_ram (unsigned long base,unsigned long top) {unsigned long addr;unsigned long memstart = memstart_addr & ~(PPC_PIN_SIZE -1 );
arch/powerpc/mm/8xx_mmu.c +1 -1
@@ -99,7 +99,7 @@ static void __init mmu_patch_cmp_limit(s32 *site, unsigned long mapped)modify_instruction_site (site,0xffff , (unsigned long )__va (mapped) >>16 ); } -unsigned long __init mmu_mapin_ram (unsigned long top) +unsigned long __init mmu_mapin_ram (unsigned long base,unsigned long top) {unsigned long mapped;
arch/powerpc/mm/fsl_booke_mmu.c +1 -1
@@ -221,7 +221,7 @@ unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx, bool dryrun)#error "LOWMEM_CAM_NUM must be less than NUM_TLBCAMS"#endif -unsigned long __init mmu_mapin_ram (unsigned long top) +unsigned long __init mmu_mapin_ram (unsigned long base,unsigned long top) {return tlbcam_addrs[tlbcam_index -1 ].limit -PAGE_OFFSET +1 ; }
arch/powerpc/mm/mmu_decl.h +1 -1
@@ -130,7 +130,7 @@ extern void wii_memory_fixups(void);*/ #ifdef CONFIG_PPC32 extern void MMU_init_hw (void ); -extern unsigned long mmu_mapin_ram (unsigned long top); +unsigned long mmu_mapin_ram (unsigned long base,unsigned long top);#endif #ifdef CONFIG_PPC_FSL_BOOK3E
arch/powerpc/mm/pgtable_32.c +3 -3
@@ -258,15 +258,15 @@ void __init mapin_ram(void)#ifndef CONFIG_WII top = total_lowmem; - s =mmu_mapin_ram (top); + s =mmu_mapin_ram (0 , top);__mapin_ram_chunk (s, top);#else if (!wii_hole_size) { - s =mmu_mapin_ram (total_lowmem); + s =mmu_mapin_ram (0 , total_lowmem);__mapin_ram_chunk (s, total_lowmem); }else { top = wii_hole_start; - s =mmu_mapin_ram (top); + s =mmu_mapin_ram (0 , top);__mapin_ram_chunk (s, top); top =memblock_end_of_DRAM ();
arch/powerpc/mm/ppc_mmu_32.c +1 -1
@@ -73,7 +73,7 @@ unsigned long p_block_mapped(phys_addr_t pa)return 0 ; } -unsigned long __init mmu_mapin_ram (unsigned long top) +unsigned long __init mmu_mapin_ram (unsigned long base,unsigned long top) {unsigned long tot, bl, done;unsigned long max_size = (256 <<20 );
Signature · 1 line
2.13.3
PATCH v2 2/15 powerpc/mm/32s: rework mmu_mapin_ram()
In reply to Christophe LeroyThis patch reworks mmu_mapin_ram() to be more generic and map as much blocks as possible. It now supports blocks not starting at address 0.
It scans DBATs array to find free ones instead of forcing the use of BAT2 and BAT3.
--- arch/powerpc/mm/ppc_mmu_32.c | 61 +++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 21 deletions(-)
arch/powerpc/mm/ppc_mmu_32.c +40 -21
@@ -73,39 +73,58 @@ unsigned long p_block_mapped(phys_addr_t pa)return 0 ; } +static int find_free_bat (void ) +{ +int b; + +if (cpu_has_feature (CPU_FTR_601 )) { +for (b =0 ; b <4 ; b++) { +struct ppc_bat *bat =BATS [b]; + +if (!(bat[0 ].batl &0x40 )) +return b; + } + }else { +int n =mmu_has_feature (MMU_FTR_USE_HIGH_BATS ) ?8 :4 ; + +for (b =0 ; b < n; b++) { +struct ppc_bat *bat =BATS [b]; + +if (!(bat[1 ].batu &3 )) +return b; + } + } +return -1 ; +} + +static unsigned int block_size (unsigned long base,unsigned long top) +{ +unsigned int max_size = (cpu_has_feature (CPU_FTR_601 ) ?8 :256 ) <<20 ; +unsigned int base_shift = (fls (base) -1 ) &31 ; +unsigned int block_shift = (fls (top - base) -1 ) &31 ; + +return min3 (max_size,1U << base_shift,1U << block_shift); +} +unsigned long __init mmu_mapin_ram (unsigned long base,unsigned long top) { -unsigned long tot, bl, done; -unsigned long max_size = (256 <<20 ); +int idx;if (__map_without_bats) {printk (KERN_DEBUG "RAM mapped without BATs\n" );return 0 ; } -/* Set up BAT2 and if necessary BAT3 to cover RAM. */ +while ((idx =find_free_bat ()) !=-1 && base != top) { +unsigned int size =block_size (base, top); -/* Make sure we don't map a block larger than the -smallest alignment of the physical address. */ - tot = top; -for (bl =128 <<10 ; bl < max_size; bl <<=1 ) { -if (bl *2 > tot) +if (size <128 <<10 )break ; +setbat (idx,PAGE_OFFSET + base, base, size,PAGE_KERNEL_X ); + base += size; } -setbat (2 ,PAGE_OFFSET ,0 , bl,PAGE_KERNEL_X ); - done = (unsigned long )bat_addrs[2 ].limit -PAGE_OFFSET +1 ; -if ((done < tot) && !bat_addrs[3 ].limit) { -/* use BAT3 to cover a bit more */ - tot -= done; -for (bl =128 <<10 ; bl < max_size; bl <<=1 ) -if (bl *2 > tot) -break ; -setbat (3 ,PAGE_OFFSET +done, done, bl,PAGE_KERNEL_X ); - done = (unsigned long )bat_addrs[3 ].limit -PAGE_OFFSET +1 ; - } - -return done; +return base; }/*
Signature · 1 line
2.13.3
PATCH v2 3/15 powerpc/mm/32s: use generic mmu_mapin_ram() for all blocks.
In reply to Christophe LeroyNow that mmu_mapin_ram() is able to handle other blocks than the one starting at 0, the WII can use it for all its blocks.
--- arch/powerpc/mm/pgtable_32.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-)
arch/powerpc/mm/pgtable_32.c +7 -18
@@ -254,26 +254,15 @@ static void __init __mapin_ram_chunk(unsigned long offset, unsigned long top)void __init mapin_ram (void ) { -unsigned long s, top; - -#ifndef CONFIG_WII - top = total_lowmem; - s =mmu_mapin_ram (0 , top); -__mapin_ram_chunk (s, top); -#else -if (!wii_hole_size) { - s =mmu_mapin_ram (0 , total_lowmem); -__mapin_ram_chunk (s, total_lowmem); - }else { - top = wii_hole_start; - s =mmu_mapin_ram (0 , top); -__mapin_ram_chunk (s, top); +struct memblock_region *reg; + +for_each_memblock (memory, reg) { +unsigned long base = reg->base; +unsigned long top = base + reg->size; - top =memblock_end_of_DRAM (); - s =wii_mmu_mapin_mem2 (top); -__mapin_ram_chunk (s, top); + base =mmu_mapin_ram (base, top); +__mapin_ram_chunk (base, top); } -#endif }/* Scan the real Linux page tables and return a PTE pointer for
Signature · 1 line
2.13.3
PATCH v2 4/15 powerpc/32: always populate page tables for Abatron BDI.
In reply to Christophe LeroyWhen CONFIG_BDI_SWITCH is set, the page tables have to be populated allthough large TLBs are used, because the BDI switch knows nothing about those large TLBs which are handled directly in TLB miss logic.
--- arch/powerpc/mm/pgtable_32.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/mm/pgtable_32.c +4 -1
@@ -261,7 +261,10 @@ void __init mapin_ram(void)unsigned long top = base + reg->size; base =mmu_mapin_ram (base, top); -__mapin_ram_chunk (base, top); +if (IS_ENABLED (CONFIG_BDI_SWITCH )) +__mapin_ram_chunk (reg->base, top); +else +__mapin_ram_chunk (base, top); } }
Signature · 1 line
2.13.3
PATCH v2 5/15 powerpc/wii: remove wii_mmu_mapin_mem2()
In reply to Christophe Leroywii_mmu_mapin_mem2() is not used anymore, remove it.
--- arch/powerpc/platforms/embedded6xx/wii.c | 24 ------------------------ 1 file changed, 24 deletions(-)
arch/powerpc/platforms/embedded6xx/wii.c +0 -24
@@ -54,10 +54,6 @@static void __iomem *hw_ctrl;static void __iomem *hw_gpio; -unsigned long wii_hole_start; -unsigned long wii_hole_size; - -static int __init page_aligned (unsigned long x) {return !(x & (PAGE_SIZE -1 ));
@@ -69,26 +65,6 @@ void __init wii_memory_fixups(void)BUG_ON (memblock.memory.cnt !=2 );BUG_ON (!page_aligned (p[0 ].base) || !page_aligned (p[1 ].base)); - -/* determine hole */ - wii_hole_start =ALIGN (p[0 ].base + p[0 ].size,PAGE_SIZE ); - wii_hole_size = p[1 ].base - wii_hole_start; -} - -unsigned long __init wii_mmu_mapin_mem2 (unsigned long top) -{ -unsigned long delta, size, bl; -unsigned long max_size = (256 <<20 ); - -/* MEM2 64MB@0x10000000 */ - delta = wii_hole_start + wii_hole_size; - size = top - delta; -for (bl =128 <<10 ; bl < max_size; bl <<=1 ) { -if (bl *2 > size) -break ; - } -setbat (4 ,PAGE_OFFSET +delta, delta, bl,PAGE_KERNEL_X ); -return delta + bl; }static void __noreturn wii_spin (void )
Signature · 1 line
2.13.3
PATCH v2 6/15 powerpc/mm/32s: use _PAGE_EXEC in setbat()
In reply to Christophe LeroyDo not set IBAT when setbat() is called without _PAGE_EXEC
--- arch/powerpc/mm/ppc_mmu_32.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/powerpc/mm/ppc_mmu_32.c +6 -4
@@ -131,6 +131,7 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)* Set up one of the I/D BAT (block address translation) register pairs. * The parameters are not checked; in particular size must be a power * of 2 between 128k and 256M. +* On 603+, only set IBAT when _PAGE_EXEC is set */ void __init setbat (int index,unsigned long virt,phys_addr_t phys,unsigned int size,pgprot_t prot)
@@ -157,11 +158,12 @@ void __init setbat(int index, unsigned long virt, phys_addr_t phys, bat[1 ].batu |=1 ;/* Vp = 1 */ if (flags & _PAGE_GUARDED) {/* G bit must be zero in IBATs */ - bat[0 ].batu = bat[0 ].batl =0 ; - }else { -/* make IBAT same as DBAT */ - bat[0 ] = bat[1 ]; + flags &= ~_PAGE_EXEC; } +if (flags & _PAGE_EXEC) + bat[0 ] = bat[1 ]; +else + bat[0 ].batu = bat[0 ].batl =0 ; }else {/* 601 cpu */ if (bl >BL_8M )
Signature · 1 line
2.13.3
PATCH v2 7/15 powerpc/mm/32s: add setibat() clearibat() and update_bats()
In reply to Christophe Leroysetibat() and clearibat() allows to manipulate IBATs independently of DBATs.
update_bats() allows to update bats after init. This is done with MMU off.
--- arch/powerpc/include/asm/book3s/32/mmu-hash.h | 2 ++ arch/powerpc/kernel/head_32.S | 35 +++++++++++++++++++++++++++ arch/powerpc/mm/ppc_mmu_32.c | 32 ++++++++++++++++++++++++ 3 files changed, 69 insertions(+)
arch/powerpc/include/asm/book3s/32/mmu-hash.h +2 -0
@@ -92,6 +92,8 @@ typedef struct {unsigned long vdso_base; } mm_context_t; +void update_bats (void ); +/* patch sites */ extern s32 patch__hash_page_A0, patch__hash_page_A1, patch__hash_page_A2;extern s32 patch__hash_page_B, patch__hash_page_C;
arch/powerpc/kernel/head_32.S +35 -0
@@ -1105,6 +1105,41 @@ BEGIN_MMU_FTR_SECTION END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) blr +_ENTRY(update_bats) + lis r4, 1f@h + ori r4, r4, 1f@l + tophys(r4, r4) + mfmsr r6 + mflr r7 + li r3, MSR_KERNEL & ~(MSR_IR | MSR_DR) + rlwinm r0, r6, 0, ~MSR_RI + rlwinm r0, r0, 0, ~MSR_EE + mtmsr r0 + mtspr SPRN_SRR0, r4 + mtspr SPRN_SRR1, r3 + SYNC + RFI +1: bl clear_bats + lis r3, BATS@ha + addi r3, r3, BATS@l + tophys(r3, r3) + LOAD_BAT(0, r3, r4, r5) + LOAD_BAT(1, r3, r4, r5) + LOAD_BAT(2, r3, r4, r5) + LOAD_BAT(3, r3, r4, r5) +BEGIN_MMU_FTR_SECTION + LOAD_BAT(4, r3, r4, r5) + LOAD_BAT(5, r3, r4, r5) + LOAD_BAT(6, r3, r4, r5) + LOAD_BAT(7, r3, r4, r5) +END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) + li r3, MSR_KERNEL & ~(MSR_IR | MSR_DR | MSR_RI) + mtmsr r3 + mtspr SPRN_SRR0, r7 + mtspr SPRN_SRR1, r6 + SYNC + RFI + flush_tlbs: lis r10, 0x40 1: addic. r10, r10, -0x1000
arch/powerpc/mm/ppc_mmu_32.c +32 -0
@@ -106,6 +106,38 @@ static unsigned int block_size(unsigned long base, unsigned long top)return min3 (max_size,1U << base_shift,1U << block_shift); } +/* +* Set up one of the IBAT (block address translation) register pairs. +* The parameters are not checked; in particular size must be a power +* of 2 between 128k and 256M. +* Only for 603+ ... +*/ +static void setibat (int index,unsigned long virt,phys_addr_t phys, +unsigned int size,pgprot_t prot) +{ +unsigned int bl = (size >>17 ) -1 ; +int wimgxpp; +struct ppc_bat *bat =BATS [index]; +unsigned long flags =pgprot_val (prot); + +if (!cpu_has_feature (CPU_FTR_NEED_COHERENT )) + flags &= ~_PAGE_COHERENT; + + wimgxpp = (flags & _PAGE_COHERENT) | (_PAGE_EXEC ?BPP_RX :BPP_XX ); + bat[0 ].batu = virt | (bl <<2 ) |2 ;/* Vs=1, Vp=0 */ + bat[0 ].batl =BAT_PHYS_ADDR (phys) | wimgxpp; +if (flags & _PAGE_USER) + bat[0 ].batu |=1 ;/* Vp = 1 */ +} + +static void clearibat (int index) +{ +struct ppc_bat *bat =BATS [index]; + + bat[0 ].batu =0 ; + bat[0 ].batl =0 ; +} +unsigned long __init mmu_mapin_ram (unsigned long base,unsigned long top) {int idx;
Signature · 1 line
2.13.3
PATCH v2 8/15 powerpc/32: add helper to write into segment registers
In reply to Christophe LeroyThis patch add an helper which wraps 'mtsrin' instruction to write into segment registers.
--- arch/powerpc/include/asm/reg.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/include/asm/reg.h +5 -0
@@ -1425,6 +1425,11 @@ static inline void msr_check_and_clear(unsigned long bits)#define mfsrin (v) ({unsigned int rval; \ asm volatile("mfsrin %0,%1" : "=r" (rval) : "r" (v)); \ rval;}) + +static inline void mtsrin (u32 val,u32 idx) +{ + asmvolatile ("mtsrin %0, %1" : :"r" (val),"r" (idx)); +}#endif #define proc_trap () asm volatile("trap")
Signature · 1 line
2.13.3
PATCH v2 9/15 powerpc/mmu: add is_strict_kernel_rwx() helper
In reply to Christophe LeroyAdd a helper to know whether STRICT_KERNEL_RWX is enabled.
This is based on rodata_enabled flag which is defined only when CONFIG_STRICT_KERNEL_RWX is selected.
--- arch/powerpc/include/asm/mmu.h | 11 +++++++++++ arch/powerpc/mm/init_32.c | 4 +--- 2 files changed, 12 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/mmu.h +11 -0
@@ -289,6 +289,17 @@ static inline u16 get_mm_addr_key(struct mm_struct *mm, unsigned long address) }#endif /* CONFIG_PPC_MEM_KEYS */ +#ifdef CONFIG_STRICT_KERNEL_RWX +static inline bool strict_kernel_rwx_enabled (void ) +{ +return rodata_enabled; +} +#else +static inline bool strict_kernel_rwx_enabled (void ) +{ +return false; +} +#endif #endif /* !__ASSEMBLY__ */ /* The kernel use the constants below to index in the page sizes array.
arch/powerpc/mm/init_32.c +1 -3
@@ -108,12 +108,10 @@ static void __init MMU_setup(void) __map_without_bats =1 ; __map_without_ltlbs =1 ; } -#ifdef CONFIG_STRICT_KERNEL_RWX -if (rodata_enabled) { +if (strict_kernel_rwx_enabled ()) { __map_without_bats =1 ; __map_without_ltlbs =1 ; } -#endif }/*
Signature · 1 line
2.13.3
PATCH v2 10/15 powerpc/kconfig: define PAGE_SHIFT inside Kconfig
In reply to Christophe LeroyThis patch defined CONFIG_PPC_PAGE_SHIFT in order to be able to use PAGE_SHIFT value inside Kconfig.
--- arch/powerpc/Kconfig | 7 +++++++ arch/powerpc/include/asm/page.h | 13 ++----------- 2 files changed, 9 insertions(+), 11 deletions(-)
arch/powerpc/Kconfig +7 -0
@@ -714,6 +714,13 @@ config PPC_256K_PAGES endchoice +config PPC_PAGE_SHIFT + int + default 18 if PPC_256K_PAGES + default 16 if PPC_64K_PAGES + default 14 if PPC_16K_PAGES + default 12 + config THREAD_SHIFT int "Thread shift" if EXPERT range 13 15
arch/powerpc/include/asm/page.h +2 -11
@@ -20,20 +20,11 @@/* * On regular PPC32 page size is 4K (but we support 4K/16K/64K/256K pages -* on PPC44x). For PPC64 we support either 4K or 64K software +* on PPC44x and 4K/16K on 8xx). For PPC64 we support either 4K or 64K software * page size. When using 64K pages however, whether we are really supporting * 64K pages in HW or not is irrelevant to those definitions. */ -#if defined(CONFIG_PPC_256K_PAGES ) -#define PAGE_SHIFT 18 -#elif defined(CONFIG_PPC_64K_PAGES ) -#define PAGE_SHIFT 16 -#elif defined(CONFIG_PPC_16K_PAGES ) -#define PAGE_SHIFT 14 -#else -#define PAGE_SHIFT 12 -#endif - +#define PAGE_SHIFT CONFIG_PPC_PAGE_SHIFT#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)#ifndef __ASSEMBLY__
Signature · 1 line
2.13.3
PATCH v2 11/15 powerpc/kconfig: define CONFIG_DATA_SHIFT and CONFIG_ETEXT_SHIFT
In reply to Christophe LeroyCONFIG_STRICT_KERNEL_RWX requires a special alignment for DATA for some subarches. Today it is just defined as an #ifdef in vmlinux.lds.S
In order to get more flexibility, this patch moves the definition of this alignment in Kconfig
On some subarches, CONFIG_STRICT_KERNEL_RWX will require a special alignment of _etext.
This patch also adds a configuration item for it in Kconfig
--- arch/powerpc/Kconfig | 9 +++++++++ arch/powerpc/kernel/vmlinux.lds.S | 9 +++------ 2 files changed, 12 insertions(+), 6 deletions(-)
arch/powerpc/Kconfig +9 -0
@@ -731,6 +731,15 @@ config THREAD_SHIFT Used to define the stack size. The default is almost always what you want. Only change this if you know what you are doing. +config ETEXT_SHIFT + int + default PPC_PAGE_SHIFT + +config DATA_SHIFT + int + default 24 if STRICT_KERNEL_RWX && PPC64 + default PPC_PAGE_SHIFT + config FORCE_MAX_ZONEORDER int "Maximum zone order" range 8 9 if PPC64 && PPC_64K_PAGES
arch/powerpc/kernel/vmlinux.lds.S +3 -6
@@ -12,11 +12,8 @@ #include <asm/cache.h> #include <asm/thread_info.h> -#if defined(CONFIG_STRICT_KERNEL_RWX) && !defined(CONFIG_PPC32) -#define STRICT_ALIGN_SIZE (1 << 24) -#else -#define STRICT_ALIGN_SIZE PAGE_SIZE -#endif +#define STRICT_ALIGN_SIZE (1 << CONFIG_DATA_SHIFT) +#define ETEXT_ALIGN_SIZE (1 << CONFIG_ETEXT_SHIFT) ENTRY(_stext)
@@ -131,7 +128,7 @@ SECTIONS } :kernel - . = ALIGN(PAGE_SIZE); + . = ALIGN(ETEXT_ALIGN_SIZE); _etext = .; PROVIDE32 (etext = .);
Signature · 1 line
2.13.3
PATCH v2 12/15 powerpc/mm/32s: Use BATs for STRICT_KERNEL_RWX
In reply to Christophe LeroyToday, STRICT_KERNEL_RWX is based on the use of regular pages to map kernel pages.
On Book3s 32, it has three consequences:
- Using pages instead of BAT for mapping kernel linear memory severely impacts performance.
- Exec protection is not effective because no-execute cannot be set at page level (except on 603 which doesn't have hash tables)
- Write protection is not effective because PP bits do not provide RO mode for kernel-only pages (except on 603 which handles it in software via PAGE_DIRTY)
On the 603+, we have:
- Independent IBAT and DBAT allowing limitation of exec parts.
- NX bit can be set in segment registers to forbit execution on memory mapped by pages.
- RO mode on DBATs even for kernel-only blocks.
On the 601, there is nothing much we can do other than warn the user about it, because:
- BATs are common to instructions and data.
- BAT do not provide RO mode for kernel-only blocks.
- segment registers don't have the NX bit.
In order to use IBAT for exec protection, this patch:
- Aligns _etext to BAT block sizes (128kb)
- Set NX bit in kernel segment register (Except on vmalloc area when CONFIG_MODULES is selected)
- Maps kernel text with IBATs.
In order to use DBAT for exec protection, this patch:
- Aligns RW DATA to BAT block sizes (4M)
- Maps kernel RO area with write prohibited DBATs
- Maps remaining memory with remaining DBATs
Here is what we get with this patch on a 832x when activating STRICT_KERNEL_RWX:
Symbols:c0000000 T _stextc0680000 R __start_rodatac0680000 R _etextc0800000 T __init_beginc0800000 T _sinittext
~# cat /sys/kernel/debug/block_address_translation ---[ Instruction Block Address Translation ]--- 0: 0xc0000000-0xc03fffff 0x00000000 Kernel EXEC coherent 1: 0xc0400000-0xc05fffff 0x00400000 Kernel EXEC coherent 2: 0xc0600000-0xc067ffff 0x00600000 Kernel EXEC coherent
3: - 4: - 5: - 6: - 7: -
---[ Data Block Address Translation ]---
0: 0xc0000000-0xc07fffff 0x00000000 Kernel RO coherent 1: 0xc0800000-0xc0ffffff 0x00800000 Kernel RW coherent 2: 0xc1000000-0xc1ffffff 0x01000000 Kernel RW coherent 3: 0xc2000000-0xc3ffffff 0x02000000 Kernel RW coherent 4: 0xc4000000-0xc7ffffff 0x04000000 Kernel RW coherent 5: 0xc8000000-0xcfffffff 0x08000000 Kernel RW coherent 6: 0xd0000000-0xdfffffff 0x10000000 Kernel RW coherent
7: -
~# cat /sys/kernel/debug/segment_registers
---[ User Segments ]---
0x00000000-0x0fffffff Kern key 1 User key 1 VSID 0xa085d0 0x10000000-0x1fffffff Kern key 1 User key 1 VSID 0xa086e1 0x20000000-0x2fffffff Kern key 1 User key 1 VSID 0xa087f2 0x30000000-0x3fffffff Kern key 1 User key 1 VSID 0xa08903 0x40000000-0x4fffffff Kern key 1 User key 1 VSID 0xa08a14 0x50000000-0x5fffffff Kern key 1 User key 1 VSID 0xa08b25 0x60000000-0x6fffffff Kern key 1 User key 1 VSID 0xa08c36 0x70000000-0x7fffffff Kern key 1 User key 1 VSID 0xa08d47 0x80000000-0x8fffffff Kern key 1 User key 1 VSID 0xa08e58 0x90000000-0x9fffffff Kern key 1 User key 1 VSID 0xa08f69 0xa0000000-0xafffffff Kern key 1 User key 1 VSID 0xa0907a 0xb0000000-0xbfffffff Kern key 1 User key 1 VSID 0xa0918b
---[ Kernel Segments ]---
0xc0000000-0xcfffffff Kern key 0 User key 1 No Exec VSID 0x000ccc 0xd0000000-0xdfffffff Kern key 0 User key 1 No Exec VSID 0x000ddd 0xe0000000-0xefffffff Kern key 0 User key 1 No Exec VSID 0x000eee 0xf0000000-0xffffffff Kern key 0 User key 1 No Exec VSID 0x000fff
Aligning _etext to 128kb allows to map up to 32Mb text with 8 IBATs:
16Mb + 8Mb + 4Mb + 2Mb + 1Mb + 512kb + 256kb + 128kb (+ 128kb) = 32Mb (A 9th IBAT is unneeded as 32Mb would need only a single 32Mb block)
Aligning data to 4M allows to map up to 512Mb data with 8 DBATs:
16Mb + 8Mb + 4Mb + 4Mb + 32Mb + 64Mb + 128Mb + 256Mb = 512Mb
Because some processors only have 4 BATs and because some targets need DBATs for mapping other areas, the following patch will allow to modify _etext and data alignment.
--- arch/powerpc/Kconfig | 2 + arch/powerpc/include/asm/book3s/32/pgtable.h | 11 ++++ arch/powerpc/mm/init_32.c | 4 +- arch/powerpc/mm/mmu_decl.h | 8 +++ arch/powerpc/mm/pgtable_32.c | 10 +++- arch/powerpc/mm/ppc_mmu_32.c | 87 ++++++++++++++++++++++++++-- 6 files changed, 112 insertions(+), 10 deletions(-)
arch/powerpc/Kconfig +2 -0
@@ -733,11 +733,13 @@ config THREAD_SHIFT config ETEXT_SHIFT int + default 17 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 default PPC_PAGE_SHIFT config DATA_SHIFT int default 24 if STRICT_KERNEL_RWX && PPC64 + default 22 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 default PPC_PAGE_SHIFT config FORCE_MAX_ZONEORDER
arch/powerpc/include/asm/book3s/32/pgtable.h +11 -0
@@ -174,7 +174,18 @@ static inline bool pte_user(pte_t pte)* of RAM. -- Cort */ #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 #define VMALLOC_END ioremap_bot#ifndef __ASSEMBLY__
arch/powerpc/mm/init_32.c +1 -3
@@ -108,10 +108,8 @@ static void __init MMU_setup(void) __map_without_bats =1 ; __map_without_ltlbs =1 ; } -if (strict_kernel_rwx_enabled ()) { - __map_without_bats =1 ; +if (strict_kernel_rwx_enabled ()) __map_without_ltlbs =1 ; - } }/*
arch/powerpc/mm/mmu_decl.h +8 -0
@@ -165,3 +165,11 @@ unsigned long p_block_mapped(phys_addr_t pa);static inline phys_addr_t v_block_mapped (unsigned long va) {return 0 ; }static inline unsigned long p_block_mapped (phys_addr_t pa) {return 0 ; }#endif + +#if defined(CONFIG_PPC_BOOK3S_32 ) +void mmu_mark_initmem_nx (void ); +void mmu_mark_rodata_ro (void ); +#else +static inline void mmu_mark_initmem_nx (void ) { } +static inline void mmu_mark_rodata_ro (void ) { } +#endif
arch/powerpc/mm/pgtable_32.c +9 -1
@@ -351,7 +351,10 @@ void mark_initmem_nx(void)unsigned long numpages =PFN_UP ((unsigned long )_einittext) -PFN_DOWN ((unsigned long )_sinittext); -change_page_attr (page, numpages,PAGE_KERNEL ); +if (v_block_mapped ((unsigned long )_stext) +1 ) +mmu_mark_initmem_nx (); +else +change_page_attr (page, numpages,PAGE_KERNEL ); }#ifdef CONFIG_STRICT_KERNEL_RWX
@@ -360,6 +363,11 @@ void mark_rodata_ro(void)struct page *page;unsigned long numpages; +if (v_block_mapped ((unsigned long )_sinittext)) { +mmu_mark_rodata_ro (); +return ; + } + page =virt_to_page (_stext); numpages =PFN_UP ((unsigned long )_etext) -PFN_DOWN ((unsigned long )_stext);
arch/powerpc/mm/ppc_mmu_32.c +81 -6
108 lines not on this page · raw message
Signature · 1 line
2.13.3
PATCH v2 13/15 powerpc/kconfig: make _etext and data areas alignment configurable on Book3s 32
In reply to Christophe LeroyDepending on the number of available BATs for mapping the different kernel areas, it might be needed to increase the alignment of _etext and/or of data areas.
This patchs allows the user to do it via Kconfig.
--- arch/powerpc/Kconfig | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-)
arch/powerpc/Kconfig +30 -2
@@ -731,16 +731,44 @@ config THREAD_SHIFT Used to define the stack size. The default is almost always what you want. Only change this if you know what you are doing. +config ETEXT_SHIFT_BOOL + bool "Set custom etext alignment" if STRICT_KERNEL_RWX && PPC_BOOK3S_32 + depends on ADVANCED_OPTIONS + help + This option allows you to set the kernel end of text alignment. When + RAM is mapped by blocks, the alignment needs to fit the size and + number of possible blocks. The default should be OK for most configs. + + Say N here unless you know what you are doing. + config ETEXT_SHIFT - int + int "_etext shift" if ETEXT_SHIFT_BOOL + range 17 28 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 default 17 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 default PPC_PAGE_SHIFT + help + On Book3S 32 (603+), IBATs are used to map kernel text. + Smaller is the alignment, greater is the number of necessary IBATs. + +config DATA_SHIFT_BOOL + bool "Set custom data alignment" if STRICT_KERNEL_RWX && PPC_BOOK3S_32 + depends on ADVANCED_OPTIONS + help + This option allows you to set the kernel data alignment. When + RAM is mapped by blocks, the alignment needs to fit the size and + number of possible blocks. The default should be OK for most configs. + + Say N here unless you know what you are doing. config DATA_SHIFT - int + int "Data shift" if DATA_SHIFT_BOOL default 24 if STRICT_KERNEL_RWX && PPC64 + range 17 28 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 default 22 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 default PPC_PAGE_SHIFT + help + On Book3S 32 (603+), DBATs are used to map kernel text and rodata RO. + Smaller is the alignment, greater is the number of necessary DBATs. config FORCE_MAX_ZONEORDER int "Maximum zone order"
Signature · 1 line
2.13.3
PATCH v2 14/15 powerpc/8xx: don't disable large TLBs with CONFIG_STRICT_KERNEL_RWX
In reply to Christophe LeroyThis patch implements handling of STRICT_KERNEL_RWX with large TLBs directly in the TLB miss handlers.
To do so, etext and sinittext are aligned on 512kB boundaries and the miss handlers use 512kB pages instead of 8Mb pages for addresses close to the boundaries.
It sets RO PP flags for addresses under sinittext.
--- arch/powerpc/Kconfig | 2 ++ arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 3 ++- arch/powerpc/kernel/head_8xx.S | 33 ++++++++++++++++++++++++++-- arch/powerpc/mm/8xx_mmu.c | 31 +++++++++++++++++++++++++- arch/powerpc/mm/init_32.c | 2 +- arch/powerpc/mm/mmu_decl.h | 2 +- 6 files changed, 67 insertions(+), 6 deletions(-)
arch/powerpc/Kconfig +2 -0
@@ -745,6 +745,7 @@ config ETEXT_SHIFT int "_etext shift" if ETEXT_SHIFT_BOOL range 17 28 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 default 17 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 + default 19 if STRICT_KERNEL_RWX && PPC_8xx default PPC_PAGE_SHIFT help On Book3S 32 (603+), IBATs are used to map kernel text.
@@ -765,6 +766,7 @@ config DATA_SHIFT default 24 if STRICT_KERNEL_RWX && PPC64 range 17 28 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 default 22 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 + default 19 if STRICT_KERNEL_RWX && PPC_8xx default PPC_PAGE_SHIFT help On Book3S 32 (603+), DBATs are used to map kernel text and rodata RO.
arch/powerpc/include/asm/nohash/32/mmu-8xx.h +2 -1
@@ -231,9 +231,10 @@ static inline unsigned int mmu_psize_to_shift(unsigned int mmu_psize) }/* patch sites */ -extern s32 patch__itlbmiss_linmem_top; +extern s32 patch__itlbmiss_linmem_top, patch__itlbmiss_linmem_top8;extern s32 patch__dtlbmiss_linmem_top, patch__dtlbmiss_immr_jmp;extern s32 patch__fixupdar_linmem_top; +extern s32 patch__dtlbmiss_romem_top, patch__dtlbmiss_romem_top8;extern s32 patch__itlbmiss_exit_1, patch__itlbmiss_exit_2;extern s32 patch__dtlbmiss_exit_1, patch__dtlbmiss_exit_2, patch__dtlbmiss_exit_3;
arch/powerpc/kernel/head_8xx.S +31 -2
@@ -405,10 +405,20 @@ InstructionTLBMiss: #ifndef CONFIG_PIN_TLB_TEXT ITLBMissLinear: mtcr r11 +#ifdef CONFIG_STRICT_KERNEL_RWX + patch_site 0f, patch__itlbmiss_linmem_top8 + + mfspr r10, SPRN_SRR0 +0: subis r11, r10, (PAGE_OFFSET - 0x80000000)@ha + rlwinm r11, r11, 4, MI_PS8MEG ^ MI_PS512K + ori r11, r11, MI_PS512K | MI_SVALID + rlwinm r10, r10, 0, 0x0ff80000 /* 8xx supports max 256Mb RAM */ +#else /* Set 8M byte page and mark it valid */ li r11, MI_PS8MEG | MI_SVALID - mtspr SPRN_MI_TWC, r11 rlwinm r10, r10, 20, 0x0f800000 /* 8xx supports max 256Mb RAM */ +#endif + mtspr SPRN_MI_TWC, r11 ori r10, r10, 0xf0 | MI_SPS16K | _PAGE_SH | _PAGE_DIRTY | \ _PAGE_PRESENT mtspr SPRN_MI_RPN, r10 /* Update TLB entry */
@@ -525,10 +535,29 @@ DTLBMissIMMR: DTLBMissLinear: mtcr r11 + rlwinm r10, r10, 20, 0x0f800000 /* 8xx supports max 256Mb RAM */ +#ifdef CONFIG_STRICT_KERNEL_RWX + patch_site 0f, patch__dtlbmiss_romem_top8 + +0: subis r11, r10, (PAGE_OFFSET - 0x80000000)@ha + rlwinm r11, r11, 0, 0xff800000 + neg r10, r11 + or r11, r11, r10 + rlwinm r11, r11, 4, MI_PS8MEG ^ MI_PS512K + ori r11, r11, MI_PS512K | MI_SVALID + mfspr r10, SPRN_MD_EPN + rlwinm r10, r10, 0, 0x0ff80000 /* 8xx supports max 256Mb RAM */ +#else /* Set 8M byte page and mark it valid */ li r11, MD_PS8MEG | MD_SVALID +#endif mtspr SPRN_MD_TWC, r11 - rlwinm r10, r10, 20, 0x0f800000 /* 8xx supports max 256Mb RAM */ +#ifdef CONFIG_STRICT_KERNEL_RWX + patch_site 0f, patch__dtlbmiss_romem_top + +0: subis r11, r10, 0 + rlwimi r10, r11, 11, _PAGE_RO +#endif ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SH | _PAGE_DIRTY | \ _PAGE_PRESENT mtspr SPRN_MD_RPN, r10 /* Update TLB entry */
arch/powerpc/mm/8xx_mmu.c +30 -1
@@ -94,11 +94,20 @@ static void __init mmu_mapin_immr(void)map_kernel_page (v + offset, p + offset,PAGE_KERNEL_NCG ); } -static void __init mmu_patch_cmp_limit (s32 *site,unsigned long mapped) +static void mmu_patch_cmp_limit (s32 *site,unsigned long mapped) {modify_instruction_site (site,0xffff , (unsigned long )__va (mapped) >>16 ); } +static void mmu_patch_addis (s32 *site,long simm) +{ +unsigned int instr = *(unsigned int *)patch_site_addr (site); + + instr &=0xffff0000 ; + instr |= ((unsigned long )simm) >>16 ; +patch_instruction_site (site, instr); +} +unsigned long __init mmu_mapin_ram (unsigned long base,unsigned long top) {unsigned long mapped;
@@ -135,6 +144,26 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)return mapped; } +void mmu_mark_initmem_nx (void ) +{ +if (IS_ENABLED (CONFIG_STRICT_KERNEL_RWX ) &&CONFIG_ETEXT_SHIFT <23 ) +mmu_patch_addis (&patch__itlbmiss_linmem_top8, + -((long )_etext & ~(LARGE_PAGE_SIZE_8M -1 ))); +if (!IS_ENABLED (CONFIG_PIN_TLB_TEXT )) +mmu_patch_cmp_limit (&patch__itlbmiss_linmem_top,__pa (_etext)); +} + +#ifdef CONFIG_STRICT_KERNEL_RWX +void mmu_mark_rodata_ro (void ) +{ +if (CONFIG_DATA_SHIFT <23 ) +mmu_patch_addis (&patch__dtlbmiss_romem_top8, + -__pa (((unsigned long )_sinittext) & + ~(LARGE_PAGE_SIZE_8M -1 ))); +mmu_patch_addis (&patch__dtlbmiss_romem_top, -__pa (_sinittext)); +} +#endif +void __init setup_initial_memory_limit (phys_addr_t first_memblock_base,phys_addr_t first_memblock_size) {
arch/powerpc/mm/init_32.c +1 -1
@@ -108,7 +108,7 @@ static void __init MMU_setup(void) __map_without_bats =1 ; __map_without_ltlbs =1 ; } -if (strict_kernel_rwx_enabled ()) +if (strict_kernel_rwx_enabled () && !IS_ENABLED (CONFIG_PPC_8xx)) __map_without_ltlbs =1 ; }
arch/powerpc/mm/mmu_decl.h +1 -1
@@ -166,7 +166,7 @@ static inline phys_addr_t v_block_mapped(unsigned long va) { return 0; }static inline unsigned long p_block_mapped (phys_addr_t pa) {return 0 ; }#endif -#if defined(CONFIG_PPC_BOOK3S_32 ) +#if defined(CONFIG_PPC_BOOK3S_32 ) || defined(CONFIG_PPC_8xx)void mmu_mark_initmem_nx (void );void mmu_mark_rodata_ro (void );#else
Signature · 1 line
2.13.3
PATCH v2 15/15 powerpc/kconfig: make _etext and data areas alignment configurable on 8xx
In reply to Christophe LeroyOn 8xx, large pages (512kb or 8M) are used to map kernel linear memory. Aligning to 8M reduces TLB misses as only 8M pages are used in that case.
This patchs allows the user to do it via Kconfig.
--- arch/powerpc/Kconfig | 16 ++++++++++++++-- arch/powerpc/kernel/head_8xx.S | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-)
arch/powerpc/Kconfig +14 -2
@@ -732,7 +732,8 @@ config THREAD_SHIFT want. Only change this if you know what you are doing. config ETEXT_SHIFT_BOOL - bool "Set custom etext alignment" if STRICT_KERNEL_RWX && PPC_BOOK3S_32 + bool "Set custom etext alignment" if STRICT_KERNEL_RWX && \ + (PPC_BOOK3S_32 || PPC_8xx) depends on ADVANCED_OPTIONS help This option allows you to set the kernel end of text alignment. When
@@ -744,6 +745,7 @@ config ETEXT_SHIFT_BOOL config ETEXT_SHIFT int "_etext shift" if ETEXT_SHIFT_BOOL range 17 28 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 + range 19 23 if STRICT_KERNEL_RWX && PPC_8xx default 17 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 default 19 if STRICT_KERNEL_RWX && PPC_8xx default PPC_PAGE_SHIFT
@@ -751,8 +753,13 @@ config ETEXT_SHIFT On Book3S 32 (603+), IBATs are used to map kernel text. Smaller is the alignment, greater is the number of necessary IBATs. + On 8xx, large pages (512kb or 8M) are used to map kernel linear + memory. Aligning to 8M reduces TLB misses as only 8M pages are used + in that case. + config DATA_SHIFT_BOOL - bool "Set custom data alignment" if STRICT_KERNEL_RWX && PPC_BOOK3S_32 + bool "Set custom data alignment" if STRICT_KERNEL_RWX && \ + (PPC_BOOK3S_32 || PPC_8xx) depends on ADVANCED_OPTIONS help This option allows you to set the kernel data alignment. When
@@ -765,6 +772,7 @@ config DATA_SHIFT int "Data shift" if DATA_SHIFT_BOOL default 24 if STRICT_KERNEL_RWX && PPC64 range 17 28 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 + range 19 23 if STRICT_KERNEL_RWX && PPC_8xx default 22 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 default 19 if STRICT_KERNEL_RWX && PPC_8xx default PPC_PAGE_SHIFT
@@ -772,6 +780,10 @@ config DATA_SHIFT On Book3S 32 (603+), DBATs are used to map kernel text and rodata RO. Smaller is the alignment, greater is the number of necessary DBATs. + On 8xx, large pages (512kb or 8M) are used to map kernel linear + memory. Aligning to 8M reduces TLB misses as only 8M pages are used + in that case. + config FORCE_MAX_ZONEORDER int "Maximum zone order" range 8 9 if PPC64 && PPC_64K_PAGES
arch/powerpc/kernel/head_8xx.S +2 -2
@@ -405,7 +405,7 @@ InstructionTLBMiss: #ifndef CONFIG_PIN_TLB_TEXT ITLBMissLinear: mtcr r11 -#ifdef CONFIG_STRICT_KERNEL_RWX +#if defined(CONFIG_STRICT_KERNEL_RWX) && CONFIG_ETEXT_SHIFT < 23 patch_site 0f, patch__itlbmiss_linmem_top8 mfspr r10, SPRN_SRR0
@@ -536,7 +536,7 @@ DTLBMissIMMR: DTLBMissLinear: mtcr r11 rlwinm r10, r10, 20, 0x0f800000 /* 8xx supports max 256Mb RAM */ -#ifdef CONFIG_STRICT_KERNEL_RWX +#if defined(CONFIG_STRICT_KERNEL_RWX) && CONFIG_DATA_SHIFT < 23 patch_site 0f, patch__dtlbmiss_romem_top8 0: subis r11, r10, (PAGE_OFFSET - 0x80000000)@ha
Signature · 1 line
2.13.3
Quoted 3 lines · Christophe Leroy
The purpose of this serie is to:
- use BATs withSTRICT_KERNEL_RWXon book3s (See patch 12 for details.)
- use LTLBs withSTRICT_KERNEL_RWXon 8xx (See patch 14 for a few details.)
Hi,
I just tested the whole series on my Wii (I didn't test any intermediate steps). Without CONFIG_STRICT_KERNEL_RWX, it seems to work fine, but with it, I get the following error while booting:
Quoted 9 lines
top of MEM2 @ 13F00000
zImage starting: loaded at
0x01000000(sp:0x0178afa0) Allocating0x166b2c8bytes for kernel... Decompressing (0x00000000<- 0x01011000:0x01788398)... Done! Decompressed0xf421f4bytesLinux/PowerPC load: root=/dev/mmcblk0p2 rootwait console=usbgecko1 Finalizing device tree... flat tree at
0x178b7a0
Quoted 10 lines
[ 0.000000] printk: bootconsole [udbg0] enabled [ 0.000000] Kernel panic - not syncing: ERROR: Failed to allocate 0x00100000 bytes below 0x00000000. [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc1-wii-00038-g335347fa417f #1337 [ 0.000000] Call Trace: [ 0.000000] [c0f1ff30] [c00280f0] panic+0x144/0x324 (unreliable) [ 0.000000] [c0f1ff90] [c0c18a34] memblock_alloc_base+0x34/0x44 [ 0.000000] [c0f1ffa0] [c0c071e0] MMU_init_hw+0xcc/0x300 [ 0.000000] [c0f1ffd0] [c0c06554] MMU_init+0x12c/0x198 [ 0.000000] [c0f1fff0] [c0003418] start_here+0x40/0x78 [ 0.000000] Rebooting in 180 seconds..
Jonathan
Le 13/01/2019 à 19:16, Jonathan Neuschäfer a écrit :
Quoted 10 lines · Christophe Leroy
Quoted 3 lines
The purpose of this serie is to:
- use BATs withSTRICT_KERNEL_RWXon book3s (See patch 12 for details.)
- use LTLBs withSTRICT_KERNEL_RWXon 8xx (See patch 14 for a few details.)Hi,
I just tested the whole series on my Wii (I didn't test any intermediate steps). Without
CONFIG_STRICT_KERNEL_RWX, it seems to work fine, but with it, I get the following error while booting:
Argh !
Can you please send the System.map file generated at compile time ?
Thanks
Christophe
Quoted 24 lines
Quoted 10 lines
top of MEM2 @ 13F00000
zImage starting: loaded at
0x01000000(sp:0x0178afa0) Allocating0x166b2c8bytes for kernel... Decompressing (0x00000000<- 0x01011000:0x01788398)... Done! Decompressed0xf421f4bytesLinux/PowerPC load: root=/dev/mmcblk0p2 rootwait console=usbgecko1 Finalizing device tree... flat tree at
0x178b7a0Quoted 10 lines
[ 0.000000] printk: bootconsole [udbg0] enabled [ 0.000000] Kernel panic - not syncing: ERROR: Failed to allocate 0x00100000 bytes below 0x00000000. [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc1-wii-00038-g335347fa417f #1337 [ 0.000000] Call Trace: [ 0.000000] [c0f1ff30] [c00280f0] panic+0x144/0x324 (unreliable) [ 0.000000] [c0f1ff90] [c0c18a34] memblock_alloc_base+0x34/0x44 [ 0.000000] [c0f1ffa0] [c0c071e0] MMU_init_hw+0xcc/0x300 [ 0.000000] [c0f1ffd0] [c0c06554] MMU_init+0x12c/0x198 [ 0.000000] [c0f1fff0] [c0003418] start_here+0x40/0x78 [ 0.000000] Rebooting in 180 seconds..Jonathan
Quoted 8 lines · Christophe Leroy
Le 13/01/2019 à 19:16, Jonathan Neuschäfer a écrit :
Quoted 3 lines
I just tested the whole series on my Wii (I didn't test any intermediate steps). Without
CONFIG_STRICT_KERNEL_RWX, it seems to work fine, but with it, I get the following error while booting:Argh !
Can you please send the System.map file generated at compile time ?
And here's the config, reduced with 'make savedefconfig':
https://gist.githubusercontent.com/neuschaefer/12ccc87ff8aeff543fad558e8742cd2b/raw/d49d321709cac364779e6893bbd91ff5a80bcb03/config
The exact code I used is here:
https://github.com/neuschaefer/linux/tree/ppcbat-test
Thanks,
Jonathan
Le 13/01/2019 à 22:02, Jonathan Neuschäfer a écrit :
Quoted 10 lines · Christophe Leroy
Quoted 8 lines
Le 13/01/2019 à 19:16, Jonathan Neuschäfer a écrit :
Quoted 3 lines
I just tested the whole series on my Wii (I didn't test any intermediate steps). Without
CONFIG_STRICT_KERNEL_RWX, it seems to work fine, but with it, I get the following error while booting:Argh !
Can you please send the System.map file generated at compile time ?
Quoted 8 lines
Here:
https://gist.githubusercontent.com/neuschaefer/12ccc87ff8aeff543fad558e8742cd2b/raw/d49d321709cac364779e6893bbd91ff5a80bcb03/System.mapAnd here's the config, reduced with 'make savedefconfig':
https://gist.githubusercontent.com/neuschaefer/12ccc87ff8aeff543fad558e8742cd2b/raw/d49d321709cac364779e6893bbd91ff5a80bcb03/configThe exact code I used is here:
https://github.com/neuschaefer/linux/tree/ppcbat-test
Thanks
I can't see anything special in your setup, and this failure looks rather unexpected because I can't see anything done that early when CONFIG_STRICT_KERNEL_RWX is selected.
Does CONFIG_STRICT_KERNEL_RWX works properly without my serie ?
Christophe
Quoted 5 lines
Thanks,
Jonathan
Quoted 8 lines · Christophe Leroy
Le 13/01/2019 à 22:02, Jonathan Neuschäfer a écrit :
Quoted 5 lines · Christophe Leroy
Quoted 4 lines
Le 13/01/2019 à 19:16, Jonathan Neuschäfer a écrit :
Quoted 3 lines
I just tested the whole series on my Wii (I didn't test any intermediate steps). Without
CONFIG_STRICT_KERNEL_RWX, it seems to work fine, but with it, I get the following error while booting:
[...]
Quoted 5 lines
I can't see anything special in your setup, and this failure looks rather unexpected because I can't see anything done that early when
CONFIG_STRICT_KERNEL_RWXis selected.Does
CONFIG_STRICT_KERNEL_RWXworks properly without my serie ?
I hadn't tried this before, but yes, without this series (on v5.0-rc2), a kernel with CONFIG_STRICT_KERNEL_RWX boots.
I've checked it patch-by-patch now (with STRICT_KERNEL_RWX):
- patches 1 and 2 build and boot fine
- patches 3 to 6 build, but fail to boot with this error:
top of MEM2 @ 13F00000 zImage starting: loaded at 0x00e00000 (sp: 0x01588fa0) Allocating 0x14e92c8 bytes for kernel... Decompressing (0x00000000 <- 0x00e11000:0x01586ba7)... Done! Decompressed 0xdc01f4 bytes Linux/PowerPC load: root=/dev/mmcblk0p2 rootwait console=usbgecko1 Finalizing device tree... flat tree at 0x15897a0 [ 0.000000] printk: bootconsole [udbg0] enabled [ 0.000000] Total memory = 319MB; using 1024kB for hash table (at (ptrval)) [ 0.000000] RAM mapped without BATs [ 0.000000] RAM mapped without BATs [ 0.000000] ------------[ cut here ]------------ [ 0.000000] kernel BUG at arch/powerpc/mm/pgtable_32.c:223! [ 0.000000] Oops: Exception in kernel mode, sig: 5 [#1] [ 0.000000] BE PREEMPT [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc1-wii-00024-g596f9fe23c13 #1337 [ 0.000000] NIP: c0017c4c LR: c0a836a0 CTR: c001edc4 [ 0.000000] REGS: c0d9deb0 TRAP: 0700 Not tainted (5.0.0-rc1-wii-00024-g596f9fe23c13) [ 0.000000] MSR: 00020030 <IR,DR> CR: 42000888 XER: 20000000 [ 0.000000] [ 0.000000] GPR00: c0a836a0 c0d9df60 c0d2a4a0 c0d29c00 00000000 c16ff000 c0d9de28 c0dc0000 [ 0.000000] GPR08: c0d9c000 00000001 00000001 00000000 28000824 00000000 00000000 00000000 [ 0.000000] GPR16: 00000000 00000000 00000020 00000000 c0860000 c0da0000 c0000000 c0a7d000 [ 0.000000] GPR24: c0acd55c c0d487c8 13f00000 c0d29000 00000c00 00000311 c0000000 c0d487c8 [ 0.000000] NIP [c0017c4c] map_kernel_page+0x78/0xf0 [ 0.000000] LR [c0a836a0] mapin_ram+0xe0/0x14c [ 0.000000] Call Trace: [ 0.000000] [c0d9df60] [c0a83f54] mmu_mapin_ram+0x54/0x1a4 (unreliable) [ 0.000000] [c0d9df90] [c0a836a0] mapin_ram+0xe0/0x14c [ 0.000000] [c0d9dfd0] [c0a83578] MMU_init+0x158/0x1a0 [ 0.000000] [c0d9dff0] [c0003418] start_here+0x40/0x78 [ 0.000000] Instruction dump: [ 0.000000] 55290026 57c5b53a 7ca54a14 3d204000 7f854800 3ca5c000 419e0088 81250000 [ 0.000000] 552afffe 552907fe 7d4a4b79 4082004c <0f0a0000> 54840026 7c84eb78 9081000c [ 0.000000] random: get_random_bytes called from print_oops_end_marker+0x34/0x6c with crng_init=0 [ 0.000000] ---[ end trace 0000000000000000 ]--- [ 0.000000] [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task! [ 0.000000] Rebooting in 180 seconds..
- patches 7 to 11 fail to build with this error (really a warning, but arch/powerpc doesn't allow warnings by default):
CC arch/powerpc/mm/ppc_mmu_32.o
../arch/powerpc/mm/ppc_mmu_32.c:133:13: error: ‘clearibat’ defined but not used [-Werror=unused-function]
static void clearibat(int index)
^~~~~~~~~
../arch/powerpc/mm/ppc_mmu_32.c:115:13: error: ‘setibat’ defined but not used [-Werror=unused-function]
static void setibat(int index, unsigned long virt, phys_addr_t phys,
^~~~~~~
cc1: all warnings being treated as errors
- patches 12 to 15 build but fail to boot with this error:
top of MEM2 @ 13F00000 zImage starting: loaded at 0x01000000 (sp: 0x0178afa0) Allocating 0x166b2c8 bytes for kernel... Decompressing (0x00000000 <- 0x01011000:0x017880ce)... Done! Decompressed 0xf421f4 bytes Linux/PowerPC load: root=/dev/mmcblk0p2 rootwait console=usbgecko1 Finalizing device tree... flat tree at 0x178b7a0 [ 0.000000] printk: bootconsole [udbg0] enabled [ 0.000000] Kernel panic - not syncing: ERROR: Failed to allocate 0x00100000 bytes below 0x00000000. [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc1-wii-00033-gc263f8162122 #1337 [ 0.000000] Call Trace: [ 0.000000] [c0f1ff30] [c00280f0] panic+0x144/0x324 (unreliable) [ 0.000000] [c0f1ff90] [c0c18a34] memblock_alloc_base+0x34/0x44 [ 0.000000] [c0f1ffa0] [c0c071e0] MMU_init_hw+0xcc/0x300 [ 0.000000] [c0f1ffd0] [c0c06554] MMU_init+0x12c/0x198 [ 0.000000] [c0f1fff0] [c0003418] start_here+0x40/0x78 [ 0.000000] Rebooting in 180 seconds..
I'll investigate some more tomorrow.
Jonathan
Le 15/01/2019 à 01:33, Jonathan Neuschäfer a écrit :
Quoted 16 lines · Christophe Leroy
Quoted 8 lines
Le 13/01/2019 à 22:02, Jonathan Neuschäfer a écrit :
Quoted 5 lines · Christophe Leroy
Quoted 4 lines
Le 13/01/2019 à 19:16, Jonathan Neuschäfer a écrit :
Quoted 3 lines
I just tested the whole series on my Wii (I didn't test any intermediate steps). Without
CONFIG_STRICT_KERNEL_RWX, it seems to work fine, but with it, I get the following error while booting:[...]
Quoted 5 lines
I can't see anything special in your setup, and this failure looks rather unexpected because I can't see anything done that early when
CONFIG_STRICT_KERNEL_RWXis selected.Does
CONFIG_STRICT_KERNEL_RWXworks properly without my serie ?
Quoted 7 lines
I hadn't tried this before, but yes, without this series (on v5.0-rc2), a kernel with
CONFIG_STRICT_KERNEL_RWXboots.I've checked it patch-by-patch now (with
STRICT_KERNEL_RWX):- patches 1 and 2 build and boot fine
- patches 3 to 6 build, but fail to boot with this error:
The bug is in patch 2, mmu_mapin_ram() should return base instead of returning 0 when __map_without_bats is set.
Quoted 47 lines
top of MEM2 @ 13F00000 zImage starting: loaded at 0x00e00000 (sp: 0x01588fa0) Allocating 0x14e92c8 bytes for kernel... Decompressing (0x00000000 <- 0x00e11000:0x01586ba7)... Done! Decompressed 0xdc01f4 bytes Linux/PowerPC load: root=/dev/mmcblk0p2 rootwait console=usbgecko1 Finalizing device tree... flat tree at 0x15897a0 [ 0.000000] printk: bootconsole [udbg0] enabled [ 0.000000] Total memory = 319MB; using 1024kB for hash table (at (ptrval)) [ 0.000000] RAM mapped without BATs [ 0.000000] RAM mapped without BATs [ 0.000000] ------------[ cut here ]------------ [ 0.000000] kernel BUG at arch/powerpc/mm/pgtable_32.c:223! [ 0.000000] Oops: Exception in kernel mode, sig: 5 [#1] [ 0.000000] BE PREEMPT [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc1-wii-00024-g596f9fe23c13 #1337 [ 0.000000] NIP: c0017c4c LR: c0a836a0 CTR: c001edc4 [ 0.000000] REGS: c0d9deb0 TRAP: 0700 Not tainted (5.0.0-rc1-wii-00024-g596f9fe23c13) [ 0.000000] MSR: 00020030 <IR,DR> CR: 42000888 XER: 20000000 [ 0.000000] [ 0.000000] GPR00: c0a836a0 c0d9df60 c0d2a4a0 c0d29c00 00000000 c16ff000 c0d9de28 c0dc0000 [ 0.000000] GPR08: c0d9c000 00000001 00000001 00000000 28000824 00000000 00000000 00000000 [ 0.000000] GPR16: 00000000 00000000 00000020 00000000 c0860000 c0da0000 c0000000 c0a7d000 [ 0.000000] GPR24: c0acd55c c0d487c8 13f00000 c0d29000 00000c00 00000311 c0000000 c0d487c8 [ 0.000000] NIP [c0017c4c] map_kernel_page+0x78/0xf0 [ 0.000000] LR [c0a836a0] mapin_ram+0xe0/0x14c [ 0.000000] Call Trace: [ 0.000000] [c0d9df60] [c0a83f54] mmu_mapin_ram+0x54/0x1a4 (unreliable) [ 0.000000] [c0d9df90] [c0a836a0] mapin_ram+0xe0/0x14c [ 0.000000] [c0d9dfd0] [c0a83578] MMU_init+0x158/0x1a0 [ 0.000000] [c0d9dff0] [c0003418] start_here+0x40/0x78 [ 0.000000] Instruction dump: [ 0.000000] 55290026 57c5b53a 7ca54a14 3d204000 7f854800 3ca5c000 419e0088 81250000 [ 0.000000] 552afffe 552907fe 7d4a4b79 4082004c <0f0a0000> 54840026 7c84eb78 9081000c [ 0.000000] random: get_random_bytes called from print_oops_end_marker+0x34/0x6c with crng_init=0 [ 0.000000] ---[ end trace 0000000000000000 ]--- [ 0.000000] [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task! [ 0.000000] Rebooting in 180 seconds..- patches 7 to 11 fail to build with this error (really a warning, but
arch/powerpcdoesn't allow warnings by default):
Quoted 8 lines
CC
arch/powerpc/mm/ppc_mmu_32.o
../arch/powerpc/mm/ppc_mmu_32.c:133:13: error: ‘clearibat’ defined but not used [-Werror=unused-function]
static void clearibat(int index)
^~~~~~~~~
../arch/powerpc/mm/ppc_mmu_32.c:115:13: error: ‘setibat’ defined but not used [-Werror=unused-function]
static void setibat(int index, unsigned long virt,phys_addr_tphys,
^~~~~~~
cc1: all warnings being treated as errors
Argh ! I have to squash the patch bringing the new functions with the one using them (patch 12). The result is a big messy patch which is more difficult to review but that's life.
Quoted 2 lines
- patches 12 to 15 build but fail to boot with this error:
Thats the one we need to really understand.
Do you have modules ? If so, can you try without ?
Quoted 22 lines
top of MEM2 @ 13F00000 zImage starting: loaded at 0x01000000 (sp: 0x0178afa0) Allocating 0x166b2c8 bytes for kernel... Decompressing (0x00000000 <- 0x01011000:0x017880ce)... Done! Decompressed 0xf421f4 bytes Linux/PowerPC load: root=/dev/mmcblk0p2 rootwait console=usbgecko1 Finalizing device tree... flat tree at 0x178b7a0 [ 0.000000] printk: bootconsole [udbg0] enabled [ 0.000000] Kernel panic - not syncing: ERROR: Failed to allocate 0x00100000 bytes below 0x00000000. [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc1-wii-00033-gc263f8162122 #1337 [ 0.000000] Call Trace: [ 0.000000] [c0f1ff30] [c00280f0] panic+0x144/0x324 (unreliable) [ 0.000000] [c0f1ff90] [c0c18a34] memblock_alloc_base+0x34/0x44 [ 0.000000] [c0f1ffa0] [c0c071e0] MMU_init_hw+0xcc/0x300 [ 0.000000] [c0f1ffd0] [c0c06554] MMU_init+0x12c/0x198 [ 0.000000] [c0f1fff0] [c0003418] start_here+0x40/0x78 [ 0.000000] Rebooting in 180 seconds..
Quoted 1 line
I'll investigate some more tomorrow.
Thanks a lot for your help.
Quoted 3 lines
Jonathan
Christophe
Michael Ellerman
reviewerQuoted 1 line · Christophe Leroy
Le 15/01/2019 à 01:33, Jonathan Neuschäfer a écrit :
...
Quoted 13 lines
Quoted 4 lines
- patches 7 to 11 fail to build with this error (really a warning, but
arch/powerpcdoesn't allow warnings by default):Quoted 8 lines
CC
arch/powerpc/mm/ppc_mmu_32.o
../arch/powerpc/mm/ppc_mmu_32.c:133:13: error: ‘clearibat’ defined but not used [-Werror=unused-function]
static void clearibat(int index)
^~~~~~~~~
../arch/powerpc/mm/ppc_mmu_32.c:115:13: error: ‘setibat’ defined but not used [-Werror=unused-function]
static void setibat(int index, unsigned long virt,phys_addr_tphys,
^~~~~~~
cc1: all warnings being treated as errors
Quoted 3 lines
Argh ! I have to squash the patch bringing the new functions with the one using them (patch 12). The result is a big messy patch which is more difficult to review but that's life.
You don't *have* to squash them.
We like to preserve bisectability, but it's not a 100% hard requirement.
Someone trying to bisect through those patches can always turn off -Werror with PPC_DISABLE_WERROR. But they probably can just skip them because they just add new code that's not called yet.
So I won't object if you send them as-is.
cheers
Le 15/01/2019 à 11:22, Michael Ellerman a écrit :
Quoted 20 lines
Quoted 1 line · Christophe Leroy
Le 15/01/2019 à 01:33, Jonathan Neuschäfer a écrit :
...
Quoted 13 lines
Quoted 4 lines
- patches 7 to 11 fail to build with this error (really a warning, but
arch/powerpcdoesn't allow warnings by default):Quoted 8 lines
CC
arch/powerpc/mm/ppc_mmu_32.o
../arch/powerpc/mm/ppc_mmu_32.c:133:13: error: ‘clearibat’ defined but not used [-Werror=unused-function]
static void clearibat(int index)
^~~~~~~~~
../arch/powerpc/mm/ppc_mmu_32.c:115:13: error: ‘setibat’ defined but not used [-Werror=unused-function]
static void setibat(int index, unsigned long virt,phys_addr_tphys,
^~~~~~~
cc1: all warnings being treated as errorsQuoted 3 lines
Argh ! I have to squash the patch bringing the new functions with the one using them (patch 12). The result is a big messy patch which is more difficult to review but that's life.
Quoted 7 lines
You don't *have* to squash them.
We like to preserve bisectability, but it's not a 100% hard requirement.
Someone trying to bisect through those patches can always turn off -Werror with
PPC_DISABLE_WERROR. But they probably can just skip them because they just add new code that's not called yet.
Ok thanks for the note.
Quoted 2 lines
So I won't object if you send them as-is.
Good to know. Anyway I think I will at least re-order so that the patch using the new functions immediatly follows the one adding the functions.
Christophe
Quoted 3 lines
cheers
Michael Ellerman
reviewerQuoted 29 lines · Christophe Leroy
Le 15/01/2019 à 11:22, Michael Ellerman a écrit :
Quoted 20 lines
Quoted 1 line · Christophe Leroy
Le 15/01/2019 à 01:33, Jonathan Neuschäfer a écrit :
...
Quoted 13 lines
Quoted 4 lines
- patches 7 to 11 fail to build with this error (really a warning, but
arch/powerpcdoesn't allow warnings by default):Quoted 8 lines
CC
arch/powerpc/mm/ppc_mmu_32.o
../arch/powerpc/mm/ppc_mmu_32.c:133:13: error: ‘clearibat’ defined but not used [-Werror=unused-function]
static void clearibat(int index)
^~~~~~~~~
../arch/powerpc/mm/ppc_mmu_32.c:115:13: error: ‘setibat’ defined but not used [-Werror=unused-function]
static void setibat(int index, unsigned long virt,phys_addr_tphys,
^~~~~~~
cc1: all warnings being treated as errorsQuoted 3 lines
Argh ! I have to squash the patch bringing the new functions with the one using them (patch 12). The result is a big messy patch which is more difficult to review but that's life.
Quoted 7 lines
You don't *have* to squash them.
We like to preserve bisectability, but it's not a 100% hard requirement.
Someone trying to bisect through those patches can always turn off -Werror with
PPC_DISABLE_WERROR. But they probably can just skip them because they just add new code that's not called yet.
Quoted 7 lines
Ok thanks for the note.
Quoted 2 lines
So I won't object if you send them as-is.
Good to know. Anyway I think I will at least re-order so that the patch using the new functions immediatly follows the one adding the functions.
Based on that I'm expecting a v3 of this series, right?
cheers
Le 20/02/2019 à 14:23, Michael Ellerman a écrit :
Quoted 34 lines
Quoted 32 lines · Christophe Leroy
Le 15/01/2019 à 11:22, Michael Ellerman a écrit :
Quoted 20 lines
Quoted 1 line · Christophe Leroy
Le 15/01/2019 à 01:33, Jonathan Neuschäfer a écrit :
...
Quoted 13 lines
Quoted 4 lines
- patches 7 to 11 fail to build with this error (really a warning, but
arch/powerpcdoesn't allow warnings by default):Quoted 8 lines
CC
arch/powerpc/mm/ppc_mmu_32.o
../arch/powerpc/mm/ppc_mmu_32.c:133:13: error: ‘clearibat’ defined but not used [-Werror=unused-function]
static void clearibat(int index)
^~~~~~~~~
../arch/powerpc/mm/ppc_mmu_32.c:115:13: error: ‘setibat’ defined but not used [-Werror=unused-function]
static void setibat(int index, unsigned long virt,phys_addr_tphys,
^~~~~~~
cc1: all warnings being treated as errorsQuoted 3 lines
Argh ! I have to squash the patch bringing the new functions with the one using them (patch 12). The result is a big messy patch which is more difficult to review but that's life.
Quoted 7 lines
You don't *have* to squash them.
We like to preserve bisectability, but it's not a 100% hard requirement.
Someone trying to bisect through those patches can always turn off -Werror with
PPC_DISABLE_WERROR. But they probably can just skip them because they just add new code that's not called yet.Ok thanks for the note.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
So I won't object if you send them as-is.
Good to know. Anyway I think I will at least re-order so that the patch using the new functions immediatly follows the one adding the functions.
Based on that I'm expecting a v3 of this series, right?
Right. Coming soon.
Christophe
Quoted 1 line · Christophe Leroy
Le 15/01/2019 à 01:33, Jonathan Neuschäfer a écrit :
[...]
Quoted 7 lines
Quoted 4 lines
I've checked it patch-by-patch now (with
STRICT_KERNEL_RWX):- patches 1 and 2 build and boot fine
- patches 3 to 6 build, but fail to boot with this error:The bug is in patch 2,
mmu_mapin_ram()should return base instead of returning 0 when__map_without_batsis set.
Indeed, with this change, I can boot up to patch 11.
Quoted 5 lines
Quoted 1 line
- patches 12 to 15 build but fail to boot with this error:
Thats the one we need to really understand.
Do you have modules ? If so, can you try without ?
I don't use any modules in my test setup, but I have module support enabled. Disabling CONFIG_MODULES makes no difference, as far as I can see (I get the same backtrace with memblock_alloc_base+0x34/0x44).
Quoted 5 lines
Quoted 5 lines
[ 0.000000] [c0f1ff30] [c00280f0] panic+0x144/0x324 (unreliable) [ 0.000000] [c0f1ff90] [c0c18a34] memblock_alloc_base+0x34/0x44 [ 0.000000] [c0f1ffa0] [c0c071e0] MMU_init_hw+0xcc/0x300 [ 0.000000] [c0f1ffd0] [c0c06554] MMU_init+0x12c/0x198 [ 0.000000] [c0f1fff0] [c0003418] start_here+0x40/0x78
With a few printks[1], I traced this error, and got the following result:
[ 0.000000] __memblock_find_range_top_down(1000:1800000, 100000:100000, ffffffff, 0) [ 0.000000] __memblock_find_range_top_down: in loop, 10000000:13f00000 [ 0.000000] __memblock_find_range_top_down: in loop, 179962d:1800000 [ 0.000000] __memblock_find_range_top_down: in loop, 1676000:17987a0 [ 0.000000] __memblock_find_range_top_down: nothing found :(
The limit of 0x1800000 comes from setup_initial_memory_limit, which only considers the first memblock, but the second memblock starts at 256MiB, so it wouldn't be usable anyway, according to the comment in setup_initial_memory_limit.
Thinning the kernel down a bit actually makes it boot again. Ooops...! Maybe enabling CONFIG_STRICT_KERNEL_RWX has made it just large enough to fail the hash table allocation, but there may have been other factors involved (I'm not sure exactly). Sorry for the confusion!
Jonathan
[1]:
mm/memblock.c +4 -0
@@ -215,8 +215,11 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,phys_addr_t this_start, this_end, cand;u64 i; +printk ("%s(%x:%x, %x:%x, %x, %x)\n" , __func__, start, end, size, align, nid, flags); +for_each_free_mem_range_reverse (i, nid, flags, &this_start, &this_end,NULL ) { +printk ("%s: in loop, %x:%x\n" , __func__, this_start, this_end); this_start =clamp (this_start, start, end); this_end =clamp (this_end, start, end);
@@ -228,6 +231,7 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,return cand; } +printk ("%s: nothing found :(\n" , __func__);return 0 ; }
Le 16/01/2019 à 01:35, Jonathan Neuschäfer a écrit :
Quoted 38 lines · Christophe Leroy
Quoted 1 line
Le 15/01/2019 à 01:33, Jonathan Neuschäfer a écrit :
[...]
Quoted 7 lines
Quoted 4 lines
I've checked it patch-by-patch now (with
STRICT_KERNEL_RWX):- patches 1 and 2 build and boot fine
- patches 3 to 6 build, but fail to boot with this error:The bug is in patch 2,
mmu_mapin_ram()should return base instead of returning 0 when__map_without_batsis set.Indeed, with this change, I can boot up to patch 11.
Quoted 5 lines
Quoted 1 line
- patches 12 to 15 build but fail to boot with this error:
Thats the one we need to really understand.
Do you have modules ? If so, can you try without ?
I don't use any modules in my test setup, but I have module support enabled. Disabling
CONFIG_MODULESmakes no difference, as far as I can see (I get the same backtrace withmemblock_alloc_base+0x34/0x44).Quoted 5 lines
Quoted 5 lines
[ 0.000000] [c0f1ff30] [c00280f0] panic+0x144/0x324 (unreliable) [ 0.000000] [c0f1ff90] [c0c18a34] memblock_alloc_base+0x34/0x44 [ 0.000000] [c0f1ffa0] [c0c071e0] MMU_init_hw+0xcc/0x300 [ 0.000000] [c0f1ffd0] [c0c06554] MMU_init+0x12c/0x198 [ 0.000000] [c0f1fff0] [c0003418] start_here+0x40/0x78With a few printks[1], I traced this error, and got the following result:
[ 0.000000] __memblock_find_range_top_down(1000:1800000, 100000:100000, ffffffff, 0) [ 0.000000] __memblock_find_range_top_down: in loop, 10000000:13f00000 [ 0.000000] __memblock_find_range_top_down: in loop, 179962d:1800000 [ 0.000000] __memblock_find_range_top_down: in loop, 1676000:17987a0 [ 0.000000] __memblock_find_range_top_down: nothing found :(
Quoted 4 lines
The limit of
0x1800000comes fromsetup_initial_memory_limit, which only considers the first memblock, but the second memblock starts at 256MiB, so it wouldn't be usable anyway, according to the comment insetup_initial_memory_limit.
Yes, initial_bats() in head_32.S sets one 256Mb BAT for initial booting:
/*
* On 601, we use 3 BATs to map up to 24M of RAM at _PAGE_OFFSET
* (we keep one for debugging) and on others, we use one 256M BAT. */initial_bats:
lis r11,PAGE_OFFSET@h mfspr r9,SPRN_PVR rlwinm r9,r9,16,16,31 /* r9 = 1 for 601, 4 for 604 */ cmpwi 0,r9,1 bne 4f ... 4: tophys(r8,r11) #ifdef CONFIG_SMP ori r8,r8,0x12 /* R/W access, M=1 */ #else ori r8,r8,2 /* R/W access */ #endif /* CONFIG_SMP */ ori r11,r11,BL_256M<<2|0x2 /* set up BAT registers for 604 */ mtspr SPRN_DBAT0L,r8 /* N.B. 6xx (not 601) have valid */ mtspr SPRN_DBAT0U,r11 /* bit in upper BAT register */ mtspr SPRN_IBAT0L,r8 mtspr SPRN_IBAT0U,r11 isync blr
Quoted 5 lines
Thinning the kernel down a bit actually makes it boot again. Ooops...! Maybe enabling
CONFIG_STRICT_KERNEL_RWXhas made it just large enough to fail the hash table allocation, but there may have been other factors involved (I'm not sure exactly). Sorry for the confusion!
Ok, that must be the reason. Thanks for testing.
What about the following modification which maps a second 256Mb BAT, does it helps ?
arch/powerpc/kernel/head_32.S +8 -0
@@ -1160,6 +1160,14 @@ initial_bats: mtspr SPRN_DBAT0U,r11 /* bit in upper BAT register */ mtspr SPRN_IBAT0L,r8 mtspr SPRN_IBAT0U,r11 +#ifdef CONFIG_WII + addis r11,r11,0x10000000@h + addis r8,r8,0x10000000@h + mtspr SPRN_DBAT2L,r8 + mtspr SPRN_DBAT2U,r11 + mtspr SPRN_IBAT2L,r8 + mtspr SPRN_IBAT2U,r11 +#endif isync blr
arch/powerpc/mm/ppc_mmu_32.c +2 -0
@@ -259,6 +259,8 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base,/* 601 can only access 16MB at the moment */ if (PVR_VER (mfspr (SPRN_PVR )) ==1 )memblock_set_current_limit (min_t (u64, first_memblock_size,0x01000000 )); +else if (IS_ENABLED (CONFIG_WII )) +memblock_set_current_limit (min_t (u64, first_memblock_size,0x20000000 ));else /* Anything else has 256M mapped */ memblock_set_current_limit (min_t (u64, first_memblock_size,0x10000000 )); }
Christophe
Quoted 30 lines
Jonathan
[1]:
mm/memblock.c +4
-0@@ -215,8 +215,11 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,phys_addr_t this_start, this_end, cand;u64 i; +printk ("%s(%x:%x, %x:%x, %x, %x)\n" , __func__, start, end, size, align, nid, flags); +for_each_free_mem_range_reverse (i, nid, flags, &this_start, &this_end,NULL ) { +printk ("%s: in loop, %x:%x\n" , __func__, this_start, this_end); this_start =clamp (this_start, start, end); this_end =clamp (this_end, start, end);@@ -228,6 +231,7 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,return cand; } +printk ("%s: nothing found :(\n" , __func__);return 0 ; }
Quoted 45 lines · Christophe Leroy
Le 16/01/2019 à 01:35, Jonathan Neuschäfer a écrit :
Quoted 4 lines
Thinning the kernel down a bit actually makes it boot again. Ooops...! Maybe enabling
CONFIG_STRICT_KERNEL_RWXhas made it just large enough to fail the hash table allocation, but there may have been other factors involved (I'm not sure exactly). Sorry for the confusion!Ok, that must be the reason. Thanks for testing.
What about the following modification which maps a second 256Mb BAT, does it helps ?
arch/powerpc/kernel/head_32.S +8
-0@@ -1160,6 +1160,14 @@ initial_bats: mtspr SPRN_DBAT0U,r11 /* bit in upper BAT register */ mtspr SPRN_IBAT0L,r8 mtspr SPRN_IBAT0U,r11 +#ifdef CONFIG_WII + addis r11,r11,0x10000000@h + addis r8,r8,0x10000000@h + mtspr SPRN_DBAT2L,r8 + mtspr SPRN_DBAT2U,r11 + mtspr SPRN_IBAT2L,r8 + mtspr SPRN_IBAT2U,r11 +#endif isync blrarch/powerpc/mm/ppc_mmu_32.c +2
-0@@ -259,6 +259,8 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base,/* 601 can only access 16MB at the moment */ if (PVR_VER (mfspr (SPRN_PVR )) ==1 )memblock_set_current_limit (min_t (u64, first_memblock_size,0x01000000 )); +else if (IS_ENABLED (CONFIG_WII )) +memblock_set_current_limit (min_t (u64, first_memblock_size,0x20000000 ));else /* Anything else has 256M mapped */ memblock_set_current_limit (min_t (u64, first_memblock_size,0x10000000 ));
Quoted 1 line
}
I haven't tested it, but this patch won't be enough, because we're only looking at the first memblock, and the additional memory in the Wii (MEM2) is the second memblock.
Jonathan
Le 16/01/2019 à 14:16, Jonathan Neuschäfer a écrit :
Quoted 43 lines · Christophe Leroy
Quoted 42 lines
Le 16/01/2019 à 01:35, Jonathan Neuschäfer a écrit :
Quoted 4 lines
Thinning the kernel down a bit actually makes it boot again. Ooops...! Maybe enabling
CONFIG_STRICT_KERNEL_RWXhas made it just large enough to fail the hash table allocation, but there may have been other factors involved (I'm not sure exactly). Sorry for the confusion!Ok, that must be the reason. Thanks for testing.
What about the following modification which maps a second 256Mb BAT, does it helps ?
arch/powerpc/kernel/head_32.S +8
-0@@ -1160,6 +1160,14 @@ initial_bats: mtspr SPRN_DBAT0U,r11 /* bit in upper BAT register */ mtspr SPRN_IBAT0L,r8 mtspr SPRN_IBAT0U,r11 +#ifdef CONFIG_WII + addis r11,r11,0x10000000@h + addis r8,r8,0x10000000@h + mtspr SPRN_DBAT2L,r8 + mtspr SPRN_DBAT2U,r11 + mtspr SPRN_IBAT2L,r8 + mtspr SPRN_IBAT2U,r11 +#endif isync blrarch/powerpc/mm/ppc_mmu_32.c +1
-0@@ -259,6 +259,8 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base,/* 601 can only access 16MB at the moment */ if (PVR_VER(mfspr(SPRN_PVR)) == 1)memblock_set_current_limit (min_t (u64, first_memblock_size,0x01000000 )); + else if (IS_ENABLED(CONFIG_WII))
Quoted 9 lines
Quoted 4 lines
arch/powerpc/mm/ppc_mmu_32.c +1
-0+memblock_set_current_limit (min_t (u64, first_memblock_size,0x20000000 )); else /* Anything else has 256M mapped */ memblock_set_current_limit(min_t(u64, first_memblock_size, 0x10000000));}I haven't tested it, but this patch won't be enough, because we're only looking at the first memblock, and the additional memory in the Wii (MEM2) is the second memblock.
Yes right.
Would the following work instead ?
memblock_set_current_limit(0x20000000);
Christophe
Quoted 54 lines · Christophe Leroy
Le 16/01/2019 à 14:16, Jonathan Neuschäfer a écrit :
Quoted 43 lines · Christophe Leroy
Quoted 42 lines
Le 16/01/2019 à 01:35, Jonathan Neuschäfer a écrit :
Quoted 4 lines
Thinning the kernel down a bit actually makes it boot again. Ooops...! Maybe enabling
CONFIG_STRICT_KERNEL_RWXhas made it just large enough to fail the hash table allocation, but there may have been other factors involved (I'm not sure exactly). Sorry for the confusion!Ok, that must be the reason. Thanks for testing.
What about the following modification which maps a second 256Mb BAT, does it helps ?
arch/powerpc/kernel/head_32.S +8
-0@@ -1160,6 +1160,14 @@ initial_bats: mtspr SPRN_DBAT0U,r11 /* bit in upper BAT register */ mtspr SPRN_IBAT0L,r8 mtspr SPRN_IBAT0U,r11 +#ifdef CONFIG_WII + addis r11,r11,0x10000000@h + addis r8,r8,0x10000000@h + mtspr SPRN_DBAT2L,r8 + mtspr SPRN_DBAT2U,r11 + mtspr SPRN_IBAT2L,r8 + mtspr SPRN_IBAT2U,r11 +#endif isync blrarch/powerpc/mm/ppc_mmu_32.c +1
-0@@ -259,6 +259,8 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base,/* 601 can only access 16MB at the moment */ if (PVR_VER(mfspr(SPRN_PVR)) == 1)memblock_set_current_limit (min_t (u64, first_memblock_size,0x01000000 )); + else if (IS_ENABLED(CONFIG_WII))Quoted 9 lines
Quoted 4 lines
arch/powerpc/mm/ppc_mmu_32.c +1
-0+memblock_set_current_limit (min_t (u64, first_memblock_size,0x20000000 )); else /* Anything else has 256M mapped */ memblock_set_current_limit(min_t(u64, first_memblock_size, 0x10000000));}I haven't tested it, but this patch won't be enough, because we're only looking at the first memblock, and the additional memory in the Wii (MEM2) is the second memblock.
Quoted 6 lines
Yes right.
Would the following work instead ?
memblock_set_current_limit(0x20000000);
With the config at https://gist.githubusercontent.com/neuschaefer/12ccc87ff8aeff543fad558e8742cd2b/raw/d49d321709cac364779e6893bbd91ff5a80bcb03/config
it still doesn't boot, but with a different error:
top of MEM2 @ 13F00000
zImage starting: loaded at 0x01000000 (sp: 0x0178afa0) Allocating 0x166b2c8 bytes for kernel... Decompressing (0x00000000 <- 0x01011000:0x01788799)... Done! Decompressed 0xf421f4 bytes
Linux/PowerPC load: root=/dev/mmcblk0p2 rootwait console=usbgecko1 Finalizing device tree... flat tree at 0x178b7a0
[ 0.000000] printk: bootconsole [udbg0] enabled [ 0.000000] __memblock_find_range_top_down(1000:20000000, 100000:100000, ffffffff, 0) [ 0.000000] __memblock_find_range_top_down: in loop, 10000000:13f00000 [ 0.000000] Total memory = 319MB; using 1024kB for hash table (at d3e00000) [ 0.000000] __memblock_find_range_top_down(1000:20000000, 1000:1000, ffffffff, 0) [ 0.000000] __memblock_find_range_top_down: in loop, 10000000:13e00000 [ 0.000000] __memblock_find_range_top_down(1000:20000000, 1000:1000, ffffffff, 0) [ 0.000000] __memblock_find_range_top_down: in loop, 10000000:13dff000 [ 0.000000] BUG: Unable to handle kernel data access at 0xc106a434 [ 0.000000] Faulting instruction address: 0xc0071bf4 [ 0.000000] Oops: Kernel access of bad area, sig: 11 [#1] [ 0.000000] BE PREEMPT [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc1-wii-00038-gc34b70d591b6-dirty #1337 [ 0.000000] NIP: c0071bf4 LR: c00727d8 CTR: 00000000 [ 0.000000] REGS: c0f1fd30 TRAP: 0300 Not tainted (5.0.0-rc1-wii-00038-gc34b70d591b6-dirty) [ 0.000000] MSR: 00001032 <ME,IR,DR,RI> CR: 44002842 XER: 00000000 [ 0.000000] DAR: c106a434 DSISR: 40000000 [ 0.000000] GPR00: c0074a98 c0f1fde0 c0ead4a0 c0ead4a0 c0ead9c8 00000008 00000000 00000000 [ 0.000000] GPR08: 00000003 c106a418 00000258 00000001 24000444 fb43ef5b c0f30000 7561f327 [ 0.000000] GPR16: c0f40000 691cfd11 38afe359 f161e513 00000000 c0ead9c8 00000001 00000000 [ 0.000000] GPR24: 00000000 c0f46288 00000000 c0ead4a0 c0ead9c8 00000008 c0ead4a0 00000100 [ 0.000000] NIP [c0071bf4] mark_lock+0x64/0x858 [ 0.000000] LR [c00727d8] __lock_acquire+0x334/0x1a40 [ 0.000000] Call Trace: [ 0.000000] [c0f1fe20] [00000006] 0x6 [ 0.000000] [c0f1fed0] [c0074a98] lock_acquire+0x110/0x20c [ 0.000000] [c0f1ff10] [c085e8cc] _raw_spin_lock+0x44/0x60 [ 0.000000] [c0f1ff30] [c007f220] vprintk_emit+0xa0/0x328 [ 0.000000] [c0f1ff70] [c007fc48] printk+0x5c/0x84 [ 0.000000] [c0f1ffb0] [c0c00854] start_kernel+0x64/0x460 [ 0.000000] [c0f1fff0] [00003438] 0x3438 [ 0.000000] Instruction dump: [ 0.000000] 41820170 55086cfe 550a083c 7d4a4214 554a1838 3d20c0f4 7d4a4214 39296288 [ 0.000000] 554a1838 3d290012 7d295214 39293f38 <8129001c> 7fe94839 41820028 3bc00001 [ 0.000000] random: get_random_bytes called from print_oops_end_marker+0x34/0x6c with crng_init=0 [ 0.000000] ---[ end trace 0000000000000000 ]--- [ 0.000000] [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
Not sure what's wrong. It does work with wii_defconfig, though. I think for now I'm happy without this patch, as it doesn't seem to be really necessary.
Jonathan
Le 17/01/2019 à 00:48, Jonathan Neuschäfer a écrit :
Quoted 114 lines · Christophe Leroy
Quoted 54 lines
Le 16/01/2019 à 14:16, Jonathan Neuschäfer a écrit :
Quoted 43 lines · Christophe Leroy
Quoted 42 lines
Le 16/01/2019 à 01:35, Jonathan Neuschäfer a écrit :
Quoted 4 lines
Thinning the kernel down a bit actually makes it boot again. Ooops...! Maybe enabling
CONFIG_STRICT_KERNEL_RWXhas made it just large enough to fail the hash table allocation, but there may have been other factors involved (I'm not sure exactly). Sorry for the confusion!Ok, that must be the reason. Thanks for testing.
What about the following modification which maps a second 256Mb BAT, does it helps ?
arch/powerpc/kernel/head_32.S +8
-0@@ -1160,6 +1160,14 @@ initial_bats: mtspr SPRN_DBAT0U,r11 /* bit in upper BAT register */ mtspr SPRN_IBAT0L,r8 mtspr SPRN_IBAT0U,r11 +#ifdef CONFIG_WII + addis r11,r11,0x10000000@h + addis r8,r8,0x10000000@h + mtspr SPRN_DBAT2L,r8 + mtspr SPRN_DBAT2U,r11 + mtspr SPRN_IBAT2L,r8 + mtspr SPRN_IBAT2U,r11 +#endif isync blrarch/powerpc/mm/ppc_mmu_32.c +1
-0@@ -259,6 +259,8 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base,/* 601 can only access 16MB at the moment */ if (PVR_VER(mfspr(SPRN_PVR)) == 1)memblock_set_current_limit (min_t (u64, first_memblock_size,0x01000000 )); + else if (IS_ENABLED(CONFIG_WII))Quoted 9 lines
Quoted 4 lines
arch/powerpc/mm/ppc_mmu_32.c +1
-0+memblock_set_current_limit (min_t (u64, first_memblock_size,0x20000000 )); else /* Anything else has 256M mapped */ memblock_set_current_limit(min_t(u64, first_memblock_size, 0x10000000));}I haven't tested it, but this patch won't be enough, because we're only looking at the first memblock, and the additional memory in the Wii (MEM2) is the second memblock.
Quoted 6 lines
Yes right.
Would the following work instead ?
memblock_set_current_limit(0x20000000);With the config at https://gist.githubusercontent.com/neuschaefer/12ccc87ff8aeff543fad558e8742cd2b/raw/d49d321709cac364779e6893bbd91ff5a80bcb03/config
it still doesn't boot, but with a different error:top of MEM2 @ 13F00000
zImage starting: loaded at
0x01000000(sp:0x0178afa0) Allocating0x166b2c8bytes for kernel... Decompressing (0x00000000<- 0x01011000:0x01788799)... Done! Decompressed0xf421f4bytesLinux/PowerPC load: root=/dev/mmcblk0p2 rootwait console=usbgecko1 Finalizing device tree... flat tree at
0x178b7a0[ 0.000000] printk: bootconsole [udbg0] enabled [ 0.000000] __memblock_find_range_top_down(1000:20000000, 100000:100000, ffffffff, 0) [ 0.000000] __memblock_find_range_top_down: in loop, 10000000:13f00000 [ 0.000000] Total memory = 319MB; using 1024kB for hash table (at d3e00000) [ 0.000000] __memblock_find_range_top_down(1000:20000000, 1000:1000, ffffffff, 0) [ 0.000000] __memblock_find_range_top_down: in loop, 10000000:13e00000 [ 0.000000] __memblock_find_range_top_down(1000:20000000, 1000:1000, ffffffff, 0) [ 0.000000] __memblock_find_range_top_down: in loop, 10000000:13dff000 [ 0.000000] BUG: Unable to handle kernel data access at 0xc106a434 [ 0.000000] Faulting instruction address: 0xc0071bf4 [ 0.000000] Oops: Kernel access of bad area, sig: 11 [#1] [ 0.000000] BE PREEMPT [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc1-wii-00038-gc34b70d591b6-dirty #1337 [ 0.000000] NIP: c0071bf4 LR: c00727d8 CTR: 00000000 [ 0.000000] REGS: c0f1fd30 TRAP: 0300 Not tainted (5.0.0-rc1-wii-00038-gc34b70d591b6-dirty) [ 0.000000] MSR: 00001032 <ME,IR,DR,RI> CR: 44002842 XER: 00000000 [ 0.000000] DAR: c106a434 DSISR: 40000000 [ 0.000000] GPR00: c0074a98 c0f1fde0 c0ead4a0 c0ead4a0 c0ead9c8 00000008 00000000 00000000 [ 0.000000] GPR08: 00000003 c106a418 00000258 00000001 24000444 fb43ef5b c0f30000 7561f327 [ 0.000000] GPR16: c0f40000 691cfd11 38afe359 f161e513 00000000 c0ead9c8 00000001 00000000 [ 0.000000] GPR24: 00000000 c0f46288 00000000 c0ead4a0 c0ead9c8 00000008 c0ead4a0 00000100 [ 0.000000] NIP [c0071bf4] mark_lock+0x64/0x858 [ 0.000000] LR [c00727d8] __lock_acquire+0x334/0x1a40 [ 0.000000] Call Trace: [ 0.000000] [c0f1fe20] [00000006] 0x6 [ 0.000000] [c0f1fed0] [c0074a98] lock_acquire+0x110/0x20c [ 0.000000] [c0f1ff10] [c085e8cc] _raw_spin_lock+0x44/0x60 [ 0.000000] [c0f1ff30] [c007f220] vprintk_emit+0xa0/0x328 [ 0.000000] [c0f1ff70] [c007fc48] printk+0x5c/0x84 [ 0.000000] [c0f1ffb0] [c0c00854] start_kernel+0x64/0x460 [ 0.000000] [c0f1fff0] [00003438] 0x3438 [ 0.000000] Instruction dump: [ 0.000000] 41820170 55086cfe 550a083c 7d4a4214 554a1838 3d20c0f4 7d4a4214 39296288 [ 0.000000] 554a1838 3d290012 7d295214 39293f38 <8129001c> 7fe94839 41820028 3bc00001 [ 0.000000] random: get_random_bytes called from print_oops_end_marker+0x34/0x6c with crng_init=0 [ 0.000000] ---[ end trace 0000000000000000 ]--- [ 0.000000] [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
Quoted 3 lines
Not sure what's wrong. It does work with
wii_defconfig, though. I think for now I'm happy without this patch, as it doesn't seem to be really necessary.
That's strange, 0xc106a434 is within the first block, should not be a problem, should it ?
According to DSISR, the fault is due to: Set if the translation of an attempted access is not found in the primary or secondary hash table entry group (HTEG), or in the range of a DBAT register (page fault condition)
Ok, won't spend more time on that for now, 24Mbytes should be OK for early init in most cases.
Christophe
Quoted 4 lines
Jonathan