1. 13 5月, 2016 40 次提交
    • J
      MIPS: Add perf counter feature · 30228c40
      James Hogan 提交于
      Add CPU feature for standard MIPS r2 performance counters, as determined
      by the Config1.PC bit. Both perf_events and oprofile probe this bit, so
      lets combine the probing and change both to use cpu_has_perf.
      
      This will also be used for VZ support in KVM to know whether performance
      counters exist which can be exposed to guests.
      
      [ralf@linux-mips.org: resolve conflict.]
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      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: oprofile-list@lists.sf.net
      Patchwork: https://patchwork.linux-mips.org/patch/13226/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      30228c40
    • J
      MIPS: Add defs & probing of [X]ContextConfig · f18bdfa1
      James Hogan 提交于
      The CP0_[X]ContextConfig registers are present if CP0_Config3.CTXTC or
      CP0_Config3.SM are set, and provide more control over which bits of
      CP0_[X]Context are set to the faulting virtual address on a TLB
      exception.
      
      KVM/VZ will need to be able to save and restore these registers in the
      guest context, so add the relevant definitions and probing of the
      ContextConfig feature in the root context first.
      
      [ralf@linux-mips.org: resolve merge conflict.]
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/13225/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      f18bdfa1
    • J
      MIPS: Add defs & probing of BadInstr[P] registers · e06a1548
      James Hogan 提交于
      The optional CP0_BadInstr and CP0_BadInstrP registers are written with
      the encoding of the instruction that caused a synchronous exception to
      occur, and the prior branch instruction if in a delay slot.
      
      These will be useful for instruction emulation in KVM, and especially
      for VZ support where reading guest virtual memory is a bit more awkward.
      
      Add CPU option numbers and cpu_has_* definitions to indicate the
      presence of each registers, and add code to probe for them using bits in
      the CP0_Config3 register.
      
      [ralf@linux-mips.org: resolve merge conflict.]
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/13224/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      e06a1548
    • J
      MIPS: Add defs & probing of extended CP0_EBase · 37fb60f8
      James Hogan 提交于
      The CP0_EBase register may optionally have a write gate (WG) bit to
      allow the upper bits to be written, i.e. bits 31:30 on MIPS32 since r3
      (to allow for an exception base outside of KSeg0/KSeg1 when segmentation
      control is in use) and bits 63:30 on MIPS64 (which also implies the
      extension of CP0_EBase to 64 bits long).
      
      The presence of this feature will need to be known about for VZ support
      in order to correctly save and restore all the bits of the guest
      CP0_EBase register, so add CPU feature definition and probing for this
      feature.
      
      Probing the WG bit on MIPS64 can be a bit fiddly, since 64-bit COP0
      register access instructions were UNDEFINED for 32-bit registers prior
      to MIPS r6, and it'd be nice to be able to probe without clobbering the
      existing state, so there are 3 potential paths:
      
      - If we do a 32-bit read of CP0_EBase and the WG bit is already set, the
        register must be 64-bit.
      
      - On MIPS r6 we can do a 64-bit read-modify-write to set CP0_EBase.WG,
        since the upper bits will read 0 and be ignored on write if the
        register is 32-bit.
      
      - On pre-r6 cores, we do a 32-bit read-modify-write of CP0_EBase. This
        avoids the potentially UNDEFINED behaviour, but will clobber the upper
        32-bits of CP0_EBase if it isn't a simple sign extension (which also
        requires us to ensure BEV=1 or modifying the exception base would be
        UNDEFINED too). It is hopefully unlikely a bootloader would set up
        CP0_EBase to a 64-bit segment and leave WG=0.
      
      [ralf@linux-mips.org: Resolved merge conflict.]
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Tested-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/13223/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      37fb60f8
    • J
      MIPS: Define & use CP0_EBase bit definitions · 37af2f30
      James Hogan 提交于
      Add definitions for the bits & fields in the CP0_EBase register, and use
      them from a few different places in arch/mips which hardcoded these
      values.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Jayachandran C <jchandra@broadcom.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
      Patchwork: https://patchwork.linux-mips.org/patch/13222/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      37af2f30
    • F
      MIPS: Allow RIXI to be used on non-R2 or R6 cores · 8256b17e
      Florian Fainelli 提交于
      Some processors, like Broadcom's BMIPS4380 and BMIPS5000 support RIXI and the
      "rotr" instruction, which can be used to get a slightly more efficient page
      table layout.
      
      Introduce a CONFIG_CPU_HAS_RIXI such that those cores can benefit from this
      feature. Perform the conditional check updates where relevant.
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Cc: john@phrozen.org
      Cc: cernekee@gmail.com
      Cc: jon.fraser@broadcom.com
      Cc: pgynther@google.com
      Cc: paul.burton@imgtec.com
      Cc: ddaney.cavm@gmail.com
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12505/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      8256b17e
    • P
      MIPS: mm: Fix MIPS32 36b physical addressing (alchemy, netlogic) · 7b2cb64f
      Paul Burton 提交于
      There are 2 distinct cases in which a kernel for a MIPS32 CPU
      (CONFIG_CPU_MIPS32=y) may use 64 bit physical addresses
      (CONFIG_PHYS_ADDR_T_64BIT=y):
      
        - 36 bit physical addressing as used by RMI Alchemy & Netlogic XLP/XLR
          CPUs.
      
        - MIPS32r5 eXtended Physical Addressing (XPA).
      
      These 2 cases are distinct in that they require different behaviour from
      the kernel - the EntryLo registers have different formats. Until Linux
      v4.1 we only supported the first case, with code conditional upon the 2
      aforementioned Kconfig variables being set. Commit c5b36783 ("MIPS:
      Add support for XPA.") added support for the second case, but did so by
      modifying the code that existed for the first case rather than treating
      the 2 cases as distinct. Since the EntryLo registers have different
      formats this breaks the 36 bit Alchemy/XLP/XLR case. Fix this by
      splitting the 2 cases, with XPA cases now being conditional upon
      CONFIG_XPA and the non-XPA case matching the code as it existed prior to
      commit c5b36783 ("MIPS: Add support for XPA.").
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Reported-by: NManuel Lauss <manuel.lauss@gmail.com>
      Tested-by: NManuel Lauss <manuel.lauss@gmail.com>
      Fixes: c5b36783 ("MIPS: Add support for XPA.")
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: David Hildenbrand <dahi@linux.vnet.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Alex Smith <alex.smith@imgtec.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: stable@vger.kernel.org # v4.1+
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/13119/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      7b2cb64f
    • P
      MIPS: mm: Unify pte_page definition · 745f3558
      Paul Burton 提交于
      The same definition for pte_page is duplicated for the MIPS32
      PHYS_ADDR_T_64BIT case & the generic case. Unify them by moving a single
      definition outside of preprocessor conditionals.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Reviewed-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/13117/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      745f3558
    • P
      MIPS: mm: Standardise on _PAGE_NO_READ, drop _PAGE_READ · 780602d7
      Paul Burton 提交于
      Ever since support for RI/XI was implemented by commit 6dd9344c
      ("MIPS: Implement Read Inhibit/eXecute Inhibit") we've had a mixture of
      _PAGE_READ & _PAGE_NO_READ bits. Rather than keep both around, switch
      away from using _PAGE_READ to determine page presence & instead invert
      the use to _PAGE_NO_READ. Wherever we formerly had no definition for
      _PAGE_NO_READ, change what was _PAGE_READ to _PAGE_NO_READ. The end
      result is that we consistently use _PAGE_NO_READ to determine whether a
      page is readable, regardless of whether RI/XI is implemented.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Reviewed-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Alex Smith <alex.smith@imgtec.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/13116/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      780602d7
    • P
      MIPS: Use enums to make asm/pgtable-bits.h readable · 69497700
      Paul Burton 提交于
      asm/pgtable-bits.h has grown to become an unreadable mess of #ifdef
      directives defining bits conditionally upon other bits all at the
      preprocessing stage, for no good reason.
      
      Instead of having quite so many #ifdef's, simply use enums to provide
      sequential numbering for bit shifts, without having to keep track
      manually of what the last bit defined was. Masks are defined separately,
      after the shifts, which allows for most of their definitions to be
      reused for all systems rather than duplicated.
      
      This patch is not intended to make any behavioural change to the code -
      all bits should be used in the same way they were before this patch.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Reviewed-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: Alex Smith <alex.smith@imgtec.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/13115/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      69497700
    • P
      MIPS: Remove redundant asm/pgtable-bits.h inclusions · 253f0d4a
      Paul Burton 提交于
      asm/pgtable-bits.h is included in 2 assembly files and thus has to
      ifdef around C code, however nothing defined by the header is used
      in either of the assembly files that include it.
      
      Remove the redundant inclusions such that asm/pgtable-bits.h doesn't
      need to #ifdef around C code, for cleanliness and in preparation for
      later patches which will add more C.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Reviewed-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: Jonas Gorski <jogo@openwrt.org>
      Cc: Alex Smith <alex.smith@imgtec.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/13114/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      253f0d4a
    • J
      MIPS: Separate XPA CPU feature into LPA and MVH · 12822570
      James Hogan 提交于
      XPA (eXtended Physical Addressing) should be detected as a combination
      of two architectural features:
      - Large Physical Address (as per Config3.LPA). With XPA this will be set
        on MIPS32r5 cores, but it may also be set for MIPS64r2 cores too.
      - MTHC0/MFHC0 instructions (as per Config5.MVH). With XPA this will be
        set, but it may also be set in VZ guest context even when Config3.LPA
        in the guest context has been cleared by the hypervisor.
      
      As such, XPA is only usable if both bits are set. Update CPU features to
      separate these two features, with cpu_has_xpa requiring both to be set.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Maciej W. Rozycki <macro@imgtec.com>
      Cc: Joshua Kinard <kumba@gentoo.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/13112/Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      12822570
    • P
      MIPS: inst: Declare fsel_op for sel.fmt instruction · b6d5c4ed
      Paul Burton 提交于
      Declare the opcode for the MIPSr6 sel.fmt instruction, as fsel_op in
      order to match other FP op names.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: Maciej W. Rozycki <macro@imgtec.com>
      Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/13152/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      b6d5c4ed
    • P
      MIPS: Support extended ASIDs · 2db003a5
      Paul Burton 提交于
      Add support for extended ASIDs as determined by the Config4.AE bit.
      Since the only supported CPUs known to implement this are Netlogic XLP
      and MIPS I6400, select this variable ASID support based upon
      CONFIG_CPU_XLP and CONFIG_CPU_MIPSR6.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Jayachandran C. <jchandra@broadcom.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
      Patchwork: https://patchwork.linux-mips.org/patch/13211/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      2db003a5
    • P
      MIPS: Retrieve ASID masks using function accepting struct cpuinfo_mips · 4edf00a4
      Paul Burton 提交于
      In preparation for supporting variable ASID masks, retrieve ASID masks
      using functions in asm/cpu-info.h which accept struct cpuinfo_mips. This
      will allow those functions to determine the ASID mask based upon the CPU
      in a later patch. This also allows for the r3k & r8k cases to be handled
      in Kconfig, which is arguably cleaner than the previous #ifdefs.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Signed-off-by: NJames Hogan <james.hogan@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
      Patchwork: https://patchwork.linux-mips.org/patch/13210/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      4edf00a4
    • P
      MIPS: KVM: Abstract guest ASID mask · ca64c2be
      Paul Burton 提交于
      In preparation for supporting varied widths of ASID mask in the kernel
      in general, switch KVM's guest ASIDs to a new KVM_ENTRYHI_ASID
      definition based on the 8-bit MIPS_ENTRYHI_ASID instead of ASID_MASK.
      
      It could potentially be used to support extended guest ASIDs in the
      future.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Signed-off-by: NJames Hogan <james.hogan@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
      Patchwork: https://patchwork.linux-mips.org/patch/13207/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      ca64c2be
    • J
      MIPS: Add & use CP0_EntryHi ASID definitions · 9b5c3399
      James Hogan 提交于
      Add definitions for the ASID field in CP0_EntryHi (along with the soon
      to be used ASIDX field), and use them in a few previously hardcoded
      cases.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Manuel Lauss <manuel.lauss@gmail.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Radim Krčmář <rkrcmar@redhat.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/13205/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      9b5c3399
    • J
      MIPS: Change my email address · 97b92108
      John Crispin 提交于
      The old address is no longer valid. Use the my new one instead.
      Signed-off-by: NJohn Crispin <john@phrozen.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/13201/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      97b92108
    • P
      MIPS: Implement __arch_bitrev* using bitswap for MIPSr6 · 87321fdd
      Paul Burton 提交于
      Release 6 of the MIPS architecture introduced the bitswap instruction,
      which reverses the bits within each byte of a word. Make use of this
      instruction to implement the __arch_bitrev* functions, which should be
      faster for most MIPSr6 CPUs, reduces code size slightly and allows us to
      avoid the lookup table used by the generic implementation, saving 256
      bytes in the kernel binary by dropping that.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/13204/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      87321fdd
    • S
      MIPS: make PCI_DMA_BUS_IS_PHYS=1 constant · e8b5325c
      Sergey Ryazanov 提交于
      No one of supported MIPS machines has an IOMMU unit, so we can safely define
      PCI_DMA_BUS_IS_PHYS = 1. Also remove iommu flag from the pci controller
      structure, since it is useless.
      Signed-off-by: NSergey Ryazanov <ryazanov.s.a@gmail.com>
      Cc: Linux MIPS <linux-mips@linux-mips.org>
      Patchwork: https://patchwork.linux-mips.org/patch/7604/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      e8b5325c
    • L
      MIPS64: Support of at least 48 bits of SEGBITS · 1e321fa9
      Leonid Yegoshin 提交于
      SEGBITS is 40 bits or more, depending on CPU type.  Introduces optional
      support for 48 bits of application virtual address space.  Only 16K and
      64K pages are supported.
      
      Enabling will result in a memory overhead of a small number of pages for
      small applications.  For 64K pages a 3rd level of page tables is required
      which has some impact during software TLB refill.
      
      [ralf@linux-mips.org: Fixed things raised in the review of the version
      posted and changed kconfig to be a bit more userfriendly.]
      Signed-off-by: NLeonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: aleksey.makarov@auriga.com
      Cc: james.hogan@imgtec.com
      Cc: paul.burton@imgtec.com
      Cc: david.daney@cavium.com
      Cc: peterz@infradead.org
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: davidlohr@hp.com
      Cc: kirill@shutemov.name
      Cc: akpm@linux-foundation.org
      Cc: mingo@kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/10051/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      1e321fa9
    • L
      MIPS64: signal: Fix o32 sigaction syscall · 7939469d
      Leonid Yegoshin 提交于
      MIPS32 o32 ABI sigaction() processing on MIPS64 n64 kernel was incorrectly
      set to processing aka rt_sigaction() variant only.
      Signed-off-by: NLeonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: paul.burton@imgtec.com
      Cc: richard@nod.at
      Cc: luto@amacapital.net
      Cc: alex.smith@imgtec.com
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: mpe@ellerman.id.au
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/11321/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      7939469d
    • H
      MIPS: Loongson-3: Introduce CONFIG_LOONGSON3_ENHANCEMENT · 1e820da3
      Huacai Chen 提交于
      New Loongson 3 CPU (since Loongson-3A R2, as opposed to Loongson-3A R1,
      Loongson-3B R1 and Loongson-3B R2) has many enhancements, such as FTLB,
      L1-VCache, EI/DI/Wait/Prefetch instruction, DSP/DSPv2 ASE, User Local
      register, Read-Inhibit/Execute-Inhibit, SFB (Store Fill Buffer), Fast
      TLB refill support, etc.
      
      This patch introduce a config option, CONFIG_LOONGSON3_ENHANCEMENT, to
      enable those enhancements which are not probed at run time. If you want
      a generic kernel to run on all Loongson 3 machines, please say 'N'
      here. If you want a high-performance kernel to run on new Loongson 3
      machines only, please say 'Y' here.
      
      Some additional explanations:
      1) SFB locates between core and L1 cache, it causes memory access out
         of order, so writel/outl (and other similar functions) need a I/O
         reorder barrier.
      2) Loongson 3 has a bug that di instruction can not save the irqflag,
         so arch_local_irq_save() is modified. Since CPU_MIPSR2 is selected
         by CONFIG_LOONGSON3_ENHANCEMENT, generic kernel doesn't use ei/di
         at all.
      3) CPU_HAS_PREFETCH is selected by CONFIG_LOONGSON3_ENHANCEMENT, so
         MIPS_CPU_PREFETCH (used by uasm) probing is also put in this patch.
      Signed-off-by: NHuacai Chen <chenhc@lemote.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Steven J . Hill <sjhill@realitydiluted.com>
      Cc: Fuxin Zhang <zhangfx@lemote.com>
      Cc: Zhangjin Wu <wuzhangjin@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12755/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      1e820da3
    • H
      MIPS: Loongson-3: Fast TLB refill handler · 380cd582
      Huacai Chen 提交于
      Loongson-3A R2 has pwbase/pwfield/pwsize/pwctl registers in CP0 (this
      is very similar to HTW) and lwdir/lwpte/lddir/ldpte instructions which
      can be used for fast TLB refill.
      
      [ralf@linux-mips.org: Resolve conflict.]
      Signed-off-by: NHuacai Chen <chenhc@lemote.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Steven J . Hill <sjhill@realitydiluted.com>
      Cc: Fuxin Zhang <zhangfx@lemote.com>
      Cc: Zhangjin Wu <wuzhangjin@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12754/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      380cd582
    • H
      MIPS: Loongson: Invalidate special TLBs when needed · 06e4814e
      Huacai Chen 提交于
      Loongson-2 has a 4 entry itlb which is a subset of jtlb, Loongson-3 has
      a 4 entry itlb and a 4 entry dtlb which are subsets of jtlb. We should
      write diag register to invalidate itlb/dtlb when flushing jtlb because
      itlb/dtlb are not totally transparent to software.
      
      For Loongson-3A R2 (and newer), we should invalidate ITLB, DTLB, VTLB
      and FTLB before we enable/disable FTLB.
      Signed-off-by: NHuacai Chen <chenhc@lemote.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Steven J . Hill <sjhill@realitydiluted.com>
      Cc: Fuxin Zhang <zhangfx@lemote.com>
      Cc: Zhangjin Wu <wuzhangjin@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12753/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      06e4814e
    • H
      MIPS: Loongson: Add Loongson-3A R2 basic support · b2edcfc8
      Huacai Chen 提交于
      Loongson-3 CPU family:
      
      Code-name       Brand-name       PRId
      Loongson-3A R1  Loongson-3A1000  0x6305
      Loongson-3A R2  Loongson-3A2000  0x6308
      Loongson-3B R1  Loongson-3B1000  0x6306
      Loongson-3B R2  Loongson-3B1500  0x6307
      
      Features of R2 revision of Loongson-3A:
      
        - Primary cache includes I-Cache, D-Cache and V-Cache (Victim Cache).
        - I-Cache, D-Cache and V-Cache are 16-way set-associative, linesize is
           64 bytes.
        - 64 entries of VTLB (classic TLB), 1024 entries of FTLB (8-way
           set-associative).
        - Supports DSP/DSPv2 instructions, UserLocal register and Read-Inhibit/
           Execute-Inhibit.
      
      [ralf@linux-mips.org: Resolved merge conflicts.]
      Signed-off-by: NHuacai Chen <chenhc@lemote.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Steven J . Hill <sjhill@realitydiluted.com>
      Cc: Fuxin Zhang <zhangfx@lemote.com>
      Cc: Zhangjin Wu <wuzhangjin@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12751/
      Patchwork: https://patchwork.linux-mips.org/patch/13136/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      b2edcfc8
    • A
      MIPS: BCM1480: bcm1480_regs.h: strip redundant comments · 44896afe
      Antonio Ospite 提交于
      Strip some comments which probably meant to repeat the same value of the
      define; they also contained a confusing 0x0x prefix.
      Signed-off-by: NAntonio Ospite <ao2@ao2.it>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12254/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      44896afe
    • J
      MIPS: Add and use watch register field definitions · 50af501c
      James Hogan 提交于
      The files watch.c and ptrace.c contain various magic masks for
      WatchLo/WatchHi register fields. Add some definitions to mipsregs.h for
      these registers and make use of them in both watch.c and ptrace.c,
      hopefully making them more readable.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Reviewed-by: NDavid Daney <david.daney@cavium.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12729/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      50af501c
    • J
      MIPS: Add and use CAUSEF_WP definition · e233c733
      James Hogan 提交于
      do_watch() clears bit 22 of cause without using a CAUSEF_* definition
      from mipsregs.h. Add a definition for this bit (CAUSEF_WP) and make use
      of it. Also use clear_c0_cause() instead of manual read/modify/write.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12728/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      e233c733
    • M
      MIPS: ELF: Restructure personality macros · 2e5832ab
      Maciej W. Rozycki 提交于
      Update the ELF personality macros used for individual ABIs to make
      actions in the same order across all of them and match formatting too.
      Signed-off-by: NMaciej W. Rozycki <macro@imgtec.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Matthew Fortune <Matthew.Fortune@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      2e5832ab
    • J
      MIPS: Fix uapi include in exported asm/siginfo.h · 987e5b83
      James Hogan 提交于
      Since commit 8cb48fe1 ("MIPS: Provide correct siginfo_t.si_stime"),
      MIPS' uapi/asm/siginfo.h has included uapi/asm-generic/siginfo.h
      directly before defining MIPS' struct siginfo, in order to get the
      necessary definitions needed for the siginfo struct without the generic
      copy_siginfo() hitting compiler errors due to struct siginfo not yet
      being defined.
      
      Now that the generic copy_siginfo() is moved out to linux/signal.h we
      can safely include asm-generic/siginfo.h before defining the MIPS
      specific struct siginfo, which avoids the uapi/ include as well as
      breakage due to generic copy_siginfo() being defined before struct
      siginfo.
      Reported-by: NChristopher Ferris <cferris@google.com>
      Fixes: 8cb48fe1 ("MIPS: Provide correct siginfo_t.si_stime")
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Petr Malat <oss@malat.biz>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 4.0-
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      987e5b83
    • Á
      MIPS: BMIPS: Add BCM6358 support · 3604b451
      Álvaro Fernández Rojas 提交于
      BCM6358 has a shared TLB which conflicts with current SMP support, so it must
      be disabled for now.
      BCM6358 uses >= 0xfffe0000 addresses for internal registers, which need to be
      remapped (by using a simplified version of BRCM63xx ioremap.h).
      However, 0xfff80000 is a better address, since it also covers BCM3368, leaving
      the possibility to add it in the future.
      Signed-off-by: NÁlvaro Fernández Rojas <noltari@gmail.com>
      Cc: f.fainelli@gmail.com
      Cc: jogo@openwrt.org
      Cc: cernekee@gmail.com
      Cc: robh@kernel.org
      Cc: simon@fire.lp0.eu
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/13040/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      3604b451
    • F
      MIPS: BMIPS: Add cpu-feature-overrides.h · f337967d
      Florian Fainelli 提交于
      BMIPS_GENERIC being multiplatform and intended to support BMIPS3200,
      BMIPS3300, BMIPS4350, BMIPS4380 and BMIPS5000-class processors, there is
      not much more we can put in there since they do not share the same I and
      D cache line sizes at all (doubled for every new generation
      essentially), some processors have a S-cache, some don't, some have a
      FPU, some don't.
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/13013/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      f337967d
    • K
      MIPS: Loongson1B: Some updates/fixes for LS1B · 9ec88b60
      Kelvin Cheung 提交于
      - Add DMA device
      - Add NAND device
      - Add GPIO device
      - Add LED device
      - Update the defconfig and rename it to loongson1b_defconfig
      - Fix ioremap size
      - Other minor fixes
      Signed-off-by: NKelvin Cheung <keguang.zhang@gmail.com>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Stephen Boyd <sboyd@codeaurora.org>
      Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Cc: Vinod Koul <vinod.koul@intel.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Cc: Alexandre Courbot <gnurou@gmail.com>
      Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
      Cc: Richard Weinberger <richard@nod.at>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Brian Norris <computersforpeace@gmail.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-clk@vger.kernel.org
      Cc: linux-pm@vger.kernel.org
      Cc: dmaengine@vger.kernel.org
      Cc: linux-gpio@vger.kernel.org
      Cc: linux-mtd@lists.infradead.org
      Patchwork: https://patchwork.linux-mips.org/patch/13033/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      9ec88b60
    • M
      MIPS: Introduce plat_get_fdt a platform API to retrieve the FDT · 5e7c1c91
      Matt Redfearn 提交于
      Early access to the kernel command line requires early access to the FDT
      for platforms which pass the command line within the device tree. There
      was no common way to retrieve the location of the FDT without incurring
      side effects, such as plat_mem_setup which, on Malta at least,
      initializes a bunch of other stuff.
      
      This patch adds plat_get_ftd() for IMG platforms.
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: kernel-hardening@lists.openwall.com
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/12988/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      5e7c1c91
    • M
      MIPS: seccomp: Support compat with both O32 and N32 · b1b4fad5
      Matt Redfearn 提交于
      Previously the seccomp would only support strict mode on O32 userland
      programs when the kernel had support for both O32 and N32 ABIs. Remove
      kludge and support both ABIs.
      
      With this patch in place, the seccomp_bpf self test now passes
      global.mode_strict_support with N32 userland.
      Suggested-by: NPaul Burton <paul.burton@imgtec.com>
      Signed-off-by: NMatt Redfearn <matt.redfearn@imgtec.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: IMG-MIPSLinuxKerneldevelopers@imgtec.com
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/12917/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      b1b4fad5
    • S
      MIPS: Use generic clkdev.h header · 3d2ca73a
      Stephen Boyd 提交于
      The generic header file is equivalent to the MIPS one, so use the
      generic one instead.
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-clk@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12261/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      3d2ca73a
    • P
      MIPS: Sync icache & dcache in set_pte_at · 37d22a0d
      Paul Burton 提交于
      It's possible for pages to become visible prior to update_mmu_cache
      running if a thread within the same address space preempts the current
      thread or runs simultaneously on another CPU. That is, the following
      scenario is possible:
      
          CPU0                            CPU1
      
          write to page
          flush_dcache_page
          flush_icache_page
          set_pte_at
                                          map page
          update_mmu_cache
      
      If CPU1 maps the page in between CPU0's set_pte_at, which marks it valid
      & visible, and update_mmu_cache where the dcache flush occurs then CPU1s
      icache will fill from stale data (unless it fills from the dcache, in
      which case all is good, but most MIPS CPUs don't have this property).
      Commit 4d46a67a ("MIPS: Fix race condition in lazy cache flushing.")
      attempted to fix that by performing the dcache flush in
      flush_icache_page such that it occurs before the set_pte_at call makes
      the page visible. However it has the problem that not all code that
      writes to pages exposed to userland call flush_icache_page. There are
      many callers of set_pte_at under mm/ and only 2 of them do call
      flush_icache_page. Thus the race window between a page becoming visible
      & being coherent between the icache & dcache remains open in some cases.
      
      To illustrate some of the cases, a WARN was added to __update_cache with
      this patch applied that triggered in cases where a page about to be
      flushed from the dcache was not the last page provided to
      flush_icache_page. That is, backtraces were obtained for cases in which
      the race window is left open without this patch. The 2 standout examples
      follow.
      
      When forking a process:
      
      [   15.271842] [<80417630>] __update_cache+0xcc/0x188
      [   15.277274] [<80530394>] copy_page_range+0x56c/0x6ac
      [   15.282861] [<8042936c>] copy_process.part.54+0xd40/0x17ac
      [   15.289028] [<80429f80>] do_fork+0xe4/0x420
      [   15.293747] [<80413808>] handle_sys+0x128/0x14c
      
      When exec'ing an ELF binary:
      
      [   14.445964] [<80417630>] __update_cache+0xcc/0x188
      [   14.451369] [<80538d88>] move_page_tables+0x414/0x498
      [   14.457075] [<8055d848>] setup_arg_pages+0x220/0x318
      [   14.462685] [<805b0f38>] load_elf_binary+0x530/0x12a0
      [   14.468374] [<8055ec3c>] search_binary_handler+0xbc/0x214
      [   14.474444] [<8055f6c0>] do_execveat_common+0x43c/0x67c
      [   14.480324] [<8055f938>] do_execve+0x38/0x44
      [   14.485137] [<80413808>] handle_sys+0x128/0x14c
      
      These code paths write into a page, call flush_dcache_page then call
      set_pte_at without flush_icache_page inbetween. The end result is that
      the icache can become corrupted & userland processes may execute
      unexpected or invalid code, typically resulting in a reserved
      instruction exception, a trap or a segfault.
      
      Fix this race condition fully by performing any cache maintenance
      required to keep the icache & dcache in sync in set_pte_at, before the
      page is made valid. This has the added bonus of ensuring the cache
      maintenance always happens in one location, rather than being duplicated
      in flush_icache_page & update_mmu_cache. It also matches the way other
      architectures solve the same problem (see arm, ia64 & powerpc).
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Reported-by: NIonela Voinescu <ionela.voinescu@imgtec.com>
      Cc: Lars Persson <lars.persson@axis.com>
      Fixes: 4d46a67a ("MIPS: Fix race condition in lazy cache flushing.")
      Cc: Steven J. Hill <sjhill@realitydiluted.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Jerome Marchand <jmarchan@redhat.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: stable <stable@vger.kernel.org> # v4.1+
      Patchwork: https://patchwork.linux-mips.org/patch/12722/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      37d22a0d
    • P
      MIPS: Flush dcache for flush_kernel_dcache_page · 763fee97
      Paul Burton 提交于
      The flush_kernel_dcache_page function was previously essentially a nop.
      This is incorrect for MIPS, where if a page has been modified & either
      it aliases or it's executable & the icache doesn't fill from dcache then
      the content needs to be written back from dcache to the next level of
      the cache hierarchy (which is shared with the icache).
      
      Implement this by simply calling flush_dcache_page, treating this
      kmapped cache flush function (flush_kernel_dcache_page) exactly the same
      as its non-kmapped counterpart (flush_dcache_page).
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: Lars Persson <lars.persson@axis.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/12719/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      763fee97
    • Z
      MIPS: Detect DSP v3 support · b5a6455c
      Zubair Lutfullah Kakakhel 提交于
      DSPv3 is supported on all MIPSr6 systems which indicate support for DSPv2.
      
      This doesn't require any changes to the kernel's handling of DSP
      resources. The patch is to detect support and indicate it in /proc/cpuinfo
      
      DSP v3 introduces a new instruction BPOSGE32C
      Signed-off-by: NZubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
      Reviewed-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/12918/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      b5a6455c