From 1dd2ad7f2b414805de2020d5bf2d5adc3cf6243c Mon Sep 17 00:00:00 2001 From: Jonas Bonn Date: Thu, 25 Oct 2012 17:17:00 +0200 Subject: [PATCH 1/9] openrisc: remove unused current_regs Signed-off-by: Jonas Bonn --- arch/openrisc/include/asm/processor.h | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/openrisc/include/asm/processor.h b/arch/openrisc/include/asm/processor.h index 33691380608e..cab746fa9e87 100644 --- a/arch/openrisc/include/asm/processor.h +++ b/arch/openrisc/include/asm/processor.h @@ -70,7 +70,6 @@ struct thread_struct { */ #define task_pt_regs(task) user_regs(task_thread_info(task)) -#define current_regs() user_regs(current_thread_info()) #define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack) From 54bd7c510ba027763130eaeb09004ef5780c06e6 Mon Sep 17 00:00:00 2001 From: Stefan Kristiansson Date: Fri, 12 Oct 2012 09:38:18 +0300 Subject: [PATCH 2/9] openrisc: avoid using function parameter regs in reset vector The kernel might be invoked through the reset vector, so to preserve parameters passed to it, temp regs that are not in the function parameter range needs to be used. Signed-off-by: Stefan Kristiansson Signed-off-by: Jonas Bonn --- arch/openrisc/kernel/head.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S index 1088b5fca3bd..46aa940ebd20 100644 --- a/arch/openrisc/kernel/head.S +++ b/arch/openrisc/kernel/head.S @@ -291,9 +291,9 @@ /* Jump to .init code at _start which lives in the .head section * and will be discarded after boot. */ - LOAD_SYMBOL_2_GPR(r4, _start) - tophys (r3,r4) /* MMU disabled */ - l.jr r3 + LOAD_SYMBOL_2_GPR(r15, _start) + tophys (r13,r15) /* MMU disabled */ + l.jr r13 l.nop /* ---[ 0x200: BUS exception ]------------------------------------------- */ From 1b3737d4c5ed2ea90efe30e7f6261f8311d20962 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Wed, 6 Feb 2013 12:58:08 +0000 Subject: [PATCH 3/9] openrisc: remove CONFIG_SYMBOL_PREFIX Remove the SYMBOL_PREFIX Kconfig symbol as it's empty anyway. Signed-off-by: James Hogan Cc: Jonas Bonn Cc: linux@lists.openrisc.net Cc: Mike Frysinger Signed-off-by: Jonas Bonn --- arch/openrisc/Kconfig | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index 0ac66f67521f..35a4e5f6e71c 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -26,10 +26,6 @@ config OPENRISC config MMU def_bool y -config SYMBOL_PREFIX - string - default "" - config HAVE_DMA_ATTRS def_bool y From 7f81ea7e28c3e4e5b762111dc676b24152f85a3a Mon Sep 17 00:00:00 2001 From: Len Brown Date: Sun, 10 Feb 2013 00:58:20 -0500 Subject: [PATCH 4/9] openrisc idle: delete pm_idle pm_idle() on openrisc was dead code. Signed-off-by: Len Brown Cc: linux@lists.openrisc.net Signed-off-by: Jonas Bonn --- arch/openrisc/kernel/idle.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arch/openrisc/kernel/idle.c b/arch/openrisc/kernel/idle.c index 7d618feb1b72..5e8a3b6d6bc6 100644 --- a/arch/openrisc/kernel/idle.c +++ b/arch/openrisc/kernel/idle.c @@ -39,11 +39,6 @@ void (*powersave) (void) = NULL; -static inline void pm_idle(void) -{ - barrier(); -} - void cpu_idle(void) { set_thread_flag(TIF_POLLING_NRFLAG); From a81252d75e14cc2cf0ee45078ef143562a0bc279 Mon Sep 17 00:00:00 2001 From: Jonas Bonn Date: Thu, 14 Feb 2013 16:16:49 +0100 Subject: [PATCH 5/9] openrisc: fix up vmalloc page table loading vmalloc'ed pages are faulted into a process' page tables on demand. In order to facilitate this, do_page_fault needs to know whether it was called via a page fault exception or a TLB-miss exception. This patch adds a wrapper around the _x_page_fault_handler entry points that the TLB-miss exceptions can call into in order to have the relevant parameter set to satisfy do_page_fault. This fixes a bug and is "good enough" for now. That said, this whole handling of vmalloc needs to be audited for correctness at some point. Signed-off-by: Jonas Bonn --- arch/openrisc/kernel/entry.S | 14 ++++++++++++-- arch/openrisc/kernel/head.S | 6 ++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S index 5e5b30601bbf..3de971224cfc 100644 --- a/arch/openrisc/kernel/entry.S +++ b/arch/openrisc/kernel/entry.S @@ -201,12 +201,17 @@ EXCEPTION_ENTRY(_bus_fault_handler) l.nop /* ---[ 0x300: Data Page Fault exception ]------------------------------- */ +EXCEPTION_ENTRY(_dtlb_miss_page_fault_handler) + l.and r5,r5,r0 + l.j 1f + l.nop EXCEPTION_ENTRY(_data_page_fault_handler) /* set up parameters for do_page_fault */ + l.ori r5,r0,0x300 // exception vector +1: l.addi r3,r1,0 // pt_regs /* r4 set be EXCEPTION_HANDLE */ // effective address of fault - l.ori r5,r0,0x300 // exception vector /* * __PHX__: TODO @@ -276,12 +281,17 @@ EXCEPTION_ENTRY(_data_page_fault_handler) l.nop /* ---[ 0x400: Insn Page Fault exception ]------------------------------- */ +EXCEPTION_ENTRY(_itlb_miss_page_fault_handler) + l.and r5,r5,r0 + l.j 1f + l.nop EXCEPTION_ENTRY(_insn_page_fault_handler) /* set up parameters for do_page_fault */ + l.ori r5,r0,0x400 // exception vector +1: l.addi r3,r1,0 // pt_regs /* r4 set be EXCEPTION_HANDLE */ // effective address of fault - l.ori r5,r0,0x400 // exception vector l.ori r6,r0,0x0 // !write access /* call fault.c handler in or32/mm/fault.c */ diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S index 46aa940ebd20..b357e7f79aca 100644 --- a/arch/openrisc/kernel/head.S +++ b/arch/openrisc/kernel/head.S @@ -1069,8 +1069,7 @@ d_pte_not_present: EXCEPTION_LOAD_GPR4 EXCEPTION_LOAD_GPR5 EXCEPTION_LOAD_GPR6 - l.j _dispatch_do_dpage_fault - l.nop + EXCEPTION_HANDLE(_dtlb_miss_page_fault_handler) /* ==============================================[ ITLB miss handler ]=== */ ENTRY(itlb_miss_handler) @@ -1192,8 +1191,7 @@ i_pte_not_present: EXCEPTION_LOAD_GPR4 EXCEPTION_LOAD_GPR5 EXCEPTION_LOAD_GPR6 - l.j _dispatch_do_ipage_fault - l.nop + EXCEPTION_HANDLE(_itlb_miss_page_fault_handler) /* ==============================================[ boot tlb handlers ]=== */ From 8668480eb79f0cbd79d6b584a10604d743853062 Mon Sep 17 00:00:00 2001 From: Jonas Bonn Date: Thu, 14 Feb 2013 07:42:30 +0100 Subject: [PATCH 6/9] openrisc: update DTLB-miss handler last The self-modifying code that updates the TLB handler at start-up has a subtle ordering requirement: the DTLB handler must be the last thing changed. What I was seeing was the following: i) The DTLB handler was updated ii) The following printk caused a TLB miss and the look-up resulted in the page containing itlb_vector (0xc0000a00) being bounced from the TLB. iii) The subsequent access to itlb_vector caused a TLB miss and reload of the page containing itlb_vector from the page tables. iv) But this reload of the page in iii) was being done by the "new" DTLB-miss handler which resulted (correctly) in the page flags being set to read-only; the subsequent write-access to itlb_vector thus resulted in a page (access) fault. This is easily remedied if we ensure that the boot-time DTLB-miss handler continues running until the very last bit of self-modifying code has been executed. This patch should ensure that the very last thing updated is the DTLB-handler itself. Signed-off-by: Jonas Bonn Acked-by: Julius Baxter Tested-by: Sebastian Macke --- arch/openrisc/mm/init.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c index 79dea9740a3c..e7fdc50c4bf0 100644 --- a/arch/openrisc/mm/init.c +++ b/arch/openrisc/mm/init.c @@ -167,15 +167,26 @@ void __init paging_init(void) unsigned long *dtlb_vector = __va(0x900); unsigned long *itlb_vector = __va(0xa00); + printk(KERN_INFO "itlb_miss_handler %p\n", &itlb_miss_handler); + *itlb_vector = ((unsigned long)&itlb_miss_handler - + (unsigned long)itlb_vector) >> 2; + + /* Soft ordering constraint to ensure that dtlb_vector is + * the last thing updated + */ + barrier(); + printk(KERN_INFO "dtlb_miss_handler %p\n", &dtlb_miss_handler); *dtlb_vector = ((unsigned long)&dtlb_miss_handler - (unsigned long)dtlb_vector) >> 2; - printk(KERN_INFO "itlb_miss_handler %p\n", &itlb_miss_handler); - *itlb_vector = ((unsigned long)&itlb_miss_handler - - (unsigned long)itlb_vector) >> 2; } + /* Soft ordering constraint to ensure that cache invalidation and + * TLB flush really happen _after_ code has been modified. + */ + barrier(); + /* Invalidate instruction caches after code modification */ mtspr(SPR_ICBIR, 0x900); mtspr(SPR_ICBIR, 0xa00); From b4f5b53603468ef229d16350639e293f12128b62 Mon Sep 17 00:00:00 2001 From: Sebastian Macke Date: Fri, 15 Feb 2013 07:54:41 +0100 Subject: [PATCH 7/9] Add bitops include needed for ext2 filesystem Signed-off-by: Jonas Bonn --- arch/openrisc/include/asm/bitops.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/openrisc/include/asm/bitops.h b/arch/openrisc/include/asm/bitops.h index a9e11efae14d..2c64f2228dc7 100644 --- a/arch/openrisc/include/asm/bitops.h +++ b/arch/openrisc/include/asm/bitops.h @@ -54,6 +54,7 @@ #include #include +#include #include #endif /* __ASM_GENERIC_BITOPS_H */ From ae6fef1790512edde8776ee2a158b1e13d085f61 Mon Sep 17 00:00:00 2001 From: Jonas Bonn Date: Fri, 15 Feb 2013 17:07:17 +0100 Subject: [PATCH 8/9] openrisc: really pass correct arg to schedule_tail Commit 287ad220cd8b5a9d29f71c78f6e4051093f051fc tried to set up the argument to schedule_tail, but ended up using TI_STACK which isn't a defined symbol. Sadly, the old openrisc compiler silently ignores this fact and it was first discovered now when building with an updated toolchain. Reported-by: Christian Svensson Signed-off-by: Jonas Bonn --- arch/openrisc/kernel/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S index 3de971224cfc..e7fadc0234cd 100644 --- a/arch/openrisc/kernel/entry.S +++ b/arch/openrisc/kernel/entry.S @@ -1050,7 +1050,7 @@ ENTRY(_switch) * we are expected to have set up the arg to schedule_tail already, * hence we do so here unconditionally: */ - l.lwz r3,TI_STACK(r3) /* Load 'prev' as schedule_tail arg */ + l.lwz r3,TI_TASK(r3) /* Load 'prev' as schedule_tail arg */ l.jr r9 l.nop From 160d83781a32e94a1e337efd6722939001e62398 Mon Sep 17 00:00:00 2001 From: Stefan Kristiansson Date: Tue, 26 Feb 2013 07:36:29 +0100 Subject: [PATCH 9/9] openrisc: add missing header inclusion Prevents build issue with updated toolchain Reported-by: Jack Thomasson Tested-by: Christian Svensson Signed-off-by: Stefan Kristiansson Signed-off-by: Jonas Bonn --- arch/openrisc/kernel/head.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S index b357e7f79aca..1d3c9c28ac25 100644 --- a/arch/openrisc/kernel/head.S +++ b/arch/openrisc/kernel/head.S @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include