1. 14 Dec, 2018 2 commits
    • Firoz Khan's avatar
      mips: rename scall64-64.S to scall64-n64.S · 6d92c268
      Firoz Khan authored
      When we get nanoMIPS support we'll be introducing the p32
      ABI, and there's a reasonable chance that the equivalent
      p64 ABI may come along in the future. Using 'n64' now would
      avoid confusion in that case where we may have 2 different
      64-bit ABIs.
      Suggested-by: default avatarPaul Burton <paul.burton@mips.com>
      Signed-off-by: default avatarFiroz Khan <firoz.khan@linaro.org>
      [paul.burton@mips.com:
        - Remove UAPI macro renaming, github code search shows at least the
          chromium project uses __NR_64_Linux & __NR_64_Linux_syscalls.]
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: y2038@lists.linaro.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-arch@vger.kernel.org
      Cc: arnd@arndb.de
      Cc: deepa.kernel@gmail.com
      Cc: marcin.juszkiewicz@linaro.org
      6d92c268
    • Firoz Khan's avatar
      mips: remove unused macros · a5ee2be9
      Firoz Khan authored
      Remove __NR_Linux_syscalls from uapi/asm/unistd.h as
      there is no users to use NR_syscalls macro in mips
      kernel.
      
      MAX_SYSCALL_NO can also remove as there is commit
      2957c9e6 ("[MIPS] IRIX: Goodbye and thanks for
      all the fish"), eight years ago.
      Signed-off-by: default avatarFiroz Khan <firoz.khan@linaro.org>
      [paul.burton@mips.com:
       - Drop the removal of NR_syscalls which is used by
         kernel/trace/trace.h.]
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: y2038@lists.linaro.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-arch@vger.kernel.org
      Cc: arnd@arndb.de
      Cc: deepa.kernel@gmail.com
      Cc: marcin.juszkiewicz@linaro.org
      a5ee2be9
  2. 13 Dec, 2018 1 commit
    • Firoz Khan's avatar
      mips: add __NR_syscalls along with __NR_Linux_syscalls · ef2512c8
      Firoz Khan authored
      __NR_Linux_syscalls macro holds the number of system call
      exist in mips architecture. We have to change the value of
      __NR_Linux_syscalls, if we add or delete a system call.
      
      One of the patch in this patch series has a script which
      will generate a uapi header based on syscall.tbl file.
      The syscall.tbl file contains the total number of system
      calls information. So we have two option to update __NR-
      _Linux_syscalls value.
      
      1. Update __NR_Linux_syscalls in asm/unistd.h manually
         by counting the no.of system calls. No need to update
         __NR_Linux_syscalls until we either add a new system
         call or delete existing system call.
      
      2. We can keep this feature it above mentioned script,
         that will count the number of syscalls and keep it in
         a generated file. In this case we don't need to expli-
         citly update __NR_Linux_syscalls in asm/unistd.h file.
      
      The 2nd option will be the recommended one. For that, I
      added the __NR_syscalls macro in uapi/asm/unistd.h along
      with __NR_Linux_syscalls. The macro __NR_syscalls also
      added for making the name convention same across all
      architecture. While __NR_syscalls isn't strictly part of
      the uapi, having it as part of the generated header to
      simplifies the implementation. We also need to enclose
      this macro with #ifdef __KERNEL__ to avoid side effects.
      Signed-off-by: default avatarFiroz Khan <firoz.khan@linaro.org>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: y2038@lists.linaro.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-arch@vger.kernel.org
      Cc: arnd@arndb.de
      Cc: deepa.kernel@gmail.com
      Cc: marcin.juszkiewicz@linaro.org
      ef2512c8
  3. 05 Dec, 2018 1 commit
    • Paul Burton's avatar
      MIPS: Expand MIPS32 ASIDs to 64 bits · ff4dd232
      Paul Burton authored
      ASIDs have always been stored as unsigned longs, ie. 32 bits on MIPS32
      kernels. This is problematic because it is feasible for the ASID version
      to overflow & wrap around to zero.
      
      We currently attempt to handle this overflow by simply setting the ASID
      version to 1, using asid_first_version(), but we make no attempt to
      account for the fact that there may be mm_structs with stale ASIDs that
      have versions which we now reuse due to the overflow & wrap around.
      
      Encountering this requires that:
      
        1) A struct mm_struct X is active on CPU A using ASID (V,n).
      
        2) That mm is not used on CPU A for the length of time that it takes
           for CPU A's asid_cache to overflow & wrap around to the same
           version V that the mm had in step 1. During this time tasks using
           the mm could either be sleeping or only scheduled on other CPUs.
      
        3) Some other mm Y becomes active on CPU A and is allocated the same
           ASID (V,n).
      
        4) mm X now becomes active on CPU A again, and now incorrectly has the
           same ASID as mm Y.
      
      Where struct mm_struct ASIDs are represented above in the format
      (version, EntryHi.ASID), and on a typical MIPS32 system version will be
      24 bits wide & EntryHi.ASID will be 8 bits wide.
      
      The length of time required in step 2 is highly dependent upon the CPU &
      workload, but for a hypothetical 2GHz CPU running a workload which
      generates a new ASID every 10000 cycles this period is around 248 days.
      Due to this long period of time & the fact that tasks need to be
      scheduled in just the right (or wrong, depending upon your inclination)
      way, this is obviously a difficult bug to encounter but it's entirely
      possible as evidenced by reports.
      
      In order to fix this, simply extend ASIDs to 64 bits even on MIPS32
      builds. This will extend the period of time required for the
      hypothetical system above to encounter the problem from 28 days to
      around 3 trillion years, which feels safely outside of the realms of
      possibility.
      
      The cost of this is slightly more generated code in some commonly
      executed paths, but this is pretty minimal:
      
                               | Code Size Gain | Percentage
        -----------------------|----------------|-------------
          decstation_defconfig |           +270 | +0.00%
              32r2el_defconfig |           +652 | +0.01%
              32r6el_defconfig |          +1000 | +0.01%
      
      I have been unable to measure any change in performance of the LMbench
      lat_ctx or lat_proc tests resulting from the 64b ASIDs on either
      32r2el_defconfig+interAptiv or 32r6el_defconfig+I6500 systems.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Suggested-by: default avatarJames Hogan <jhogan@kernel.org>
      References: https://lore.kernel.org/linux-mips/80B78A8B8FEE6145A87579E8435D78C30205D5F3@fzex.ruijie.com.cn/
      References: https://lore.kernel.org/linux-mips/1488684260-18867-1-git-send-email-jiwei.sun@windriver.com/
      Cc: Jiwei Sun <jiwei.sun@windriver.com>
      Cc: Yu Huabing <yhb@ruijie.com.cn>
      Cc: stable@vger.kernel.org # 2.6.12+
      Cc: linux-mips@vger.kernel.org
      ff4dd232
  4. 04 Dec, 2018 6 commits
  5. 03 Dec, 2018 1 commit
    • Mathieu Malaterre's avatar
      mips: annotate implicit fall throughs · 69095e39
      Mathieu Malaterre authored
      There is a plan to build the kernel with -Wimplicit-fallthrough and
      these places in the code produced warnings. Fix them up.
      
      This patch produces no change in behaviour, but should be reviewed in
      case these are actually bugs not intentional fallthoughs.
      Signed-off-by: default avatarMathieu Malaterre <malat@debian.org>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Kees Cook <keescook@google.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      69095e39
  6. 27 Nov, 2018 2 commits
  7. 22 Nov, 2018 1 commit
    • Paul Burton's avatar
      MIPS: Only include mmzone.h when CONFIG_NEED_MULTIPLE_NODES=y · 66a4059b
      Paul Burton authored
      MIPS' asm/mmzone.h includes the machine/platform mmzone.h
      unconditionally, but since commit bb53fdf3 ("MIPS: c-r4k: Add
      r4k_blast_scache_node for Loongson-3") is included by asm/rk4cache.h for
      all r4k-style configs regardless of CONFIG_NEED_MULTIPLE_NODES.
      
      This is problematic when CONFIG_NEED_MULTIPLE_NODES=n because both the
      loongson3 & ip27 mmzone.h headers unconditionally define the NODE_DATA
      preprocessor macro which is aready defined by linux/mmzone.h, resulting
      in the following build error:
      
        In file included from ./arch/mips/include/asm/mmzone.h:10,
                         from ./arch/mips/include/asm/r4kcache.h:23,
                         from arch/mips/mm/c-r4k.c:33:
        ./arch/mips/include/asm/mach-loongson64/mmzone.h:48: error: "NODE_DATA" redefined [-Werror]
         #define NODE_DATA(n)  (&__node_data[(n)]->pglist)
      
        In file included from ./include/linux/topology.h:32,
                         from ./include/linux/irq.h:19,
                         from ./include/asm-generic/hardirq.h:13,
                         from ./arch/mips/include/asm/hardirq.h:16,
                         from ./include/linux/hardirq.h:9,
                         from arch/mips/mm/c-r4k.c:11:
        ./include/linux/mmzone.h:907: note: this is the location of the previous definition
         #define NODE_DATA(nid)  (&contig_page_data)
      
      Resolve this by only including the machine mmzone.h when
      CONFIG_NEED_MULTIPLE_NODES=y, which also removes the need for the empty
      mach-generic version of the header which we delete.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: bb53fdf3 ("MIPS: c-r4k: Add r4k_blast_scache_node for Loongson-3")
      66a4059b
  8. 21 Nov, 2018 26 commits