1. Aug 22, 2019
    • Masahiro Yamada's avatar
      arm64: add arch/arm64/Kbuild · 6bfa3134
      Masahiro Yamada authored
      
      
      Use the standard obj-y form to specify the sub-directories under
      arch/arm64/. No functional change intended.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      6bfa3134
    • James Morse's avatar
      arm64: entry: Move ct_user_exit before any other exception · 2671828c
      James Morse authored
      When taking an SError or Debug exception from EL0, we run the C
      handler for these exceptions before updating the context tracking
      code and unmasking lower priority interrupts.
      
      When booting with nohz_full lockdep tells us we got this wrong:
      | =============================
      | WARNING: suspicious RCU usage
      | 5.3.0-rc2-00010-gb4b5e9dcb11b-dirty #11271 Not tainted
      | -----------------------------
      | include/linux/rcupdate.h:643 rcu_read_unlock() used illegally wh!
      |
      | other info that might help us debug this:
      |
      |
      | RCU used illegally from idle CPU!
      | rcu_scheduler_active = 2, debug_locks = 1
      | RCU used illegally from extended quiescent state!
      | 1 lock held by a.out/432:
      |  #0: 00000000c7a79515 (rcu_read_lock){....}, at: brk_handler+0x00
      |
      | stack backtrace:
      | CPU: 1 PID: 432 Comm: a.out Not tainted 5.3.0-rc2-00010-gb4b5e9d1
      | Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno De8
      | Call trace:
      |  dump_backtrace+0x0/0x140
      |  show_stack+0x14/0x20
      |  dump_stack+0xbc/0x104
      |  lockdep_rcu_suspicious+0xf8/0x108
      |  brk_handler+0x164/0x1b0
      |  do_debug_exception+0x11c/0x278
      |  el0_dbg+0x14/0x20
      
      Moving the ct_user_exit calls to be before do_debug_exception() means
      they are also before trace_hardirqs_off() has been updated. Add a new
      ct_user_exit_irqoff macro to avoid the context-tracking code using
      irqsave/restore before we've updated trace_hardirqs_off(). To be
      consistent, do this everywhere.
      
      The C helper is called enter_from_user_mode() to match x86 in the hope
      we can merge them into kernel/context_tracking.c later.
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Fixes: 6c81fe79
      
       ("arm64: enable context tracking")
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      2671828c
  2. Aug 20, 2019
    • Will Deacon's avatar
      Revert "init/Kconfig: Fix infinite Kconfig recursion on PPC" · 2d122942
      Will Deacon authored
      This reverts commit 71c67a31.
      
      Commit 117acf5c
      
       ("powerpc/Makefile: Always pass --synthetic to nm if
      supported") removed the only conditional definition of $(NM), so we can
      revert our temporary bodge to avoid Kconfig recursion and go back to
      passing $(NM) through to the 'tools-support-relr.sh' when detecting
      support for RELR relocations.
      
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      2d122942
    • Michael Ellerman's avatar
      powerpc/Makefile: Always pass --synthetic to nm if supported · 117acf5c
      Michael Ellerman authored
      
      
      Back in 2004 we added logic to arch/ppc64/Makefile to pass
      the --synthetic option to nm, if it was supported by nm.
      
      Then in 2005 when arch/ppc64 and arch/ppc were merged, the logic to
      add --synthetic was moved inside an #ifdef CONFIG_PPC64 block within
      arch/powerpc/Makefile, and has remained there since.
      
      That was fine, though crufty, until recently when a change to
      init/Kconfig added a config time check that uses $(NM). On powerpc
      that leads to an infinite loop because Kconfig uses $(NM) to calculate
      some values, then the powerpc Makefile changes $(NM), which Kconfig
      notices and restarts.
      
      The original commit that added --synthetic simply said:
        On new toolchains we need to use nm --synthetic or we miss code
        symbols.
      
      And the nm man page says that the --synthetic option causes nm to:
        Include synthetic symbols in the output. These are special symbols
        created by the linker for various purposes.
      
      So it seems safe to always pass --synthetic if nm supports it, ie. on
      32-bit and 64-bit, it just means 32-bit kernels might have more
      symbols reported (and in practice I see no extra symbols). Making it
      unconditional avoids the #ifdef CONFIG_PPC64, which in turn avoids the
      infinite loop.
      
      Debugged-by: default avatarPeter Collingbourne <pcc@google.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      117acf5c
  3. Aug 15, 2019
    • Christoph Hellwig's avatar
      arm64: unexport set_memory_x and set_memory_nx · d225bb8d
      Christoph Hellwig authored
      
      
      No module currently messed with clearing or setting the execute
      permission of kernel memory, and none really should.
      
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      d225bb8d
    • Kees Cook's avatar
      arm64/efi: Move variable assignments after SECTIONS · 90776dd1
      Kees Cook authored
      It seems that LLVM's linker does not correctly handle variable assignments
      involving section positions that are updated during the SECTIONS
      parsing. Commit aa69fb62 ("arm64/efi: Mark __efistub_stext_offset as
      an absolute symbol explicitly") ran into this too, but found a different
      workaround.
      
      However, this was not enough, as other variables were also miscalculated
      which manifested as boot failures under UEFI where __efistub__end was
      not taking the correct _end value (they should be the same):
      
      $ ld.lld -EL -maarch64elf --no-undefined -X -shared \
      	-Bsymbolic -z notext -z norelro --no-apply-dynamic-relocs \
      	-o vmlinux.lld -T poc.lds --whole-archive vmlinux.o && \
        readelf -Ws vmlinux.lld | egrep '\b(__efistub_|)_end\b'
      368272: ffff000002218000     0 NOTYPE  LOCAL  HIDDEN    38 __efistub__end
      368322: ffff000012318000     0 NOTYPE  GLOBAL DEFAULT   38 _end
      
      $ aarch64-linux-gnu-ld.bfd -EL -maarch64elf --no-undefined -X -shared \
      	-Bsymbolic -z notext -z norelro --no-apply-dynamic-relocs \
      	-o vmlinux.bfd -T poc.lds --whole-archive vmlinux.o && \
        readelf -Ws vmlinux.bfd | egrep '\b(__efistub_|)_end\b'
      338124: ffff000012318000     0 NOTYPE  LOCAL  DEFAULT  ABS __efistub__end
      383812: ffff000012318000     0 NOTYPE  GLOBAL DEFAULT 15325 _end
      
      To work around this, all of the __efistub_-prefixed variable assignments
      need to be moved after the linker script's SECTIONS entry. As it turns
      out, this also solves the problem fixed in commit aa69fb62, so those
      changes are reverted here.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/634
      Link: https://bugs.llvm.org/show_bug.cgi?id=42990
      
      
      Acked-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      90776dd1
    • Mark Brown's avatar
      arm64: Clarify when cpu_enable() is called · 38d16667
      Mark Brown authored
      
      
      Strengthen the wording in the documentation for cpu_enable() to make it
      more obvious to readers not already familiar with the code when the core
      will call this callback and that this is intentional.
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      [will: minor tweak to emphasis in the comment]
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      38d16667
  4. Aug 14, 2019
  5. Aug 07, 2019
    • Julien Grall's avatar
      arm64/ptrace: Fix typoes in sve_set() comment · 08f103b9
      Julien Grall authored
      
      
      The ptrace trace SVE flags are prefixed with SVE_PT_*. Update the
      comment accordingly.
      
      Reviewed-by: default avatarDave Martin <Dave.Martin@arm.com>
      Signed-off-by: default avatarJulien Grall <julien.grall@arm.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      08f103b9
    • Miles Chen's avatar
      arm64: mm: print hexadecimal EC value in mem_abort_decode() · 2951d5ef
      Miles Chen authored
      This change prints the hexadecimal EC value in mem_abort_decode(),
      which makes it easier to lookup the corresponding EC in
      the ARM Architecture Reference Manual.
      
      The commit 1f9b8936
      
       ("arm64: Decode information from ESR upon mem
      faults") prints useful information when memory abort occurs. It would
      be easier to lookup "0x25" instead of "DABT" in the document. Then we
      can check the corresponding ISS.
      
      For example:
      Current	info	  	Document
      		  	EC	Exception class
      "CP15 MCR/MRC"		0x3	"MCR or MRC access to CP15a..."
      "ASIMD"			0x7	"Access to SIMD or floating-point..."
      "DABT (current EL)" 	0x25	"Data Abort taken without..."
      ...
      
      Before:
      Unable to handle kernel paging request at virtual address 000000000000c000
      Mem abort info:
        ESR = 0x96000046
        Exception class = DABT (current EL), IL = 32 bits
        SET = 0, FnV = 0
        EA = 0, S1PTW = 0
      Data abort info:
        ISV = 0, ISS = 0x00000046
        CM = 0, WnR = 1
      
      After:
      Unable to handle kernel paging request at virtual address 000000000000c000
      Mem abort info:
        ESR = 0x96000046
        EC = 0x25: DABT (current EL), IL = 32 bits
        SET = 0, FnV = 0
        EA = 0, S1PTW = 0
      Data abort info:
        ISV = 0, ISS = 0x00000046
        CM = 0, WnR = 1
      
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Acked-by: default avatarMark Rutland <Mark.rutland@arm.com>
      Signed-off-by: default avatarMiles Chen <miles.chen@mediatek.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      2951d5ef
    • Qian Cai's avatar
      arm64/prefetch: fix a -Wtype-limits warning · b99286b0
      Qian Cai authored
      The commit d5370f75
      
       ("arm64: prefetch: add alternative pattern for
      CPUs without a prefetcher") introduced MIDR_IS_CPU_MODEL_RANGE() to be
      used in has_no_hw_prefetch() with rv_min=0 which generates a compilation
      warning from GCC,
      
      In file included from ./arch/arm64/include/asm/cache.h:8,
                     from ./include/linux/cache.h:6,
                     from ./include/linux/printk.h:9,
                     from ./include/linux/kernel.h:15,
                     from ./include/linux/cpumask.h:10,
                     from arch/arm64/kernel/cpufeature.c:11:
      arch/arm64/kernel/cpufeature.c: In function 'has_no_hw_prefetch':
      ./arch/arm64/include/asm/cputype.h:59:26: warning: comparison of
      unsigned expression >= 0 is always true [-Wtype-limits]
      _model == (model) && rv >= (rv_min) && rv <= (rv_max);  \
                              ^~
      arch/arm64/kernel/cpufeature.c:889:9: note: in expansion of macro
      'MIDR_IS_CPU_MODEL_RANGE'
      return MIDR_IS_CPU_MODEL_RANGE(midr, MIDR_THUNDERX,
             ^~~~~~~~~~~~~~~~~~~~~~~
      
      Fix it by converting MIDR_IS_CPU_MODEL_RANGE to a static inline
      function.
      
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      b99286b0
    • Will Deacon's avatar
      init/Kconfig: Fix infinite Kconfig recursion on PPC · 71c67a31
      Will Deacon authored
      Commit 5cf896fb
      
       ("arm64: Add support for relocating the kernel with
      RELR relocations") introduced CONFIG_TOOLS_SUPPORT_RELR, which checks
      for RELR support in the toolchain as part of the kernel configuration.
      During this procedure, "$(NM)" is invoked to see if it supports the new
      relocation format, however PowerPC conditionally overrides this variable
      in the architecture Makefile in order to pass '--synthetic' when
      targetting PPC64.
      
      This conditional override causes Kconfig to recurse forever, since
      CONFIG_TOOLS_SUPPORT_RELR cannot be determined without $(NM) being
      defined, but that in turn depends on CONFIG_PPC64:
      
        $ make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-
        scripts/kconfig/conf  --syncconfig Kconfig
        scripts/kconfig/conf  --syncconfig Kconfig
        scripts/kconfig/conf  --syncconfig Kconfig
        [...]
      
      In this particular case, it looks like PowerPC may be able to pass
      '--synthetic' unconditionally to nm or even drop it altogether. While
      that is being resolved, let's just bodge the RELR check by picking up
      $(NM) directly from the environment in whatever state it happens to be
      in.
      
      Cc: Peter Collingbourne <pcc@google.com>
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Suggested-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      71c67a31
  6. Aug 05, 2019
  7. Aug 04, 2019