1. 23 1月, 2018 1 次提交
    • J
      MIPS: Add helpers for assembler macro instructions · fc62f53b
      James Hogan 提交于
      Implement a parse_r assembler macro in asm/mipsregs.h to parse a
      register in $n form, and a few C macros for defining assembler macro
      instructions. These can be used to more transparently support older
      binutils versions which don't support for example the msa, virt, xpa, or
      crc instructions.
      
      In particular they overcome the difficulty of turning a register name in
      $n form into an instruction encoding suitable for giving to .word /
      .hword, which is particularly problematic when needed from inline
      assembly where the compiler is responsible for register allocation.
      Traditionally this had required the use of $at and an extra MOV
      instruction, but for CRC instructions with multiple GP register operands
      that approach becomes more difficult.
      
      Three assembler macro creation helpers are added:
      
       - _ASM_MACRO_0(OP, ENC)
         This is to define an assembler macro for an instruction which has no
         operands, for example the VZ TLBGR instruction.
      
       - _ASM_MACRO_2R(OP, R1, R2, ENC)
         This is to define an assembler macro for an instruction which has 2
         register operands, for example the CFCMSA instruction.
      
       - _ASM_MACRO_3R(OP, R1, R2, R3, ENC)
         This is to define an assembler macro for an instruction which has 3
         register operands, for example the crc32 instructions.
      
       - _ASM_MACRO_2R_1S(OP, R1, R2, SEL3, ENC)
         This is to define an assembler macro for a Cop0 move instruction,
         with 2 register operands and an optional register select operand
         which defaults to 0, for example the VZ MFGC0 instruction.
      Suggested-by: NRalf Baechle <ralf@linux-mips.org>
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Marcin Nowakowski <marcin.nowakowski@mips.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17770/
      fc62f53b
  2. 10 1月, 2018 2 次提交
    • J
      MIPS: mipsregs.h: Make read_c0_prid use const accessor · 6538953f
      James Hogan 提交于
      Make read_c0_prid() use the new constant accessor macros so that it can
      potentially be optimised or removed by the compiler. This is
      particularly important under virtualisation, where even with hardware
      assisted virtualisation (VZ), access to the PRid register may need to be
      emulated by the hypervisor.
      
      In particular this helps eliminate the read of the PRid register in the
      rather frequently called add_interrupt_randomness() (which calls into
      arch/mips/include/asm/timex.h) when the prid is unused but the read
      can't be removed due to the inline asm being marked __volatile__.
      Reported-by: NYann LeDu <Yann.LeDu@imgtec.com>
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Maciej W. Rozycki <macro@mips.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17923/
      6538953f
    • J
      MIPS: mipsregs.h: Add read const Cop0 macros · cd1e0737
      James Hogan 提交于
      Some Cop0 registers are constant and have no side effects when read.
      There is no need for the inline asm to read these to be marked
      __volatile__, and doing so prevents them from being removed by the
      compiler.
      
      Add a few new accessor macros to handle these registers more efficiently
      (especially for the sake of running in a guest where redundant access to
      the register may trap to the hypervisor):
        __read_const_32bit_c0_register()
        __read_const_64bit_c0_register()
        __read_const_ulong_c0_register()
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Maciej W. Rozycki <macro@mips.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17922/
      cd1e0737
  3. 09 11月, 2017 1 次提交
  4. 21 9月, 2017 1 次提交
    • J
      MIPS: Fix input modify in __write_64bit_c0_split() · c22c8043
      James Hogan 提交于
      The inline asm in __write_64bit_c0_split() modifies the 64-bit input
      operand by shifting the high register left by 32, and constructing the
      full 64-bit value in the low register (even on a 32-bit kernel), so if
      that value is used again it could cause breakage as GCC would assume the
      registers haven't changed when they have.
      
      To quote the GCC extended asm documentation:
      > Warning: Do not modify the contents of input-only operands (except for
      > inputs tied to outputs). The compiler assumes that on exit from the
      > asm statement these operands contain the same values as they had
      > before executing the statement.
      
      Avoid modifying the input by using a temporary variable as an output
      which is modified instead of the input and not otherwise used. The asm
      is always __volatile__ so GCC shouldn't optimise it out. The low
      register of the temporary output is written before the high register of
      the input is read, so we have two constraint alternatives, one where
      both use the same registers (for when the input value isn't subsequently
      used), and one with an early clobber on the output in case the low
      output uses the same register as the high input. This allows the
      resulting assembly to remain mostly unchanged.
      
      A diff of a MIPS32r6 kernel reveals only three differences, two in
      relation to write_c0_r10k_diag() in cpu_probe() (register allocation
      rearranged slightly but otherwise identical), and one in relation to
      write_c0_cvmmemctl2() in kvm_vz_local_flush_guesttlb_all(), but the
      octeon CPU is only supported on 64-bit kernels where
      __write_64bit_c0_split() isn't used so that shouldn't matter in
      practice. So there currently doesn't appear to be anything broken by
      this bug.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17315/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      c22c8043
  5. 30 8月, 2017 1 次提交
  6. 05 7月, 2017 1 次提交
  7. 28 3月, 2017 4 次提交
    • J
      KVM: MIPS/VZ: Handle Octeon III guest.PRid register · 1f48f9be
      James Hogan 提交于
      Octeon III implements a read-only guest CP0_PRid register, so add cases
      to the KVM register access API for Octeon to ensure the correct value is
      read and writes are ignored.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim Krčmář" <rkrcmar@redhat.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      1f48f9be
    • J
      MIPS: Add Octeon III register accessors & definitions · 7d8a528d
      James Hogan 提交于
      Add accessors for some VZ related Cavium Octeon III specific COP0
      registers, along with field definitions. These will mostly be used by
      KVM to set up interrupt routing and partition the TLB between root and
      guest.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Acked-by: NRalf Baechle <ralf@linux-mips.org>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim Krčmář" <rkrcmar@redhat.com>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      7d8a528d
    • J
      MIPS: Add some missing guest CP0 accessors & defs · eb0bab38
      James Hogan 提交于
      Add some missing guest accessors and register field definitions for KVM
      for MIPS VZ to make use of.
      
      Guest CP0_LLAddr register accessors and definitions for the LLB field
      allow KVM to clear the guest LLB to cancel in-progress LL/SC atomics on
      restore, and to emulate accesses by the guest to the CP0_LLAddr
      register.
      
      Bitwise modifiers and definitions for the guest CP0_Wired and
      CP0_Config1 registers allow KVM to modify fields within the CP0_Wired
      and CP0_Config1 registers.
      
      Finally a definition for the CP0_Config5.SBRI bit allows KVM to
      initialise and allow modification of the guest version of the SBRI bit.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Acked-by: NRalf Baechle <ralf@linux-mips.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim Krčmář" <rkrcmar@redhat.com>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      eb0bab38
    • J
      MIPS: Separate MAAR V bit into VL and VH for XPA · f359a111
      James Hogan 提交于
      The MAAR V bit has been renamed VL since another bit called VH is added
      at the top of the register when it is extended to 64-bits on a 32-bit
      processor with XPA. Rename the V definition, fix the various users, and
      add definitions for the VH bit. Also add a definition for the MAARI
      Index field.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Acked-by: NRalf Baechle <ralf@linux-mips.org>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim Krčmář" <rkrcmar@redhat.com>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      f359a111
  8. 14 2月, 2017 1 次提交
    • J
      MIPS: Unify perf counter register definitions · 2654294b
      James Hogan 提交于
      Unify definitions for MIPS performance counter register fields in
      mipsregs.h rather than duplicating them in perf_events and oprofile.
      This will allow future patches to use them to expose performance
      counters to KVM guests.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Robert Richter <rric@kernel.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: oprofile-list@lists.sf.net
      Patchwork: https://patchwork.linux-mips.org/patch/15212/Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      2654294b
  9. 24 11月, 2016 1 次提交
    • P
      MIPS: Mask out limit field when calculating wired entry count · 10313980
      Paul Burton 提交于
      Since MIPSr6 the Wired register is split into 2 fields, with the upper
      16 bits of the register indicating a limit on the value that the wired
      entry count in the bottom 16 bits of the register can take. This means
      that simply reading the wired register doesn't get us a valid TLB entry
      index any longer, and we instead need to retrieve only the lower 16 bits
      of the register. Introduce a new num_wired_entries() function which does
      this on MIPSr6 or higher and simply returns the value of the wired
      register on older architecture revisions, and make use of it when
      reading the number of wired entries.
      
      Since commit e710d666 ("MIPS: tlb-r4k: If there are wired entries,
      don't use TLBINVF") we have been using a non-zero number of wired
      entries to determine whether we should avoid use of the tlbinvf
      instruction (which would invalidate wired entries) and instead loop over
      TLB entries in local_flush_tlb_all(). This loop begins with the number
      of wired entries, or before this patch some large bogus TLB index on
      MIPSr6 systems. Thus since the aforementioned commit some MIPSr6 systems
      with FTLBs have been prone to leaving stale address translations in the
      FTLB & crashing in various weird & wonderful ways when we later observe
      the wrong memory.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: Matt Redfearn <matt.redfearn@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14557/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      10313980
  10. 30 9月, 2016 1 次提交
    • P
      MIPS: Stop setting I6400 FTLBP · 72c70f01
      Paul Burton 提交于
      The FTLBP field in Config7 for the I6400 is intended as chicken bits for
      debugging rather than as a field that software actually makes use of.
      For best performance, FTLBP should be left at its default value of 0
      with all TLB writes hitting the FTLB by default.
      
      Additionally, since set_ftlb_enable is called from decode_configs before
      decode_config4 which determines the size of the TLBs, this was
      previously always setting FTLBP=3 for a 3:1 FTLB:VTLB write ratio which
      makes abysmal use of the available FTLB resources.
      
      This effectively reverts b0c4e1b79d8a ("MIPS: Set up FTLB probability
      for I6400").
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: b0c4e1b79d8a ("MIPS: Set up FTLB probability for I6400")
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14021/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      72c70f01
  11. 16 6月, 2016 2 次提交
  12. 28 5月, 2016 7 次提交
  13. 17 5月, 2016 1 次提交
    • J
      MIPS: Fix VZ probe gas errors with binutils <2.24 · bad50d79
      James Hogan 提交于
      The VZ guest register & TLB access macros introduced in commit "MIPS:
      Add guest CP0 accessors" use VZ ASE specific instructions that aren't
      understood by versions of binutils prior to 2.24.
      
      Add a check for whether the toolchain supports the -mvirt option,
      similar to the MSA toolchain check, and implement the accessors using
      .word if not.
      
      Due to difficulty in converting compiler specified registers (e.g. "$3")
      to usable numbers (e.g. "3") in inline asm, we need to copy to/from a
      temporary register, namely the assembler temporary (at/$1), and specify
      guest CP0 registers numerically in the gc0 macros.
      
      Fixes: 7eb91118 ("MIPS: Add guest CP0 accessors")
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Reported-by: NGuenter Roeck <linux@roeck-us.net>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-next@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/13255/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      bad50d79
  14. 13 5月, 2016 14 次提交
  15. 24 1月, 2016 2 次提交