22 May, 2020

2 commits

  • This is a MIPS32 Release 5 based IP core with XPA, EVA, dual/quad issue
    exec pipes, MMU with two-levels TLB, UCA, MSA, MDU core level features
    and system level features like up to six P5600 calculation cores, CM2
    with L2 cache, IOCU/IOMMU (though might be unused depending on the
    system-specific IP core configuration), GIC, CPC, virtualisation module,
    eJTAG and PDtrace.

    As being MIPS32 Release 5 based core it provides all the features
    available by the CPU_MIPS32_R5 config, while adding a few more like
    UCA attribute support, availability of CPU-freq (by means of L2/CM
    clock ratio setting), EI/VI GIC modes detection at runtime.

    In addition to this if P5600 architecture is enabled modern GNU GCC
    provides a specific tuning for P5600 processors with respect to the
    classic MIPS32 Release 5. First of all branch-likely avoidance is
    activated only when the code is compiled with the speed optimization
    (avoidance is always enabled for the pure MIPS32 Release 5
    architecture). Secondly the madd/msub avoidance is enabled since
    madd/msub utilization isn't profitable due to overhead of getting the
    result out of the HI/LO registers. Multiply-accumulate instructions are
    activated and utilized together with the necessary code reorder when
    multiply-add/multiply-subtract statements are met. Finally load/store
    bonding is activated by default. All of these optimizations may make
    the code relatively faster than if just MIP32 release 5 architecture
    was requested.

    Co-developed-by: Alexey Malahov
    Signed-off-by: Alexey Malahov
    Signed-off-by: Serge Semin
    Cc: Thomas Bogendoerfer
    Cc: Paul Burton
    Cc: Ralf Baechle
    Cc: Arnd Bergmann
    Cc: Rob Herring
    Cc: devicetree@vger.kernel.org
    Signed-off-by: Thomas Bogendoerfer

    Serge Semin
     
  • There are five MIPS32/64 architecture releases currently available:
    from 1 to 6 except fourth one, which was intentionally skipped.
    Three of them can be called as major: 1st, 2nd and 6th, that not only
    have some system level alterations, but also introduced significant
    core/ISA level updates. The rest of the MIPS architecture releases are
    minor.

    Even though they don't have as much ISA/system/core level changes
    as the major ones with respect to the previous releases, they still
    provide a set of updates (I'd say they were intended to be the
    intermediate releases before a major one) that might be useful for the
    kernel and user-level code, when activated by the kernel or compiler.
    In particular the following features were introduced or ended up being
    available at/after MIPS32/64 Release 5 architecture:
    + the last release of the misaligned memory access instructions,
    + virtualisation - VZ ASE - is optional component of the arch,
    + SIMD - MSA ASE - is optional component of the arch,
    + DSP ASE is optional component of the arch,
    + CP0.Status.FR=1 for CP1.FIR.F64=1 (pure 64-bit FPU general registers)
    must be available if FPU is implemented,
    + CP1.FIR.Has2008 support is required so CP1.FCSR.{ABS2008,NAN2008} bits
    are available.
    + UFR/UNFR aliases to access CP0.Status.FR from user-space by means of
    ctc1/cfc1 instructions (enabled by CP0.Config5.UFR),
    + CP0.COnfig5.LLB=1 and eretnc instruction are implemented to without
    accidentally clearing LL-bit when returning from an interrupt,
    exception, or error trap,
    + XPA feature together with extended versions of CPx registers is
    introduced, which needs to have mfhc0/mthc0 instructions available.

    So due to these changes GNU GCC provides an extended instructions set
    support for MIPS32/64 Release 5 by default like eretnc/mfhc0/mthc0. Even
    though the architecture alteration isn't that big, it still worth to be
    taken into account by the kernel software. Finally we can't deny that
    some optimization/limitations might be found in future and implemented
    on some level in kernel or compiler. In this case having even
    intermediate MIPS architecture releases support would be more than
    useful.

    So the most of the changes provided by this commit can be split into
    either compile- or runtime configs related. The compile-time related
    changes are caused by adding the new CONFIG_CPU_MIPS32_R5/CONFIG_CPU_MIPSR5
    configs and concern the code activating MIPSR2 or MIPSR6 already
    implemented features (like eretnc/LLbit, mthc0/mfhc0). In addition
    CPU_HAS_MSA can be now freely enabled for MIPS32/64 release 5 based
    platforms as this is done for CPU_MIPS32_R6 CPUs. The runtime changes
    concerns the features which are handled with respect to the MIPS ISA
    revision detected at run-time by means of CP0.Config.{AT,AR} bits. Alas
    these fields can be used to detect either r1 or r2 or r6 releases.
    But since we know which CPUs in fact support the R5 arch, we can manually
    set MIPS_CPU_ISA_M32R5/MIPS_CPU_ISA_M64R5 bit of c->isa_level and then
    use cpu_has_mips32r5/cpu_has_mips64r5 where it's appropriate.

    Since XPA/EVA provide too complex alterationss and to have them used with
    MIPS32 Release 2 charged kernels (for compatibility with current platform
    configs) they are left to be setup as a separate kernel configs.

    Co-developed-by: Alexey Malahov
    Signed-off-by: Alexey Malahov
    Signed-off-by: Serge Semin
    Cc: Thomas Bogendoerfer
    Cc: Paul Burton
    Cc: Ralf Baechle
    Cc: Arnd Bergmann
    Cc: Rob Herring
    Cc: devicetree@vger.kernel.org
    Signed-off-by: Thomas Bogendoerfer

    Serge Semin
     

12 May, 2020

1 commit

  • This was all done to work around a GCC bug that has been fixed after
    4.2. The kernel requires GCC 4.6 or newer so remove all of these hacks
    and just use the traditional flags.

    $ mips64-linux-gcc --version | head -n1
    mips64-linux-gcc (GCC) 4.6.3

    $ mips64-linux-gcc -EB -dM -E -C -x c /dev/null | grep MIPSE
    #define MIPSEB 1
    #define __MIPSEB__ 1
    #define _MIPSEB 1
    #define __MIPSEB 1

    $ mips64-linux-gcc -EL -dM -E -C -x c /dev/null | grep MIPSE
    #define __MIPSEL__ 1
    #define MIPSEL 1
    #define _MIPSEL 1
    #define __MIPSEL 1

    This is necessary when converting the MIPS VDSO to use $(LD) instead of
    $(CC) to link because the OUTPUT_FORMAT is defaulted to little endian
    and only flips to big endian when '-EB' is set on the command line.
    There is no issue currently because the compiler explicitly passes
    '-EB' or '-EL' to the linker regardless of whether or not it was
    provided by the user. Passing '-v' to VDSO_LDFLAGS shows:

    /libexec/gcc/mips64-linux/9.3.0/collect2 ... -EB ...

    even though '-EB' is nowhere to be found in KBUILD_CFLAGS. The VDSO
    Makefile already supports getting '-EB' or '-EL' from KBUILD_CFLAGS
    through a filter directive but '-EB' or '-EL' is not always present.

    If we do not do this, we will see the following error when compiling
    for big endian:

    $ make -j$(nproc) ARCH=mips CROSS_COMPILE=mips64-linux- \
    64r2el_defconfig arch/mips/vdso/
    ...
    mips64-linux-ld: arch/mips/vdso/elf.o: compiled for a big endian system
    and target is little endian
    mips64-linux-ld: arch/mips/vdso/elf.o: endianness incompatible with that
    of the selected emulation
    mips64-linux-ld: failed to merge target specific data of file
    arch/mips/vdso/elf.o
    ...

    Remove this legacy hack and just use '-EB' and '-EL' unconditionally.

    Reported-by: Thomas Bogendoerfer
    Signed-off-by: Nathan Chancellor
    Signed-off-by: Thomas Bogendoerfer

    Nathan Chancellor
     

10 May, 2020

1 commit


07 May, 2020

1 commit

  • LLD failed to link vmlinux with 64bit load address for 32bit ELF
    while bfd will strip 64bit address into 32bit silently.
    To fix LLD build, we should truncate load address provided by platform
    into 32bit for 32bit kernel.

    Signed-off-by: Jiaxun Yang
    Link: https://github.com/ClangBuiltLinux/linux/issues/786
    Link: https://sourceware.org/bugzilla/show_bug.cgi?id=25784
    Reviewed-by: Fangrui Song
    Reviewed-by: Kees Cook
    Tested-by: Nathan Chancellor
    Cc: Maciej W. Rozycki
    Tested-by: Nick Desaulniers
    Signed-off-by: Thomas Bogendoerfer

    Jiaxun Yang
     

26 Nov, 2019

1 commit

  • Pull crypto updates from Herbert Xu:
    "API:
    - Add library interfaces of certain crypto algorithms for WireGuard
    - Remove the obsolete ablkcipher and blkcipher interfaces
    - Move add_early_randomness() out of rng_mutex

    Algorithms:
    - Add blake2b shash algorithm
    - Add blake2s shash algorithm
    - Add curve25519 kpp algorithm
    - Implement 4 way interleave in arm64/gcm-ce
    - Implement ciphertext stealing in powerpc/spe-xts
    - Add Eric Biggers's scalar accelerated ChaCha code for ARM
    - Add accelerated 32r2 code from Zinc for MIPS
    - Add OpenSSL/CRYPTOGRAMS poly1305 implementation for ARM and MIPS

    Drivers:
    - Fix entropy reading failures in ks-sa
    - Add support for sam9x60 in atmel
    - Add crypto accelerator for amlogic GXL
    - Add sun8i-ce Crypto Engine
    - Add sun8i-ss cryptographic offloader
    - Add a host of algorithms to inside-secure
    - Add NPCM RNG driver
    - add HiSilicon HPRE accelerator
    - Add HiSilicon TRNG driver"

    * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (285 commits)
    crypto: vmx - Avoid weird build failures
    crypto: lib/chacha20poly1305 - use chacha20_crypt()
    crypto: x86/chacha - only unregister algorithms if registered
    crypto: chacha_generic - remove unnecessary setkey() functions
    crypto: amlogic - enable working on big endian kernel
    crypto: sun8i-ce - enable working on big endian
    crypto: mips/chacha - select CRYPTO_SKCIPHER, not CRYPTO_BLKCIPHER
    hwrng: ks-sa - Enable COMPILE_TEST
    crypto: essiv - remove redundant null pointer check before kfree
    crypto: atmel-aes - Change data type for "lastc" buffer
    crypto: atmel-tdes - Set the IV after {en,de}crypt
    crypto: sun4i-ss - fix big endian issues
    crypto: sun4i-ss - hide the Invalid keylen message
    crypto: sun4i-ss - use crypto_ahash_digestsize
    crypto: sun4i-ss - remove dependency on not 64BIT
    crypto: sun4i-ss - Fix 64-bit size_t warnings on sun4i-ss-hash.c
    MAINTAINERS: Add maintainer for HiSilicon SEC V2 driver
    crypto: hisilicon - add DebugFS for HiSilicon SEC
    Documentation: add DebugFS doc for HiSilicon SEC
    crypto: hisilicon - add SRIOV for HiSilicon SEC
    ...

    Linus Torvalds
     

17 Nov, 2019

1 commit

  • This integrates the accelerated MIPS 32r2 implementation of ChaCha
    into both the API and library interfaces of the kernel crypto stack.

    The significance of this is that, in addition to becoming available
    as an accelerated library implementation, it can also be used by
    existing crypto API code such as Adiantum (for block encryption on
    ultra low performance cores) or IPsec using chacha20poly1305. These
    are use cases that have already opted into using the abstract crypto
    API. In order to support Adiantum, the core assembler routine has
    been adapted to take the round count as a function argument rather
    than hardcoding it to 20.

    Co-developed-by: René van Dorst
    Signed-off-by: René van Dorst
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     

08 Oct, 2019

1 commit

  • When Loongson3 LL/SC errata workarounds are enabled (ie.
    CONFIG_CPU_LOONGSON3_WORKAROUNDS=y) run a tool to scan through the
    compiled kernel & ensure that the workaround is applied correctly. That
    is, ensure that:

    - Every LL or LLD instruction is preceded by a sync instruction.

    - Any branches from within an LL/SC loop to outside of that loop
    target a sync instruction.

    Reasoning for these conditions can be found by reading the comment above
    the definition of __SYNC_loongson3_war in arch/mips/include/asm/sync.h.

    This tool will help ensure that we don't inadvertently introduce code
    paths that miss the required workarounds.

    Signed-off-by: Paul Burton
    Cc: linux-mips@vger.kernel.org
    Cc: Huacai Chen
    Cc: Jiaxun Yang
    Cc: linux-kernel@vger.kernel.org

    Paul Burton
     

24 Jul, 2019

3 commits


21 Jun, 2019

1 commit

  • scripts/package/builddeb calls "make dtbs_install" after executing
    a plain make (i.e. no build targets specified). It will fail if dtbs
    were not built beforehand. Match the arm64 architecture where DTBs get
    built by the "all" target.

    Signed-off-by: Cedric Hombourger
    [paul.burton@mips.com: s/builddep/builddeb]
    Signed-off-by: Paul Burton
    Cc: linux-mips@vger.kernel.org
    Cc: stable@vger.kernel.org # v4.1+

    Cedric Hombourger
     

05 Feb, 2019

1 commit

  • Add a family of ginvt_* functions making it easy to emit a GINVT
    instruction to globally invalidate TLB entries. We make use of the
    _ASM_MACRO infrastructure to support emitting the instructions even if
    the assembler isn't new enough to support them natively.

    An associated STYPE_GINV definition & sync_ginv() function are added to
    emit a sync instruction of type 0x14, which operates as a completion
    barrier for these new GINVT (and GINVI) instructions.

    Signed-off-by: Paul Burton
    Cc: linux-mips@vger.kernel.org

    Paul Burton
     

15 Dec, 2018

1 commit

  • System call table generation script must be run to gener-
    ate unistd_(nr_)n64/n32/o32.h and syscall_table_32_o32/
    64_n64/64_n32/64-o32.h files. This patch will have changes
    which will invokes the script.

    This patch will generate unistd_(nr_)n64/n32/o32.h and
    syscall_table_32_o32/64_n64/64-n32/64-o32.h files by the
    syscall table generation script invoked by parisc/Make-
    file and the generated files against the removed files
    must be identical.

    The generated uapi header file will be included in uapi/-
    asm/unistd.h and generated system call table header file
    will be included by kernel/scall32-o32/64-n64/64-n32/-
    64-o32.Sfile.

    Signed-off-by: Firoz Khan
    Signed-off-by: Paul Burton
    Cc: linux-mips@vger.kernel.org
    Cc: Ralf Baechle
    Cc: James Hogan
    Cc: Greg Kroah-Hartman
    Cc: Philippe Ombredanne
    Cc: Thomas Gleixner
    Cc: Kate Stewart
    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

    Firoz Khan
     

10 Nov, 2018

1 commit

  • When CONFIG_MIPS_FP_SUPPORT=n we don't support floating point, so
    there's no point compiling in our FPU emulator. Avoid doing so,
    providing stub versions of dsemul cleanup functions that are called from
    signal & task handling code.

    Signed-off-by: Paul Burton
    Patchwork: https://patchwork.linux-mips.org/patch/21012/
    Cc: linux-mips@linux-mips.org

    Paul Burton
     

02 Nov, 2018

1 commit

  • Evaluating cc-name invokes the compiler every time even when you are
    not compiling anything, like 'make help'. This is not efficient.

    The compiler type has been already detected in the Kconfig stage.
    Use CONFIG_CC_IS_CLANG, instead.

    Signed-off-by: Masahiro Yamada
    Acked-by: Michael Ellerman (powerpc)
    Acked-by: Paul Burton (MIPS)
    Acked-by: Joel Stanley

    Masahiro Yamada
     

27 Oct, 2018

1 commit

  • Pull MIPS updates from Paul Burton:

    - kexec support for the generic MIPS platform when running on a CPU
    including the MIPS Coherence Manager & related hardware.

    - Improvements to the definition of memory barriers used around MMIO
    accesses, and fixes in their use.

    - Switch to CONFIG_NO_BOOTMEM from Mike Rapoport, finally dropping
    reliance on the old bootmem code.

    - A number of fixes & improvements for Loongson 3 systems.

    - DT & config updates for the Microsemi Ocelot platform.

    - Workaround to enable USB power on the Netgear WNDR3400v3.

    - Various cleanups & fixes.

    * tag 'mips_4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: (51 commits)
    MIPS: Cleanup DSP ASE detection
    MIPS: dts: Change upper case to lower case
    MIPS: generic: Add Network, SPI and I2C to ocelot_defconfig
    MIPS: Loongson-3: Fix BRIDGE irq delivery problem
    MIPS: Loongson-3: Fix CPU UART irq delivery problem
    MIPS: Remove unused PREF, PREFE & PREFX macros
    MIPS: lib: Use kernel_pref & user_pref in memcpy()
    MIPS: Remove unused CAT macro
    MIPS: Add kernel_pref & user_pref helpers
    MIPS: Remove unused TTABLE macro
    MIPS: Remove unused PIC macros
    MIPS: Remove unused MOVN & MOVZ macros
    MIPS: Provide actually relaxed MMIO accessors
    MIPS: Enforce strong ordering for MMIO accessors
    MIPS: Correct `mmiowb' barrier for `wbflush' platforms
    MIPS: Define MMIO ordering barriers
    MIPS: mscc: add PCB120 to the ocelot fitImage
    MIPS: mscc: add DT for Ocelot PCB120
    MIPS: memset: Limit excessive `noreorder' assembly mode use
    MIPS: memset: Fix CPU_DADDI_WORKAROUNDS `small_fixup' regression
    ...

    Linus Torvalds
     

17 Oct, 2018

1 commit

  • Currently we hardcode a list of files for which we specify that the
    toolchain has DSP ASE support when building for MIPSr2 only. This has a
    number of problems:

    1) It doesn't actually ensure that the toolchain supports the DSP ASE
    at all.

    2) It's fragile if we try to use DSP ASE macros in other files.

    3) It makes no provision for MIPSr6 & later systems which also support
    the DSP ASE & end up using the .word directive implementation of
    the DSP macros.

    Fix this by detecting assembler support for the DSP ASE globally, not
    just for a small set of files, and not just for MIPSr2. This now exposes
    use of toolchain DSP support to kernel builds targeting MIPSr1 and
    older, so we add .set MIPS_ISA_LEVEL directives prior to all .set dsp
    directives in order to prevent the assembler from complaining that the
    DSP ASE is only supported with MIPSr2 & higher.

    Signed-off-by: Paul Burton
    Patchwork: https://patchwork.linux-mips.org/patch/20901/
    Cc: linux-mips@linux-mips.org

    Paul Burton
     

02 Oct, 2018

1 commit

  • There is nothing arch specific about building dtb files other than their
    location under /arch/*/boot/dts/. Keeping each arch aligned is a pain.
    The dependencies and supported targets are all slightly different.
    Also, a cross-compiler for each arch is needed, but really the host
    compiler preprocessor is perfectly fine for building dtbs. Move the
    build rules to a common location and remove the arch specific ones. This
    is done in a single step to avoid warnings about overriding rules.

    The build dependencies had been a mixture of 'scripts' and/or 'prepare'.
    These pull in several dependencies some of which need a target compiler
    (specifically devicetable-offsets.h) and aren't needed to build dtbs.
    All that is really needed is dtc, so adjust the dependencies to only be
    dtc.

    This change enables support 'dtbs_install' on some arches which were
    missing the target.

    Acked-by: Will Deacon
    Acked-by: Paul Burton
    Acked-by: Ley Foon Tan
    Acked-by: Masahiro Yamada
    Cc: Michal Marek
    Cc: Vineet Gupta
    Cc: Russell King
    Cc: Catalin Marinas
    Cc: Yoshinori Sato
    Cc: Michal Simek
    Cc: Ralf Baechle
    Cc: James Hogan
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: Michael Ellerman
    Cc: Chris Zankel
    Cc: Max Filippov
    Cc: linux-kbuild@vger.kernel.org
    Cc: linux-snps-arc@lists.infradead.org
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: uclinux-h8-devel@lists.sourceforge.jp
    Cc: linux-mips@linux-mips.org
    Cc: nios2-dev@lists.rocketboards.org
    Cc: linuxppc-dev@lists.ozlabs.org
    Cc: linux-xtensa@linux-xtensa.org
    Signed-off-by: Rob Herring

    Rob Herring
     

31 Aug, 2018

1 commit

  • For a long time arch/mips/Makefile used nm to discover the kernel entry
    point by looking for the address of the kernel_entry symbol. This
    doesn't work for systems which make use of bit 0 of the PC to reflect
    the ISA mode - ie. microMIPS (and MIPS16, but we don't support building
    kernels that target MIPS16 anyway).

    So for a while with commit 5fc9484f5e41 ("MIPS: Set ISA bit in entry-y
    for microMIPS kernels") we manually modified the last nibble of the
    output from nm, which worked but wasn't particularly pretty.

    Commit 27c524d17430 ("MIPS: Use the entry point from the ELF file
    header") then cleaned this up by using objdump to print the ELF entry
    point which includes the ISA bit, rather than using nm to print the
    address of the kernel_entry symbol which doesn't. That removed the ugly
    replacement of the last nibble, but added its own ugliness by needing to
    manually sign extend in the 32 bit case.

    Unfortunately it has been pointed out that objdump's output is
    localised, and therefore grepping for its "start address" output doesn't
    work when the user's language settings are such that objdump doesn't
    print in English.

    We could simply revert commit 27c524d17430 ("MIPS: Use the entry point
    from the ELF file header") and return to the manual replacement of the
    last nibble of entry-y, but it seems that was found sufficiently
    unpalatable to avoid. We could attempt to force the language used by
    objdump by setting an environment variable such as LC_ALL, but that
    seems fragile. Instead we add a small tool named elf-entry which simply
    prints out the entry point of the kernel in the format we require.

    Signed-off-by: Paul Burton
    Reported-by: Philippe Reynes
    Tested-by: Philippe Reynes
    Fixes: 27c524d17430 ("MIPS: Use the entry point from the ELF file header")
    Patchwork: https://patchwork.linux-mips.org/patch/20322/
    Cc: James Hogan
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org

    Paul Burton
     

24 Aug, 2018

1 commit

  • Commit a0f97e06a43c ("kbuild: enable 'make CFLAGS=...' to add
    additional options to CC") renamed CFLAGS to KBUILD_CFLAGS.

    Commit 222d394d30e7 ("kbuild: enable 'make AFLAGS=...' to add
    additional options to AS") renamed AFLAGS to KBUILD_AFLAGS.

    Commit 06c5040cdb13 ("kbuild: enable 'make CPPFLAGS=...' to add
    additional options to CPP") renamed CPPFLAGS to KBUILD_CPPFLAGS.

    For some reason, LDFLAGS was not renamed.

    Using a well-known variable like LDFLAGS may result in accidental
    override of the variable.

    Kbuild generally uses KBUILD_ prefixed variables for the internally
    appended options, so here is one more conversion to sanitize the
    naming convention.

    I did not touch Makefiles under tools/ since the tools build system
    is a different world.

    Signed-off-by: Masahiro Yamada
    Acked-by: Kirill A. Shutemov
    Reviewed-by: Palmer Dabbelt

    Masahiro Yamada
     

08 Aug, 2018

1 commit

  • When building using clang, always specify -EB or -EL in order to ensure
    we target the desired endianness.

    Since clang cross compiles using a single compiler build with multiple
    targets, our -dumpmachine tests which don't specify clang's --target
    argument check output based upon the build machine rather than the
    machine our build will target. This means our detection of whether to
    specify -EB fails miserably & we never do. Providing the endianness flag
    unconditionally for clang resolves this issue & simplifies the clang
    path somewhat.

    Signed-off-by: Paul Burton

    Paul Burton
     

29 Jun, 2018

1 commit

  • The VDSO Makefile filters CFLAGS to select a subset which it uses whilst
    building the VDSO ELF. One of the flags it allows through is the -march=
    flag that selects the architecture/ISA to target.

    Unfortunately in cases where CONFIG_CPU_MIPS32_R{1,2}=y and the
    toolchain defaults to building for MIPS64, the main MIPS Makefile ends
    up using the short-form - flags in cflags-y. This is because the
    calls to cc-option always fail to use the long-form -march= flag
    due to the lack of an -mabi= flag in KBUILD_CFLAGS at the point
    where the cc-option function is executed. The resulting GCC invocation
    is something like:

    $ mips64-linux-gcc -Werror -march=mips32r2 -c -x c /dev/null -o tmp
    cc1: error: '-march=mips32r2' is not compatible with the selected ABI

    These short-form - flags are dropped by the VDSO Makefile's
    filtering, and so we attempt to build the VDSO without specifying any
    architecture. This results in an attempt to build the VDSO using
    whatever the compiler's default architecture is, regardless of whether
    that is suitable for the kernel configuration.

    One encountered build failure resulting from this mismatch is a
    rejection of the sync instruction if the kernel is configured for a
    MIPS32 or MIPS64 r1 or r2 target but the toolchain defaults to an older
    architecture revision such as MIPS1 which did not include the sync
    instruction:

    CC arch/mips/vdso/gettimeofday.o
    /tmp/ccGQKoOj.s: Assembler messages:
    /tmp/ccGQKoOj.s:273: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:329: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:520: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:714: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:1009: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:1066: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:1114: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:1279: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:1334: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:1374: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:1459: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:1514: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:1814: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:2002: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    /tmp/ccGQKoOj.s:2066: Error: opcode not supported on this processor: mips1 (mips1) `sync'
    make[2]: *** [scripts/Makefile.build:318: arch/mips/vdso/gettimeofday.o] Error 1
    make[1]: *** [scripts/Makefile.build:558: arch/mips/vdso] Error 2
    make[1]: *** Waiting for unfinished jobs....

    This can be reproduced for example by attempting to build
    pistachio_defconfig using Arnd's GCC 8.1.0 mips64 toolchain from
    kernel.org:

    https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/8.1.0/x86_64-gcc-8.1.0-nolibc-mips64-linux.tar.xz

    Resolve this problem by using the long-form -march= in all cases,
    which makes it through the arch/mips/vdso/Makefile's filtering & is thus
    consistently used to build both the kernel proper & the VDSO.

    The use of cc-option to prefer the long-form & fall back to the
    short-form flags makes no sense since the short-form is just an
    abbreviation for the also-supported long-form in all GCC versions that
    we support building with. This means there is no case in which we have
    to use the short-form - flags, so we can simply remove them.

    The manual redefinition of _MIPS_ISA is removed naturally along with the
    use of the short-form flags that it accompanied, and whilst here we
    remove the separate assembler ISA selection. I suspect that both of
    these were only required due to the mips32 vs mips2 mismatch that was
    introduced by commit 59b3e8e9aac6 ("[MIPS] Makefile crapectomy.") and
    fixed but not cleaned up by commit 9200c0b2a07c ("[MIPS] Fix Makefile
    bugs for MIPS32/MIPS64 R1 and R2.").

    I've marked this for backport as far as v4.4 where the MIPS VDSO was
    introduced. In earlier kernels there should be no ill effect to using
    the short-form flags.

    Signed-off-by: Paul Burton
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Cc: stable@vger.kernel.org # v4.4+
    Reviewed-by: James Hogan
    Patchwork: https://patchwork.linux-mips.org/patch/19579/

    Paul Burton
     

01 Jun, 2018

1 commit

  • By default, sparse assumes a 64bit machine when compiled on x86-64
    and 32bit when compiled on anything else.

    This can of course create all sort of problems for the other archs, like
    issuing false warnings ('shift too big (32) for type unsigned long'), or
    worse, failing to emit legitimate warnings.

    Fix this by adding the -m32/-m64 flag, depending on CONFIG_64BIT,
    to CHECKFLAGS in the main Makefile (and so for all archs).
    Also, remove the now unneeded -m32/-m64 in arch specific Makefiles.

    Signed-off-by: Luc Van Oostenryck
    Signed-off-by: Masahiro Yamada

    Luc Van Oostenryck
     

23 Mar, 2018

1 commit

  • In order to fetch the correct entry point with the ISA bit included, for
    use by non-ELF boot loaders, parse the output of `objdump -f' for the
    start address recorded in the kernel executable itself, rather than
    using `nm' to get the value of the `kernel_entry' symbol.

    Sign-extend the address retrieved if 32-bit, so that execution is
    correctly started on 64-bit processors as well. The tool always prints
    the entry point using either 8 or 16 hexadecimal digits, matching the
    address width (aka class) of the ELF file, even in the presence of
    leading zeros.

    Signed-off-by: Maciej W. Rozycki
    Cc: Ralf Baechle
    Cc: Paul Burton
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/18912/
    Signed-off-by: James Hogan

    Maciej W. Rozycki
     

22 Mar, 2018

1 commit

  • Introduce support for the MIPS based Microsemi Ocelot SoCs.

    Signed-off-by: Alexandre Belloni
    Cc: Ralf Baechle
    Cc: Allan Nielsen
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/18858/
    [jhogan@kernel.org: update ocelot_defconfig specification]
    Signed-off-by: James Hogan

    Alexandre Belloni
     

05 Mar, 2018

1 commit

  • Expand the MIPS Makefile help text to list generic board names, generic
    defconfigs, and legacy defconfigs which have been converted to generic
    and are still usable.

    Here's a snippet of the new "make ARCH=mips help" output:
    ...
    If you are targeting a system supported by generic kernels you may
    configure the kernel for a given architecture target like so:

    {micro32,32,64}{r1,r2,r6}{el,}_defconfig

    Where BOARDS is some subset of the following:
    boston
    ni169445
    ranchu
    sead-3
    xilfpga

    Specifically the following generic default configurations are
    supported:

    32r1_defconfig - Build generic kernel for MIPS32 r1
    32r1el_defconfig - Build generic kernel for MIPS32 r1 little endian
    32r2_defconfig - Build generic kernel for MIPS32 r2
    32r2el_defconfig - Build generic kernel for MIPS32 r2 little endian
    32r6_defconfig - Build generic kernel for MIPS32 r6
    32r6el_defconfig - Build generic kernel for MIPS32 r6 little endian
    64r1_defconfig - Build generic kernel for MIPS64 r1
    64r1el_defconfig - Build generic kernel for MIPS64 r1 little endian
    64r2_defconfig - Build generic kernel for MIPS64 r2
    64r2el_defconfig - Build generic kernel for MIPS64 r2 little endian
    64r6_defconfig - Build generic kernel for MIPS64 r6
    64r6el_defconfig - Build generic kernel for MIPS64 r6 little endian
    micro32r2_defconfig - Build generic kernel for microMIPS32 r2
    micro32r2el_defconfig - Build generic kernel for microMIPS32 r2 little endian

    The following legacy default configurations have been converted to
    generic and can still be used:

    sead3_defconfig - Build 32r2el_defconfig BOARDS=sead-3
    sead3micro_defconfig - Build micro32r2el_defconfig BOARDS=sead-3
    xilfpga_defconfig - Build 32r2el_defconfig BOARDS=xilfpga
    ...

    Signed-off-by: James Hogan
    Cc: Ralf Baechle
    Cc: Paul Burton
    Cc: Matt Redfearn
    Cc: linux-mips@linux-mips.org
    Cc: linux-kbuild@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/18598/

    James Hogan
     

20 Feb, 2018

2 commits

  • Define legacy defconfigs which have been converted to the generic
    platform more programatically, so that they can be listed in the
    Makefile help text and as a separate Makefile target without
    duplication.

    Signed-off-by: James Hogan
    Cc: Ralf Baechle
    Cc: Paul Burton
    Cc: Matt Redfearn
    Cc: linux-mips@linux-mips.org
    Cc: linux-kbuild@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/18596/

    James Hogan
     
  • This module registers crc32 and crc32c algorithms that use the
    optional CRC32[bhwd] and CRC32C[bhwd] instructions in MIPSr6 cores.

    Signed-off-by: Marcin Nowakowski
    Signed-off-by: James Hogan
    Cc: Ralf Baechle
    Cc: "David S. Miller"
    Cc: linux-mips@linux-mips.org
    Cc: linux-crypto@vger.kernel.org
    Acked-by: Herbert Xu
    Patchwork: https://patchwork.linux-mips.org/patch/18601/
    [jhogan@kernel.org: Add CRYPTO_ALG_OPTIONAL_KEY flag on Eric Biggers'
    suggestion, due to commit a208fa8f3303 ("crypto: hash - annotate
    algorithms taking optional key") in v4.16-rc1]

    Marcin Nowakowski
     

23 Jan, 2018

1 commit

  • Utilise XPA instructions MFHC0 & MTHC0 in inline assembly instead of
    directly encoding them with the _ASM_INSN* macros, and transparently
    implement these instructions as assembler macros if the toolchain
    doesn't support them natively, using the recently introduced assembler
    macro helpers.

    The old direct encodings were restricted to using the register $at, so
    this allows the extra register moves to go away (saving a grand total of
    24 bytes).

    Signed-off-by: James Hogan
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/17775/

    James Hogan
     

19 Jan, 2018

1 commit

  • vmlinuz is not built by default for platforms using
    COMPRESSION_FNAME (e.g. Malta) due to an erroneous
    check on ZBOOT

    Signed-off-by: Daniel Sabogal
    Reviewed-by: James Hogan
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/18466/
    Signed-off-by: James Hogan

    Daniel Sabogal
     

09 Nov, 2017

2 commits

  • Use the generic platform code and remove arch/mips/xilfpga

    Signed-off-by: Zubair Lutfullah Kakakhel
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/15847/
    [jhogan@kernel.org: Update arch/mips/Makefile snippet and move to end]
    Signed-off-by: James Hogan

    Zubair Lutfullah Kakakhel
     
  • The default system type should be a MIPS generic kernel. In order to
    include some level of board support, select a 32r2el generic defconfig
    by default. The alternative would be to use "generic_defconfig" but
    rather unintuitvely that is a bare bones configuration with no platform
    support so is not usable in practice.

    Signed-off-by: Matt Redfearn
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14715/
    Signed-off-by: James Hogan

    Matt Redfearn
     

06 Sep, 2017

1 commit

  • This will allow kdump dumps to work correclty with MIPS and
    future DWARF unwinding of the stack to give accurate tracebacks.

    Signed-off-by: Corey Minyard
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/16990/
    Signed-off-by: Ralf Baechle

    Corey Minyard
     

30 Aug, 2017

2 commits

  • Using generic_defconfig directly is unlikely to be what a user actually
    wants to do - it doesn't specify any particular ISA revision & it
    doesn't enable any board or driver support, resulting in a largely
    useless kernel.

    Prevent users from using it directly, printing a helpful message to
    point them in the right direction if they attempt to.

    Signed-off-by: Paul Burton
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/16946/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Up until now when configuring a generic kernel all board config
    fragments have been merged by default unless boards are explicitly
    selected by the user specifying BOARDS=.

    In many cases this is sub-optimal, since some boards don't make sense to
    include in some kernels. For example the MIPS SEAD-3 development board
    has only ever been used with 32 bit CPUs, so including support for the
    SEAD-3 in a 64 bit kernel is wasteful.

    This patch introduces support for specifying requirements in board
    config fragments, using comments formatted like so:

    # require CONFIG_BLA=y

    For example the SEAD-3 board could specify that it should only be merged
    for 32 bit kernels using a requirement line like the following:

    # require CONFIG_32BIT=y

    A new generic-board-config.sh script is introduced to handle selecting
    the board config fragments to merge & calling merge_config.sh to merge
    them. In order to allow requirements to check Kconfig symbols that are
    implicitly selected, rather than explicitly specified by
    generic_defconfig or one of the ISA config fragments, an intermediate
    .config file is saved & used as a reference when checking requirements.

    Signed-off-by: Paul Burton
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/16943/
    Signed-off-by: Ralf Baechle

    Paul Burton
     

29 Aug, 2017

2 commits

  • In preparation for splitting arch/mips/generic/vmlinux.its.S into
    multiple files such that it doesn't become a conflict magnet as boards
    are added, allow platforms to specify a list of image tree source files
    which will be concatenated to form the final source used to build the
    image tree.

    Signed-off-by: Paul Burton
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/16938/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • The kernel contains a small amount of incomplete code aimed at
    supporting old R6000 CPUs. This is:

    - Unused, as no machine selects CONFIG_SYS_HAS_CPU_R6000.

    - Broken, since there are glaring errors such as r6000_fpu.S moving
    the FCSR register to t1, then ignoring it & instead saving t0 into
    struct sigcontext...

    - A maintenance headache, since it's code that nobody can test which
    nevertheless imposes constraints on code which it shares with other
    machines.

    Remove this incomplete & broken R6000 CPU support in order to clean up
    and in preparation for changes which will no longer need to consider
    dragging the pretense of R6000 support along with them.

    Signed-off-by: Paul Burton
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/16236/
    Signed-off-by: Ralf Baechle

    Paul Burton
     

08 Aug, 2017

1 commit

  • When building a kernel for the microMIPS ISA, ensure that the ISA bit
    (ie. bit 0) in the entry address is set. Otherwise we may include an
    entry address in images which bootloaders will jump to as MIPS32 code.

    I originally tried using "objdump -f" to obtain the entry address, which
    works for microMIPS but it always outputs a 32 bit address for a 32 bit
    ELF whilst nm will sign extend to 64 bit. That matters for systems where
    we might want to run a MIPS32 kernel on a MIPS64 CPU & load it with a
    MIPS64 bootloader, which would then jump to a non-canonical
    (non-sign-extended) address.

    This works in all cases as it only changes the behaviour for microMIPS
    kernels, but isn't the prettiest solution. A possible alternative would
    be to write a custom tool to just extract, sign extend & print the entry
    point of an ELF executable. I'm open to feedback if that would be
    preferred.

    Signed-off-by: Paul Burton
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/16950/
    Signed-off-by: Ralf Baechle

    Paul Burton
     

29 Jun, 2017

1 commit

  • Add "-modd-spreg" when compiling the kernel for mips32r6 target.

    This makes sure the kernel builds properly even with toolchains that
    use "-mno-odd-spreg" by default. This is the case with Android gcc.
    Prior to this patch, kernel builds using gcc for Android failed with
    following error messages, if target architecture is set to mips32r6:

    arch/mips/kernel/r4k_switch.S: Assembler messages:
    .../r4k_switch.S:210: Error: float register should be even, was 1
    .../r4k_switch.S:212: Error: float register should be even, was 3
    .../r4k_switch.S:214: Error: float register should be even, was 5
    .../r4k_switch.S:216: Error: float register should be even, was 7
    .../r4k_switch.S:218: Error: float register should be even, was 9
    .../r4k_switch.S:220: Error: float register should be even, was 11
    .../r4k_switch.S:222: Error: float register should be even, was 13
    .../r4k_switch.S:224: Error: float register should be even, was 15
    .../r4k_switch.S:226: Error: float register should be even, was 17
    .../r4k_switch.S:228: Error: float register should be even, was 19
    .../r4k_switch.S:230: Error: float register should be even, was 21
    .../r4k_switch.S:232: Error: float register should be even, was 23
    .../r4k_switch.S:234: Error: float register should be even, was 25
    .../r4k_switch.S:236: Error: float register should be even, was 27
    .../r4k_switch.S:238: Error: float register should be even, was 29
    .../r4k_switch.S:240: Error: float register should be even, was 31
    make[2]: *** [arch/mips/kernel/r4k_switch.o] Error 1

    Signed-off-by: Miodrag Dinic
    Signed-off-by: Goran Ferenc
    Signed-off-by: Aleksandar Markovic
    Cc: James.Hogan@imgtec.com
    Cc: Paul.Burton@imgtec.com
    Cc: Raghu.Gandham@imgtec.com
    Cc: Leonid.Yegoshin@imgtec.com
    Cc: Douglas.Leung@imgtec.com
    Cc: Petar.Jovanovic@imgtec.com
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/16509/
    Signed-off-by: Ralf Baechle

    Miodrag Dinic