1. 02 Nov, 2017 1 commit
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  2. 06 Sep, 2017 1 commit
  3. 04 Sep, 2017 1 commit
  4. 29 Aug, 2017 1 commit
    • Paul Burton's avatar
      MIPS: CPS: Have asm/mips-cps.h include CM & CPC headers · e83f7e02
      Paul Burton authored
      With Coherence Manager (CM) 3.5 information about the topology of the
      system, which has previously only been available through & accessed from
      the CM, is now also provided by the Cluster Power Controller (CPC). This
      includes a new CPC_CONFIG register mirroring GCR_CONFIG, and similarly a
      new CPC_Cx_CONFIG register mirroring GCR_Cx_CONFIG.
      
      In preparation for adjusting functions such as mips_cm_numcores(), which
      have previously only needed to access the CM, to also access the CPC
      this patch modifies the way we use the various CPS headers. Rather than
      having users include asm/mips-cm.h or asm/mips-cpc.h individually we
      instead have users include asm/mips-cps.h which in turn includes
      asm/mips-cm.h & asm/mips-cpc.h. This means that users will gain access
      to both CM & CPC registers by including one header, and most importantly
      it makes asm/mips-cps.h an ideal location for helper functions which
      need to access the various components of the CPS.
      Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17015/
      Patchwork: https://patchwork.linux-mips.org/patch/17217/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      e83f7e02
  5. 07 Aug, 2017 1 commit
  6. 29 Jun, 2017 4 commits
    • Aleksandar Markovic's avatar
      MIPS: VDSO: Fix a mismatch between comment and preprocessor constant · bdb94f6e
      Aleksandar Markovic authored
      Sync the comment with its preprocessor constant counterpart.
      Signed-off-by: default avatarAleksandar Markovic <aleksandar.markovic@imgtec.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Miodrag Dinic <miodrag.dinic@imgtec.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Petar Jovanovic <petar.jovanovic@imgtec.com>
      Cc: Raghu Gandham <raghu.gandham@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16641/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      bdb94f6e
    • Goran Ferenc's avatar
      MIPS: VDSO: Add implementation of gettimeofday() fallback · 0b523a85
      Goran Ferenc authored
      This patch adds gettimeofday_fallback() function that wraps assembly
      invocation of gettimeofday() syscall using __NR_gettimeofday.
      
      This function is used if pure VDSO implementation gettimeofday()
      does not succeed for any reason. Its imeplementation is enclosed in
      "#ifdef CONFIG_MIPS_CLOCK_VSYSCALL" to be in sync with the similar
      arrangement for __vdso_gettimeofday().
      
      If syscall invocation via __NR_gettimeofday fails, register a3 will
      be set. So, after the syscall, register a3 is tested and the return
      valuem is negated if it's set.
      Signed-off-by: default avatarGoran Ferenc <goran.ferenc@imgtec.com>
      Signed-off-by: default avatarMiodrag Dinic <miodrag.dinic@imgtec.com>
      Signed-off-by: default avatarAleksandar Markovic <aleksandar.markovic@imgtec.com>
      Cc: Douglas Leung <douglas.leung@imgtec.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Petar Jovanovic <petar.jovanovic@imgtec.com>
      Cc: Raghu Gandham <raghu.gandham@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16640/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      0b523a85
    • Goran Ferenc's avatar
      MIPS: VDSO: Add implementation of clock_gettime() fallback · 180902e0
      Goran Ferenc authored
      This patch adds clock_gettime_fallback() function that wraps assembly
      invocation of clock_gettime() syscall using __NR_clock_gettime.
      
      This function is used if pure VDSO implementation of clock_gettime()
      does not succeed for any reason. For example, it is called if the
      clkid parameter of clock_gettime() is not one of the clkids listed
      in the switch-case block of the function __vdso_clock_gettime()
      (one such case for clkid is CLOCK_BOOTIME).
      
      If syscall invocation via __NR_clock_gettime fails, register a3 will
      be set. So, after the syscall, register a3 is tested and the return
      value is negated if it's set.
      Signed-off-by: default avatarGoran Ferenc <goran.ferenc@imgtec.com>
      Signed-off-by: default avatarMiodrag Dinic <miodrag.dinic@imgtec.com>
      Signed-off-by: default avatarAleksandar Markovic <aleksandar.markovic@imgtec.com>
      Cc: Douglas Leung <douglas.leung@imgtec.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Petar Jovanovic <petar.jovanovic@imgtec.com>
      Cc: Raghu Gandham <raghu.gandham@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16639/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      180902e0
    • Goran Ferenc's avatar
      MIPS: VDSO: Fix conversions in do_monotonic()/do_monotonic_coarse() · 8ec7f15b
      Goran Ferenc authored
      Fix incorrect calculation in do_monotonic() and do_monotonic_coarse()
      function that in turn caused incorrect values returned by the vdso
      version of system call clock_gettime() on mips64 if its system clock
      ID parameter was CLOCK_MONOTONIC or CLOCK_MONOTONIC_COARSE.
      
      Consider these variables and their types on mips32 and mips64:
      
      tk->wall_to_monotonic.tv_sec  s64, s64   (kernel/vdso.c)
      vdso_data.wall_to_mono_sec    u32, u32   (kernel/vdso.c)
      to_mono_sec                   u32, u32   (vdso/gettimeofday.c)
      ts->tv_sec                    s32, s64   (vdso/gettimeofday.c)
      
      For mips64 case, u32 vdso_data.wall_to_mono_sec variable is updated
      from the 64-bit signed variable tk->wall_to_monotonic.tv_sec
      (kernel/vdso.c:76) which is a negative number holding the time passed
      from 1970-01-01 to the time boot started. This 64-bit signed value is
      currently around 47+ years, in seconds. For instance, let this value
      be:
      
      -1489757461
      
      or
      
      11111111111111111111111111111111 10100111001101000001101011101011
      
      By updating 32-bit vdso_data.wall_to_mono_sec variable, we lose upper
      32 bits (signed 1's).
      
      to_mono_sec variable is a parameter of do_monotonic() and
      do_monotonic_coarse() functions which holds vdso_data.wall_to_mono_sec
      value. Its value needs to be added (or subtracted considering it holds
      negative value from the tk->wall_to_monotonic.tv_sec) to the current
      time passed from 1970-01-01 (ts->tv_sec), which is again something like
      47+ years, but increased by the time passed from the boot to the
      current time. ts->tv_sec is 32-bit long in case of 32-bit architecture
      and 64-bit long in case of 64-bit architecture. Consider the update of
      ts->tv_sec (vdso/gettimeofday.c:55 & 167):
      
      ts->tv_sec += to_mono_sec;
      
      mips32 case: This update will be performed correctly, since both
      ts->tv_sec and to_mono_sec are 32-bit long and the sign in to_mono_sec
      is preserved. Implicit conversion from u32 to s32 will be done
      correctly.
      
      mips64 case: This update will be wrong, since the implicit conversion
      will not be done correctly. The reason is that the conversion will be
      from u32 to s64. This is because to_mono_sec is 32-bit long for both
      mips32 and mips64 cases and s64..33 bits of converted to_mono_sec
      variable will be zeros.
      
      So, in order to make MIPS64 implementation work properly for
      MONOTONIC and MONOTONIC_COARSE clock ids on mips64, the size of
      wall_to_mono_sec variable in mips_vdso_data union and respective
      parameters in do_monotonic() and do_monotonic_coarse() functions
      should be changed from u32 to u64. Because of consistency, this
      size change from u32 and u64 is also done for wall_to_mono_nsec
      variable and corresponding function parameters.
      
      As far as similar situations for other architectures are concerned,
      let's take a look at arm. Arm has two distinct vdso_data structures
      for 32-bit & 64-bit cases, and arm's wall_to_mono_sec and
      wall_to_mono_nsec are u32 for 32-bit and u64 for 64-bit cases.
      On the other hand, MIPS has only one structure (mips_vdso_data),
      hence the need for changing the size of above mentioned parameters.
      Signed-off-by: default avatarGoran Ferenc <goran.ferenc@imgtec.com>
      Signed-off-by: default avatarMiodrag Dinic <miodrag.dinic@imgtec.com>
      Signed-off-by: default avatarAleksandar Markovic <aleksandar.markovic@imgtec.com>
      Cc: Douglas Leung <douglas.leung@imgtec.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Petar Jovanovic <petar.jovanovic@imgtec.com>
      Cc: Raghu Gandham <raghu.gandham@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/16638/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      8ec7f15b
  7. 17 Feb, 2017 1 commit
  8. 24 Jan, 2017 1 commit
    • Arnd Bergmann's avatar
      MIPS: Fix modversions · b668970e
      Arnd Bergmann authored
      kernelci.org reports tons of build warnings for linux-next:
      
      35	WARNING: "memcpy" [fs/fat/msdos.ko] has no CRC!
      35	WARNING: "__copy_user" [fs/fat/fat.ko] has no CRC!
      32	WARNING: EXPORT symbol "memset" [vmlinux] version generation failed, symbol will not be versioned.
      32	WARNING: EXPORT symbol "copy_page" [vmlinux] version generation failed, symbol will not be versioned.
      32	WARNING: EXPORT symbol "clear_page" [vmlinux] version generation failed, symbol will not be versioned.
      32	WARNING: EXPORT symbol "__strncpy_from_user_nocheck_asm" [vmlinux] version generation failed, symbol will not be versioned.
      
      The problem here is mainly the missing asm/asm-prototypes.h header file
      that is supposed to include the prototypes for each symbol that is exported
      from an assembler file.
      
      A second problem is that the asm/uaccess.h header contains some but not
      all the necessary declarations for the user access helpers.
      
      Finally, the vdso build is broken once we add asm/asm-prototypes.h, so
      we have to fix this at the same time by changing the vdso header. My
      approach here is to just not look for exported symbols in the VDSO
      assembler files, as the symbols cannot be exported anyway.
      
      Fixes: 576a2f0c ("MIPS: Export memcpy & memset functions alongside their definitions")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Maciej W. Rozycki <macro@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/15038/
      Patchwork: https://patchwork.linux-mips.org/patch/15069/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      b668970e
  9. 11 Oct, 2016 2 commits
  10. 28 May, 2016 2 commits
    • James Hogan's avatar
      MIPS: Build microMIPS VDSO for microMIPS kernels · bb93078e
      James Hogan authored
      MicroMIPS kernels may be expected to run on microMIPS only cores which
      don't support the normal MIPS instruction set, so be sure to pass the
      -mmicromips flag through to the VDSO cflags.
      
      Fixes: ebb5e78c ("MIPS: Initial implementation of a VDSO")
      Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 4.4.x-
      Patchwork: https://patchwork.linux-mips.org/patch/13349/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      bb93078e
    • Maciej W. Rozycki's avatar
      MIPS: VDSO: Build with `-fno-strict-aliasing' · 94cc36b8
      Maciej W. Rozycki authored
      Avoid an aliasing issue causing a build error in VDSO:
      
      In file included from include/linux/srcu.h:34:0,
                       from include/linux/notifier.h:15,
                       from ./arch/mips/include/asm/uprobes.h:9,
                       from include/linux/uprobes.h:61,
                       from include/linux/mm_types.h:13,
                       from ./arch/mips/include/asm/vdso.h:14,
                       from arch/mips/vdso/vdso.h:27,
                       from arch/mips/vdso/gettimeofday.c:11:
      include/linux/workqueue.h: In function 'work_static':
      include/linux/workqueue.h:186:2: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
        return *work_data_bits(work) & WORK_STRUCT_STATIC;
        ^
      cc1: all warnings being treated as errors
      make[2]: *** [arch/mips/vdso/gettimeofday.o] Error 1
      
      with a CONFIG_DEBUG_OBJECTS_WORK configuration and GCC 5.2.0.  Include
      `-fno-strict-aliasing' along with compiler options used, as required for
      kernel code, fixing a problem present since the introduction of VDSO
      with commit ebb5e78c ("MIPS: Initial implementation of a VDSO").
      
      Thanks to Tejun for diagnosing this properly!
      Signed-off-by: default avatarMaciej W. Rozycki <macro@imgtec.com>
      Reviewed-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Fixes: ebb5e78c ("MIPS: Initial implementation of a VDSO")
      Cc: Tejun Heo <tj@kernel.org>
      Cc: linux-mips@linux-mips.org
      Cc: stable@vger.kernel.org # v4.3+
      Patchwork: https://patchwork.linux-mips.org/patch/13357/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      94cc36b8
  11. 13 May, 2016 1 commit
    • James Hogan's avatar
      MIPS: Fix genvdso error on rebuild · 2afb9745
      James Hogan authored
      The genvdso program modifies the debug and stripped versions of the
      VDSOs in place, and errors if the modification has already taken place.
      Unfortunately this means that a rebuild which tries to rerun genvdso to
      generate vdso*-image.c without also rebuilding vdso.so.dbg (for example
      if genvdso.c is modified) hits a build error like this:
      
      arch/mips/vdso/genvdso 'arch/mips/vdso/vdso.so.dbg' already contains a '.MIPS.abiflags' section
      
      This is fixed by reorganising the rules such that unmodified .so files
      have a .raw suffix, and these are copied in the same rule that runs
      genvdso on the copies.
      
      I.e. previously we had:
      
       cmd_vdsold:
        link objects -> vdso.so.dbg
      
       cmd_genvdso:
        strip vdso.so.dbg -> vdso.so
        run genvdso -> vdso-image.c
         and modify vdso.so.dbg and vdso.so in place
      
      Now we have:
      
       cmd_vdsold:
        link objects -> vdso.so.dbg.raw
      
       a new cmd_objcopy based strip rule (inspired by ARM):
        strip vdso.so.dbg.raw -> vdso.so.raw
      
       cmd_genvdso:
        copy vdso.so.dbg.raw -> vdso.so.dbg
        copy vdso.so.raw -> vdso.so
        run genvdso -> vdso-image.c
         and modify vdso.so.dbg and vdso.so in place
      Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/13250/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      2afb9745
  12. 04 Jan, 2016 1 commit
  13. 29 Dec, 2015 1 commit
    • Guenter Roeck's avatar
      MIPS: VDSO: Fix build error with binutils 2.24 and earlier · 398c7500
      Guenter Roeck authored
      Commit 2a037f31 ("MIPS: VDSO: Fix build error") tries to fix a build
      error seen with binutils 2.24 and earlier. However, the fix does not work,
      and again results in the already known build errors if the kernel is built
      with an earlier version of binutils.
      
      CC      arch/mips/vdso/gettimeofday.o
      /tmp/ccnOVbHT.s: Assembler messages:
      /tmp/ccnOVbHT.s:50: Error: can't resolve `_start' {*UND* section} - `L0 {.text section}
      /tmp/ccnOVbHT.s:374: Error: can't resolve `_start' {*UND* section} - `L0 {.text section}
      scripts/Makefile.build:258: recipe for target 'arch/mips/vdso/gettimeofday.o' failed
      make[2]: *** [arch/mips/vdso/gettimeofday.o] Error 1
      
      Fixes: 2a037f31 ("MIPS: VDSO: Fix build error")
      Cc: Qais Yousef <qais.yousef@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/11926/Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      398c7500
  14. 22 Dec, 2015 1 commit
    • Qais Yousef's avatar
      MIPS: VDSO: Fix build error · 2a037f31
      Qais Yousef authored
      Commit ebb5e78c ("MIPS: Initial implementation of a VDSO") introduced a
      build error.
      
      For MIPS VDSO to be compiled it requires binutils version 2.25 or above but
      the check in the Makefile had inverted logic causing it to be compiled in if
      binutils is below 2.25.
      
      This fixes the following compilation error:
      
      CC      arch/mips/vdso/gettimeofday.o
      /tmp/ccsExcUd.s: Assembler messages:
      /tmp/ccsExcUd.s:62: Error: can't resolve `_start' {*UND* section} - `L0' {.text section}
      /tmp/ccsExcUd.s:467: Error: can't resolve `_start' {*UND* section} - `L0' {.text section}
      make[2]: *** [arch/mips/vdso/gettimeofday.o] Error 1
      make[1]: *** [arch/mips/vdso] Error 2
      make: *** [arch/mips] Error 2
      
      [ralf@linux-mips: Fixed Sergei's complaint on the formatting of the
      cited commit and generally reformatted the log message.]
      Signed-off-by: default avatarQais Yousef <qais.yousef@imgtec.com>
      Cc: alex@alex-smith.me.uk
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/11745/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      2a037f31
  15. 11 Nov, 2015 2 commits
    • Alex Smith's avatar
      MIPS: VDSO: Add implementations of gettimeofday() and clock_gettime() · a7f4df4e
      Alex Smith authored
      Add user-mode implementations of gettimeofday() and clock_gettime() to
      the VDSO. This is currently usable with 2 clocksources: the CP0 count
      register, which is accessible to user-mode via RDHWR on R2 and later
      cores, or the MIPS Global Interrupt Controller (GIC) timer, which
      provides a "user-mode visible" section containing a mirror of its
      counter registers. This section must be mapped into user memory, which
      is done below the VDSO data page.
      
      When a supported clocksource is not in use, the VDSO functions will
      return -ENOSYS, which causes libc to fall back on the standard syscall
      path.
      
      When support for neither of these clocksources is compiled into the
      kernel at all, the VDSO still provides clock_gettime(), as the coarse
      realtime/monotonic clocks can still be implemented. However,
      gettimeofday() is not provided in this case as nothing can be done
      without a suitable clocksource. This causes the symbol lookup to fail
      in libc and it will then always use the standard syscall path.
      
      This patch includes a workaround for a bug in QEMU which results in
      RDHWR on the CP0 count register always returning a constant (incorrect)
      value. A fix for this has been submitted, and the workaround can be
      removed after the fix has been in stable releases for a reasonable
      amount of time.
      
      A simple performance test which calls gettimeofday() 1000 times in a
      loop and calculates the average execution time gives the following
      results on a Malta + I6400 (running at 20MHz):
      
       - Syscall:    ~31000 ns
       - VDSO (GIC): ~15000 ns
       - VDSO (CP0): ~9500 ns
      
      [markos.chandras@imgtec.com:
      - Minor code re-arrangements in order for mappings to be made
      in the order they appear to the process' address space.
      - Move do_{monotonic, realtime} outside of the MIPS_CLOCK_VSYSCALL ifdef
      - Use gic_get_usm_range so we can do the GIC mapping in the
      arch/mips/kernel/vdso instead of the GIC irqchip driver]
      Signed-off-by: default avatarAlex Smith <alex.smith@imgtec.com>
      Signed-off-by: default avatarMarkos Chandras <markos.chandras@imgtec.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/11338/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      a7f4df4e
    • Alex Smith's avatar
      MIPS: Initial implementation of a VDSO · ebb5e78c
      Alex Smith authored
      Add an initial implementation of a proper (i.e. an ELF shared library)
      VDSO. With this commit it does not export any symbols, it only replaces
      the current signal return trampoline page. A later commit will add user
      implementations of gettimeofday()/clock_gettime().
      
      To support both new toolchains and old ones which don't generate ABI
      flags section, we define its content manually and then use a tool
      (genvdso) to patch up the section to have the correct name and type.
      genvdso also extracts symbol offsets ({,rt_}sigreturn) needed by the
      kernel, and generates a C file containing a "struct mips_vdso_image"
      containing both the VDSO data and these offsets. This C file is
      compiled into the kernel.
      
      On 64-bit kernels we require a different VDSO for each supported ABI,
      so we may build up to 3 different VDSOs. The VDSO to use is selected by
      the mips_abi structure.
      
      A kernel/user shared data page is created and mapped below the VDSO
      image. This is currently empty, but will be used by the user time
      function implementations which are added later.
      
      [markos.chandras@imgtec.com:
      - Add more comments
      - Move abi detection in genvdso.h since it's the get_symbol function
      that needs it.
      - Add an R6 specific way to calculate the base address of VDSO in order
      to avoid the branch instruction which affects performance.
      - Do not patch .gnu.attributes since it's not needed for dynamic linking.
      - Simplify Makefile a little bit.
      - checkpatch fixes
      - Restrict VDSO support for binutils < 2.25 for pre-R6
      - Include atomic64.h for O32 variant on MIPS64]
      Signed-off-by: default avatarAlex Smith <alex.smith@imgtec.com>
      Signed-off-by: default avatarMarkos Chandras <markos.chandras@imgtec.com>
      Cc: Matthew Fortune <matthew.fortune@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/11337/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      ebb5e78c