powerpc/book3e: mtmsr should not be mtmsrd on book3e 64-bit
Subsystems (2)
PATCH 1/13 powerpc/book3e: mtmsr should not be mtmsrd on book3e 64-bit
--- arch/powerpc/include/asm/reg.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/include/asm/reg.h +1 -1
@@ -890,7 +890,7 @@#ifndef __ASSEMBLY__#define mfmsr () ({unsigned long rval; \ asm volatile("mfmsr %0" : "=r" (rval)); rval;}) -#ifdef CONFIG_PPC64 +#ifdef CONFIG_PPC_BOOK3S_64 #define __mtmsrd (v, l) asm volatile("mtmsrd %0," __stringify(l) \ : : "r" (v) : "memory")#define mtmsrd (v) __mtmsrd((v), 0)
Signature · 1 line
1.6.3.3
PATCH 2/13 powerpc/book3e: Hack to get gdb moving along on Book3E 64-bit
Our handling of debug interrupts on Book3E 64-bit is not quite the way it should be just yet. This is a workaround to let gdb work at least for now. We ensure that when context switching, we set the appropriate DBCR0 value for the new task. We also make sure that we turn off MSR[DE] within the kernel, and set it as part of the bits that get set when going back to userspace.
In the long run, we will probably set the userspace DBCR0 on the exception exit code path and ensure we have some proper kernel value to set on the way into the kernel, a bit like ppc32 does, but that will take more work.
--- arch/powerpc/include/asm/reg_booke.h | 4 ++-- arch/powerpc/kernel/process.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/reg_booke.h +2 -2
@@ -29,8 +29,8 @@#if defined(CONFIG_PPC_BOOK3E_64 )#define MSR_ MSR_ME | MSR_CE#define MSR_KERNEL MSR_ | MSR_CM -#define MSR_USER32 MSR_ | MSR_PR | MSR_EE -#define MSR_USER64 MSR_USER32 | MSR_CM +#define MSR_USER32 MSR_ | MSR_PR | MSR_EE | MSR_DE +#define MSR_USER64 MSR_USER32 | MSR_CM | MSR_DE#elif defined (CONFIG_40x)#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR|MSR_CE)#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE)
arch/powerpc/kernel/process.c +22 -0
@@ -477,6 +477,28 @@ struct task_struct *__switch_to(struct task_struct *prev, new_thread = &new->thread; old_thread = ¤t->thread; +#if defined(CONFIG_PPC_BOOK3E_64 ) +/* XXX Current Book3E code doesn't deal with kernel side DBCR0, +* we always hold the user values, so we set it now. +* +* However, we ensure the kernel MSR:DE is appropriately cleared too +* to avoid spurrious single step exceptions in the kernel. +* +* This will have to change to merge with the ppc32 code at some point, +* but I don't like much what ppc32 is doing today so there's some +* thinking needed there +*/ +if ((new_thread->dbcr0 | old_thread->dbcr0) &DBCR0_IDM ) { +u32 dbcr0; + +mtmsr (mfmsr () & ~MSR_DE ); +isync (); + dbcr0 =mfspr (SPRN_DBCR0 ); + dbcr0 = (dbcr0 &DBCR0_EDM ) | new_thread->dbcr0; +mtspr (SPRN_DBCR0 , dbcr0); + } +#endif /* CONFIG_PPC64_BOOK3E */ +#ifdef CONFIG_PPC64 /* * Collect processor utilization data per process
Signature · 1 line
1.6.3.3
PATCH 4/13 powerpc/book3e: More doorbell cleanups. Sample the PIR register
In reply to Benjamin HerrenschmidtThe doorbells use the content of the PIR register to match messages from other CPUs. This may or may not be the same as our linux CPU number, so using that as the "target" is no right.
Instead, we sample the PIR register at boot on every processor and use that value subsequently when sending IPIs.
We also use a per-cpu message mask rather than a global array which should limit cache line contention.
Note: We could use the CPU number in the device-tree instead of the PIR register, as they are supposed to be equivalent. This might prove useful if doorbells are to be used to kick CPUs out of FW at boot time, thus before we can sample the PIR. This is however not the case now and using the PIR just works.
--- arch/powerpc/include/asm/dbell.h | 7 ++--- arch/powerpc/kernel/dbell.c | 47 ++++++++++++++++++++++++++---------- arch/powerpc/platforms/85xx/smp.c | 4 ++- 3 files changed, 40 insertions(+), 18 deletions(-)
arch/powerpc/include/asm/dbell.h +3 -4
@@ -27,10 +27,9 @@ enum ppc_dbell { PPC_G_DBELL_MC = 4, /* guest mcheck doorbell */ }; -#ifdef CONFIG_SMP -extern unsigned long dbell_smp_message[NR_CPUS ]; -extern void smp_dbell_message_pass (int target,int msg); -#endif +extern void doorbell_message_pass (int target,int msg); +extern void doorbell_exception (struct pt_regs *regs); +extern void doorbell_setup_this_cpu (void );static inline void ppc_msgsnd (enum ppc_dbell type,u32 flags,u32 tag) {
arch/powerpc/kernel/dbell.c +34 -13
79 lines not on this page · raw message
arch/powerpc/platforms/85xx/smp.c +3 -1
@@ -99,6 +99,8 @@ static void __init smp_85xx_setup_cpu(int cpu_nr) {mpic_setup_this_cpu (); +if (cpu_has_feature (CPU_FTR_DBELL )) +doorbell_setup_this_cpu (); }struct smp_ops_t smp_85xx_ops = {
@@ -117,7 +119,7 @@ void __init mpc85xx_smp_init(void) }if (cpu_has_feature (CPU_FTR_DBELL )) - smp_85xx_ops.message_pass = smp_dbell_message_pass; + smp_85xx_ops.message_pass = doorbell_message_pass;BUG_ON (!smp_85xx_ops.message_pass);
Signature · 1 line
1.6.3.3
PATCH 3/13 powerpc/book3e: Move doorbell_exception from traps.c to dbell.c
In reply to Benjamin Herrenschmidt... where it belongs
--- arch/powerpc/kernel/dbell.c | 22 +++++++++++++++++++++- arch/powerpc/kernel/traps.c | 21 --------------------- 2 files changed, 21 insertions(+), 22 deletions(-)
arch/powerpc/kernel/dbell.c +21 -1
@@ -41,4 +41,24 @@ void smp_dbell_message_pass(int target, int msg) ppc_msgsnd(PPC_DBELL, PPC_DBELL_MSG_BRDCAST, 0); } } -#endif + +void doorbell_exception (struct pt_regs *regs) +{ +int cpu =smp_processor_id (); +int msg; + +if (num_online_cpus () <2 ) +return ; + +for (msg =0 ; msg <4 ; msg++) +if (test_and_clear_bit (msg, &dbell_smp_message[cpu])) +smp_message_recv (msg); +} + +#else /* CONFIG_SMP */ +void doorbell_exception (struct pt_regs *regs) +{ +printk (KERN_WARNING "Received doorbell on non-smp system\n" ); +} +#endif /* CONFIG_SMP */ +
arch/powerpc/kernel/traps.c +0 -21
@@ -55,9 +55,6 @@#endif #include <asm/kexec.h> #include <asm/ppc-opcode.h> -#ifdef CONFIG_FSL_BOOKE -#include <asm/dbell.h> -#endif #if defined(CONFIG_DEBUGGER ) || defined(CONFIG_KEXEC )int (*__debugger)(struct pt_regs *regs)__read_mostly ;
@@ -1342,24 +1339,6 @@ void vsx_assist_exception(struct pt_regs *regs)#endif /* CONFIG_VSX */ #ifdef CONFIG_FSL_BOOKE - -void doorbell_exception (struct pt_regs *regs) -{ -#ifdef CONFIG_SMP -int cpu =smp_processor_id (); -int msg; - -if (num_online_cpus () <2 ) -return ; - -for (msg =0 ; msg <4 ; msg++) -if (test_and_clear_bit (msg, &dbell_smp_message[cpu])) -smp_message_recv (msg); -#else -printk (KERN_WARNING "Received doorbell on non-smp system\n" ); -#endif -} -void CacheLockingException (struct pt_regs *regs,unsigned long address,unsigned long error_code) {
Signature · 1 line
1.6.3.3
PATCH 5/13 powerpc/book3e: Don't re-trigger decrementer on lazy irq restore
In reply to Benjamin HerrenschmidtThe decrementer on BookE acts as a level interrupt and doesn't need to be re-triggered when going negative. It doesn't go negative anyways (unless programmed to auto-reload with a negative value) as it stops when reaching 0.
--- arch/powerpc/kernel/irq.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
arch/powerpc/kernel/irq.c +9 -0
@@ -159,8 +159,17 @@ notrace void raw_local_irq_restore(unsigned long en)* use local_paca instead of get_paca() to avoid preemption checking. */ local_paca->hard_enabled = en; + +#ifndef CONFIG_BOOKE +/* On server, re-trigger the decrementer if it went negative since +* some processors only trigger on edge transitions of the sign bit. +* +* BookE has a level sensitive decrementer (latches in TSR) so we +* don't need that +*/ if ((int )mfspr (SPRN_DEC ) <0 )mtspr (SPRN_DEC ,1 ); +#endif /* CONFIG_BOOKE */ /* * Force the delivery of pending soft-disabled interrupts on PS3.
Signature · 1 line
1.6.3.3
PATCH 7/13 powerpc/book3e: Use set_irq_regs() in the msgsnd/msgrcv IPI path
In reply to Benjamin HerrenschmidtFrom: David Gibson <[email protected]>
include/asm-generic/irq_regs.h declares per-cpu irq_regs variables and get_irq_regs() and set_irq_regs() helper functions to maintain them. These can be used to access the proper pt_regs structure related to the current interrupt entry (if any).
In the powerpc arch code, this is used to maintain irq regs on decrementer and external interrupt exceptions. However, for the doorbell exceptions used by the msgsnd/msgrcv IPI mechanism of newer BookE CPUs, the irq_regs are not kept up to date.
In particular this means that xmon will not work properly on SMP, because the secondary xmon instances started by IPI will blow up when they cannot retrieve the irq regs.
This patch fixes the problem by adding calls to maintain the irq regs across doorbell exceptions.
--- arch/powerpc/kernel/dbell.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
arch/powerpc/kernel/dbell.c +6 -1
@@ -16,6 +16,7 @@#include <linux/percpu.h> #include <asm/dbell.h> +#include <asm/irq_regs.h> #ifdef CONFIG_SMP struct doorbell_cpu_info {
@@ -63,17 +64,21 @@ void doorbell_message_pass(int target, int msg)void doorbell_exception (struct pt_regs *regs) { +struct pt_regs *old_regs =set_irq_regs (regs);struct doorbell_cpu_info *info = &__get_cpu_var (doorbell_cpu_info);int msg;/* Warning: regs can be NULL when called from irq enable */ if (!info->messages || (num_online_cpus () <2 )) -return ; + goto out;for (msg =0 ; msg <4 ; msg++)if (test_and_clear_bit (msg, &info->messages))smp_message_recv (msg); + +out: +set_irq_regs (old_regs); }#else /* CONFIG_SMP */
Signature · 1 line
1.6.3.3
PATCH 6/13 powerpc/book3e: Hookup doorbells exceptions on 64-bit Book3E
In reply to Benjamin HerrenschmidtNote that critical doorbells are an unimplemented stub just like other critical or machine check handlers, since we haven't done support for "levelled" exceptions yet.
--- arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/exceptions-64e.S | 21 +++++++++++++++++---- arch/powerpc/kernel/irq.c | 7 +++++++ 3 files changed, 25 insertions(+), 4 deletions(-)
arch/powerpc/kernel/Makefile +1 -0
@@ -68,6 +68,7 @@ obj64-$(CONFIG_HIBERNATION) += swsusp_asm64.o obj-$(CONFIG_MODULES) += module.o module_$(CONFIG_WORD_SIZE).o obj-$(CONFIG_44x) += cpu_setup_44x.o obj-$(CONFIG_FSL_BOOKE) += cpu_setup_fsl_booke.o dbell.o +obj-$(CONFIG_PPC_BOOK3E_64) += dbell.o extra-y := head_$(CONFIG_WORD_SIZE).o extra-$(CONFIG_PPC_BOOK3E_32) := head_new_booke.o
arch/powerpc/kernel/exceptions-64e.S +17 -4
@@ -246,11 +246,9 @@ interrupt_base_book3e: /* fake trap */ EXCEPTION_STUB(0x1a0, watchdog) /* 0x09f0 */ EXCEPTION_STUB(0x1c0, data_tlb_miss) EXCEPTION_STUB(0x1e0, instruction_tlb_miss) + EXCEPTION_STUB(0x280, doorbell) + EXCEPTION_STUB(0x2a0, doorbell_crit) -#if 0 - EXCEPTION_STUB(0x280, processor_doorbell) - EXCEPTION_STUB(0x220, processor_doorbell_crit) -#endif .globl interrupt_end_book3e interrupt_end_book3e:
@@ -428,6 +426,19 @@ interrupt_end_book3e: kernel_dbg_exc: b . /* NYI */ +/* Doorbell interrupt */ + MASKABLE_EXCEPTION(0x2070, doorbell, .doorbell_exception, ACK_NONE) + +/* Doorbell critical Interrupt */ + START_EXCEPTION(doorbell_crit); + CRIT_EXCEPTION_PROLOG(0x2080, PROLOG_ADDITION_NONE) +// EXCEPTION_COMMON(0x2080, PACA_EXCRIT, INTS_DISABLE_ALL) +// bl special_reg_save_crit +// addi r3,r1,STACK_FRAME_OVERHEAD +// bl .doorbell_critical_exception +// b ret_from_crit_except + b . + /* * An interrupt came in while soft-disabled; clear EE in SRR1,
@@ -563,6 +574,8 @@ BAD_STACK_TRAMPOLINE(0xd00) BAD_STACK_TRAMPOLINE(0xe00) BAD_STACK_TRAMPOLINE(0xf00) BAD_STACK_TRAMPOLINE(0xf20) +BAD_STACK_TRAMPOLINE(0x2070) +BAD_STACK_TRAMPOLINE(0x2080) .globl bad_stack_book3e bad_stack_book3e:
arch/powerpc/kernel/irq.c +7 -0
@@ -64,6 +64,8 @@#include <asm/ptrace.h> #include <asm/machdep.h> #include <asm/udbg.h> +#include <asm/dbell.h> +#ifdef CONFIG_PPC64 #include <asm/paca.h> #include <asm/firmware.h>
@@ -153,6 +155,11 @@ notrace void raw_local_irq_restore(unsigned long en)if (get_hard_enabled ())return ; +#if defined(CONFIG_BOOKE ) && defined(CONFIG_SMP ) +/* Check for pending doorbell interrupts on SMP */ +doorbell_exception (NULL ); +#endif +/* * Need to hard-enable interrupts here. Since currently disabled, * no need to take further asm precautions against preemption; but
Signature · 1 line
1.6.3.3
PATCH 9/13 powerpc/book3e: Add generic 64-bit idle powersave support
In reply to Benjamin HerrenschmidtWe use a similar technique to ppc32: We set a thread local flag to indicate that we are about to enter or have entered the stop state, and have fixup code in the async interrupt entry code that reacts to this flag to make us return to a different location (sets NIP to LINK in our case).
--- arch/powerpc/include/asm/machdep.h | 1 + arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/exceptions-64e.S | 23 ++++++++++ arch/powerpc/kernel/idle_book3e.S | 81 ++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 1 deletions(-) create mode 100644 arch/powerpc/kernel/idle_book3e.S
arch/powerpc/include/asm/machdep.h +1 -0
@@ -278,6 +278,7 @@ extern void e500_idle(void);extern void power4_idle (void );extern void power4_cpu_offline_powersave (void );extern void ppc6xx_idle (void ); +extern void book3e_idle (void );/* * ppc_md contains a copy of the machine description structure for the
arch/powerpc/kernel/Makefile +1 -1
@@ -37,7 +37,7 @@ obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \ obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o obj64-$(CONFIG_RELOCATABLE) += reloc_64.o -obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o +obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o idle_book3e.o obj-$(CONFIG_PPC64) += vdso64/ obj-$(CONFIG_ALTIVEC) += vecemu.o obj-$(CONFIG_PPC_970_NAP) += idle_power4.o
arch/powerpc/kernel/exceptions-64e.S +23 -0
@@ -204,11 +204,30 @@ exc_##n##_bad_stack: \ lis r,TSR_FIS@h; \ mtspr SPRN_TSR,r +/* Used by asynchronous interrupt that may happen in the idle loop. + * + * This check if the thread was in the idle loop, and if yes, returns + * to the caller rather than the PC. This is to avoid a race if + * interrupts happen before the wait instruction. + */ +#define CHECK_NAPPING() \ + clrrdi r11,r1,THREAD_SHIFT; \ + ld r10,TI_LOCAL_FLAGS(r11); \ + andi. r9,r10,_TLF_NAPPING; \ + beq+ 1f; \ + ld r8,_LINK(r1); \ + rlwinm r7,r10,0,~_TLF_NAPPING; \ + std r8,_NIP(r1); \ + std r7,TI_LOCAL_FLAGS(r11); \ +1: + + #define MASKABLE_EXCEPTION(trapnum, label, hdlr, ack) \ START_EXCEPTION(label); \ NORMAL_EXCEPTION_PROLOG(trapnum, PROLOG_ADDITION_MASKABLE) \ EXCEPTION_COMMON(trapnum, PACA_EXGEN, INTS_DISABLE_ALL) \ ack(r8); \ + CHECK_NAPPING(); \ addi r3,r1,STACK_FRAME_OVERHEAD; \ bl hdlr; \ b .ret_from_except_lite;
@@ -257,6 +276,7 @@ interrupt_end_book3e: CRIT_EXCEPTION_PROLOG(0x100, PROLOG_ADDITION_NONE) // EXCEPTION_COMMON(0x100, PACA_EXCRIT, INTS_DISABLE_ALL) // bl special_reg_save_crit +// CHECK_NAPPING(); // addi r3,r1,STACK_FRAME_OVERHEAD // bl .critical_exception // b ret_from_crit_except
@@ -268,6 +288,7 @@ interrupt_end_book3e: // EXCEPTION_COMMON(0x200, PACA_EXMC, INTS_DISABLE_ALL) // bl special_reg_save_mc // addi r3,r1,STACK_FRAME_OVERHEAD +// CHECK_NAPPING(); // bl .machine_check_exception // b ret_from_mc_except b .
@@ -338,6 +359,7 @@ interrupt_end_book3e: CRIT_EXCEPTION_PROLOG(0x9f0, PROLOG_ADDITION_NONE) // EXCEPTION_COMMON(0x9f0, PACA_EXCRIT, INTS_DISABLE_ALL) // bl special_reg_save_crit +// CHECK_NAPPING(); // addi r3,r1,STACK_FRAME_OVERHEAD // bl .unknown_exception // b ret_from_crit_except
@@ -434,6 +456,7 @@ kernel_dbg_exc: CRIT_EXCEPTION_PROLOG(0x2080, PROLOG_ADDITION_NONE) // EXCEPTION_COMMON(0x2080, PACA_EXCRIT, INTS_DISABLE_ALL) // bl special_reg_save_crit +// CHECK_NAPPING(); // addi r3,r1,STACK_FRAME_OVERHEAD // bl .doorbell_critical_exception // b ret_from_crit_except
arch/powerpc/kernel/idle_book3e.S new file +81 -0
82 lines not on this page · raw message
Signature · 1 line
1.6.3.3
PATCH 8/13 powerpc/book3e: Resend doorbell exceptions to ourself
In reply to Benjamin HerrenschmidtFrom: Michael Ellerman <[email protected]>
If we are soft disabled and receive a doorbell exception we don't process it immediately. This means we need to check on the way out of irq restore if there are any doorbell exceptions to process.
The problem is at that point we don't know what our regs are, and that in turn makes xmon unhappy. To workaround the problem, instead of checking for and processing doorbells, we check for any doorbells and if there were any we send ourselves another.
--- arch/powerpc/include/asm/dbell.h | 1 + arch/powerpc/kernel/dbell.c | 10 ++++++++++ arch/powerpc/kernel/irq.c | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/dbell.h +1 -0
@@ -29,6 +29,7 @@ enum ppc_dbell {extern void doorbell_message_pass (int target,int msg);extern void doorbell_exception (struct pt_regs *regs); +extern void doorbell_check_self (void );extern void doorbell_setup_this_cpu (void );static inline void ppc_msgsnd (enum ppc_dbell type,u32 flags,u32 tag)
arch/powerpc/kernel/dbell.c +10 -0
@@ -81,6 +81,16 @@ out: set_irq_regs(old_regs); } +void doorbell_check_self (void ) +{ +struct doorbell_cpu_info *info = &__get_cpu_var (doorbell_cpu_info); + +if (!info->messages) +return ; + +ppc_msgsnd (PPC_DBELL ,0 , info->tag); +} +#else /* CONFIG_SMP */ void doorbell_exception (struct pt_regs *regs) {
arch/powerpc/kernel/irq.c +2 -2
@@ -156,8 +156,8 @@ notrace void raw_local_irq_restore(unsigned long en)return ;#if defined(CONFIG_BOOKE ) && defined(CONFIG_SMP ) -/* Check for pending doorbell interrupts on SMP */ -doorbell_exception (NULL ); +/* Check for pending doorbell interrupts and resend to ourself */ +doorbell_check_self ();#endif /*
Signature · 1 line
1.6.3.3
PATCH 10/13 powerpc/book3e: Fix single step when using HW page tables
In reply to Benjamin HerrenschmidtWe patch the TLB miss exception vectors to point to alternate functions when using HW page table on BookE.
However, we were patching in a new branch in the first instruction of the exception handler instead of the second one, thus overriding the nop that is in the first instruction.
This cause problems when single stepping as we rely on that nop for the single step to stop properly within the exception vector range rather than on the target of the branch.
--- arch/powerpc/kernel/exceptions-64e.S | 6 ++++++ arch/powerpc/mm/tlb_nohash.c | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-)
arch/powerpc/kernel/exceptions-64e.S +6 -0
@@ -191,6 +191,12 @@ exc_##n##_bad_stack: \ sth r1,PACA_TRAP_SAVE(r13); /* store trap */ \ b bad_stack_book3e; /* bad stack error */ +/* WARNING: If you change the layout of this stub, make sure you chcek + * the debug exception handler which handles single stepping + * into exceptions from userspace, and the MM code in + * arch/powerpc/mm/tlb_nohash.c which patches the branch here + * and would need to be updated if that branch is moved + */ #define EXCEPTION_STUB(loc, label) \ . = interrupt_base_book3e + loc; \ nop; /* To make debug interrupts happy */ \
arch/powerpc/mm/tlb_nohash.c +9 -4
@@ -391,10 +391,15 @@ static void __early_init_mmu(int boot_cpu)/* Check if HW loader is supported */ if ((tlb0cfg & TLBnCFG_IND) && (tlb0cfg & TLBnCFG_PT)) { -patch_branch (ibase + (0x1c0 /4 ), - (unsigned long )&exc_data_tlb_miss_htw_book3e,0 ); -patch_branch (ibase + (0x1e0 /4 ), - (unsigned long )&exc_instruction_tlb_miss_htw_book3e,0 ); +/* Our exceptions vectors start with a NOP and -then- a branch +* to deal with single stepping from userspace which stops on +* the second instruction. Thus we need to patch the second +* instruction of the exception, not the first one +*/ +patch_branch (ibase + (0x1c0 /4 ) +1 , + (unsigned long )&exc_data_tlb_miss_htw_book3e,0 ); +patch_branch (ibase + (0x1e0 /4 ) +1 , + (unsigned long )&exc_instruction_tlb_miss_htw_book3e,0 ); book3e_htw_enabled =1 ; } pr_info("MMU: Book3E Page Tables %s\n",
Signature · 1 line
1.6.3.3
PATCH 11/13 powerpc/book3e: Add TLB dump in xmon for Book3E
--- arch/powerpc/xmon/xmon.c | 152 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 152 insertions(+), 0 deletions(-)
arch/powerpc/xmon/xmon.c +152 -0
@@ -155,6 +155,9 @@ static int do_spu_cmd(void);#ifdef CONFIG_44xstatic void dump_tlb_44x (void );#endif +#ifdef CONFIG_PPC_BOOK3E +static void dump_tlb_book3e (void ); +#endif static int xmon_no_auto_backtrace;
@@ -888,6 +891,11 @@ cmds(struct pt_regs *excp)dump_tlb_44x ();break ;#endif +#ifdef CONFIG_PPC_BOOK3E +case 'u' : +dump_tlb_book3e (); +break ; +#endif default :printf ("Unrecognized command: " ); do {
@@ -2701,6 +2709,150 @@ static void dump_tlb_44x(void) }#endif /* CONFIG_44x */ +#ifdef CONFIG_PPC_BOOK3E +static void dump_tlb_book3e (void ) +{ +u32 mmucfg, pidmask, lpidmask; +u64 ramask; +int i, tlb, ntlbs, pidsz, lpidsz, rasz, lrat =0 ; +int mmu_version; +static const char *pgsz_names[] = { +" 1K" , +" 2K" , +" 4K" , +" 8K" , +" 16K" , +" 32K" , +" 64K" , +"128K" , +"256K" , +"512K" , +" 1M" , +" 2M" , +" 4M" , +" 8M" , +" 16M" , +" 32M" , +" 64M" , +"128M" , +"256M" , +"512M" , +" 1G" , +" 2G" , +" 4G" , +" 8G" , +" 16G" , +" 32G" , +" 64G" , +"128G" , +"256G" , +"512G" , +" 1T" , +" 2T" , + }; + +/* Gather some infos about the MMU */ + mmucfg =mfspr (SPRN_MMUCFG ); + mmu_version = (mmucfg &3 ) +1 ; + ntlbs = ((mmucfg >>2 ) &3 ) +1 ; + pidsz = ((mmucfg >>6 ) &0x1f ) +1 ; + lpidsz = (mmucfg >>24 ) &0xf ; + rasz = (mmucfg >>16 ) &0x7f ; +if ((mmu_version >1 ) && (mmucfg &0x10000 )) + lrat =1 ; +printf ("Book3E MMU MAV=%d.0,%d TLBs,%d-bit PID,%d-bit LPID,%d-bit RA\n" , + mmu_version, ntlbs, pidsz, lpidsz, rasz); + pidmask = (1ul << pidsz) -1 ; + lpidmask = (1ul << lpidsz) -1 ; + ramask = (1ull << rasz) -1 ; + +for (tlb =0 ; tlb < ntlbs; tlb++) { +u32 tlbcfg; +int nent, assoc, new_cc =1 ; +printf ("TLB %d:\n------\n" , tlb); +switch (tlb) { +case 0 : + tlbcfg =mfspr (SPRN_TLB0CFG ); +break ; +case 1 : + tlbcfg =mfspr (SPRN_TLB1CFG ); +break ; +case 2 : + tlbcfg =mfspr (SPRN_TLB2CFG ); +break ; +case 3 : + tlbcfg =mfspr (SPRN_TLB3CFG ); +break ; +default : +printf ("Unsupported TLB number !\n" ); +continue ; + } + nent = tlbcfg &0xfff ; + assoc = (tlbcfg >>24 ) &0xff ; +for (i =0 ; i < nent; i++) { +u32 mas0 =MAS0_TLBSEL (tlb); +u32 mas1 =MAS1_TSIZE (BOOK3E_PAGESZ_4K ); +u64 mas2 =0 ; +u64 mas7_mas3; +int esel = i, cc = i; + +if (assoc !=0 ) { + cc = i / assoc; + esel = i % assoc; + mas2 = cc *0x1000 ; + } + + mas0 |=MAS0_ESEL (esel); +mtspr (SPRN_MAS0 , mas0); +mtspr (SPRN_MAS1 , mas1); +mtspr (SPRN_MAS2 , mas2); + asmvolatile ("tlbre 0,0,0" : : :"memory" ); + mas1 =mfspr (SPRN_MAS1 ); + mas2 =mfspr (SPRN_MAS2 ); + mas7_mas3 =mfspr (SPRN_MAS7_MAS3 ); +if (assoc && (i % assoc) ==0 ) + new_cc =1 ; +if (!(mas1 &MAS1_VALID )) +continue ; +if (assoc ==0 ) +printf ("%04x- " , i); +else if (new_cc) +printf ("%04x-%c" , cc,'A' + esel); +else +printf (" |%c" ,'A' + esel); + new_cc =0 ; +printf (" %016llx %04x %s %c%c AS%c" , + mas2 & ~0x3ffull , + (mas1 >>16 ) &0x3fff , + pgsz_names[(mas1 >>7 ) &0x1f ], + mas1 &MAS1_IND ?'I' :' ' , + mas1 &MAS1_IPROT ?'P' :' ' , + mas1 &MAS1_TS ?'1' :'0' ); +printf (" %c%c%c%c%c%c%c" , + mas2 &MAS2_X0 ?'a' :' ' , + mas2 &MAS2_X1 ?'v' :' ' , + mas2 &MAS2_W ?'w' :' ' , + mas2 &MAS2_I ?'i' :' ' , + mas2 &MAS2_M ?'m' :' ' , + mas2 &MAS2_G ?'g' :' ' , + mas2 &MAS2_E ?'e' :' ' ); +printf (" %016llx" , mas7_mas3 & ramask & ~0x7ffull ); +if (mas1 &MAS1_IND ) +printf (" %s\n" , + pgsz_names[(mas7_mas3 >>1 ) &0x1f ]); +else +printf (" U%c%c%c S%c%c%c\n" , + mas7_mas3 &MAS3_UX ?'x' :' ' , + mas7_mas3 &MAS3_UW ?'w' :' ' , + mas7_mas3 &MAS3_UR ?'r' :' ' , + mas7_mas3 &MAS3_SX ?'x' :' ' , + mas7_mas3 &MAS3_SW ?'w' :' ' , + mas7_mas3 &MAS3_SR ?'r' :' ' ); + } + } +} +#endif /* CONFIG_PPC_BOOK3E */ +static void xmon_init (int enable) {#ifdef CONFIG_PPC_ISERIES
Signature · 1 line
1.6.3.3
PATCH 12/13 powerpc/book3e: Adjust the page sizes list based on MMU config
Use the MMU config registers to scan for available direct and indirect page sizes and print out the result. Will be needed for future hugetlbfs implementation.
--- arch/powerpc/include/asm/mmu-book3e.h | 4 + arch/powerpc/include/asm/reg_booke.h | 1 + arch/powerpc/mm/tlb_nohash.c | 136 +++++++++++++++++++++++++-------- 3 files changed, 109 insertions(+), 32 deletions(-)
arch/powerpc/include/asm/mmu-book3e.h +4 -0
@@ -193,6 +193,10 @@ struct mmu_psize_def {unsigned int shift;/* number of bits */ unsigned int enc;/* PTE encoding */ +unsigned int ind;/* Corresponding indirect page size shift */ +unsigned int flags; +#define MMU_PAGE_SIZE_DIRECT 0x1/* Supported as a direct size */ +#define MMU_PAGE_SIZE_INDIRECT 0x2/* Supported as an indirect size */ };extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT ];
arch/powerpc/include/asm/reg_booke.h +1 -0
@@ -62,6 +62,7 @@#define SPRN_TLB0PS 0x158/* TLB 0 Page Size Register */ #define SPRN_MAS5_MAS6 0x15c/* MMU Assist Register 5 || 6 */ #define SPRN_MAS8_MAS1 0x15d/* MMU Assist Register 8 || 1 */ +#define SPRN_EPTCFG 0x15e/* Embedded Page Table Config */ #define SPRN_MAS7_MAS3 0x174/* MMU Assist Register 7 || 3 */ #define SPRN_MAS0_MAS1 0x175/* MMU Assist Register 0 || 1 */ #define SPRN_IVOR0 0x190/* Interrupt Vector Offset Register 0 */
arch/powerpc/mm/tlb_nohash.c +104 -32
178 lines not on this page · raw message
Signature · 1 line
1.6.3.3
PATCH 13/13 powerpc/oprofile: Don't build server oprofile drivers on 64-bit BookE
They will fail to build due to the lack of mtmsrd, and wouldn't be useful anyways
--- arch/powerpc/oprofile/Makefile | 2 +- arch/powerpc/oprofile/common.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/oprofile/Makefile +1 -1
@@ -16,6 +16,6 @@ oprofile-y := $(DRIVER_OBJS) common.o backtrace.o oprofile-$(CONFIG_OPROFILE_CELL) += op_model_cell.o \ cell/spu_profiler.o cell/vma_map.o \ cell/spu_task_sync.o -oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o op_model_pa6t.o +oprofile-$(CONFIG_PPC_BOOK3S_64) += op_model_rs64.o op_model_power4.o op_model_pa6t.o oprofile-$(CONFIG_FSL_EMB_PERFMON) += op_model_fsl_emb.o oprofile-$(CONFIG_6xx) += op_model_7450.o
arch/powerpc/oprofile/common.c +1 -1
@@ -199,7 +199,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)return -ENODEV ;switch (cur_cpu_spec->oprofile_type) { -#ifdef CONFIG_PPC64 +#ifdef CONFIG_PPC_BOOK3S_64 #ifdef CONFIG_OPROFILE_CELL case PPC_OPROFILE_CELL :if (firmware_has_feature (FW_FEATURE_LPAR ))
Signature · 1 line
1.6.3.3
Re: [PATCH 02/13] powerpc/book3e: Hack to get gdb moving along on Book3E 64-bit
In reply to Benjamin HerrenschmidtOn Fri, Jul 09, 2010 at 04:16:44PM +1000, Benjamin Herrenschmidt wrote:
Hi,
A few questions and some trivial comments below.
Quoted 7 lines
Our handling of debug interrupts on Book3E 64-bit is not quite the way it should be just yet. This is a workaround to let gdb work at least for now. We ensure that when context switching, we set the appropriate DBCR0 value for the new task. We also make sure that we turn off MSR[DE] within the kernel, and set it as part of the bits that get set when going back to userspace.
I think I'm missing the code where MSR_DE is set before returning to user-space? I just found one instance where MSR_USER64 (which now includes MSR_DE) is used (in start_thread()). If not set, we'll lose the interrupts caused in IDM too.
Quoted 4 lines
In the long run, we will probably set the userspace DBCR0 on the exception exit code path and ensure we have some proper kernel value to set on the way into the kernel, a bit like ppc32 does, but that will take more work.
The effort to port ppc32 BookIII E debug register usage to use generic hw-breakpoint interfaces (linuxppc-dev message-id:
[email protected]), in its final form, should cleanup most of this code. Even the hook switch_booke_debug_regs() in __switch_to() should be done away.
Quoted 11 lines
Signed-off-by Benjamin Herrenschmidt <[email protected]>--- arch/powerpc/include/asm/reg_booke.h | 4 ++-- arch/powerpc/kernel/process.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-)arch/powerpc/include/asm/reg_booke.h +0
-0
arch/powerpc/include/asm/reg_booke.h line 33
Quoted 7 lines
arch/powerpc/include/asm/reg_booke.h +2
-2@@ -29,8 +29,8 @@#if defined(CONFIG_PPC_BOOK3E_64 )#define MSR_ MSR_ME | MSR_CE#define MSR_KERNEL MSR_ | MSR_CM -#define MSR_USER32 MSR_ | MSR_PR | MSR_EE -#define MSR_USER64 MSR_USER32 | MSR_CM +#define MSR_USER32 MSR_ | MSR_PR | MSR_EE | MSR_DE +#define MSR_USER64 MSR_USER32 | MSR_CM | MSR_DE
MSR_DE is included twice in MSR_USER64 (once through MSR_USER32).
arch/powerpc/kernel/process.c struct task_struct *__switch_to(struct task_struct *prev, · line 481
Quoted 13 lines
arch/powerpc/include/asm/reg_booke.h +0
-0#elif defined (CONFIG_40x)#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR|MSR_CE)#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE)arch/powerpc/kernel/process.c +2
-0@@ -477,6 +477,28 @@ struct task_struct *__switch_to(struct task_struct *prev, new_thread = &new->thread; old_thread = ¤t->thread; +#if defined(CONFIG_PPC_BOOK3E_64 ) +/* XXX Current Book3E code doesn't deal with kernel side DBCR0,
You may want to use the style
/* * ......
arch/powerpc/kernel/process.c struct task_struct *__switch_to(struct task_struct *prev, · line 485
Quoted 4 lines
arch/powerpc/kernel/process.c +4
-0+* we always hold the user values, so we set it now. +* +* However, we ensure the kernel MSR:DE is appropriately cleared too +* to avoid spurrious single step exceptions in the kernel.
^^^spurious^^^
arch/powerpc/kernel/process.c struct task_struct *__switch_to(struct task_struct *prev, · line 492
Quoted 7 lines
arch/powerpc/kernel/process.c +7
-0+* +* This will have to change to merge with the ppc32 code at some point, +* but I don't like much what ppc32 is doing today so there's some +* thinking needed there +*/ +if ((new_thread->dbcr0 | old_thread->dbcr0) &DBCR0_IDM ) { +u32 dbcr0;
thread->dbcr0 is defined as "unsigned long" in processor.h however "u32 dbcr0" here must be fine (given that DBCR0 uses 32-bits in ppc32 and uses only 32:63 bits in BOOKIIIE_64). Should dbcr<0-n> be made u32, given that there will be no 64-bit long value to store (or am I missing something)?
Thanks,
K.Prasad
Quoted 19 lines
arch/powerpc/kernel/process.c +9
-0+ +mtmsr (mfmsr () & ~MSR_DE ); +isync (); + dbcr0 =mfspr (SPRN_DBCR0 ); + dbcr0 = (dbcr0 &DBCR0_EDM ) | new_thread->dbcr0; + mtspr(SPRN_DBCR0, dbcr0); + } +#endif /* CONFIG_PPC64_BOOK3E */ +#ifdef CONFIG_PPC64 /* * Collect processor utilization data per process Signature · 6 lines
1.6.3.3 _______________________________________________ Linuxppc-dev mailing list [email protected] https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 09/13] powerpc/book3e: Add generic 64-bit idle powersave support
In reply to Benjamin HerrenschmidtQuoted 5 lines · Benjamin Herrenschmidt
We use a similar technique to ppc32: We set a thread local flag to indicate that we are about to enter or have entered the stop state, and have fixup code in the async interrupt entry code that reacts to this flag to make us return to a different location (sets NIP to LINK in our case).
.../...
Commenting on my own patch ... :-) This has issues:
Quoted 12 lines
arch/powerpc/kernel/idle_book3e.S new file +12
-0+_GLOBAL(book3e_idle) + /* Save LR for later */ + mflr r0 + std r0,16(r1) + + /* Hard disable interrupts */ + wrteei 0 + + /* Now check if an interrupt came in while we were soft disabled + * since we may otherwise lose it (doorbells etc...). We know + * that since PACAHARDIRQEN will have been cleared in that case. + */
arch/powerpc/kernel/idle_book3e.S line 44
Quoted 10 lines
arch/powerpc/kernel/idle_book3e.S new file +10
-0+ lbz r3,PACAHARDIRQEN(r13) + cmpwi cr0,r3,0 + beqlr + + /* Now we are going to mark ourselves as soft and hard enables in + * order to be able to take interrupts while asleep. We inform lockdep + * of that. We don't actually turn interrupts on just yet tho. + */ +#ifdef CONFIG_TRACE_IRQFLAGS + bl .trace_hardirqs_on
Oops... we just clobbered our saved LR on the stack. Need a stackframe
arch/powerpc/kernel/idle_book3e.S line 53
Quoted 9 lines
arch/powerpc/kernel/idle_book3e.S new file +9
-0+#endif + li r0,1 + stb r0,PACASOFTIRQEN(r13) + stb r0,PACAHARDIRQEN(r13) + + /* Interrupts will make use return to LR, so get something we want + * in there + */ + bl 1f
We return here with IRQs enabled, we really need to turn them back off or bad things will happen if an interrupt pops before we clear TFL_NAPPING.
I'll send a respin.
Cheers,
Ben.
Quoted 28 lines
arch/powerpc/kernel/idle_book3e.S new file +27
-0+ /* We are back from the interrupt, the caller will local_irq_enable() + * so to avoid stupid warning, let's turn them off here if irqtrace + * is enabled. + */ +#ifdef CONFIG_TRACE_IRQFLAGS + li r0,0 + stb r0,PACASOFTIRQEN(r13) + bl .trace_hardirqs_off +#endif + ld r0,16(r1) + mtlr r0 + blr + +1: /* Let's set the _TLF_NAPPING flag so interrupts make us return + * to the right spot + */ + clrrdi r11,r1,THREAD_SHIFT + ld r10,TI_LOCAL_FLAGS(r11) + ori r10,r10,_TLF_NAPPING + std r10,TI_LOCAL_FLAGS(r11) + + /* We can now re-enable hard interrupts and go to sleep */ + wrteei 1 +1: PPC_WAIT(0) + b 1b + +#endif /* CONFIG_PPC64 */