17 Feb, 2018

1 commit

  • commit 932b50c7c1c65e6f23002e075b97ee083c4a9e71 upstream.

    The ARM architecture defines the memory locations that are permitted
    to be accessed as the result of a speculative instruction fetch from
    an exception level for which all stages of translation are disabled.
    Specifically, the core is permitted to speculatively fetch from the
    4KB region containing the current program counter 4K and next 4K.

    When translation is changed from enabled to disabled for the running
    exception level (SCTLR_ELn[M] changed from a value of 1 to 0), the
    Falkor core may errantly speculatively access memory locations outside
    of the 4KB region permitted by the architecture. The errant memory
    access may lead to one of the following unexpected behaviors.

    1) A System Error Interrupt (SEI) being raised by the Falkor core due
    to the errant memory access attempting to access a region of memory
    that is protected by a slave-side memory protection unit.
    2) Unpredictable device behavior due to a speculative read from device
    memory. This behavior may only occur if the instruction cache is
    disabled prior to or coincident with translation being changed from
    enabled to disabled.

    The conditions leading to this erratum will not occur when either of the
    following occur:
    1) A higher exception level disables translation of a lower exception level
    (e.g. EL2 changing SCTLR_EL1[M] from a value of 1 to 0).
    2) An exception level disabling its stage-1 translation if its stage-2
    translation is enabled (e.g. EL1 changing SCTLR_EL1[M] from a value of 1
    to 0 when HCR_EL2[VM] has a value of 1).

    To avoid the errant behavior, software must execute an ISB immediately
    prior to executing the MSR that will change SCTLR_ELn[M] from 1 to 0.

    Signed-off-by: Shanker Donthineni
    Signed-off-by: Will Deacon
    Cc: Timur Tabi
    Signed-off-by: Greg Kroah-Hartman

    Shanker Donthineni
     

18 Jan, 2017

1 commit

  • Some places in the kernel open-code sequences using ADRP for a symbol
    another instruction using a :lo12: relocation for that same symbol.
    These sequences are easy to get wrong, and more painful to read than is
    necessary. For these reasons, it is preferable to use the
    {adr,ldr,str}_l macros for these cases.

    This patch makes use of these in efi-entry.S, removing open-coded
    sequences using adrp.

    Signed-off-by: Mark Rutland
    Reviewed-by: Ard Biesheuvel
    Cc: Catalin Marinas
    Cc: Matt Fleming
    Cc: Will Deacon
    Signed-off-by: Will Deacon

    Mark Rutland
     

15 Apr, 2016

1 commit

  • Apart from the arm64/linux and EFI header data structures, there is nothing
    in the .head.text section that must reside at the beginning of the Image.
    So let's move it to the .init section where it belongs.

    Note that this involves some minor tweaking of the EFI header, primarily
    because the address of 'stext' no longer coincides with the start of the
    .text section. It also requires a couple of relocated symbol references
    to be slightly rewritten or their definition moved to the linker script.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Will Deacon

    Ard Biesheuvel
     

05 Mar, 2016

1 commit


24 Feb, 2016

1 commit

  • Before implementing KASLR for arm64 by building a self-relocating PIE
    executable, we have to ensure that values we use before the relocation
    routine is executed are not subject to dynamic relocation themselves.
    This applies not only to virtual addresses, but also to values that are
    supplied by the linker at build time and relocated using R_AARCH64_ABS64
    relocations.

    So instead, use assemble time constants, or force the use of static
    relocations by folding the constants into the instructions.

    Reviewed-by: Mark Rutland
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Catalin Marinas

    Ard Biesheuvel
     

12 Oct, 2015

1 commit

  • Since arm64 does not use a builtin decompressor, the EFI stub is built
    into the kernel proper. So far, this has been working fine, but actually,
    since the stub is in fact a PE/COFF relocatable binary that is executed
    at an unknown offset in the 1:1 mapping provided by the UEFI firmware, we
    should not be seamlessly sharing code with the kernel proper, which is a
    position dependent executable linked at a high virtual offset.

    So instead, separate the contents of libstub and its dependencies, by
    putting them into their own namespace by prefixing all of its symbols
    with __efistub. This way, we have tight control over what parts of the
    kernel proper are referenced by the stub.

    Signed-off-by: Ard Biesheuvel
    Reviewed-by: Matt Fleming
    Signed-off-by: Catalin Marinas

    Ard Biesheuvel
     

10 Dec, 2014

1 commit

  • Pull arm64 updates from Will Deacon:
    "Here's the usual mixed bag of arm64 updates, also including some
    related EFI changes (Acked by Matt) and the MMU gather range cleanup
    (Acked by you).

    Changes include:
    - support for alternative instruction patching from Andre
    - seccomp from Akashi
    - some AArch32 instruction emulation, required by the Android folks
    - optimisations for exception entry/exit code, cmpxchg, pcpu atomics
    - mmu_gather range calculations moved into core code
    - EFI updates from Ard, including long-awaited SMBIOS support
    - /proc/cpuinfo fixes to align with the format used by arch/arm/
    - a few non-critical fixes across the architecture"

    * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (70 commits)
    arm64: remove the unnecessary arm64_swiotlb_init()
    arm64: add module support for alternatives fixups
    arm64: perf: Prevent wraparound during overflow
    arm64/include/asm: Fixed a warning about 'struct pt_regs'
    arm64: Provide a namespace to NCAPS
    arm64: bpf: lift restriction on last instruction
    arm64: Implement support for read-mostly sections
    arm64: compat: align cacheflush syscall with arch/arm
    arm64: add seccomp support
    arm64: add SIGSYS siginfo for compat task
    arm64: add seccomp syscall for compat task
    asm-generic: add generic seccomp.h for secure computing mode 1
    arm64: ptrace: allow tracer to skip a system call
    arm64: ptrace: add NT_ARM_SYSTEM_CALL regset
    arm64: Move some head.text functions to executable section
    arm64: jump labels: NOP out NOP -> NOP replacement
    arm64: add support to dump the kernel page tables
    arm64: Add FIX_HOLE to permanent fixed addresses
    arm64: alternatives: fix pr_fmt string for consistency
    arm64: vmlinux.lds.S: don't discard .exit.* sections at link-time
    ...

    Linus Torvalds
     

13 Nov, 2014

1 commit

  • While efi-entry.S mentions that efi_entry() will have relocated the
    kernel image, it actually means that efi_entry will have placed a copy
    of the kernel in the appropriate location, and until this is branched to
    at the end of efi_entry.S, all instructions are executed from the
    original image.

    Thus while the flush in efi_entry.S does ensure that the copy is visible
    to noncacheable accesses, it does not guarantee that this is true for
    the image instructions are being executed from. This could have
    disasterous effects when the MMU and caches are disabled if the image
    has not been naturally evicted to the PoC.

    Additionally, due to a missing dsb following the ic ialluis, the new
    kernel image is not necessarily clean in the I-cache when it is branched
    to, with similar potentially disasterous effects.

    This patch adds additional flushing to ensure that the currently
    executing stub text is flushed to the PoC and is thus visible to
    noncacheable accesses. As it is placed after the instructions cache
    maintenance for the new image and __flush_dcache_area already contains a
    dsb, we do not need to add a separate barrier to ensure completion of
    the icache maintenance.

    Comments are updated to clarify the situation with regard to the two
    images and the maintenance required for both.

    Fixes: 3c7f255039a2ad6ee1e3890505caf0d029b22e29
    Signed-off-by: Mark Rutland
    Acked-by: Joel Schopp
    Reviewed-by: Roy Franz
    Tested-by: Tom Lendacky
    Cc: Ard Biesheuvel
    Cc: Ian Campbell
    Cc: Leif Lindholm
    Cc: Mark Salter
    Cc: Will Deacon
    Cc: stable@vger.kernel.org
    Signed-off-by: Catalin Marinas

    Mark Rutland
     

05 Nov, 2014

1 commit

  • After the EFI stub has done its business, it jumps into the kernel by
    branching to offset #0 of the loaded Image, which is where it expects
    to find the header containing a 'branch to stext' instruction.

    However, the UEFI spec 2.1.1 states the following regarding PE/COFF
    image loading:
    "A UEFI image is loaded into memory through the LoadImage() Boot
    Service. This service loads an image with a PE32+ format into memory.
    This PE32+ loader is required to load all sections of the PE32+ image
    into memory."

    In other words, it is /not/ required to load parts of the image that are
    not covered by a PE/COFF section, so it may not have loaded the header
    at the expected offset, as it is not covered by any PE/COFF section.

    So instead, jump to 'stext' directly, which is at the base of the
    PE/COFF .text section, by supplying a symbol 'stext_offset' to
    efi-entry.o which contains the relative offset of stext into the Image.
    Also replace other open coded calculations of the same value with a
    reference to 'stext_offset'

    Acked-by: Mark Rutland
    Acked-by: Roy Franz
    Signed-off-by: Ard Biesheuvel

    Ard Biesheuvel
     

04 Jul, 2014

1 commit

  • The CurrentEL system register reports the Current Exception Level
    of the CPU. It doesn't say anything about the stack handling, and
    yet we compare it to PSR_MODE_EL2t and PSR_MODE_EL2h.

    It works by chance because PSR_MODE_EL2t happens to match the right
    bits, but that's otherwise a very bad idea. Just check for the EL
    value instead.

    Signed-off-by: Marc Zyngier
    [catalin.marinas@arm.com: fixed arch/arm64/kernel/efi-entry.S]
    Signed-off-by: Catalin Marinas

    Marc Zyngier
     

01 May, 2014

1 commit

  • This patch adds PE/COFF header fields to the start of the kernel
    Image so that it appears as an EFI application to UEFI firmware.
    An EFI stub is included to allow direct booting of the kernel
    Image.

    Signed-off-by: Mark Salter
    [Add support in PE/COFF header for signed images]
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Leif Lindholm
    Acked-by: Catalin Marinas
    Signed-off-by: Matt Fleming

    Mark Salter