2005-09-26 14:04:21 +08:00
|
|
|
/*
|
|
|
|
* PowerPC version
|
|
|
|
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
|
|
|
|
*
|
|
|
|
* Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
|
|
|
|
* Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
|
|
|
|
* Adapted for Power Macintosh by Paul Mackerras.
|
|
|
|
* Low-level exception handlers and MMU support
|
|
|
|
* rewritten by Paul Mackerras.
|
|
|
|
* Copyright (C) 1996 Paul Mackerras.
|
|
|
|
*
|
|
|
|
* Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
|
|
|
|
* Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
|
|
|
|
*
|
2009-06-03 05:17:38 +08:00
|
|
|
* This file contains the entry point for the 64-bit kernel along
|
|
|
|
* with some early initialization code common to all 64-bit powerpc
|
|
|
|
* variants.
|
2005-09-26 14:04:21 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/threads.h>
|
2005-10-10 12:01:07 +08:00
|
|
|
#include <asm/reg.h>
|
2005-09-26 14:04:21 +08:00
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/mmu.h>
|
|
|
|
#include <asm/ppc_asm.h>
|
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
#include <asm/bug.h>
|
|
|
|
#include <asm/cputable.h>
|
|
|
|
#include <asm/setup.h>
|
|
|
|
#include <asm/hvcall.h>
|
[PATCH] powerpc: Merge thread_info.h
Merge ppc32 and ppc64 versions of thread_info.h. They were pretty
similar already, the chief changes are:
- Instead of inline asm to implement current_thread_info(),
which needs to be different for ppc32 and ppc64, we use C with an
asm("r1") register variable. gcc turns it into the same asm as we
used to have for both platforms.
- We replace ppc32's 'local_flags' with the ppc64
'syscall_noerror' field. The noerror flag was in fact the only thing
in the local_flags field anyway, so the ppc64 approach is simpler, and
means we only need a load-immediate/store instead of load/mask/store
when clearing the flag.
- In readiness for 64k pages, when THREAD_SIZE will be less
than a page, ppc64 used kmalloc() rather than get_free_pages() to
allocate the kernel stack. With this patch we do the same for ppc32,
since there's no strong reason not to.
- For ppc64, we no longer export THREAD_SHIFT and THREAD_SIZE
via asm-offsets, thread_info.h can now be safely included in asm, as
on ppc32.
Built and booted on G4 Powerbook (ARCH=ppc and ARCH=powerpc) and
Power5 (ARCH=ppc64 and ARCH=powerpc).
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-10-21 13:45:50 +08:00
|
|
|
#include <asm/thread_info.h>
|
2006-09-25 16:19:00 +08:00
|
|
|
#include <asm/firmware.h>
|
2007-08-20 12:58:36 +08:00
|
|
|
#include <asm/page_64.h>
|
2008-04-17 12:35:01 +08:00
|
|
|
#include <asm/irqflags.h>
|
2010-04-16 06:11:32 +08:00
|
|
|
#include <asm/kvm_book3s_asm.h>
|
2010-11-18 23:06:17 +08:00
|
|
|
#include <asm/ptrace.h>
|
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 15:27:59 +08:00
|
|
|
#include <asm/hw_irq.h>
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2011-03-31 09:57:33 +08:00
|
|
|
/* The physical memory is laid out such that the secondary processor
|
2009-06-03 05:17:38 +08:00
|
|
|
* spin code sits at 0x0000...0x00ff. On server, the vectors follow
|
|
|
|
* using the layout described in exceptions-64s.S
|
2005-09-26 14:04:21 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Entering into this code we make the following assumptions:
|
2009-06-03 05:17:38 +08:00
|
|
|
*
|
|
|
|
* For pSeries or server processors:
|
2005-09-26 14:04:21 +08:00
|
|
|
* 1. The MMU is off & open firmware is running in real mode.
|
|
|
|
* 2. The kernel is entered at __start
|
2011-09-20 02:27:58 +08:00
|
|
|
* -or- For OPAL entry:
|
|
|
|
* 1. The MMU is off, processor in HV mode, primary CPU enters at 0
|
2011-09-20 01:44:59 +08:00
|
|
|
* with device-tree in gpr3. We also get OPAL base in r8 and
|
|
|
|
* entry in r9 for debugging purposes
|
2011-09-20 02:27:58 +08:00
|
|
|
* 2. Secondary processors enter at 0x60 with PIR in gpr3
|
2005-09-26 14:04:21 +08:00
|
|
|
*
|
2009-06-03 05:17:38 +08:00
|
|
|
* For Book3E processors:
|
|
|
|
* 1. The MMU is on running in AS0 in a state defined in ePAPR
|
|
|
|
* 2. The kernel is entered at __start
|
2005-09-26 14:04:21 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
.text
|
|
|
|
.globl _stext
|
|
|
|
_stext:
|
|
|
|
_GLOBAL(__start)
|
|
|
|
/* NOP this out unconditionally */
|
|
|
|
BEGIN_FTR_SECTION
|
2005-10-06 08:59:19 +08:00
|
|
|
b .__start_initialization_multiplatform
|
2005-09-26 14:04:21 +08:00
|
|
|
END_FTR_SECTION(0, 1)
|
|
|
|
|
|
|
|
/* Catch branch to 0 in real mode */
|
|
|
|
trap
|
|
|
|
|
2008-08-30 09:40:24 +08:00
|
|
|
/* Secondary processors spin on this value until it becomes nonzero.
|
|
|
|
* When it does it contains the real address of the descriptor
|
|
|
|
* of the function that the cpu should jump to to continue
|
|
|
|
* initialization.
|
|
|
|
*/
|
2005-09-26 14:04:21 +08:00
|
|
|
.globl __secondary_hold_spinloop
|
|
|
|
__secondary_hold_spinloop:
|
|
|
|
.llong 0x0
|
|
|
|
|
|
|
|
/* Secondary processors write this value with their cpu # */
|
|
|
|
/* after they enter the spin loop immediately below. */
|
|
|
|
.globl __secondary_hold_acknowledge
|
|
|
|
__secondary_hold_acknowledge:
|
|
|
|
.llong 0x0
|
|
|
|
|
2010-11-18 08:35:07 +08:00
|
|
|
#ifdef CONFIG_RELOCATABLE
|
2008-10-24 02:41:09 +08:00
|
|
|
/* This flag is set to 1 by a loader if the kernel should run
|
|
|
|
* at the loaded address instead of the linked address. This
|
|
|
|
* is used by kexec-tools to keep the the kdump kernel in the
|
|
|
|
* crash_kernel region. The loader is responsible for
|
|
|
|
* observing the alignment requirement.
|
|
|
|
*/
|
|
|
|
/* Do not move this variable as kexec-tools knows about it. */
|
|
|
|
. = 0x5c
|
|
|
|
.globl __run_at_load
|
|
|
|
__run_at_load:
|
|
|
|
.long 0x72756e30 /* "run0" -- relocate to 0 by default */
|
|
|
|
#endif
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
. = 0x60
|
|
|
|
/*
|
2007-06-16 06:06:23 +08:00
|
|
|
* The following code is used to hold secondary processors
|
|
|
|
* in a spin loop after they have entered the kernel, but
|
2005-09-26 14:04:21 +08:00
|
|
|
* before the bulk of the kernel has been relocated. This code
|
|
|
|
* is relocated to physical address 0x60 before prom_init is run.
|
|
|
|
* All of it must fit below the first exception vector at 0x100.
|
2008-08-30 09:40:24 +08:00
|
|
|
* Use .globl here not _GLOBAL because we want __secondary_hold
|
|
|
|
* to be the actual text address, not a descriptor.
|
2005-09-26 14:04:21 +08:00
|
|
|
*/
|
2008-08-30 09:40:24 +08:00
|
|
|
.globl __secondary_hold
|
|
|
|
__secondary_hold:
|
2009-07-24 07:15:59 +08:00
|
|
|
#ifndef CONFIG_PPC_BOOK3E
|
2005-09-26 14:04:21 +08:00
|
|
|
mfmsr r24
|
|
|
|
ori r24,r24,MSR_RI
|
|
|
|
mtmsrd r24 /* RI on */
|
2009-07-24 07:15:59 +08:00
|
|
|
#endif
|
2006-02-13 15:11:13 +08:00
|
|
|
/* Grab our physical cpu number */
|
2005-09-26 14:04:21 +08:00
|
|
|
mr r24,r3
|
|
|
|
|
|
|
|
/* Tell the master cpu we're here */
|
|
|
|
/* Relocation is off & we are located at an address less */
|
|
|
|
/* than 0x100, so only need to grab low order offset. */
|
2008-08-30 09:41:12 +08:00
|
|
|
std r24,__secondary_hold_acknowledge-_stext(0)
|
2005-09-26 14:04:21 +08:00
|
|
|
sync
|
|
|
|
|
|
|
|
/* All secondary cpus wait here until told to start. */
|
2008-08-30 09:41:12 +08:00
|
|
|
100: ld r4,__secondary_hold_spinloop-_stext(0)
|
2008-08-30 09:40:24 +08:00
|
|
|
cmpdi 0,r4,0
|
|
|
|
beq 100b
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2006-02-13 15:11:13 +08:00
|
|
|
#if defined(CONFIG_SMP) || defined(CONFIG_KEXEC)
|
2008-08-30 09:40:24 +08:00
|
|
|
ld r4,0(r4) /* deref function descriptor */
|
2005-12-06 05:49:00 +08:00
|
|
|
mtctr r4
|
2005-09-26 14:04:21 +08:00
|
|
|
mr r3,r24
|
2009-07-24 07:15:59 +08:00
|
|
|
li r4,0
|
2011-04-05 12:34:58 +08:00
|
|
|
/* Make sure that patched code is visible */
|
|
|
|
isync
|
2005-12-06 05:49:00 +08:00
|
|
|
bctr
|
2005-09-26 14:04:21 +08:00
|
|
|
#else
|
|
|
|
BUG_OPCODE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* This value is used to mark exception frames on the stack. */
|
|
|
|
.section ".toc","aw"
|
|
|
|
exception_marker:
|
|
|
|
.tc ID_72656773_68657265[TC],0x7265677368657265
|
|
|
|
.text
|
|
|
|
|
|
|
|
/*
|
2009-06-03 05:17:38 +08:00
|
|
|
* On server, we include the exception vectors code here as it
|
|
|
|
* relies on absolute addressing which is only possible within
|
|
|
|
* this compilation unit
|
2005-11-07 08:06:55 +08:00
|
|
|
*/
|
2009-06-03 05:17:38 +08:00
|
|
|
#ifdef CONFIG_PPC_BOOK3S
|
|
|
|
#include "exceptions-64s.S"
|
2008-08-30 09:40:24 +08:00
|
|
|
#endif
|
2005-11-07 08:06:55 +08:00
|
|
|
|
2009-07-24 07:15:59 +08:00
|
|
|
_GLOBAL(generic_secondary_thread_init)
|
|
|
|
mr r24,r3
|
|
|
|
|
|
|
|
/* turn on 64-bit mode */
|
|
|
|
bl .enable_64b_mode
|
|
|
|
|
|
|
|
/* get a valid TOC pointer, wherever we're mapped at */
|
|
|
|
bl .relative_toc
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPC_BOOK3E
|
|
|
|
/* Book3E initialization */
|
|
|
|
mr r3,r24
|
|
|
|
bl .book3e_secondary_thread_init
|
|
|
|
#endif
|
|
|
|
b generic_secondary_common_init
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
/*
|
2006-08-11 13:07:08 +08:00
|
|
|
* On pSeries and most other platforms, secondary processors spin
|
|
|
|
* in the following code.
|
2005-09-26 14:04:21 +08:00
|
|
|
* At entry, r3 = this processor's number (physical cpu id)
|
2009-07-24 07:15:59 +08:00
|
|
|
*
|
|
|
|
* On Book3E, r4 = 1 to indicate that the initial TLB entry for
|
|
|
|
* this core already exists (setup via some other mechanism such
|
|
|
|
* as SCOM before entry).
|
2005-09-26 14:04:21 +08:00
|
|
|
*/
|
2006-08-11 13:07:08 +08:00
|
|
|
_GLOBAL(generic_secondary_smp_init)
|
2005-09-26 14:04:21 +08:00
|
|
|
mr r24,r3
|
2009-07-24 07:15:59 +08:00
|
|
|
mr r25,r4
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
/* turn on 64-bit mode */
|
|
|
|
bl .enable_64b_mode
|
|
|
|
|
2009-07-24 07:15:59 +08:00
|
|
|
/* get a valid TOC pointer, wherever we're mapped at */
|
2008-08-30 09:41:12 +08:00
|
|
|
bl .relative_toc
|
|
|
|
|
2009-07-24 07:15:59 +08:00
|
|
|
#ifdef CONFIG_PPC_BOOK3E
|
|
|
|
/* Book3E initialization */
|
|
|
|
mr r3,r24
|
|
|
|
mr r4,r25
|
|
|
|
bl .book3e_secondary_core_init
|
|
|
|
#endif
|
|
|
|
|
|
|
|
generic_secondary_common_init:
|
2005-09-26 14:04:21 +08:00
|
|
|
/* Set up a paca value for this processor. Since we have the
|
|
|
|
* physical cpu id in r24, we need to search the pacas to find
|
|
|
|
* which logical id maps to our physical one.
|
|
|
|
*/
|
2010-01-28 21:23:22 +08:00
|
|
|
LOAD_REG_ADDR(r13, paca) /* Load paca pointer */
|
|
|
|
ld r13,0(r13) /* Get base vaddr of paca array */
|
2011-05-11 03:28:37 +08:00
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
addi r13,r13,PACA_SIZE /* know r13 if used accidentally */
|
|
|
|
b .kexec_wait /* wait for next kernel if !SMP */
|
|
|
|
#else
|
|
|
|
LOAD_REG_ADDR(r7, nr_cpu_ids) /* Load nr_cpu_ids address */
|
|
|
|
lwz r7,0(r7) /* also the max paca allocated */
|
2005-09-26 14:04:21 +08:00
|
|
|
li r5,0 /* logical cpu id */
|
|
|
|
1: lhz r6,PACAHWCPUID(r13) /* Load HW procid from paca */
|
|
|
|
cmpw r6,r24 /* Compare to our id */
|
|
|
|
beq 2f
|
|
|
|
addi r13,r13,PACA_SIZE /* Loop to next PACA on miss */
|
|
|
|
addi r5,r5,1
|
2011-05-11 03:28:37 +08:00
|
|
|
cmpw r5,r7 /* Check if more pacas exist */
|
2005-09-26 14:04:21 +08:00
|
|
|
blt 1b
|
|
|
|
|
|
|
|
mr r3,r24 /* not found, copy phys to r3 */
|
|
|
|
b .kexec_wait /* next kernel might do better */
|
|
|
|
|
2011-01-20 14:50:21 +08:00
|
|
|
2: SET_PACA(r13)
|
2009-07-24 07:15:59 +08:00
|
|
|
#ifdef CONFIG_PPC_BOOK3E
|
|
|
|
addi r12,r13,PACA_EXTLB /* and TLB exc frame in another */
|
|
|
|
mtspr SPRN_SPRG_TLB_EXFRAME,r12
|
|
|
|
#endif
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
/* From now on, r24 is expected to be logical cpuid */
|
|
|
|
mr r24,r5
|
2008-07-12 07:00:26 +08:00
|
|
|
|
2006-08-11 13:07:08 +08:00
|
|
|
/* See if we need to call a cpu state restore handler */
|
2008-08-30 09:41:12 +08:00
|
|
|
LOAD_REG_ADDR(r23, cur_cpu_spec)
|
2006-08-11 13:07:08 +08:00
|
|
|
ld r23,0(r23)
|
|
|
|
ld r23,CPU_SPEC_RESTORE(r23)
|
|
|
|
cmpdi 0,r23,0
|
2011-03-16 11:54:35 +08:00
|
|
|
beq 3f
|
2006-08-11 13:07:08 +08:00
|
|
|
ld r23,0(r23)
|
|
|
|
mtctr r23
|
|
|
|
bctrl
|
|
|
|
|
2011-05-26 02:09:12 +08:00
|
|
|
3: LOAD_REG_ADDR(r3, spinning_secondaries) /* Decrement spinning_secondaries */
|
2011-03-16 11:54:35 +08:00
|
|
|
lwarx r4,0,r3
|
|
|
|
subi r4,r4,1
|
|
|
|
stwcx. r4,0,r3
|
|
|
|
bne 3b
|
|
|
|
isync
|
|
|
|
|
|
|
|
4: HMT_LOW
|
2011-02-01 09:13:09 +08:00
|
|
|
lbz r23,PACAPROCSTART(r13) /* Test if this processor should */
|
|
|
|
/* start. */
|
|
|
|
cmpwi 0,r23,0
|
2011-03-16 11:54:35 +08:00
|
|
|
beq 4b /* Loop until told to go */
|
2011-02-01 09:13:09 +08:00
|
|
|
|
|
|
|
sync /* order paca.run and cur_cpu_spec */
|
2011-03-16 11:54:35 +08:00
|
|
|
isync /* In case code patching happened */
|
2011-02-01 09:13:09 +08:00
|
|
|
|
2011-03-16 11:54:35 +08:00
|
|
|
/* Create a temp kernel stack for use before relocation is on. */
|
2005-09-26 14:04:21 +08:00
|
|
|
ld r1,PACAEMERGSP(r13)
|
|
|
|
subi r1,r1,STACK_FRAME_OVERHEAD
|
|
|
|
|
2006-11-27 11:59:50 +08:00
|
|
|
b __secondary_start
|
2011-05-11 03:28:37 +08:00
|
|
|
#endif /* SMP */
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2008-08-30 09:41:12 +08:00
|
|
|
/*
|
|
|
|
* Turn the MMU off.
|
|
|
|
* Assumes we're mapped EA == RA if the MMU is on.
|
|
|
|
*/
|
2009-07-24 07:15:59 +08:00
|
|
|
#ifdef CONFIG_PPC_BOOK3S
|
2005-09-26 14:04:21 +08:00
|
|
|
_STATIC(__mmu_off)
|
|
|
|
mfmsr r3
|
|
|
|
andi. r0,r3,MSR_IR|MSR_DR
|
|
|
|
beqlr
|
2008-08-30 09:41:12 +08:00
|
|
|
mflr r4
|
2005-09-26 14:04:21 +08:00
|
|
|
andc r3,r3,r0
|
|
|
|
mtspr SPRN_SRR0,r4
|
|
|
|
mtspr SPRN_SRR1,r3
|
|
|
|
sync
|
|
|
|
rfid
|
|
|
|
b . /* prevent speculative execution */
|
2009-07-24 07:15:59 +08:00
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Here is our main kernel entry point. We support currently 2 kind of entries
|
|
|
|
* depending on the value of r5.
|
|
|
|
*
|
|
|
|
* r5 != NULL -> OF entry, we go to prom_init, "legacy" parameter content
|
|
|
|
* in r3...r7
|
|
|
|
*
|
|
|
|
* r5 == NULL -> kexec style entry. r3 is a physical pointer to the
|
|
|
|
* DT block, r4 is a physical pointer to the kernel itself
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
_GLOBAL(__start_initialization_multiplatform)
|
2008-08-30 09:41:12 +08:00
|
|
|
/* Make sure we are running in 64 bits mode */
|
|
|
|
bl .enable_64b_mode
|
|
|
|
|
|
|
|
/* Get TOC pointer (current runtime address) */
|
|
|
|
bl .relative_toc
|
|
|
|
|
|
|
|
/* find out where we are now */
|
|
|
|
bcl 20,31,$+4
|
|
|
|
0: mflr r26 /* r26 = runtime addr here */
|
|
|
|
addis r26,r26,(_stext - 0b)@ha
|
|
|
|
addi r26,r26,(_stext - 0b)@l /* current runtime base addr */
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
/*
|
|
|
|
* Are we booted from a PROM Of-type client-interface ?
|
|
|
|
*/
|
|
|
|
cmpldi cr0,r5,0
|
2007-07-31 14:44:13 +08:00
|
|
|
beq 1f
|
|
|
|
b .__boot_from_prom /* yes -> prom */
|
|
|
|
1:
|
2005-09-26 14:04:21 +08:00
|
|
|
/* Save parameters */
|
|
|
|
mr r31,r3
|
|
|
|
mr r30,r4
|
2011-09-20 01:44:59 +08:00
|
|
|
#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL
|
|
|
|
/* Save OPAL entry */
|
|
|
|
mr r28,r8
|
|
|
|
mr r29,r9
|
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2009-07-24 07:15:59 +08:00
|
|
|
#ifdef CONFIG_PPC_BOOK3E
|
|
|
|
bl .start_initialization_book3e
|
|
|
|
b .__after_prom_start
|
|
|
|
#else
|
2005-09-26 14:04:21 +08:00
|
|
|
/* Setup some critical 970 SPRs before switching MMU off */
|
2006-08-11 13:07:08 +08:00
|
|
|
mfspr r0,SPRN_PVR
|
|
|
|
srwi r0,r0,16
|
|
|
|
cmpwi r0,0x39 /* 970 */
|
|
|
|
beq 1f
|
|
|
|
cmpwi r0,0x3c /* 970FX */
|
|
|
|
beq 1f
|
|
|
|
cmpwi r0,0x44 /* 970MP */
|
2006-10-26 06:32:40 +08:00
|
|
|
beq 1f
|
|
|
|
cmpwi r0,0x45 /* 970GX */
|
2006-08-11 13:07:08 +08:00
|
|
|
bne 2f
|
|
|
|
1: bl .__cpu_preinit_ppc970
|
|
|
|
2:
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2008-08-30 09:41:12 +08:00
|
|
|
/* Switch off MMU if not already off */
|
2005-09-26 14:04:21 +08:00
|
|
|
bl .__mmu_off
|
|
|
|
b .__after_prom_start
|
2009-07-24 07:15:59 +08:00
|
|
|
#endif /* CONFIG_PPC_BOOK3E */
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2007-07-31 14:44:13 +08:00
|
|
|
_INIT_STATIC(__boot_from_prom)
|
2009-03-11 01:53:27 +08:00
|
|
|
#ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE
|
2005-09-26 14:04:21 +08:00
|
|
|
/* Save parameters */
|
|
|
|
mr r31,r3
|
|
|
|
mr r30,r4
|
|
|
|
mr r29,r5
|
|
|
|
mr r28,r6
|
|
|
|
mr r27,r7
|
|
|
|
|
[PATCH] correct the comment about stackpointer alignment in __boot_from_prom
The address of variable val in prom_init_stdout is passed to prom_getprop.
prom_getprop casts the pointer to u32 and passes it to call_prom in the hope
that OpenFirmware stores something there.
But the pointer is truncated in the lower bits and the expected value is
stored somewhere else.
In my testing I had a stackpointer of 0x0023e6b4. val was at offset 120,
wich has address 0x0023e72c. But the value passed to OF was 0x0023e728.
c00000000040b710: 3b 01 00 78 addi r24,r1,120
...
c00000000040b754: 57 08 00 38 rlwinm r8,r24,0,0,28
...
c00000000040b784: 80 01 00 78 lwz r0,120(r1)
...
c00000000040b798: 90 1b 00 0c stw r0,12(r27)
...
The stackpointer came from 32bit code.
The chain was yaboot -> zImage -> vmlinux
PowerMac OpenFirmware does appearently not handle the ELF sections
correctly. If yaboot was compiled in
/usr/src/packages/BUILD/lilo-10.1.1/yaboot, then the stackpointer is
unaligned. But the stackpointer is correct if yaboot is compiled in
/tmp/yaboot.
This bug triggered since 2.6.15, now prom_getprop is an inline
function. gcc clears the lower bits, instead of just clearing the
upper 32 bits.
Signed-off-by: Olaf Hering <olh@suse.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-03-24 04:50:59 +08:00
|
|
|
/*
|
|
|
|
* Align the stack to 16-byte boundary
|
|
|
|
* Depending on the size and layout of the ELF sections in the initial
|
2008-08-30 09:41:12 +08:00
|
|
|
* boot binary, the stack pointer may be unaligned on PowerMac
|
[PATCH] correct the comment about stackpointer alignment in __boot_from_prom
The address of variable val in prom_init_stdout is passed to prom_getprop.
prom_getprop casts the pointer to u32 and passes it to call_prom in the hope
that OpenFirmware stores something there.
But the pointer is truncated in the lower bits and the expected value is
stored somewhere else.
In my testing I had a stackpointer of 0x0023e6b4. val was at offset 120,
wich has address 0x0023e72c. But the value passed to OF was 0x0023e728.
c00000000040b710: 3b 01 00 78 addi r24,r1,120
...
c00000000040b754: 57 08 00 38 rlwinm r8,r24,0,0,28
...
c00000000040b784: 80 01 00 78 lwz r0,120(r1)
...
c00000000040b798: 90 1b 00 0c stw r0,12(r27)
...
The stackpointer came from 32bit code.
The chain was yaboot -> zImage -> vmlinux
PowerMac OpenFirmware does appearently not handle the ELF sections
correctly. If yaboot was compiled in
/usr/src/packages/BUILD/lilo-10.1.1/yaboot, then the stackpointer is
unaligned. But the stackpointer is correct if yaboot is compiled in
/tmp/yaboot.
This bug triggered since 2.6.15, now prom_getprop is an inline
function. gcc clears the lower bits, instead of just clearing the
upper 32 bits.
Signed-off-by: Olaf Hering <olh@suse.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-03-24 04:50:59 +08:00
|
|
|
*/
|
2006-03-05 07:00:45 +08:00
|
|
|
rldicr r1,r1,0,59
|
|
|
|
|
powerpc: Make the 64-bit kernel as a position-independent executable
This implements CONFIG_RELOCATABLE for 64-bit by making the kernel as
a position-independent executable (PIE) when it is set. This involves
processing the dynamic relocations in the image in the early stages of
booting, even if the kernel is being run at the address it is linked at,
since the linker does not necessarily fill in words in the image for
which there are dynamic relocations. (In fact the linker does fill in
such words for 64-bit executables, though not for 32-bit executables,
so in principle we could avoid calling relocate() entirely when we're
running a 64-bit kernel at the linked address.)
The dynamic relocations are processed by a new function relocate(addr),
where the addr parameter is the virtual address where the image will be
run. In fact we call it twice; once before calling prom_init, and again
when starting the main kernel. This means that reloc_offset() returns
0 in prom_init (since it has been relocated to the address it is running
at), which necessitated a few adjustments.
This also changes __va and __pa to use an equivalent definition that is
simpler. With the relocatable kernel, PAGE_OFFSET and MEMORY_START are
constants (for 64-bit) whereas PHYSICAL_START is a variable (and
KERNELBASE ideally should be too, but isn't yet).
With this, relocatable kernels still copy themselves down to physical
address 0 and run there.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-08-30 09:43:47 +08:00
|
|
|
#ifdef CONFIG_RELOCATABLE
|
|
|
|
/* Relocate code for where we are now */
|
|
|
|
mr r3,r26
|
|
|
|
bl .relocate
|
|
|
|
#endif
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
/* Restore parameters */
|
|
|
|
mr r3,r31
|
|
|
|
mr r4,r30
|
|
|
|
mr r5,r29
|
|
|
|
mr r6,r28
|
|
|
|
mr r7,r27
|
|
|
|
|
|
|
|
/* Do all of the interaction with OF client interface */
|
powerpc: Make the 64-bit kernel as a position-independent executable
This implements CONFIG_RELOCATABLE for 64-bit by making the kernel as
a position-independent executable (PIE) when it is set. This involves
processing the dynamic relocations in the image in the early stages of
booting, even if the kernel is being run at the address it is linked at,
since the linker does not necessarily fill in words in the image for
which there are dynamic relocations. (In fact the linker does fill in
such words for 64-bit executables, though not for 32-bit executables,
so in principle we could avoid calling relocate() entirely when we're
running a 64-bit kernel at the linked address.)
The dynamic relocations are processed by a new function relocate(addr),
where the addr parameter is the virtual address where the image will be
run. In fact we call it twice; once before calling prom_init, and again
when starting the main kernel. This means that reloc_offset() returns
0 in prom_init (since it has been relocated to the address it is running
at), which necessitated a few adjustments.
This also changes __va and __pa to use an equivalent definition that is
simpler. With the relocatable kernel, PAGE_OFFSET and MEMORY_START are
constants (for 64-bit) whereas PHYSICAL_START is a variable (and
KERNELBASE ideally should be too, but isn't yet).
With this, relocatable kernels still copy themselves down to physical
address 0 and run there.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-08-30 09:43:47 +08:00
|
|
|
mr r8,r26
|
2005-09-26 14:04:21 +08:00
|
|
|
bl .prom_init
|
2009-03-11 01:53:27 +08:00
|
|
|
#endif /* #CONFIG_PPC_OF_BOOT_TRAMPOLINE */
|
|
|
|
|
|
|
|
/* We never return. We also hit that trap if trying to boot
|
|
|
|
* from OF while CONFIG_PPC_OF_BOOT_TRAMPOLINE isn't selected */
|
2005-09-26 14:04:21 +08:00
|
|
|
trap
|
|
|
|
|
|
|
|
_STATIC(__after_prom_start)
|
powerpc: Make the 64-bit kernel as a position-independent executable
This implements CONFIG_RELOCATABLE for 64-bit by making the kernel as
a position-independent executable (PIE) when it is set. This involves
processing the dynamic relocations in the image in the early stages of
booting, even if the kernel is being run at the address it is linked at,
since the linker does not necessarily fill in words in the image for
which there are dynamic relocations. (In fact the linker does fill in
such words for 64-bit executables, though not for 32-bit executables,
so in principle we could avoid calling relocate() entirely when we're
running a 64-bit kernel at the linked address.)
The dynamic relocations are processed by a new function relocate(addr),
where the addr parameter is the virtual address where the image will be
run. In fact we call it twice; once before calling prom_init, and again
when starting the main kernel. This means that reloc_offset() returns
0 in prom_init (since it has been relocated to the address it is running
at), which necessitated a few adjustments.
This also changes __va and __pa to use an equivalent definition that is
simpler. With the relocatable kernel, PAGE_OFFSET and MEMORY_START are
constants (for 64-bit) whereas PHYSICAL_START is a variable (and
KERNELBASE ideally should be too, but isn't yet).
With this, relocatable kernels still copy themselves down to physical
address 0 and run there.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-08-30 09:43:47 +08:00
|
|
|
#ifdef CONFIG_RELOCATABLE
|
|
|
|
/* process relocations for the final address of the kernel */
|
|
|
|
lis r25,PAGE_OFFSET@highest /* compute virtual base of kernel */
|
|
|
|
sldi r25,r25,32
|
2008-10-24 02:41:09 +08:00
|
|
|
lwz r7,__run_at_load-_stext(r26)
|
2010-11-18 08:35:07 +08:00
|
|
|
cmplwi cr0,r7,1 /* flagged to stay where we are ? */
|
2008-10-22 01:38:10 +08:00
|
|
|
bne 1f
|
|
|
|
add r25,r25,r26
|
|
|
|
1: mr r3,r25
|
powerpc: Make the 64-bit kernel as a position-independent executable
This implements CONFIG_RELOCATABLE for 64-bit by making the kernel as
a position-independent executable (PIE) when it is set. This involves
processing the dynamic relocations in the image in the early stages of
booting, even if the kernel is being run at the address it is linked at,
since the linker does not necessarily fill in words in the image for
which there are dynamic relocations. (In fact the linker does fill in
such words for 64-bit executables, though not for 32-bit executables,
so in principle we could avoid calling relocate() entirely when we're
running a 64-bit kernel at the linked address.)
The dynamic relocations are processed by a new function relocate(addr),
where the addr parameter is the virtual address where the image will be
run. In fact we call it twice; once before calling prom_init, and again
when starting the main kernel. This means that reloc_offset() returns
0 in prom_init (since it has been relocated to the address it is running
at), which necessitated a few adjustments.
This also changes __va and __pa to use an equivalent definition that is
simpler. With the relocatable kernel, PAGE_OFFSET and MEMORY_START are
constants (for 64-bit) whereas PHYSICAL_START is a variable (and
KERNELBASE ideally should be too, but isn't yet).
With this, relocatable kernels still copy themselves down to physical
address 0 and run there.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-08-30 09:43:47 +08:00
|
|
|
bl .relocate
|
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
/*
|
2008-08-30 09:41:12 +08:00
|
|
|
* We need to run with _stext at physical address PHYSICAL_START.
|
2005-09-26 14:04:21 +08:00
|
|
|
* This will leave some code in the first 256B of
|
|
|
|
* real memory, which are reserved for software use.
|
|
|
|
*
|
|
|
|
* Note: This process overwrites the OF exception vectors.
|
|
|
|
*/
|
powerpc: Make the 64-bit kernel as a position-independent executable
This implements CONFIG_RELOCATABLE for 64-bit by making the kernel as
a position-independent executable (PIE) when it is set. This involves
processing the dynamic relocations in the image in the early stages of
booting, even if the kernel is being run at the address it is linked at,
since the linker does not necessarily fill in words in the image for
which there are dynamic relocations. (In fact the linker does fill in
such words for 64-bit executables, though not for 32-bit executables,
so in principle we could avoid calling relocate() entirely when we're
running a 64-bit kernel at the linked address.)
The dynamic relocations are processed by a new function relocate(addr),
where the addr parameter is the virtual address where the image will be
run. In fact we call it twice; once before calling prom_init, and again
when starting the main kernel. This means that reloc_offset() returns
0 in prom_init (since it has been relocated to the address it is running
at), which necessitated a few adjustments.
This also changes __va and __pa to use an equivalent definition that is
simpler. With the relocatable kernel, PAGE_OFFSET and MEMORY_START are
constants (for 64-bit) whereas PHYSICAL_START is a variable (and
KERNELBASE ideally should be too, but isn't yet).
With this, relocatable kernels still copy themselves down to physical
address 0 and run there.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-08-30 09:43:47 +08:00
|
|
|
li r3,0 /* target addr */
|
2009-07-24 07:15:59 +08:00
|
|
|
#ifdef CONFIG_PPC_BOOK3E
|
|
|
|
tovirt(r3,r3) /* on booke, we already run at PAGE_OFFSET */
|
|
|
|
#endif
|
powerpc: Make the 64-bit kernel as a position-independent executable
This implements CONFIG_RELOCATABLE for 64-bit by making the kernel as
a position-independent executable (PIE) when it is set. This involves
processing the dynamic relocations in the image in the early stages of
booting, even if the kernel is being run at the address it is linked at,
since the linker does not necessarily fill in words in the image for
which there are dynamic relocations. (In fact the linker does fill in
such words for 64-bit executables, though not for 32-bit executables,
so in principle we could avoid calling relocate() entirely when we're
running a 64-bit kernel at the linked address.)
The dynamic relocations are processed by a new function relocate(addr),
where the addr parameter is the virtual address where the image will be
run. In fact we call it twice; once before calling prom_init, and again
when starting the main kernel. This means that reloc_offset() returns
0 in prom_init (since it has been relocated to the address it is running
at), which necessitated a few adjustments.
This also changes __va and __pa to use an equivalent definition that is
simpler. With the relocatable kernel, PAGE_OFFSET and MEMORY_START are
constants (for 64-bit) whereas PHYSICAL_START is a variable (and
KERNELBASE ideally should be too, but isn't yet).
With this, relocatable kernels still copy themselves down to physical
address 0 and run there.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-08-30 09:43:47 +08:00
|
|
|
mr. r4,r26 /* In some cases the loader may */
|
2008-08-30 09:41:12 +08:00
|
|
|
beq 9f /* have already put us at zero */
|
2005-09-26 14:04:21 +08:00
|
|
|
li r6,0x100 /* Start offset, the first 0x100 */
|
|
|
|
/* bytes were copied earlier. */
|
2009-07-24 07:15:59 +08:00
|
|
|
#ifdef CONFIG_PPC_BOOK3E
|
|
|
|
tovirt(r6,r6) /* on booke, we already run at PAGE_OFFSET */
|
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2008-10-22 01:38:10 +08:00
|
|
|
#ifdef CONFIG_CRASH_DUMP
|
|
|
|
/*
|
|
|
|
* Check if the kernel has to be running as relocatable kernel based on the
|
2008-10-24 02:41:09 +08:00
|
|
|
* variable __run_at_load, if it is set the kernel is treated as relocatable
|
2008-10-22 01:38:10 +08:00
|
|
|
* kernel, otherwise it will be moved to PHYSICAL_START
|
|
|
|
*/
|
2008-10-24 02:41:09 +08:00
|
|
|
lwz r7,__run_at_load-_stext(r26)
|
|
|
|
cmplwi cr0,r7,1
|
2008-10-22 01:38:10 +08:00
|
|
|
bne 3f
|
|
|
|
|
|
|
|
li r5,__end_interrupts - _stext /* just copy interrupts */
|
|
|
|
b 5f
|
|
|
|
3:
|
|
|
|
#endif
|
|
|
|
lis r5,(copy_to_here - _stext)@ha
|
|
|
|
addi r5,r5,(copy_to_here - _stext)@l /* # bytes of memory to copy */
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
bl .copy_and_flush /* copy the first n bytes */
|
|
|
|
/* this includes the code being */
|
|
|
|
/* executed here. */
|
2008-08-30 09:41:12 +08:00
|
|
|
addis r8,r3,(4f - _stext)@ha /* Jump to the copy of this code */
|
|
|
|
addi r8,r8,(4f - _stext)@l /* that we just made */
|
|
|
|
mtctr r8
|
2005-09-26 14:04:21 +08:00
|
|
|
bctr
|
|
|
|
|
2008-10-22 01:38:10 +08:00
|
|
|
p_end: .llong _end - _stext
|
|
|
|
|
2008-08-30 09:41:12 +08:00
|
|
|
4: /* Now copy the rest of the kernel up to _end */
|
|
|
|
addis r5,r26,(p_end - _stext)@ha
|
|
|
|
ld r5,(p_end - _stext)@l(r5) /* get _end */
|
2008-10-22 01:38:10 +08:00
|
|
|
5: bl .copy_and_flush /* copy the rest */
|
2008-08-30 09:41:12 +08:00
|
|
|
|
|
|
|
9: b .start_here_multiplatform
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
/*
|
|
|
|
* Copy routine used to copy the kernel to start at physical address 0
|
|
|
|
* and flush and invalidate the caches as needed.
|
|
|
|
* r3 = dest addr, r4 = source addr, r5 = copy limit, r6 = start offset
|
|
|
|
* on exit, r3, r4, r5 are unchanged, r6 is updated to be >= r5.
|
|
|
|
*
|
|
|
|
* Note: this routine *only* clobbers r0, r6 and lr
|
|
|
|
*/
|
|
|
|
_GLOBAL(copy_and_flush)
|
|
|
|
addi r5,r5,-8
|
|
|
|
addi r6,r6,-8
|
2006-09-07 03:34:41 +08:00
|
|
|
4: li r0,8 /* Use the smallest common */
|
2005-09-26 14:04:21 +08:00
|
|
|
/* denominator cache line */
|
|
|
|
/* size. This results in */
|
|
|
|
/* extra cache line flushes */
|
|
|
|
/* but operation is correct. */
|
|
|
|
/* Can't get cache line size */
|
|
|
|
/* from NACA as it is being */
|
|
|
|
/* moved too. */
|
|
|
|
|
|
|
|
mtctr r0 /* put # words/line in ctr */
|
|
|
|
3: addi r6,r6,8 /* copy a cache line */
|
|
|
|
ldx r0,r6,r4
|
|
|
|
stdx r0,r6,r3
|
|
|
|
bdnz 3b
|
|
|
|
dcbst r6,r3 /* write it to memory */
|
|
|
|
sync
|
|
|
|
icbi r6,r3 /* flush the icache line */
|
|
|
|
cmpld 0,r6,r5
|
|
|
|
blt 4b
|
|
|
|
sync
|
|
|
|
addi r5,r5,8
|
|
|
|
addi r6,r6,8
|
|
|
|
blr
|
|
|
|
|
|
|
|
.align 8
|
|
|
|
copy_to_here:
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
#ifdef CONFIG_PPC_PMAC
|
|
|
|
/*
|
|
|
|
* On PowerMac, secondary processors starts from the reset vector, which
|
|
|
|
* is temporarily turned into a call to one of the functions below.
|
|
|
|
*/
|
|
|
|
.section ".text";
|
|
|
|
.align 2 ;
|
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
.globl __secondary_start_pmac_0
|
|
|
|
__secondary_start_pmac_0:
|
|
|
|
/* NB the entries for cpus 0, 1, 2 must each occupy 8 bytes. */
|
|
|
|
li r24,0
|
|
|
|
b 1f
|
|
|
|
li r24,1
|
|
|
|
b 1f
|
|
|
|
li r24,2
|
|
|
|
b 1f
|
|
|
|
li r24,3
|
|
|
|
1:
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
_GLOBAL(pmac_secondary_start)
|
|
|
|
/* turn on 64-bit mode */
|
|
|
|
bl .enable_64b_mode
|
|
|
|
|
2009-01-12 03:03:45 +08:00
|
|
|
li r0,0
|
|
|
|
mfspr r3,SPRN_HID4
|
|
|
|
rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
|
|
|
|
sync
|
|
|
|
mtspr SPRN_HID4,r3
|
|
|
|
isync
|
|
|
|
sync
|
|
|
|
slbia
|
|
|
|
|
2008-08-30 09:41:12 +08:00
|
|
|
/* get TOC pointer (real address) */
|
|
|
|
bl .relative_toc
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
/* Copy some CPU settings from CPU 0 */
|
2006-08-11 13:07:08 +08:00
|
|
|
bl .__restore_cpu_ppc970
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
/* pSeries do that early though I don't think we really need it */
|
|
|
|
mfmsr r3
|
|
|
|
ori r3,r3,MSR_RI
|
|
|
|
mtmsrd r3 /* RI on */
|
|
|
|
|
|
|
|
/* Set up a paca value for this processor. */
|
2010-01-28 21:23:22 +08:00
|
|
|
LOAD_REG_ADDR(r4,paca) /* Load paca pointer */
|
|
|
|
ld r4,0(r4) /* Get base vaddr of paca array */
|
2008-08-30 09:41:12 +08:00
|
|
|
mulli r13,r24,PACA_SIZE /* Calculate vaddr of right paca */
|
2005-09-26 14:04:21 +08:00
|
|
|
add r13,r13,r4 /* for this processor. */
|
2011-01-20 14:50:21 +08:00
|
|
|
SET_PACA(r13) /* Save vaddr of paca in an SPRG*/
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2011-02-21 13:49:58 +08:00
|
|
|
/* Mark interrupts soft and hard disabled (they might be enabled
|
|
|
|
* in the PACA when doing hotplug)
|
|
|
|
*/
|
|
|
|
li r0,0
|
|
|
|
stb r0,PACASOFTIRQEN(r13)
|
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 15:27:59 +08:00
|
|
|
li r0,PACA_IRQ_HARD_DIS
|
|
|
|
stb r0,PACAIRQHAPPENED(r13)
|
2011-02-21 13:49:58 +08:00
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
/* Create a temp kernel stack for use before relocation is on. */
|
|
|
|
ld r1,PACAEMERGSP(r13)
|
|
|
|
subi r1,r1,STACK_FRAME_OVERHEAD
|
|
|
|
|
2006-11-27 11:59:50 +08:00
|
|
|
b __secondary_start
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
#endif /* CONFIG_PPC_PMAC */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function is called after the master CPU has released the
|
|
|
|
* secondary processors. The execution environment is relocation off.
|
|
|
|
* The paca for this processor has the following fields initialized at
|
|
|
|
* this point:
|
|
|
|
* 1. Processor number
|
|
|
|
* 2. Segment table pointer (virtual address)
|
|
|
|
* On entry the following are set:
|
2012-02-28 10:44:58 +08:00
|
|
|
* r1 = stack pointer (real addr of temp stack)
|
2009-07-15 04:52:54 +08:00
|
|
|
* r24 = cpu# (in Linux terms)
|
|
|
|
* r13 = paca virtual address
|
|
|
|
* SPRG_PACA = paca virtual address
|
2005-09-26 14:04:21 +08:00
|
|
|
*/
|
2009-07-24 07:15:59 +08:00
|
|
|
.section ".text";
|
|
|
|
.align 2 ;
|
|
|
|
|
2007-08-22 11:44:58 +08:00
|
|
|
.globl __secondary_start
|
2006-11-27 11:59:50 +08:00
|
|
|
__secondary_start:
|
2005-11-10 10:37:51 +08:00
|
|
|
/* Set thread priority to MEDIUM */
|
|
|
|
HMT_MEDIUM
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2012-02-28 10:44:58 +08:00
|
|
|
/* Initialize the kernel stack */
|
2006-01-13 11:56:25 +08:00
|
|
|
LOAD_REG_ADDR(r3, current_set)
|
2005-09-26 14:04:21 +08:00
|
|
|
sldi r28,r24,3 /* get current_set[cpu#] */
|
2010-08-26 05:04:25 +08:00
|
|
|
ldx r14,r3,r28
|
|
|
|
addi r14,r14,THREAD_SIZE-STACK_FRAME_OVERHEAD
|
|
|
|
std r14,PACAKSAVE(r13)
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2010-08-13 04:58:28 +08:00
|
|
|
/* Do early setup for that CPU (stab, slb, hash table pointer) */
|
|
|
|
bl .early_setup_secondary
|
|
|
|
|
2010-08-26 05:04:25 +08:00
|
|
|
/*
|
|
|
|
* setup the new stack pointer, but *don't* use this until
|
|
|
|
* translation is on.
|
|
|
|
*/
|
|
|
|
mr r1, r14
|
|
|
|
|
2005-11-10 10:37:51 +08:00
|
|
|
/* Clear backchain so we get nice backtraces */
|
2005-09-26 14:04:21 +08:00
|
|
|
li r7,0
|
|
|
|
mtlr r7
|
|
|
|
|
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 15:27:59 +08:00
|
|
|
/* Mark interrupts soft and hard disabled (they might be enabled
|
|
|
|
* in the PACA when doing hotplug)
|
|
|
|
*/
|
2012-02-28 10:44:58 +08:00
|
|
|
stb r7,PACASOFTIRQEN(r13)
|
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 15:27:59 +08:00
|
|
|
li r0,PACA_IRQ_HARD_DIS
|
|
|
|
stb r0,PACAIRQHAPPENED(r13)
|
2012-02-28 10:44:58 +08:00
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
/* enable MMU and jump to start_secondary */
|
2006-01-13 11:56:25 +08:00
|
|
|
LOAD_REG_ADDR(r3, .start_secondary_prolog)
|
|
|
|
LOAD_REG_IMMEDIATE(r4, MSR_KERNEL)
|
[POWERPC] Lazy interrupt disabling for 64-bit machines
This implements a lazy strategy for disabling interrupts. This means
that local_irq_disable() et al. just clear the 'interrupts are
enabled' flag in the paca. If an interrupt comes along, the interrupt
entry code notices that interrupts are supposed to be disabled, and
clears the EE bit in SRR1, clears the 'interrupts are hard-enabled'
flag in the paca, and returns. This means that interrupts only
actually get disabled in the processor when an interrupt comes along.
When interrupts are enabled by local_irq_enable() et al., the code
sets the interrupts-enabled flag in the paca, and then checks whether
interrupts got hard-disabled. If so, it also sets the EE bit in the
MSR to hard-enable the interrupts.
This has the potential to improve performance, and also makes it
easier to make a kernel that can boot on iSeries and on other 64-bit
machines, since this lazy-disable strategy is very similar to the
soft-disable strategy that iSeries already uses.
This version renames paca->proc_enabled to paca->soft_enabled, and
changes a couple of soft-disables in the kexec code to hard-disables,
which should fix the crash that Michael Ellerman saw. This doesn't
yet use a reserved CR field for the soft_enabled and hard_enabled
flags. This applies on top of Stephen Rothwell's patches to make it
possible to build a combined iSeries/other kernel.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-10-04 14:47:49 +08:00
|
|
|
|
2005-10-10 12:01:07 +08:00
|
|
|
mtspr SPRN_SRR0,r3
|
|
|
|
mtspr SPRN_SRR1,r4
|
2009-07-24 07:15:59 +08:00
|
|
|
RFI
|
2005-09-26 14:04:21 +08:00
|
|
|
b . /* prevent speculative execution */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Running with relocation on at this point. All we want to do is
|
2008-08-30 09:41:12 +08:00
|
|
|
* zero the stack back-chain pointer and get the TOC virtual address
|
|
|
|
* before going into C code.
|
2005-09-26 14:04:21 +08:00
|
|
|
*/
|
|
|
|
_GLOBAL(start_secondary_prolog)
|
2008-08-30 09:41:12 +08:00
|
|
|
ld r2,PACATOC(r13)
|
2005-09-26 14:04:21 +08:00
|
|
|
li r3,0
|
|
|
|
std r3,0(r1) /* Zero the stack frame pointer */
|
|
|
|
bl .start_secondary
|
2005-11-10 10:37:51 +08:00
|
|
|
b .
|
2010-03-01 10:58:09 +08:00
|
|
|
/*
|
|
|
|
* Reset stack pointer and call start_secondary
|
|
|
|
* to continue with online operation when woken up
|
|
|
|
* from cede in cpu offline.
|
|
|
|
*/
|
|
|
|
_GLOBAL(start_secondary_resume)
|
|
|
|
ld r1,PACAKSAVE(r13) /* Reload kernel stack pointer */
|
|
|
|
li r3,0
|
|
|
|
std r3,0(r1) /* Zero the stack frame pointer */
|
|
|
|
bl .start_secondary
|
|
|
|
b .
|
2005-09-26 14:04:21 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This subroutine clobbers r11 and r12
|
|
|
|
*/
|
|
|
|
_GLOBAL(enable_64b_mode)
|
|
|
|
mfmsr r11 /* grab the current MSR */
|
2009-07-24 07:15:59 +08:00
|
|
|
#ifdef CONFIG_PPC_BOOK3E
|
|
|
|
oris r11,r11,0x8000 /* CM bit set, we'll set ICM later */
|
|
|
|
mtmsr r11
|
|
|
|
#else /* CONFIG_PPC_BOOK3E */
|
2011-04-08 05:56:03 +08:00
|
|
|
li r12,(MSR_64BIT | MSR_ISF)@highest
|
2008-08-30 09:41:12 +08:00
|
|
|
sldi r12,r12,48
|
2005-09-26 14:04:21 +08:00
|
|
|
or r11,r11,r12
|
|
|
|
mtmsrd r11
|
|
|
|
isync
|
2009-07-24 07:15:59 +08:00
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
blr
|
|
|
|
|
2008-08-30 09:41:12 +08:00
|
|
|
/*
|
|
|
|
* This puts the TOC pointer into r2, offset by 0x8000 (as expected
|
|
|
|
* by the toolchain). It computes the correct value for wherever we
|
|
|
|
* are running at the moment, using position-independent code.
|
|
|
|
*/
|
|
|
|
_GLOBAL(relative_toc)
|
|
|
|
mflr r0
|
|
|
|
bcl 20,31,$+4
|
2011-09-20 01:44:51 +08:00
|
|
|
0: mflr r11
|
|
|
|
ld r2,(p_toc - 0b)(r11)
|
|
|
|
add r2,r2,r11
|
2008-08-30 09:41:12 +08:00
|
|
|
mtlr r0
|
|
|
|
blr
|
|
|
|
|
|
|
|
p_toc: .llong __toc_start + 0x8000 - 0b
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
/*
|
|
|
|
* This is where the main kernel code starts.
|
|
|
|
*/
|
2007-07-31 14:44:13 +08:00
|
|
|
_INIT_STATIC(start_here_multiplatform)
|
2008-08-30 09:41:12 +08:00
|
|
|
/* set up the TOC (real address) */
|
|
|
|
bl .relative_toc
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
/* Clear out the BSS. It may have been done in prom_init,
|
|
|
|
* already but that's irrelevant since prom_init will soon
|
|
|
|
* be detached from the kernel completely. Besides, we need
|
|
|
|
* to clear it now for kexec-style entry.
|
|
|
|
*/
|
2008-08-30 09:41:12 +08:00
|
|
|
LOAD_REG_ADDR(r11,__bss_stop)
|
|
|
|
LOAD_REG_ADDR(r8,__bss_start)
|
2005-09-26 14:04:21 +08:00
|
|
|
sub r11,r11,r8 /* bss size */
|
|
|
|
addi r11,r11,7 /* round up to an even double word */
|
2008-08-30 09:41:12 +08:00
|
|
|
srdi. r11,r11,3 /* shift right by 3 */
|
2005-09-26 14:04:21 +08:00
|
|
|
beq 4f
|
|
|
|
addi r8,r8,-8
|
|
|
|
li r0,0
|
|
|
|
mtctr r11 /* zero this many doublewords */
|
|
|
|
3: stdu r0,8(r8)
|
|
|
|
bdnz 3b
|
|
|
|
4:
|
|
|
|
|
2011-09-20 01:44:59 +08:00
|
|
|
#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL
|
|
|
|
/* Setup OPAL entry */
|
|
|
|
std r28,0(r11);
|
|
|
|
std r29,8(r11);
|
|
|
|
#endif
|
|
|
|
|
2009-07-24 07:15:59 +08:00
|
|
|
#ifndef CONFIG_PPC_BOOK3E
|
2005-09-26 14:04:21 +08:00
|
|
|
mfmsr r6
|
|
|
|
ori r6,r6,MSR_RI
|
|
|
|
mtmsrd r6 /* RI on */
|
2009-07-24 07:15:59 +08:00
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
|
powerpc: Make the 64-bit kernel as a position-independent executable
This implements CONFIG_RELOCATABLE for 64-bit by making the kernel as
a position-independent executable (PIE) when it is set. This involves
processing the dynamic relocations in the image in the early stages of
booting, even if the kernel is being run at the address it is linked at,
since the linker does not necessarily fill in words in the image for
which there are dynamic relocations. (In fact the linker does fill in
such words for 64-bit executables, though not for 32-bit executables,
so in principle we could avoid calling relocate() entirely when we're
running a 64-bit kernel at the linked address.)
The dynamic relocations are processed by a new function relocate(addr),
where the addr parameter is the virtual address where the image will be
run. In fact we call it twice; once before calling prom_init, and again
when starting the main kernel. This means that reloc_offset() returns
0 in prom_init (since it has been relocated to the address it is running
at), which necessitated a few adjustments.
This also changes __va and __pa to use an equivalent definition that is
simpler. With the relocatable kernel, PAGE_OFFSET and MEMORY_START are
constants (for 64-bit) whereas PHYSICAL_START is a variable (and
KERNELBASE ideally should be too, but isn't yet).
With this, relocatable kernels still copy themselves down to physical
address 0 and run there.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-08-30 09:43:47 +08:00
|
|
|
#ifdef CONFIG_RELOCATABLE
|
|
|
|
/* Save the physical address we're running at in kernstart_addr */
|
|
|
|
LOAD_REG_ADDR(r4, kernstart_addr)
|
|
|
|
clrldi r0,r25,2
|
|
|
|
std r0,0(r4)
|
|
|
|
#endif
|
|
|
|
|
2008-08-30 09:41:12 +08:00
|
|
|
/* The following gets the stack set up with the regs */
|
2005-09-26 14:04:21 +08:00
|
|
|
/* pointing to the real addr of the kernel stack. This is */
|
|
|
|
/* all done to support the C function call below which sets */
|
|
|
|
/* up the htab. This is done because we have relocated the */
|
|
|
|
/* kernel but are still running in real mode. */
|
|
|
|
|
2008-08-30 09:41:12 +08:00
|
|
|
LOAD_REG_ADDR(r3,init_thread_union)
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2008-08-30 09:41:12 +08:00
|
|
|
/* set up a stack pointer */
|
2005-09-26 14:04:21 +08:00
|
|
|
addi r1,r3,THREAD_SIZE
|
|
|
|
li r0,0
|
|
|
|
stdu r0,-STACK_FRAME_OVERHEAD(r1)
|
|
|
|
|
|
|
|
/* Do very early kernel initializations, including initial hash table,
|
|
|
|
* stab and slb setup before we turn on relocation. */
|
|
|
|
|
|
|
|
/* Restore parameters passed from prom_init/kexec */
|
|
|
|
mr r3,r31
|
2009-07-15 04:52:54 +08:00
|
|
|
bl .early_setup /* also sets r13 and SPRG_PACA */
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2008-08-30 09:41:12 +08:00
|
|
|
LOAD_REG_ADDR(r3, .start_here_common)
|
|
|
|
ld r4,PACAKMSR(r13)
|
2005-10-10 12:01:07 +08:00
|
|
|
mtspr SPRN_SRR0,r3
|
|
|
|
mtspr SPRN_SRR1,r4
|
2009-07-24 07:15:59 +08:00
|
|
|
RFI
|
2005-09-26 14:04:21 +08:00
|
|
|
b . /* prevent speculative execution */
|
|
|
|
|
|
|
|
/* This is where all platforms converge execution */
|
2007-08-22 11:44:58 +08:00
|
|
|
_INIT_GLOBAL(start_here_common)
|
2005-09-26 14:04:21 +08:00
|
|
|
/* relocation is on at this point */
|
2008-08-30 09:41:12 +08:00
|
|
|
std r1,PACAKSAVE(r13)
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2008-08-30 09:41:12 +08:00
|
|
|
/* Load the TOC (virtual address) */
|
2005-09-26 14:04:21 +08:00
|
|
|
ld r2,PACATOC(r13)
|
|
|
|
|
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 15:27:59 +08:00
|
|
|
/* Do more system initializations in virtual mode */
|
2005-09-26 14:04:21 +08:00
|
|
|
bl .setup_system
|
|
|
|
|
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 15:27:59 +08:00
|
|
|
/* Mark interrupts soft and hard disabled (they might be enabled
|
|
|
|
* in the PACA when doing hotplug)
|
|
|
|
*/
|
|
|
|
li r0,0
|
|
|
|
stb r0,PACASOFTIRQEN(r13)
|
|
|
|
li r0,PACA_IRQ_HARD_DIS
|
|
|
|
stb r0,PACAIRQHAPPENED(r13)
|
2005-09-26 14:04:21 +08:00
|
|
|
|
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 15:27:59 +08:00
|
|
|
/* Generic kernel entry */
|
2008-04-02 12:58:40 +08:00
|
|
|
bl .start_kernel
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2006-02-13 15:11:13 +08:00
|
|
|
/* Not reached */
|
|
|
|
BUG_OPCODE
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We put a few things here that have to be page-aligned.
|
|
|
|
* This stuff goes at the beginning of the bss, which is page-aligned.
|
|
|
|
*/
|
|
|
|
.section ".bss"
|
|
|
|
|
|
|
|
.align PAGE_SHIFT
|
|
|
|
|
|
|
|
.globl empty_zero_page
|
|
|
|
empty_zero_page:
|
|
|
|
.space PAGE_SIZE
|
|
|
|
|
|
|
|
.globl swapper_pg_dir
|
|
|
|
swapper_pg_dir:
|
2007-09-18 15:22:59 +08:00
|
|
|
.space PGD_TABLE_SIZE
|