22 Feb, 2015

1 commit

  • Pull misc x86 fixes from Ingo Molnar:
    "This contains:

    - EFI fixes
    - a boot printout fix
    - ASLR/kASLR fixes
    - intel microcode driver fixes
    - other misc fixes

    Most of the linecount comes from an EFI revert"

    * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    x86/mm/ASLR: Avoid PAGE_SIZE redefinition for UML subarch
    x86/microcode/intel: Handle truncated microcode images more robustly
    x86/microcode/intel: Guard against stack overflow in the loader
    x86, mm/ASLR: Fix stack randomization on 64-bit systems
    x86/mm/init: Fix incorrect page size in init_memory_mapping() printks
    x86/mm/ASLR: Propagate base load address calculation
    Documentation/x86: Fix path in zero-page.txt
    x86/apic: Fix the devicetree build in certain configs
    Revert "efi/libstub: Call get_memory_map() to obtain map and desc sizes"
    x86/efi: Avoid triple faults during EFI mixed mode calls

    Linus Torvalds
     

18 Feb, 2015

1 commit

  • This reverts commit d1a8d66b9177105e898e73716f97eb61842c457a.

    Ard reported a boot failure when running UEFI under Qemu and Xen and
    experimenting with various Tianocore build options,

    "As it turns out, when allocating room for the UEFI memory map using
    UEFI's AllocatePool (), it may result in two new memory map entries
    being created, for instance, when using Tianocore's preallocated region
    feature. For example, the following region

    0x00005ead5000-0x00005ebfffff [Conventional Memory| | | | | |WB|WT|WC|UC]

    may be split like this

    0x00005ead5000-0x00005eae2fff [Conventional Memory| | | | | |WB|WT|WC|UC]
    0x00005eae3000-0x00005eae4fff [Loader Data | | | | | |WB|WT|WC|UC]
    0x00005eae5000-0x00005ebfffff [Conventional Memory| | | | | |WB|WT|WC|UC]

    if the preallocated Loader Data region was chosen to be right in the
    middle of the original free space.

    After patch d1a8d66b9177 ("efi/libstub: Call get_memory_map() to
    obtain map and desc sizes"), this is not being dealt with correctly
    anymore, as the existing logic to allocate room for a single additional
    entry has become insufficient."

    Mark requested to reinstate the old loop we had before commit
    d1a8d66b9177, which grows the memory map buffer until it's big enough to
    hold the EFI memory map.

    Acked-by: Ard Biesheuvel
    Acked-by: Mark Rutland
    Signed-off-by: Matt Fleming

    Matt Fleming
     

14 Feb, 2015

2 commits

  • Recently instrumentation of builtin functions calls was removed from GCC
    5.0. To check the memory accessed by such functions, userspace asan
    always uses interceptors for them.

    So now we should do this as well. This patch declares
    memset/memmove/memcpy as weak symbols. In mm/kasan/kasan.c we have our
    own implementation of those functions which checks memory before accessing
    it.

    Default memset/memmove/memcpy now now always have aliases with '__'
    prefix. For files that built without kasan instrumentation (e.g.
    mm/slub.c) original mem* replaced (via #define) with prefixed variants,
    cause we don't want to check memory accesses there.

    Signed-off-by: Andrey Ryabinin
    Cc: Dmitry Vyukov
    Cc: Konstantin Serebryany
    Cc: Dmitry Chernenkov
    Signed-off-by: Andrey Konovalov
    Cc: Yuri Gribov
    Cc: Konstantin Khlebnikov
    Cc: Sasha Levin
    Cc: Christoph Lameter
    Cc: Joonsoo Kim
    Cc: Dave Hansen
    Cc: Andi Kleen
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: David Rientjes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • Kernel Address sanitizer (KASan) is a dynamic memory error detector. It
    provides fast and comprehensive solution for finding use-after-free and
    out-of-bounds bugs.

    KASAN uses compile-time instrumentation for checking every memory access,
    therefore GCC > v4.9.2 required. v4.9.2 almost works, but has issues with
    putting symbol aliases into the wrong section, which breaks kasan
    instrumentation of globals.

    This patch only adds infrastructure for kernel address sanitizer. It's
    not available for use yet. The idea and some code was borrowed from [1].

    Basic idea:

    The main idea of KASAN is to use shadow memory to record whether each byte
    of memory is safe to access or not, and use compiler's instrumentation to
    check the shadow memory on each memory access.

    Address sanitizer uses 1/8 of the memory addressable in kernel for shadow
    memory and uses direct mapping with a scale and offset to translate a
    memory address to its corresponding shadow address.

    Here is function to translate address to corresponding shadow address:

    unsigned long kasan_mem_to_shadow(unsigned long addr)
    {
    return (addr >> KASAN_SHADOW_SCALE_SHIFT) + KASAN_SHADOW_OFFSET;
    }

    where KASAN_SHADOW_SCALE_SHIFT = 3.

    So for every 8 bytes there is one corresponding byte of shadow memory.
    The following encoding used for each shadow byte: 0 means that all 8 bytes
    of the corresponding memory region are valid for access; k (1
    Acked-by: Michal Marek
    Signed-off-by: Andrey Konovalov
    Cc: Dmitry Vyukov
    Cc: Konstantin Serebryany
    Cc: Dmitry Chernenkov
    Cc: Yuri Gribov
    Cc: Konstantin Khlebnikov
    Cc: Sasha Levin
    Cc: Christoph Lameter
    Cc: Joonsoo Kim
    Cc: Dave Hansen
    Cc: Andi Kleen
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: David Rientjes
    Cc: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     

12 Feb, 2015

1 commit

  • Pull arm64 updates from Catalin Marinas:
    "arm64 updates for 3.20:

    - reimplementation of the virtual remapping of UEFI Runtime Services
    in a way that is stable across kexec
    - emulation of the "setend" instruction for 32-bit tasks (user
    endianness switching trapped in the kernel, SCTLR_EL1.E0E bit set
    accordingly)
    - compat_sys_call_table implemented in C (from asm) and made it a
    constant array together with sys_call_table
    - export CPU cache information via /sys (like other architectures)
    - DMA API implementation clean-up in preparation for IOMMU support
    - macros clean-up for KVM
    - dropped some unnecessary cache+tlb maintenance
    - CONFIG_ARM64_CPU_SUSPEND clean-up
    - defconfig update (CPU_IDLE)

    The EFI changes going via the arm64 tree have been acked by Matt
    Fleming. There is also a patch adding sys_*stat64 prototypes to
    include/linux/syscalls.h, acked by Andrew Morton"

    * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (47 commits)
    arm64: compat: Remove incorrect comment in compat_siginfo
    arm64: Fix section mismatch on alloc_init_p[mu]d()
    arm64: Avoid breakage caused by .altmacro in fpsimd save/restore macros
    arm64: mm: use *_sect to check for section maps
    arm64: drop unnecessary cache+tlb maintenance
    arm64:mm: free the useless initial page table
    arm64: Enable CPU_IDLE in defconfig
    arm64: kernel: remove ARM64_CPU_SUSPEND config option
    arm64: make sys_call_table const
    arm64: Remove asm/syscalls.h
    arm64: Implement the compat_sys_call_table in C
    syscalls: Declare sys_*stat64 prototypes if __ARCH_WANT_(COMPAT_)STAT64
    compat: Declare compat_sys_sigpending and compat_sys_sigprocmask prototypes
    arm64: uapi: expose our struct ucontext to the uapi headers
    smp, ARM64: Kill SMP single function call interrupt
    arm64: Emulate SETEND for AArch32 tasks
    arm64: Consolidate hotplug notifier for instruction emulation
    arm64: Track system support for mixed endian EL0
    arm64: implement generic IOMMU configuration
    arm64: Combine coherent and non-coherent swiotlb dma_ops
    ...

    Linus Torvalds
     

30 Jan, 2015

1 commit

  • Pull EFI updates from Matt Fleming:

    " - Move efivarfs from the misc filesystem section to pseudo filesystem,
    since that's a more logical and accurate place - Leif Lindholm

    - Update efibootmgr URL in Kconfig help - Peter Jones

    - Improve accuracy of EFI guid function names - Borislav Petkov

    - Expose firmware platform size in sysfs for the benefit of EFI boot
    loader installers and other utilities - Steve McIntyre

    - Cleanup __init annotations for arm64/efi code - Ard Biesheuvel

    - Mark the UIE as unsupported for rtc-efi - Ard Biesheuvel

    - Fix memory leak in error code path of runtime map code - Dan Carpenter

    - Improve robustness of get_memory_map() by removing assumptions on the
    size of efi_memory_desc_t (which could change in future spec
    versions) and querying the firmware instead of guessing about the
    memmap size - Ard Biesheuvel

    - Remove superfluous guid unparse calls - Ivan Khoronzhuk

    - Delete unnecessary chosen@0 DT node FDT code since was duplicated
    from code in drivers/of and is entirely unnecessary - Leif Lindholm

    There's nothing super scary, mainly cleanups, and a merge from Ricardo who
    kindly picked up some patches from the linux-efi mailing list while I
    was out on annual leave in December.

    Perhaps the biggest risk is the get_memory_map() change from Ard, which
    changes the way that both the arm64 and x86 EFI boot stub build the
    early memory map. It would be good to have it bake in linux-next for a
    while.
    "

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

21 Jan, 2015

3 commits

  • Due to some scary special case handling noticed in drivers/of, various
    bits of the ARM* EFI support patches did duplicate looking for @0
    variants of various nodes. Unless on an ancient PPC system, these are
    not in fact required. Most instances have become refactored out along
    the way, this removes the last one.

    Signed-off-by: Leif Lindholm
    Signed-off-by: Matt Fleming

    Leif Lindholm
     
  • There is no reason to translate guid number to string here.
    So remove it in order to not do unneeded work.

    Signed-off-by: Ivan Khoronzhuk
    Acked-by: Ard Biesheuvel
    Acked-by: Leif Lindholm
    Signed-off-by: Matt Fleming

    Ivan Khoronzhuk
     
  • This fixes two minor issues in the implementation of get_memory_map():
    - Currently, it assumes that sizeof(efi_memory_desc_t) == desc_size,
    which is usually true, but not mandated by the spec. (This was added
    intentionally to allow future additions to the definition of
    efi_memory_desc_t). The way the loop is implemented currently, the
    added slack space may be insufficient if desc_size is larger, which in
    some corner cases could result in the loop never terminating.
    - It allocates 32 efi_memory_desc_t entries first (again, using the size
    of the struct instead of desc_size), and frees and reallocates if it
    turns out to be insufficient. Few implementations of UEFI have such small
    memory maps, which results in a unnecessary allocate/free pair on each
    invocation.

    Fix this by calling the get_memory_map() boot service first with a '0'
    input value for map size to retrieve the map size and desc size from the
    firmware and only then perform the allocation, using desc_size rather
    than sizeof(efi_memory_desc_t).

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Matt Fleming

    Ard Biesheuvel
     

20 Jan, 2015

1 commit


16 Jan, 2015

1 commit

  • This ensures all stub component are freed when the kernel proper is
    done booting, by prefixing the names of all ELF sections that have
    the SHF_ALLOC attribute with ".init". This approach ensures that even
    implicitly emitted allocated data (like initializer values and string
    literals) are covered.

    At the same time, remove some __init annotations in the stub that have
    now become redundant, and add the __init annotation to handle_kernel_image
    which will now trigger a section mismatch warning without it.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Matt Fleming

    Ard Biesheuvel
     

13 Jan, 2015

1 commit

  • In order to support kexec, the kernel needs to be able to deal with the
    state of the UEFI firmware after SetVirtualAddressMap() has been called.
    To avoid having separate code paths for non-kexec and kexec, let's move
    the call to SetVirtualAddressMap() to the stub: this will guarantee us
    that it will only be called once (since the stub is not executed during
    kexec), and ensures that the UEFI state is identical between kexec and
    normal boot.

    This implies that the layout of the virtual mapping needs to be created
    by the stub as well. All regions are rounded up to a naturally aligned
    multiple of 64 KB (for compatibility with 64k pages kernels) and recorded
    in the UEFI memory map. The kernel proper reads those values and installs
    the mappings in a dedicated set of page tables that are swapped in during
    UEFI Runtime Services calls.

    Acked-by: Leif Lindholm
    Acked-by: Matt Fleming
    Tested-by: Leif Lindholm
    Signed-off-by: Ard Biesheuvel

    Ard Biesheuvel
     

12 Jan, 2015

3 commits

  • In some cases (e.g. Intel Bay Trail machines), the kernel will happily
    run in 64-bit even if the underlying UEFI firmware platform is
    32-bit. That's great, but it's difficult for userland utilities like
    grub-install to do the right thing in such a situation.

    The kernel already knows about the size of the firmware via
    efi_enabled(EFI_64BIT). Add an extra sysfs interface
    /sys/firmware/efi/fw_platform_size to expose that information to
    userland for low-level utilities to use.

    Signed-off-by: Steve McIntyre
    Cc: Matthew Garrett
    Signed-off-by: Matt Fleming

    Steve McIntyre
     
  • On systems with 64 KB pages, it is preferable for UEFI memory map
    entries to be 64 KB aligned multiples of 64 KB, because it relieves
    us of having to deal with the residues.
    So, if EFI_ALLOC_ALIGN is #define'd by the platform, use it to round
    up all memory allocations made.

    Acked-by: Matt Fleming
    Acked-by: Borislav Petkov
    Tested-by: Leif Lindholm
    Signed-off-by: Ard Biesheuvel

    Ard Biesheuvel
     
  • Split of the remapping code from efi_config_init() so that the caller
    can perform its own remapping. This is necessary to correctly handle
    virtually remapped UEFI memory regions under kexec, as efi.systab will
    have been updated to a virtual address.

    Acked-by: Matt Fleming
    Tested-by: Leif Lindholm
    Signed-off-by: Ard Biesheuvel

    Ard Biesheuvel
     

08 Jan, 2015

2 commits


15 Dec, 2014

1 commit

  • Pull driver core update from Greg KH:
    "Here's the set of driver core patches for 3.19-rc1.

    They are dominated by the removal of the .owner field in platform
    drivers. They touch a lot of files, but they are "simple" changes,
    just removing a line in a structure.

    Other than that, a few minor driver core and debugfs changes. There
    are some ath9k patches coming in through this tree that have been
    acked by the wireless maintainers as they relied on the debugfs
    changes.

    Everything has been in linux-next for a while"

    * tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits)
    Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries"
    fs: debugfs: add forward declaration for struct device type
    firmware class: Deletion of an unnecessary check before the function call "vunmap"
    firmware loader: fix hung task warning dump
    devcoredump: provide a one-way disable function
    device: Add dev__once variants
    ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries
    ath: use seq_file api for ath9k debugfs files
    debugfs: add helper function to create device related seq_file
    drivers/base: cacheinfo: remove noisy error boot message
    Revert "core: platform: add warning if driver has no owner"
    drivers: base: support cpu cache information interface to userspace via sysfs
    drivers: base: add cpu_device_create to support per-cpu devices
    topology: replace custom attribute macros with standard DEVICE_ATTR*
    cpumask: factor out show_cpumap into separate helper function
    driver core: Fix unbalanced device reference in drivers_probe
    driver core: fix race with userland in device_add()
    sysfs/kernfs: make read requests on pre-alloc files use the buffer.
    sysfs/kernfs: allow attributes to request write buffer be pre-allocated.
    fs: sysfs: return EGBIG on write if offset is larger than file size
    ...

    Linus Torvalds
     

11 Dec, 2014

2 commits

  • Pull tracing updates from Steven Rostedt:
    "There was a lot of clean ups and minor fixes. One of those clean ups
    was to the trace_seq code. It also removed the return values to the
    trace_seq_*() functions and use trace_seq_has_overflowed() to see if
    the buffer filled up or not. This is similar to work being done to
    the seq_file code as well in another tree.

    Some of the other goodies include:

    - Added some "!" (NOT) logic to the tracing filter.

    - Fixed the frame pointer logic to the x86_64 mcount trampolines

    - Added the logic for dynamic trampolines on !CONFIG_PREEMPT systems.
    That is, the ftrace trampoline can be dynamically allocated and be
    called directly by functions that only have a single hook to them"

    * tag 'trace-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (55 commits)
    tracing: Truncated output is better than nothing
    tracing: Add additional marks to signal very large time deltas
    Documentation: describe trace_buf_size parameter more accurately
    tracing: Allow NOT to filter AND and OR clauses
    tracing: Add NOT to filtering logic
    ftrace/fgraph/x86: Have prepare_ftrace_return() take ip as first parameter
    ftrace/x86: Get rid of ftrace_caller_setup
    ftrace/x86: Have save_mcount_regs macro also save stack frames if needed
    ftrace/x86: Add macro MCOUNT_REG_SIZE for amount of stack used to save mcount regs
    ftrace/x86: Simplify save_mcount_regs on getting RIP
    ftrace/x86: Have save_mcount_regs store RIP in %rdi for first parameter
    ftrace/x86: Rename MCOUNT_SAVE_FRAME and add more detailed comments
    ftrace/x86: Move MCOUNT_SAVE_FRAME out of header file
    ftrace/x86: Have static tracing also use ftrace_caller_setup
    ftrace/x86: Have static function tracing always test for function graph
    kprobes: Add IPMODIFY flag to kprobe_ftrace_ops
    ftrace, kprobes: Support IPMODIFY flag to find IP modify conflict
    kprobes/ftrace: Recover original IP if pre_handler doesn't change it
    tracing/trivial: Fix typos and make an int into a bool
    tracing: Deletion of an unnecessary check before iput()
    ...

    Linus Torvalds
     
  • Pull EFI updates from Ingo Molnar:
    "Changes in this cycle are:

    - support module unload for efivarfs (Mathias Krause)

    - another attempt at moving x86 to libstub taking advantage of the
    __pure attribute (Ard Biesheuvel)

    - add EFI runtime services section to ptdump (Mathias Krause)"

    * 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    x86, ptdump: Add section for EFI runtime services
    efi/x86: Move x86 back to libstub
    efivarfs: Allow unloading when build as module

    Linus Torvalds
     

20 Nov, 2014

1 commit


12 Nov, 2014

1 commit

  • This reverts commit 84be880560fb, which itself reverted my original
    attempt to move x86 from #include'ing .c files from across the tree
    to using the EFI stub built as a static library.

    The issue that affected the original approach was that splitting
    the implementation into several .o files resulted in the variable
    'efi_early' becoming a global with external linkage, which under
    -fPIC implies that references to it must go through the GOT. However,
    dealing with this additional GOT entry turned out to be troublesome
    on some EFI implementations. (GCC's visibility=hidden attribute is
    supposed to lift this requirement, but it turned out not to work on
    the 32-bit build.)

    Instead, use a pure getter function to get a reference to efi_early.
    This approach results in no additional GOT entries being generated,
    so there is no need for any changes in the early GOT handling.

    Tested-by: Maarten Lankhorst
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Matt Fleming

    Ard Biesheuvel
     

05 Nov, 2014

3 commits

  • In the absence of a DTB configuration table, the EFI stub will happily
    continue attempting to boot a kernel, despite the fact that this kernel
    may not function without a description of the hardware. In this case, as
    with a typo'd "dtb=" option (e.g. "dbt=") or many other possible
    failures, the only output seen by the user will be the rather terse
    output from the EFI stub:

    EFI stub: Booting Linux Kernel...

    To aid those attempting to debug such failures, this patch adds a notice
    when no DTB is found, making the output more helpful:

    EFI stub: Booting Linux Kernel...
    EFI stub: Generating empty DTB

    Additionally, a positive acknowledgement is added when a user-specified
    DTB is in use:

    EFI stub: Booting Linux Kernel...
    EFI stub: Using DTB from command line

    Similarly, a positive acknowledgement is added when a DTB from a
    configuration table is in use:

    EFI stub: Booting Linux Kernel...
    EFI stub: Using DTB from configuration table

    Signed-off-by: Mark Rutland
    Acked-by: Leif Lindholm
    Acked-by: Ard Biesheuvel
    Acked-by: Roy Franz
    Acked-by: Matt Fleming
    Signed-off-by: Ard Biesheuvel

    Mark Rutland
     
  • The DMTF SMBIOS reference spec v3.0.0 defines a new 64-bit entry point,
    which enables support for SMBIOS structure tables residing at a physical
    offset over 4 GB. This is especially important for upcoming arm64
    platforms whose system RAM resides entirely above the 4 GB boundary.

    For the UEFI case, this code attempts to detect the new SMBIOS 3.0
    header magic at the offset passed in the SMBIOS3_TABLE_GUID UEFI
    configuration table. If this configuration table is not provided, or
    if we fail to parse the header, we fall back to using the legacy
    SMBIOS_TABLE_GUID configuration table. This is in line with the spec,
    that allows both configuration tables to be provided, but mandates that
    they must point to the same structure table, unless the version pointed
    to by the 64-bit entry point is a superset of the 32-bit one.

    For the non-UEFI case, the detection logic is modified to look for the
    SMBIOS 3.0 header magic before it looks for the legacy header magic.

    Note that this patch is based on version 3.0.0d [draft] of the
    specification, which is expected not to deviate from the final version
    in ways that would affect the correctness of this implementation.

    Tested-by: Suravee Suthikulpanit
    Acked-by: Leif Lindholm
    Tested-by: Leif Lindholm
    Cc: Andrew Morton
    Cc: Tony Luck
    Acked-by: Matt Fleming
    Signed-off-by: Ard Biesheuvel

    Ard Biesheuvel
     
  • This adds support to the UEFI side for detecting the presence of
    a SMBIOS 3.0 64-bit entry point. This allows the actual SMBIOS
    structure table to reside at a physical offset over 4 GB, which
    cannot be supported by the legacy SMBIOS 32-bit entry point.

    Since the firmware can legally provide both entry points, store
    the SMBIOS 3.0 entry point in a separate variable, and let the
    DMI decoding layer decide which one will be used.

    Tested-by: Suravee Suthikulpanit
    Acked-by: Leif Lindholm
    Acked-by: Matt Fleming
    Signed-off-by: Ard Biesheuvel

    Ard Biesheuvel
     

04 Nov, 2014

1 commit


24 Oct, 2014

1 commit

  • Pull x86 EFI updates from Peter Anvin:
    "This patchset falls under the "maintainers that grovel" clause in the
    v3.18-rc1 announcement. We had intended to push it late in the merge
    window since we got it into the -tip tree relatively late.

    Many of these are relatively simple things, but there are a couple of
    key bits, especially Ard's and Matt's patches"

    * 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (24 commits)
    rtc: Disable EFI rtc for x86
    efi: rtc-efi: Export platform:rtc-efi as module alias
    efi: Delete the in_nmi() conditional runtime locking
    efi: Provide a non-blocking SetVariable() operation
    x86/efi: Adding efi_printks on memory allocationa and pci.reads
    x86/efi: Mark initialization code as such
    x86/efi: Update comment regarding required phys mapped EFI services
    x86/efi: Unexport add_efi_memmap variable
    x86/efi: Remove unused efi_call* macros
    efi: Resolve some shadow warnings
    arm64: efi: Format EFI memory type & attrs with efi_md_typeattr_format()
    ia64: efi: Format EFI memory type & attrs with efi_md_typeattr_format()
    x86: efi: Format EFI memory type & attrs with efi_md_typeattr_format()
    efi: Introduce efi_md_typeattr_format()
    efi: Add macro for EFI_MEMORY_UCE memory attribute
    x86/efi: Clear EFI_RUNTIME_SERVICES if failing to enter virtual mode
    arm64/efi: Do not enter virtual mode if booting with efi=noruntime or noefi
    arm64/efi: uefi_init error handling fix
    efi: Add kernel param efi=noruntime
    lib: Add a generic cmdline parse function parse_option_str
    ...

    Linus Torvalds
     

20 Oct, 2014

1 commit


10 Oct, 2014

1 commit

  • By the following commits, we prevented from allocating firmware_map_entry
    of same memory range:
    f0093ede: drivers/firmware/memmap.c: don't allocate firmware_map_entry
    of same memory range
    49c8b24d: drivers/firmware/memmap.c: pass the correct argument to
    firmware_map_find_entry_bootmem()

    But it's not enough. When PNP0C80 device is added by acpi_scan_init(),
    memmap sysfses of same firmware_map_entry are created twice as follows:

    # cat /sys/firmware/memmap/*/start
    0x40000000000
    0x60000000000
    0x4a837000
    0x4a83a000
    0x4a8b5000
    ...
    0x40000000000
    0x60000000000
    ...

    The flows of the issues are as follows:

    1. e820_reserve_resources() allocates firmware_map_entrys of all
    memory ranges defined in e820. And, these firmware_map_entrys
    are linked with map_entries list.

    map_entries -> entry 1 -> ... -> entry N

    2. When PNP0C80 device is limited by mem= boot option, acpi_scan_init()
    added the memory device. In this case, firmware_map_add_hotplug()
    allocates firmware_map_entry and creates memmap sysfs.

    map_entries -> entry 1 -> ... -> entry N -> entry N+1
    |
    memmap 1

    3. firmware_memmap_init() creates memmap sysfses of firmware_map_entrys
    linked with map_entries.

    map_entries -> entry 1 -> ... -> entry N -> entry N+1
    | | |
    memmap 2 memmap N+1 memmap 1
    memmap N+2

    So while hot removing the PNP0C80 device, kernel panic occurs as follows:

    BUG: unable to handle kernel paging request at 00000001003e000b
    IP: sysfs_open_file+0x46/0x2b0
    PGD 203a89fe067 PUD 0
    Oops: 0000 [#1] SMP
    ...
    Call Trace:
    do_dentry_open+0x1ef/0x2a0
    finish_open+0x31/0x40
    do_last+0x57c/0x1220
    path_openat+0xc2/0x4c0
    do_filp_open+0x4b/0xb0
    do_sys_open+0xf3/0x1f0
    SyS_open+0x1e/0x20
    system_call_fastpath+0x16/0x1b

    The patch adds a check of confirming whether memmap sysfs of
    firmware_map_entry has been created, and does not create memmap
    sysfs of same firmware_map_entry.

    Signed-off-by: Yasuaki Ishimatsu
    Cc: Santosh Shilimkar
    Cc: Toshi Kani
    Cc: Greg Kroah-Hartman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yasuaki Ishimatsu
     

04 Oct, 2014

9 commits

  • Conflicts:
    arch/x86/boot/compressed/eboot.c

    Matt Fleming
     
  • commit 5dc3826d9f08 ("efi: Implement mandatory locking for UEFI Runtime
    Services") implemented some conditional locking when accessing variable
    runtime services that Ingo described as "pretty disgusting".

    The intention with the !efi_in_nmi() checks was to avoid live-locks when
    trying to write pstore crash data into an EFI variable. Such lockless
    accesses are allowed according to the UEFI specification when we're in a
    "non-recoverable" state, but whether or not things are implemented
    correctly in actual firmware implementations remains an unanswered
    question, and so it would seem sensible to avoid doing any kind of
    unsynchronized variable accesses.

    Furthermore, the efi_in_nmi() tests are inadequate because they don't
    account for the case where we call EFI variable services from panic or
    oops callbacks and aren't executing in NMI context. In other words,
    live-locking is still possible.

    Let's just remove the conditional locking altogether. Now we've got the
    ->set_variable_nonblocking() EFI variable operation we can abort if the
    runtime lock is already held. Aborting is by far the safest option.

    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Cc: Ard Biesheuvel
    Cc: Matthew Garrett
    Signed-off-by: Matt Fleming

    Matt Fleming
     
  • There are some circumstances that call for trying to write an EFI
    variable in a non-blocking way. One such scenario is when writing pstore
    data in efi_pstore_write() via the pstore_dump() kdump callback.

    Now that we have an EFI runtime spinlock we need a way of aborting if
    there is contention instead of spinning, since when writing pstore data
    from the kdump callback, the runtime lock may already be held by the CPU
    that's running the callback if we crashed in the middle of an EFI
    variable operation.

    The situation is sufficiently special that a new EFI variable operation
    is warranted.

    Introduce ->set_variable_nonblocking() for this use case. It is an
    optional EFI backend operation, and need only be implemented by those
    backends that usually acquire locks to serialize access to EFI
    variables, as is the case for virt_efi_set_variable() where we now grab
    the EFI runtime spinlock.

    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Cc: Ard Biesheuvel
    Cc: Matthew Garrett
    Signed-off-by: Matt Fleming

    Matt Fleming
     
  • It is a really bad idea to declare variables or parameters that
    have the same name as common types. It is valid C, but it gets
    surprising if a macro expansion attempts to declare an inner
    local with that type. Change the local names to eliminate the
    hazard.

    Change s16 => str16, s8 => str8.

    This resolves warnings seen when using W=2 during make, for instance:

    drivers/firmware/efi/vars.c: In function ‘dup_variable_bug’:
    drivers/firmware/efi/vars.c:324:44: warning: declaration of ‘s16’ shadows a global declaration [-Wshadow]
    static void dup_variable_bug(efi_char16_t *s16, efi_guid_t *vendor_guid,

    drivers/firmware/efi/vars.c:328:8: warning: declaration of ‘s8’ shadows a global declaration [-Wshadow]
    char *s8;

    Signed-off-by: Mark Rustad
    Signed-off-by: Jeff Kirsher
    Signed-off-by: Matt Fleming

    Mark Rustad
     
  • At the moment, there are three architectures debug-printing the EFI memory
    map at initialization: x86, ia64, and arm64. They all use different format
    strings, plus the EFI memory type and the EFI memory attributes are
    similarly hard to decode for a human reader.

    Introduce a helper __init function that formats the memory type and the
    memory attributes in a unified way, to a user-provided character buffer.

    The array "memory_type_name" is copied from the arm64 code, temporarily
    duplicating it. The (otherwise optional) braces around each string literal
    in the initializer list are dropped in order to match the kernel coding
    style more closely. The element size is tightened from 32 to 20 bytes
    (maximum actual string length + 1) so that we can derive the field width
    from the element size.

    Signed-off-by: Laszlo Ersek
    Tested-by: Ard Biesheuvel
    Acked-by: Ard Biesheuvel
    [ Dropped useless 'register' keyword, which compiler will ignore ]
    Signed-off-by: Matt Fleming

    Laszlo Ersek
     
  • noefi kernel param means actually disabling efi runtime, Per suggestion
    from Leif Lindholm efi=noruntime should be better. But since noefi is
    already used in X86 thus just adding another param efi=noruntime for
    same purpose.

    Signed-off-by: Dave Young
    Signed-off-by: Matt Fleming

    Dave Young
     
  • noefi param can be used for arches other than X86 later, thus move it
    out of x86 platform code.

    Signed-off-by: Dave Young
    Signed-off-by: Matt Fleming

    Dave Young
     
  • We need a way to customize the behaviour of the EFI boot stub, in
    particular, we need a way to disable the "chunking" workaround, used
    when reading files from the EFI System Partition.

    One of my machines doesn't cope well when reading files in 1MB chunks to
    a buffer above the 4GB mark - it appears that the "chunking" bug
    workaround triggers another firmware bug. This was only discovered with
    commit 4bf7111f5016 ("x86/efi: Support initrd loaded above 4G"), and
    that commit is perfectly valid. The symptom I observed was a corrupt
    initrd rather than any kind of crash.

    efi= is now used to specify EFI parameters in two very different
    execution environments, the EFI boot stub and during kernel boot.

    There is also a slight performance optimization by enabling efi=nochunk,
    but that's offset by the fact that you're more likely to run into
    firmware issues, at least on x86. This is the rationale behind leaving
    the workaround enabled by default.

    Also provide some documentation for EFI_READ_CHUNK_SIZE and why we're
    using the current value of 1MB.

    Tested-by: Ard Biesheuvel
    Cc: Roy Franz
    Cc: Maarten Lankhorst
    Cc: Leif Lindholm
    Cc: Borislav Petkov
    Signed-off-by: Matt Fleming

    Matt Fleming
     
  • According to section 7.1 of the UEFI spec, Runtime Services are not fully
    reentrant, and there are particular combinations of calls that need to be
    serialized. Use a spinlock to serialize all Runtime Services with respect
    to all others, even if this is more than strictly needed.

    We've managed to get away without requiring a runtime services lock
    until now because most of the interactions with EFI involve EFI
    variables, and those operations are already serialised with
    __efivars->lock.

    Some of the assumptions underlying the decision whether locks are
    needed or not (e.g., SetVariable() against ResetSystem()) may not
    apply universally to all [new] architectures that implement UEFI.
    Rather than try to reason our way out of this, let's just implement at
    least what the spec requires in terms of locking.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Matt Fleming

    Ard Biesheuvel
     

24 Sep, 2014

1 commit

  • This reverts commit f23cf8bd5c1f ("efi/x86: efistub: Move shared
    dependencies to ") as well as the x86 parts of commit
    f4f75ad5741f ("efi: efistub: Convert into static library").

    The road leading to these two reverts is long and winding.

    The above two commits were merged during the v3.17 merge window and
    turned the common EFI boot stub code into a static library. This
    necessitated making some symbols global in the x86 boot stub which
    introduced new entries into the early boot GOT.

    The problem was that we weren't fixing up the newly created GOT entries
    before invoking the EFI boot stub, which sometimes resulted in hangs or
    resets. This failure was reported by Maarten on his Macbook pro.

    The proposed fix was commit 9cb0e394234d ("x86/efi: Fixup GOT in all
    boot code paths"). However, that caused issues for Linus when booting
    his Sony Vaio Pro 11. It was subsequently reverted in commit
    f3670394c29f.

    So that leaves us back with Maarten's Macbook pro not booting.

    At this stage in the release cycle the least risky option is to revert
    the x86 EFI boot stub to the pre-merge window code structure where we
    explicitly #include efi-stub-helper.c instead of linking with the static
    library. The arm64 code remains unaffected.

    We can take another swing at the x86 parts for v3.18.

    Conflicts:
    arch/x86/include/asm/efi.h

    Tested-by: Josh Boyer
    Tested-by: Maarten Lankhorst
    Tested-by: Leif Lindholm [arm64]
    Tested-by: Linus Torvalds
    Cc: H. Peter Anvin
    Cc: Ard Biesheuvel ,
    Cc: Ingo Molnar
    Signed-off-by: Matt Fleming

    Matt Fleming
     

09 Sep, 2014

1 commit

  • Commit 86c8b27a01cf:
    "arm64: ignore DT memreserve entries when booting in UEFI mode

    prevents early_init_fdt_scan_reserved_mem() from being called for
    arm64 kernels booting via UEFI. This was done because the kernel
    will use the UEFI memory map to determine reserved memory regions.
    That approach has problems in that early_init_fdt_scan_reserved_mem()
    also reserves the FDT itself and any node-specific reserved memory.
    By chance of some kernel configs, the FDT may be overwritten before
    it can be unflattened and the kernel will fail to boot. More subtle
    problems will result if the FDT has node specific reserved memory
    which is not really reserved.

    This patch has the UEFI stub remove the memory reserve map entries
    from the FDT as it does with the memory nodes. This allows
    early_init_fdt_scan_reserved_mem() to be called unconditionally
    so that the other needed reservations are made.

    Signed-off-by: Mark Salter
    Acked-by: Ard Biesheuvel
    Acked-by: Mark Rutland
    Signed-off-by: Matt Fleming

    Mark Salter