1. 11 1月, 2020 10 次提交
    • A
      efi/x86: Simplify mixed mode call wrapper · ea5e1919
      Ard Biesheuvel 提交于
      Calling 32-bit EFI runtime services from a 64-bit OS involves
      switching back to the flat mapping with a stack carved out of
      memory that is 32-bit addressable.
      
      There is no need to actually execute the 64-bit part of this
      routine from the flat mapping as well, as long as the entry
      and return address fit in 32 bits. There is also no need to
      preserve part of the calling context in global variables: we
      can simply push the old stack pointer value to the new stack,
      and keep the return address from the code32 section in EBX.
      
      While at it, move the conditional check whether to invoke
      the mixed mode version of SetVirtualAddressMap() into the
      64-bit implementation of the wrapper routine.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-11-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      ea5e1919
    • A
      efi/x86: Simplify 64-bit EFI firmware call wrapper · e5f930fe
      Ard Biesheuvel 提交于
      The efi_call() wrapper used to invoke EFI runtime services serves
      a number of purposes:
      - realign the stack to 16 bytes
      - preserve FP and CR0 register state
      - translate from SysV to MS calling convention.
      
      Preserving CR0.TS is no longer necessary in Linux, and preserving the
      FP register state is also redundant in most cases, since efi_call() is
      almost always used from within the scope of a pair of kernel_fpu_begin()/
      kernel_fpu_end() calls, with the exception of the early call to
      SetVirtualAddressMap() and the SGI UV support code.
      
      So let's add a pair of kernel_fpu_begin()/_end() calls there as well,
      and remove the unnecessary code from the assembly implementation of
      efi_call(), and only keep the pieces that deal with the stack
      alignment and the ABI translation.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-10-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      e5f930fe
    • A
      efi/x86: Simplify i386 efi_call_phys() firmware call wrapper · a46d6740
      Ard Biesheuvel 提交于
      The variadic efi_call_phys() wrapper that exists on i386 was
      originally created to call into any EFI firmware runtime service,
      but in practice, we only use it once, to call SetVirtualAddressMap()
      during early boot.
      The flexibility provided by the variadic nature also makes it
      type unsafe, and makes the assembler code more complicated than
      needed, since it has to deal with an unknown number of arguments
      living on the stack.
      
      So clean this up, by renaming the helper to efi_call_svam(), and
      dropping the unneeded complexity. Let's also drop the reference
      to the efi_phys struct and grab the address from the EFI system
      table directly.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-9-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      a46d6740
    • A
      efi/x86: Split SetVirtualAddresMap() wrappers into 32 and 64 bit versions · 69829470
      Ard Biesheuvel 提交于
      Split the phys_efi_set_virtual_address_map() routine into 32 and 64 bit
      versions, so we can simplify them individually in subsequent patches.
      
      There is very little overlap between the logic anyway, and this has
      already been factored out in prolog/epilog routines which are completely
      different between 32 bit and 64 bit. So let's take it one step further,
      and get rid of the overlap completely.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-8-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      69829470
    • A
      efi/x86: Split off some old memmap handling into separate routines · 98dd0e3a
      Ard Biesheuvel 提交于
      In a subsequent patch, we will fold the prolog/epilog routines that are
      part of the support code to call SetVirtualAddressMap() with a 1:1
      mapping into the callers. However, the 64-bit version mostly consists
      of ugly mapping code that is only used when efi=old_map is in effect,
      which is extremely rare. So let's move this code out of the way so it
      does not clutter the common code.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-7-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      98dd0e3a
    • A
      efi/x86: Avoid redundant cast of EFI firmware service pointer · 89ed4865
      Ard Biesheuvel 提交于
      All EFI firmware call prototypes have been annotated as __efiapi,
      permitting us to attach attributes regarding the calling convention
      by overriding __efiapi to an architecture specific value.
      
      On 32-bit x86, EFI firmware calls use the plain calling convention
      where all arguments are passed via the stack, and cleaned up by the
      caller. Let's add this to the __efiapi definition so we no longer
      need to cast the function pointers before invoking them.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-6-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      89ed4865
    • A
      efi/x86: Map the entire EFI vendor string before copying it · ffc2760b
      Ard Biesheuvel 提交于
      Fix a couple of issues with the way we map and copy the vendor string:
      - we map only 2 bytes, which usually works since you get at least a
        page, but if the vendor string happens to cross a page boundary,
        a crash will result
      - only call early_memunmap() if early_memremap() succeeded, or we will
        call it with a NULL address which it doesn't like,
      - while at it, switch to early_memremap_ro(), and array indexing rather
        than pointer dereferencing to read the CHAR16 characters.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Fixes: 5b83683f ("x86: EFI runtime service support")
      Link: https://lkml.kernel.org/r/20200103113953.9571-5-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      ffc2760b
    • A
      efi/x86: Re-disable RT services for 32-bit kernels running on 64-bit EFI · 6cfcd6f0
      Ard Biesheuvel 提交于
      Commit a8147dba ("efi/x86: Rename efi_is_native() to efi_is_mixed()")
      renamed and refactored efi_is_native() into efi_is_mixed(), but failed
      to take into account that these are not diametrical opposites.
      
      Mixed mode is a construct that permits 64-bit kernels to boot on 32-bit
      firmware, but there is another non-native combination which is supported,
      i.e., 32-bit kernels booting on 64-bit firmware, but only for boot and not
      for runtime services. Also, mixed mode can be disabled in Kconfig, in
      which case the 64-bit kernel can still be booted from 32-bit firmware,
      but without access to runtime services.
      
      Due to this oversight, efi_runtime_supported() now incorrectly returns
      true for such configurations, resulting in crashes at boot. So fix this
      by making efi_runtime_supported() aware of this.
      
      As a side effect, some efi_thunk_xxx() stubs have become obsolete, so
      remove them as well.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-4-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      6cfcd6f0
    • A
      efi/libstub/x86: Force 'hidden' visibility for extern declarations · bc7c9d62
      Ard Biesheuvel 提交于
      Commit c3710de5 ("efi/libstub/x86: Drop __efi_early() export and
      efi_config struct") introduced a reference from C code in eboot.c to
      the startup_32 symbol defined in the .S startup code. This results in
      a GOT based reference to startup_32, and since GOT entries carry
      absolute addresses, they need to be fixed up before they can be used.
      
      On modern toolchains (binutils 2.26 or later), this reference is
      relaxed into a R_386_GOTOFF relocation (or the analogous X86_64 one)
      which never uses the absolute address in the entry, and so we get
      away with not fixing up the GOT table before calling the EFI entry
      point. However, GCC 4.6 combined with a binutils of the era (2.24)
      will produce a true GOT indirected reference, resulting in a wrong
      value to be returned for the address of startup_32() if the boot
      code is not running at the address it was linked at.
      
      Fortunately, we can easily override this behavior, and force GCC to
      emit the GOTOFF relocations explicitly, by setting the visibility
      pragma 'hidden'.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-3-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      bc7c9d62
    • A
      efi/libstub: Fix boot argument handling in mixed mode entry code · 12dc9e15
      Ard Biesheuvel 提交于
      The mixed mode refactor actually broke mixed mode by failing to
      pass the bootparam structure to startup_32(). This went unnoticed
      because it apparently has a high tolerance for being passed random
      junk, and still boots fine in some cases. So let's fix this by
      populating %esi as required when entering via efi32_stub_entry,
      and while at it, preserve the arguments themselves instead of their
      address in memory (via the stack pointer) since that memory could
      be clobbered before we get to it.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-2-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      12dc9e15
  2. 07 1月, 2020 1 次提交
    • C
      arm64: Revert support for execute-only user mappings · 24cecc37
      Catalin Marinas 提交于
      The ARMv8 64-bit architecture supports execute-only user permissions by
      clearing the PTE_USER and PTE_UXN bits, practically making it a mostly
      privileged mapping but from which user running at EL0 can still execute.
      
      The downside, however, is that the kernel at EL1 inadvertently reading
      such mapping would not trip over the PAN (privileged access never)
      protection.
      
      Revert the relevant bits from commit cab15ce6 ("arm64: Introduce
      execute-only page access permissions") so that PROT_EXEC implies
      PROT_READ (and therefore PTE_USER) until the architecture gains proper
      support for execute-only user mappings.
      
      Fixes: cab15ce6 ("arm64: Introduce execute-only page access permissions")
      Cc: <stable@vger.kernel.org> # 4.9.x-
      Acked-by: NWill Deacon <will@kernel.org>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      24cecc37
  3. 05 1月, 2020 5 次提交
  4. 03 1月, 2020 5 次提交
  5. 30 12月, 2019 1 次提交
  6. 29 12月, 2019 1 次提交
  7. 28 12月, 2019 3 次提交
    • O
      riscv: export flush_icache_all to modules · 1833e327
      Olof Johansson 提交于
      This is needed by LKDTM (crash dump test module), it calls
      flush_icache_range(), which on RISC-V turns into flush_icache_all(). On
      other architectures, the actual implementation is exported, so follow
      that precedence and export it here too.
      
      Fixes build of CONFIG_LKDTM that fails with:
      ERROR: "flush_icache_all" [drivers/misc/lkdtm/lkdtm.ko] undefined!
      Signed-off-by: NOlof Johansson <olof@lixom.net>
      Signed-off-by: NPaul Walmsley <paul.walmsley@sifive.com>
      1833e327
    • D
      riscv: reject invalid syscalls below -1 · 556f47ac
      David Abdurachmanov 提交于
      Running "stress-ng --enosys 4 -t 20 -v" showed a large number of kernel oops
      with "Unable to handle kernel paging request at virtual address" message. This
      happens when enosys stressor starts testing random non-valid syscalls.
      
      I forgot to redirect any syscall below -1 to sys_ni_syscall.
      
      With the patch kernel oops messages are gone while running stress-ng enosys
      stressor.
      Signed-off-by: NDavid Abdurachmanov <david.abdurachmanov@sifive.com>
      Fixes: 5340627e ("riscv: add support for SECCOMP and SECCOMP_FILTER")
      Signed-off-by: NPaul Walmsley <paul.walmsley@sifive.com>
      556f47ac
    • L
      riscv: fix compile failure with EXPORT_SYMBOL() & !MMU · 4d47ce15
      Luc Van Oostenryck 提交于
      When support for !MMU was added, the declaration of
      __asm_copy_to_user() & __asm_copy_from_user() were #ifdefed
      out hence their EXPORT_SYMBOL() give an error message like:
        .../riscv_ksyms.c:13:15: error: '__asm_copy_to_user' undeclared here
        .../riscv_ksyms.c:14:15: error: '__asm_copy_from_user' undeclared here
      
      Since these symbols are not defined with !MMU it's wrong to export them.
      Same for __clear_user() (even though this one is also declared in
      include/asm-generic/uaccess.h and thus doesn't give an error message).
      
      Fix this by doing the EXPORT_SYMBOL() directly where these symbols
      are defined: inside lib/uaccess.S itself.
      
      Fixes: 6bd33e1e ("riscv: fix compile failure with EXPORT_SYMBOL() & !MMU")
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Signed-off-by: NLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
      Signed-off-by: NPaul Walmsley <paul.walmsley@sifive.com>
      4d47ce15
  8. 25 12月, 2019 14 次提交