1. 31 10月, 2008 1 次提交
    • M
      powerpc/ppc64/kdump: Better flag for running relocatable · 8b8b0cc1
      Milton Miller 提交于
      The __kdump_flag ABI is overly constraining for future development.
      
      As of 2.6.27, the kernel entry point has 4 constraints:  Offset 0 is
      the starting point for the master (boot) cpu (entered with r3 pointing
      to the device tree structure), offset 0x60 is code for the slave cpus
      (entered with r3 set to their device tree physical id), offset 0x20 is
      used by the iseries hypervisor, and secondary cpus must be well behaved
      when the first 256 bytes are copied to address 0.
      
      Placing the __kdump_flag at 0x18 is bad because:
      
      - It was taking the last 8 bytes before the iseries hypervisor data.
      - It was 8 bytes for a boolean flag
      - It had no way of identifying that the flag was present
      - It does leave any room for the master to add any additional code
        before branching, which hurts debug.
      - It will be unnecessarily hard for 32 bit code to be common (8 bytes)
      
      Now that we have eliminated the use of __kdump_flag in favor of
      the standard is_kdump_kernel(), this flag only controls run without
      relocating the kernel to PHYSICAL_START (0), so rename it __run_at_load.
      
      Move the flag to 0x5c, 1 word before the secondary cpu entry point at
      0x60.  Initialize it with "run0" to say it will run at 0 unless it is
      set to 1.  It only exists if we are relocatable.
      Signed-off-by: NMilton Miller <miltonm@bga.com>
      Signed-off-by: NMichael Neuling <mikey@neuling.org>
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      8b8b0cc1
  2. 22 10月, 2008 1 次提交
    • M
      powerpc: Support for relocatable kdump kernel · 54622f10
      Mohan Kumar M 提交于
      This adds relocatable kernel support for kdump. With this one can
      use the same regular kernel to capture the kdump. A signature (0xfeed1234)
      is passed in r6 from panic code to the next kernel through kexec_sequence
      and purgatory code. The signature is used to differentiate between
      kdump kernel and non-kdump kernels.
      
      The purgatory code compares the signature and sets the __kdump_flag in
      head_64.S.  During the boot up, kernel code checks __kdump_flag and if it
      is set, the kernel will behave as relocatable kdump kernel. This kernel
      will boot at the address where it was loaded by kexec-tools ie. at the
      address reserved through crashkernel boot parameter.
      
      CONFIG_CRASH_DUMP depends on CONFIG_RELOCATABLE option to build kdump
      kernel as relocatable. So the same kernel can be used as production and
      kdump kernel.
      
      This patch incorporates the changes suggested by Paul Mackerras to avoid
      GOT use and to avoid two copies of the code.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      Signed-off-by: NMohan Kumar M <mohan@in.ibm.com>
      Signed-off-by: NMichael Ellerman <michael@ellerman.id.au>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      54622f10
  3. 16 9月, 2008 4 次提交
    • P
      powerpc: Make the 64-bit kernel as a position-independent executable · 549e8152
      Paul Mackerras 提交于
      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: NPaul Mackerras <paulus@samba.org>
      549e8152
    • P
      powerpc: Use LOAD_REG_IMMEDIATE only for constants on 64-bit · e31aa453
      Paul Mackerras 提交于
      Using LOAD_REG_IMMEDIATE to get the address of kernel symbols
      generates 5 instructions where LOAD_REG_ADDR can do it in one,
      and will generate R_PPC64_ADDR16_* relocations in the output when
      we get to making the kernel as a position-independent executable,
      which we'd rather not have to handle.  This changes various bits
      of assembly code to use LOAD_REG_ADDR when we need to get the
      address of a symbol, or to use suitable position-independent code
      for cases where we can't access the TOC for various reasons, or
      if we're not running at the address we were linked at.
      
      It also cleans up a few minor things; there's no reason to save and
      restore SRR0/1 around RTAS calls, __mmu_off can get the return
      address from LR more conveniently than the caller can supply it in
      R4 (and we already assume elsewhere that EA == RA if the MMU is on
      in early boot), and enable_64b_mode was using 5 instructions where
      2 would do.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      e31aa453
    • P
      powerpc: Make it possible to move the interrupt handlers away from the kernel · 1f6a93e4
      Paul Mackerras 提交于
      This changes the way that the exception prologs transfer control to
      the handlers in 64-bit kernels with the aim of making it possible to
      have the prologs separate from the main body of the kernel.  Now,
      instead of computing the address of the handler by taking the top
      32 bits of the paca address (to get the 0xc0000000........ part) and
      ORing in something in the bottom 16 bits, we get the base address of
      the kernel by doing a load from the paca and add an offset.
      
      This also replaces an mfmsr and an ori to compute the MSR value for
      the handler with a load from the paca.  That makes it unnecessary to
      have a separate version of EXCEPTION_PROLOG_PSERIES that forces 64-bit
      mode.
      
      We can no longer use a direct branches in the exception prolog code,
      which means that the SLB miss handlers can't branch directly to
      .slb_miss_realmode any more.  Instead we have to compute the address
      and do an indirect branch.  This is conditional on CONFIG_RELOCATABLE;
      for non-relocatable kernels we use a direct branch as before.  (A later
      change will allow CONFIG_RELOCATABLE to be set on 64-bit powerpc.)
      
      Since the secondary CPUs on pSeries start execution in the first 0x100
      bytes of real memory and then have to get to wherever the kernel is,
      we can't use a direct branch to get there.  Instead this changes
      __secondary_hold_spinloop from a flag to a function pointer.  When it
      is set to a non-NULL value, the secondary CPUs jump to the function
      pointed to by that value.
      
      Finally this eliminates one code difference between 32-bit and 64-bit
      by making __secondary_hold be the text address of the secondary CPU
      spinloop rather than a function descriptor for it.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      1f6a93e4
    • P
      powerpc: Rearrange head_64.S to move interrupt handler code to the beginning · 9a955167
      Paul Mackerras 提交于
      This rearranges head_64.S so that we have all the first-level exception
      prologs together starting at 0x100, followed by all the second-level
      handlers that are invoked from the first-level prologs, followed by
      other code.  This doesn't make any functional change but will make
      following changes for relocatable kernel support easier.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      9a955167
  4. 15 7月, 2008 1 次提交
  5. 01 7月, 2008 3 次提交
  6. 09 5月, 2008 1 次提交
  7. 29 4月, 2008 1 次提交
    • P
      [POWERPC] Add fast little-endian switch system call · 745a14cc
      Paul Mackerras 提交于
      This adds a system call on 64-bit platforms for switching between
      little-endian and big-endian modes that is much faster than doing a
      prctl call.  This system call is handled as a special case right at
      the start of the system call entry code, and because it is a special
      case, it uses a system call number which is out of the range of
      normal system calls, namely 0x1ebe.
      
      Measurements with lmbench on a 4.2GHz POWER6 showed no measurable
      change in the speed of normal system calls with this patch.
      
      Switching endianness with this new system call takes around 60ns on a
      4.2GHz POWER6, compared with around 300ns to switch endian mode with a
      prctl.  This can provide a significant performance advantage for
      emulators for little-endian architectures that want to switch between
      big-endian and little-endian mode frequently, e.g. because they are
      generating instructions sequences on the fly and they want to run
      those sequences in little-endian mode.
      
      The other thing about this system call is that it doesn't clobber as
      many registers as a normal system call.  It only clobbers r12.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      745a14cc
  8. 18 4月, 2008 1 次提交
  9. 17 4月, 2008 1 次提交
  10. 14 4月, 2008 1 次提交
    • P
      [POWERPC] Fix handling of unrecoverable SLB miss interrupts · 320787c7
      Paul Mackerras 提交于
      If an SLB miss interrupt happens while the RI bit of MSR is zero, we
      can't just return, because RI being zero indicates that SRR0/SRR1
      potentially had live values in them, and the process of taking an
      interrupt overwrites them.
      
      This should never happen, but if it does, we try to print a nice oops
      message.  That doesn't work, however, because the code at unrecov_slb
      assumes that the MMU has been turned on, but we call it with the MMU
      off (and have done so since the SLB miss handler was rewritten to run
      without turning the MMU on) -- except on iSeries, where everything runs
      with the MMU on.
      
      This fixes it by adding the necessary code to turn the MMU on if
      necessary.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      320787c7
  11. 03 4月, 2008 1 次提交
    • B
      [POWERPC] Fix iSeries hard irq enabling regression · ff3da2e0
      Benjamin Herrenschmidt 提交于
      A subtle bug sneaked into iSeries recently.  On this platform, we must
      not normally clear MSR:EE (the hardware external interrupt enable)
      except for short periods of time.  Taking an interrupt while
      soft-disabled doesn't cause us to clear it for example.
      
      The iSeries kernel expects to mostly run with MSR:EE enabled at all
      times except in a few exception entry/exit code paths.  Thus
      local_irq_enable() doesn't check if it needs to hard-enable as it
      expects this to be unnecessary on iSeries.
      
      However, hard_irq_disable() _does_ cause MSR:EE to be cleared,
      including on iSeries.  A call to it was recently added to the
      context switch code, thus causing interrupts to become disabled
      for a long periods of time, causing the iSeries watchdog to kick
      in under some circumstances and other nasty things.
      
      This patch fixes it by making local_irq_enable() properly re-enable
      MSR:EE on iSeries.  It basically removes a return statement here
      to make iSeries use the same code path as everybody else.  That does
      mean that we might occasionally get spurious decrementer interrupts
      but I don't think that matters.
      
      Another option would have been to make hard_irq_disable() a nop
      on iSeries but I didn't like it much, in case we have good reasons
      to hard-disable.
      
      Part of the patch is fixes to make sure the hard_enabled PACA field
      is properly set on iSeries as it used not to be before, since it
      was mostly unused.
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      ff3da2e0
  12. 24 1月, 2008 1 次提交
    • P
      [POWERPC] Provide a way to protect 4k subpages when using 64k pages · fa28237c
      Paul Mackerras 提交于
      Using 64k pages on 64-bit PowerPC systems makes life difficult for
      emulators that are trying to emulate an ISA, such as x86, which use a
      smaller page size, since the emulator can no longer use the MMU and
      the normal system calls for controlling page protections.  Of course,
      the emulator can emulate the MMU by checking and possibly remapping
      the address for each memory access in software, but that is pretty
      slow.
      
      This provides a facility for such programs to control the access
      permissions on individual 4k sub-pages of 64k pages.  The idea is
      that the emulator supplies an array of protection masks to apply to a
      specified range of virtual addresses.  These masks are applied at the
      level where hardware PTEs are inserted into the hardware page table
      based on the Linux PTEs, so the Linux PTEs are not affected.  Note
      that this new mechanism does not allow any access that would otherwise
      be prohibited; it can only prohibit accesses that would otherwise be
      allowed.  This new facility is only available on 64-bit PowerPC and
      only when the kernel is configured for 64k pages.
      
      The masks are supplied using a new subpage_prot system call, which
      takes a starting virtual address and length, and a pointer to an array
      of protection masks in memory.  The array has a 32-bit word per 64k
      page to be protected; each 32-bit word consists of 16 2-bit fields,
      for which 0 allows any access (that is otherwise allowed), 1 prevents
      write accesses, and 2 or 3 prevent any access.
      
      Implicit in this is that the regions of the address space that are
      protected are switched to use 4k hardware pages rather than 64k
      hardware pages (on machines with hardware 64k page support).  In fact
      the whole process is switched to use 4k hardware pages when the
      subpage_prot system call is used, but this could be improved in future
      to switch only the affected segments.
      
      The subpage protection bits are stored in a 3 level tree akin to the
      page table tree.  The top level of this tree is stored in a structure
      that is appended to the top level of the page table tree, i.e., the
      pgd array.  Since it will often only be 32-bit addresses (below 4GB)
      that are protected, the pointers to the first four bottom level pages
      are also stored in this structure (each bottom level page contains the
      protection bits for 1GB of address space), so the protection bits for
      addresses below 4GB can be accessed with one fewer loads than those
      for higher addresses.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      fa28237c
  13. 08 11月, 2007 1 次提交
  14. 12 10月, 2007 1 次提交
    • P
      [POWERPC] Use 1TB segments · 1189be65
      Paul Mackerras 提交于
      This makes the kernel use 1TB segments for all kernel mappings and for
      user addresses of 1TB and above, on machines which support them
      (currently POWER5+, POWER6 and PA6T).
      
      We detect that the machine supports 1TB segments by looking at the
      ibm,processor-segment-sizes property in the device tree.
      
      We don't currently use 1TB segments for user addresses < 1T, since
      that would effectively prevent 32-bit processes from using huge pages
      unless we also had a way to revert to using 256MB segments.  That
      would be possible but would involve extra complications (such as
      keeping track of which segment size was used when HPTEs were inserted)
      and is not addressed here.
      
      Parts of this patch were originally written by Ben Herrenschmidt.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      1189be65
  15. 19 9月, 2007 3 次提交
  16. 13 9月, 2007 1 次提交
  17. 22 8月, 2007 4 次提交
  18. 10 8月, 2007 1 次提交
  19. 26 7月, 2007 1 次提交
  20. 28 6月, 2007 1 次提交
  21. 24 4月, 2007 1 次提交
  22. 13 4月, 2007 1 次提交
  23. 09 3月, 2007 1 次提交
  24. 07 2月, 2007 1 次提交
    • L
      [POWERPC] Fix performance monitor exception · 449d846d
      Livio Soares 提交于
      To the issue: some point during 2.6.20 development, Paul Mackerras
      introduced the "lazy IRQ  disabling" patch (very cool work,  BTW).
      In that patch, the performance monitor unit exception was marked as
      "maskable", in the sense that if interrupts were soft-disabled, that
      exception could be ignored.  This broke my PowerPC profiling code.
      The symptom that I see is that a varying number of interrupts
      (from 0 to $n$, typically closer to 0) get delivered, when, in
      reality, it should always be very close to $n$.
      
      The issue stems from the way masking is being done.   Masking in
      this fashion seems to  work well with the decrementer and external
      interrupts, because they are raised again until "really"  handled.
      For the PMU, however, this does not apply (at least on my Xserver
      machine with a 970FX processor).  If the PMU exception is not handled,
      it will _not_ be re-raised (at least on my machine).  The documentation
      states that the PMXE bit in MMCR0 is set to 0 when the PMU exception
      is raised.  However, software must re-set the bit to re-enable PMU
      exceptions.  If the exception is ignored (as currently) not only is
      that interrupt lost, but because software does not re-set PMXE, the
      PMU registers are "frozen" forever.
      
      [This patch means that performance monitor exceptions are taken and
      handled even if irqs are off, as long as some other interrupt hasn't
      come along and caused interrupts to be hard-disabled.  In this sense
      the PMU exception becomes like an NMI.  The oprofile code for most
      powerpc processors does nothing that is unsafe in an NMI context, but
      the Cell oprofile code does a spin_lock_irqsave.  However, that turns
      out to be OK because Cell doesn't actually use the performance
      monitor exception; performance monitor interrupts come in as a
      regular interrupt on Cell, so will be disabled when irqs are off.
       -- paulus.]
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      449d846d
  25. 04 12月, 2006 1 次提交
  26. 13 11月, 2006 1 次提交
  27. 02 11月, 2006 1 次提交
  28. 26 10月, 2006 1 次提交
  29. 25 10月, 2006 1 次提交
  30. 18 10月, 2006 1 次提交
    • P
      [POWERPC] Make sure interrupt enable gets restored properly · b0a779de
      Paul Mackerras 提交于
      The lazy IRQ disable patch missed a couple of places where the
      interrupt enable flags need to be restored correctly.  First, we
      weren't restoring the paca->hard_enabled flag on interrupt exit.
      Instead of saving it on entry, we compute it from the MSR_EE bit
      in the MSR we are restoring at exit.  Secondly, the MMU hash miss
      code was clearing both paca->soft_enabled and paca->hard_enabled
      but not restoring them in the case where hash_page was able to
      resolve the miss from the Linux page tables.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      b0a779de