Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 9 Apr 2020 18:04:16 +0000 (11:04 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 9 Apr 2020 18:04:16 +0000 (11:04 -0700)
Pull arm64 fixes from Catalin Marinas:

 - Ensure that the compiler and linker versions are aligned so that ld
   doesn't complain about not understanding a .note.gnu.property section
   (emitted when pointer authentication is enabled).

 - Force -mbranch-protection=none when the feature is not enabled, in
   case a compiler may choose a different default value.

 - Remove CONFIG_DEBUG_ALIGN_RODATA. It was never in defconfig and
   rarely enabled.

 - Fix checking 16-bit Thumb-2 instructions checking mask in the
   emulation of the SETEND instruction (it could match the bottom half
   of a 32-bit Thumb-2 instruction).

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
  arm64: armv8_deprecated: Fix undef_hook mask for thumb setend
  arm64: remove CONFIG_DEBUG_ALIGN_RODATA feature
  arm64: Always force a branch protection mode when the compiler has one
  arm64: Kconfig: ptrauth: Add binutils version check to fix mismatch
  init/kconfig: Add LD_VERSION Kconfig

arch/arm64/Kconfig
arch/arm64/Kconfig.debug
arch/arm64/Makefile
arch/arm64/include/asm/memory.h
arch/arm64/kernel/armv8_deprecated.c
drivers/firmware/efi/libstub/arm64-stub.c
init/Kconfig

index 6e41c4b..40fb05d 100644 (file)
@@ -1502,7 +1502,10 @@ config ARM64_PTR_AUTH
        default y
        depends on !KVM || ARM64_VHE
        depends on (CC_HAS_SIGN_RETURN_ADDRESS || CC_HAS_BRANCH_PROT_PAC_RET) && AS_HAS_PAC
-       depends on CC_IS_GCC || (CC_IS_CLANG && AS_HAS_CFI_NEGATE_RA_STATE)
+       # GCC 9.1 and later inserts a .note.gnu.property section note for PAC
+       # which is only understood by binutils starting with version 2.33.1.
+       depends on !CC_IS_GCC || GCC_VERSION < 90100 || LD_VERSION >= 233010000
+       depends on !CC_IS_CLANG || AS_HAS_CFI_NEGATE_RA_STATE
        depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS)
        help
          Pointer authentication (part of the ARMv8.3 Extensions) provides
index 1c906d9..a1efa24 100644 (file)
@@ -52,19 +52,6 @@ config DEBUG_WX
 
          If in doubt, say "Y".
 
-config DEBUG_ALIGN_RODATA
-       depends on STRICT_KERNEL_RWX
-       bool "Align linker sections up to SECTION_SIZE"
-       help
-         If this option is enabled, sections that may potentially be marked as
-         read only or non-executable will be aligned up to the section size of
-         the kernel. This prevents sections from being split into pages and
-         avoids a potential TLB penalty. The downside is an increase in
-         alignment and potentially wasted space. Turn on this option if
-         performance is more important than memory pressure.
-
-         If in doubt, say N.
-
 config DEBUG_EFI
        depends on EFI && DEBUG_INFO
        bool "UEFI debugging"
index f15f92b..85e4149 100644 (file)
@@ -65,6 +65,10 @@ stack_protector_prepare: prepare0
                                        include/generated/asm-offsets.h))
 endif
 
+# Ensure that if the compiler supports branch protection we default it
+# off, this will be overridden if we are using branch protection.
+branch-prot-flags-y += $(call cc-option,-mbranch-protection=none)
+
 ifeq ($(CONFIG_ARM64_PTR_AUTH),y)
 branch-prot-flags-$(CONFIG_CC_HAS_SIGN_RETURN_ADDRESS) := -msign-return-address=all
 branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET) := -mbranch-protection=pac-ret+leaf
@@ -73,9 +77,10 @@ branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET) := -mbranch-protection=pa
 # we pass it only to the assembler. This option is utilized only in case of non
 # integrated assemblers.
 branch-prot-flags-$(CONFIG_AS_HAS_PAC) += -Wa,-march=armv8.3-a
-KBUILD_CFLAGS += $(branch-prot-flags-y)
 endif
 
+KBUILD_CFLAGS += $(branch-prot-flags-y)
+
 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS        += -mbig-endian
 CHECKFLAGS     += -D__AARCH64EB__
index 2be67b2..a1871bb 100644 (file)
 
 /*
  * Alignment of kernel segments (e.g. .text, .data).
- */
-#if defined(CONFIG_DEBUG_ALIGN_RODATA)
-/*
- *  4 KB granule:   1 level 2 entry
- * 16 KB granule: 128 level 3 entries, with contiguous bit
- * 64 KB granule:  32 level 3 entries, with contiguous bit
- */
-#define SEGMENT_ALIGN          SZ_2M
-#else
-/*
+ *
  *  4 KB granule:  16 level 3 entries, with contiguous bit
  * 16 KB granule:   4 level 3 entries, without contiguous bit
  * 64 KB granule:   1 level 3 entry
  */
 #define SEGMENT_ALIGN          SZ_64K
-#endif
 
 /*
  * Memory types available.
index 4cc581a..c19aa81 100644 (file)
@@ -601,7 +601,7 @@ static struct undef_hook setend_hooks[] = {
        },
        {
                /* Thumb mode */
-               .instr_mask     = 0x0000fff7,
+               .instr_mask     = 0xfffffff7,
                .instr_val      = 0x0000b650,
                .pstate_mask    = (PSR_AA32_T_BIT | PSR_AA32_MODE_MASK),
                .pstate_val     = (PSR_AA32_T_BIT | PSR_AA32_MODE_USR),
index db0c1a9..fc9f8ab 100644 (file)
@@ -75,14 +75,12 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
 
        if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && phys_seed != 0) {
                /*
-                * If CONFIG_DEBUG_ALIGN_RODATA is not set, produce a
-                * displacement in the interval [0, MIN_KIMG_ALIGN) that
-                * doesn't violate this kernel's de-facto alignment
+                * Produce a displacement in the interval [0, MIN_KIMG_ALIGN)
+                * that doesn't violate this kernel's de-facto alignment
                 * constraints.
                 */
                u32 mask = (MIN_KIMG_ALIGN - 1) & ~(EFI_KIMG_ALIGN - 1);
-               u32 offset = !IS_ENABLED(CONFIG_DEBUG_ALIGN_RODATA) ?
-                            (phys_seed >> 32) & mask : TEXT_OFFSET;
+               u32 offset = (phys_seed >> 32) & mask;
 
                /*
                 * With CONFIG_RANDOMIZE_TEXT_OFFSET=y, TEXT_OFFSET may not
index 574b721..9e22ee8 100644 (file)
@@ -16,6 +16,10 @@ config GCC_VERSION
        default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC
        default 0
 
+config LD_VERSION
+       int
+       default $(shell,$(LD) --version | $(srctree)/scripts/ld-version.sh)
+
 config CC_IS_CLANG
        def_bool $(success,$(CC) --version | head -n 1 | grep -q clang)