1. 01 2月, 2019 5 次提交
    • C
      x86/boot: Search for RSDP in memory · 93a209aa
      Chao Fan 提交于
      Scan memory (EBDA) for the RSDP and verify RSDP by signature and
      checksum.
      
       [ bp:
         - Trim commit message.
         - Simplify bios_get_rsdp_addr() and cleanup mad casting.
       ]
      Signed-off-by: NChao Fan <fanc.fnst@cn.fujitsu.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: bhe@redhat.com
      Cc: caoj.fnst@cn.fujitsu.com
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: indou.takao@jp.fujitsu.com
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: kasong@redhat.com
      Cc: Kees Cook <keescook@chromium.org>
      Cc: msys.mizuma@gmail.com
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20190123110850.12433-5-fanc.fnst@cn.fujitsu.com
      93a209aa
    • C
      x86/boot: Search for RSDP in the EFI tables · 33f0df8d
      Chao Fan 提交于
      The immovable memory ranges information in the SRAT table is necessary
      to fix the issue of KASLR not paying attention to movable memory regions
      when selecting the offset. Therefore, SRAT needs to be parsed.
      
      Depending on the boot: KEXEC/EFI/BIOS, the methods to compute RSDP are
      different. When booting from EFI, the EFI table points to the RSDP. So
      iterate over the EFI system tables in order to find the RSDP.
      
       [ bp:
         - Heavily massage commit message
         - Trim comments
         - Move the CONFIG_ACPI ifdeffery into the Makefile.
       ]
      Signed-off-by: NChao Fan <fanc.fnst@cn.fujitsu.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: bhe@redhat.com
      Cc: caoj.fnst@cn.fujitsu.com
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: indou.takao@jp.fujitsu.com
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: kasong@redhat.com
      Cc: Kees Cook <keescook@chromium.org>
      Cc: msys.mizuma@gmail.com
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20190123110850.12433-4-fanc.fnst@cn.fujitsu.com
      33f0df8d
    • C
      x86/boot: Add "acpi_rsdp=" early parsing · 3c98e71b
      Chao Fan 提交于
      KASLR may randomly choose offsets which are located in movable memory
      regions resulting in the movable memory becoming immovable.
      
      The ACPI SRAT (System/Static Resource Affinity Table) describes memory
      ranges including ranges of memory provided by hot-added memory devices.
      In order to access SRAT, one needs the Root System Description Pointer
      (RSDP) with which to find the Root/Extended System Description Table
      (R/XSDT) which then contains the system description tables of which SRAT
      is one of.
      
      In case the RSDP address has been passed on the command line (kexec-ing
      a second kernel) parse it from there.
      
       [ bp: Rewrite the commit message and cleanup the code. ]
      Signed-off-by: NChao Fan <fanc.fnst@cn.fujitsu.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: bhe@redhat.com
      Cc: caoj.fnst@cn.fujitsu.com
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: indou.takao@jp.fujitsu.com
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: kasong@redhat.com
      Cc: Kees Cook <keescook@chromium.org>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: msys.mizuma@gmail.com
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20190123110850.12433-3-fanc.fnst@cn.fujitsu.com
      3c98e71b
    • C
      x86/boot: Copy kstrtoull() to boot/string.c · de50ce20
      Chao Fan 提交于
      Copy kstrtoull() and the other necessary functions from lib/kstrtox.c
      to boot/string.c so that code in boot/ can use kstrtoull() and the old
      simple_strtoull() can gradually be phased out.
      
      Using div_u64() from math64.h directly will cause the dividend to be
      handled as a 64-bit value and cause the infamous __divdi3 linker error
      due to gcc trying to use its library function for the 64-bit division.
      
      Therefore, separate the dividend into an upper and lower part.
      
       [ bp: Rewrite commit message. ]
      Signed-off-by: NChao Fan <fanc.fnst@cn.fujitsu.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: bhe@redhat.com
      Cc: caoj.fnst@cn.fujitsu.com
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: indou.takao@jp.fujitsu.com
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: kasong@redhat.com
      Cc: Kees Cook <keescook@chromium.org>
      Cc: msys.mizuma@gmail.com
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20190123110850.12433-2-fanc.fnst@cn.fujitsu.com
      de50ce20
    • B
      x86/boot: Build the command line parsing code unconditionally · ac09c5f4
      Borislav Petkov 提交于
      Just drop the three-item ifdeffery and build it in unconditionally.
      Early cmdline parsing is needed more often than not.
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: bhe@redhat.com
      Cc: hpa@zytor.com
      Cc: indou.takao@jp.fujitsu.com
      Cc: kasong@redhat.com
      Cc: keescook@chromium.org
      Cc: mingo@redhat.com
      Cc: msys.mizuma@gmail.com
      Cc: tglx@linutronix.de
      Cc: x86@kernel.org
      Link: https://lkml.kernel.org/r/20190130112238.GB18383@zn.tnic
      ac09c5f4
  2. 06 1月, 2019 1 次提交
  3. 30 11月, 2018 1 次提交
    • E
      x86/efi: Allocate e820 buffer before calling efi_exit_boot_service · b84a64fa
      Eric Snowberg 提交于
      The following commit:
      
        d6493401 ("x86/efi: Use efi_exit_boot_services()")
      
      introduced a regression on systems with large memory maps causing them
      to hang on boot. The first "goto get_map" that was removed from
      exit_boot() ensured there was enough room for the memory map when
      efi_call_early(exit_boot_services) was called. This happens when
      (nr_desc > ARRAY_SIZE(params->e820_table).
      
      Chain of events:
      
        exit_boot()
          efi_exit_boot_services()
            efi_get_memory_map                  <- at this point the mm can't grow over 8 desc
            priv_func()
              exit_boot_func()
                allocate_e820ext()              <- new mm grows over 8 desc from e820 alloc
            efi_call_early(exit_boot_services)  <- mm key doesn't match so retry
            efi_call_early(get_memory_map)      <- not enough room for new mm
            system hangs
      
      This patch allocates the e820 buffer before calling efi_exit_boot_services()
      and fixes the regression.
      
       [ mingo: minor cleanliness edits. ]
      Signed-off-by: NEric Snowberg <eric.snowberg@oracle.com>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: <stable@vger.kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
      Cc: Bhupesh Sharma <bhsharma@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Jon Hunter <jonathanh@nvidia.com>
      Cc: Julien Thierry <julien.thierry@arm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Nathan Chancellor <natechancellor@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
      Cc: Sedat Dilek <sedat.dilek@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: YiFei Zhu <zhuyifei1999@gmail.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20181129171230.18699-2-ard.biesheuvel@linaro.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      b84a64fa
  4. 29 11月, 2018 1 次提交
  5. 20 11月, 2018 1 次提交
  6. 07 11月, 2018 1 次提交
  7. 29 10月, 2018 1 次提交
  8. 14 10月, 2018 1 次提交
    • N
      x86/boot: Add -Wno-pointer-sign to KBUILD_CFLAGS · dca5203e
      Nathan Chancellor 提交于
      When compiling the kernel with Clang, this warning appears even though
      it is disabled for the whole kernel because this folder has its own set
      of KBUILD_CFLAGS. It was disabled before the beginning of git history.
      
      In file included from arch/x86/boot/compressed/kaslr.c:29:
      In file included from arch/x86/boot/compressed/misc.h:21:
      In file included from ./include/linux/elf.h:5:
      In file included from ./arch/x86/include/asm/elf.h:77:
      In file included from ./arch/x86/include/asm/vdso.h:11:
      In file included from ./include/linux/mm_types.h:9:
      In file included from ./include/linux/spinlock.h:88:
      In file included from ./arch/x86/include/asm/spinlock.h:43:
      In file included from ./arch/x86/include/asm/qrwlock.h:6:
      ./include/asm-generic/qrwlock.h:101:53: warning: passing 'u32 *' (aka
      'unsigned int *') to parameter of type 'int *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
              if (likely(atomic_try_cmpxchg_acquire(&lock->cnts, &cnts, _QW_LOCKED)))
                                                                 ^~~~~
      ./include/linux/compiler.h:76:40: note: expanded from macro 'likely'
      # define likely(x)      __builtin_expect(!!(x), 1)
                                                  ^
      ./include/asm-generic/atomic-instrumented.h:69:66: note: passing
      argument to parameter 'old' here
      static __always_inline bool atomic_try_cmpxchg(atomic_t *v, int *old, int new)
                                                                       ^
      Signed-off-by: NNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Link: https://lkml.kernel.org/r/20181013010713.6999-1-natechancellor@gmail.com
      dca5203e
  9. 10 10月, 2018 1 次提交
    • J
      x86/boot: Add ACPI RSDP address to setup_header · ae7e1238
      Juergen Gross 提交于
      Xen PVH guests receive the address of the RSDP table from Xen. In order
      to support booting a Xen PVH guest via Grub2 using the standard x86
      boot entry we need a way for Grub2 to pass the RSDP address to the
      kernel.
      
      For this purpose expand the struct setup_header to hold the physical
      address of the RSDP address. Being zero means it isn't specified and
      has to be located the legacy way (searching through low memory or
      EBDA).
      
      While documenting the new setup_header layout and protocol version
      2.14 add the missing documentation of protocol version 2.13.
      
      There are Grub2 versions in several distros with a downstream patch
      violating the boot protocol by writing past the end of setup_header.
      This requires another update of the boot protocol to enable the kernel
      to distinguish between a specified RSDP address and one filled with
      garbage by such a broken Grub2.
      
      From protocol 2.14 on Grub2 will write the version it is supporting
      (but never a higher value than found to be supported by the kernel)
      ored with 0x8000 to the version field of setup_header. This enables
      the kernel to know up to which field Grub2 has written information
      to. All fields after that are supposed to be clobbered.
      Signed-off-by: NJuergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: boris.ostrovsky@oracle.com
      Cc: bp@alien8.de
      Cc: corbet@lwn.net
      Cc: linux-doc@vger.kernel.org
      Cc: xen-devel@lists.xenproject.org
      Link: http://lkml.kernel.org/r/20181010061456.22238-3-jgross@suse.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      ae7e1238
  10. 28 9月, 2018 1 次提交
    • K
      x86/boot: Fix kexec booting failure in the SEV bit detection code · bdec8d7f
      Kairui Song 提交于
      Commit
      
        1958b5fc ("x86/boot: Add early boot support when running with SEV active")
      
      can occasionally cause system resets when kexec-ing a second kernel even
      if SEV is not active.
      
      That's because get_sev_encryption_bit() uses 32-bit rIP-relative
      addressing to read the value of enc_bit - a variable which caches a
      previously detected encryption bit position - but kexec may allocate
      the early boot code to a higher location, beyond the 32-bit addressing
      limit.
      
      In this case, garbage will be read and get_sev_encryption_bit() will
      return the wrong value, leading to accessing memory with the wrong
      encryption setting.
      
      Therefore, remove enc_bit, and thus get rid of the need to do 32-bit
      rIP-relative addressing in the first place.
      
       [ bp: massage commit message heavily. ]
      
      Fixes: 1958b5fc ("x86/boot: Add early boot support when running with SEV active")
      Suggested-by: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NKairui Song <kasong@redhat.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Reviewed-by: NTom Lendacky <thomas.lendacky@amd.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: tglx@linutronix.de
      Cc: mingo@redhat.com
      Cc: hpa@zytor.com
      Cc: brijesh.singh@amd.com
      Cc: kexec@lists.infradead.org
      Cc: dyoung@redhat.com
      Cc: bhe@redhat.com
      Cc: ghook@redhat.com
      Link: https://lkml.kernel.org/r/20180927123845.32052-1-kasong@redhat.com
      bdec8d7f
  11. 26 9月, 2018 2 次提交
    • B
      x86: boot: Fix EFI stub alignment · 9c1442a9
      Ben Hutchings 提交于
      We currently align the end of the compressed image to a multiple of
      16.  However, the PE-COFF header included in the EFI stub says that
      the file alignment is 32 bytes, and when adding an EFI signature to
      the file it must first be padded to this alignment.
      
      sbsigntool commands warn about this:
      
        warning: file-aligned section .text extends beyond end of file
        warning: checksum areas are greater than image size. Invalid section table?
      
      Worse, pesign -at least when creating a detached signature- uses the
      hash of the unpadded file, resulting in an invalid signature if
      padding is required.
      
      Avoid both these problems by increasing alignment to 32 bytes when
      CONFIG_EFI_STUB is enabled.
      Signed-off-by: NBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      9c1442a9
    • H
      efi/x86: Call efi_parse_options() from efi_main() · c33ce984
      Hans de Goede 提交于
      Before this commit we were only calling efi_parse_options() from
      make_boot_params(), but make_boot_params() only gets called if the
      kernel gets booted directly as an EFI executable. So when booted through
      e.g. grub we ended up not parsing the commandline in the boot code.
      
      This makes the drivers/firmware/efi/libstub code ignore the "quiet"
      commandline argument resulting in the following message being printed:
      "EFI stub: UEFI Secure Boot is enabled."
      
      Despite the quiet request. This commits adds an extra call to
      efi_parse_options() to efi_main() to make sure that the options are
      always processed. This fixes quiet not working.
      
      This also fixes the libstub code ignoring nokaslr and efi=nochunk.
      Reported-by: NPeter Robinson <pbrobinson@redhat.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      c33ce984
  12. 10 9月, 2018 1 次提交
  13. 03 9月, 2018 1 次提交
  14. 24 8月, 2018 1 次提交
  15. 23 8月, 2018 1 次提交
  16. 02 8月, 2018 2 次提交
  17. 31 7月, 2018 1 次提交
  18. 25 7月, 2018 1 次提交
    • K
      x86/boot: Fix if_changed build flip/flop bug · 92a47286
      Kees Cook 提交于
      Dirk Gouders reported that two consecutive "make" invocations on an
      already compiled tree will show alternating behaviors:
      
      $ make
        CALL    scripts/checksyscalls.sh
        DESCEND  objtool
        CHK     include/generated/compile.h
        DATAREL arch/x86/boot/compressed/vmlinux
      Kernel: arch/x86/boot/bzImage is ready  (#48)
        Building modules, stage 2.
        MODPOST 165 modules
      
      $ make
        CALL    scripts/checksyscalls.sh
        DESCEND  objtool
        CHK     include/generated/compile.h
        LD      arch/x86/boot/compressed/vmlinux
        ZOFFSET arch/x86/boot/zoffset.h
        AS      arch/x86/boot/header.o
        LD      arch/x86/boot/setup.elf
        OBJCOPY arch/x86/boot/setup.bin
        OBJCOPY arch/x86/boot/vmlinux.bin
        BUILD   arch/x86/boot/bzImage
      Setup is 15644 bytes (padded to 15872 bytes).
      System is 6663 kB
      CRC 3eb90f40
      Kernel: arch/x86/boot/bzImage is ready  (#48)
        Building modules, stage 2.
        MODPOST 165 modules
      
      He bisected it back to:
      
          commit 98f78525 ("x86/boot: Refuse to build with data relocations")
      
      The root cause was the use of the "if_changed" kbuild function multiple
      times for the same target. It was designed to only be used once per
      target, otherwise it will effectively always trigger, flipping back and
      forth between the two commands getting recorded by "if_changed". Instead,
      this patch merges the two commands into a single function to get stable
      build artifacts (i.e. .vmlinux.cmd), and a single build behavior.
      Bisected-and-Reported-by: NDirk Gouders <dirk@gouders.net>
      Fix-Suggested-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180724230827.GA37823@beastSigned-off-by: NIngo Molnar <mingo@kernel.org>
      92a47286
  19. 22 7月, 2018 6 次提交
  20. 16 7月, 2018 1 次提交
  21. 11 7月, 2018 1 次提交
    • A
      efi/x86: Fix mixed mode reboot loop by removing pointless call to PciIo->Attributes() · e2967018
      Ard Biesheuvel 提交于
      Hans de Goede reported that his mixed EFI mode Bay Trail tablet
      would not boot at all any more, but enter a reboot loop without
      any logs printed by the kernel.
      
      Unbreak 64-bit Linux/x86 on 32-bit UEFI:
      
      When it was first introduced, the EFI stub code that copies the
      contents of PCI option ROMs originally only intended to do so if
      the EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM attribute was *not* set.
      
      The reason was that the UEFI spec permits PCI option ROM images
      to be provided by the platform directly, rather than via the ROM
      BAR, and in this case, the OS can only access them at runtime if
      they are preserved at boot time by copying them from the areas
      described by PciIo->RomImage and PciIo->RomSize.
      
      However, it implemented this check erroneously, as can be seen in
      commit:
      
        dd5fc854 ("EFI: Stash ROMs if they're not in the PCI BAR")
      
      which introduced:
      
          if (!attributes & EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM)
                  continue;
      
      and given that the numeric value of EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM
      is 0x4000, this condition never becomes true, and so the option ROMs
      were copied unconditionally.
      
      This was spotted and 'fixed' by commit:
      
        886d751a ("x86, efi: correct precedence of operators in setup_efi_pci")
      
      but inadvertently inverted the logic at the same time, defeating
      the purpose of the code, since it now only preserves option ROM
      images that can be read from the ROM BAR as well.
      
      Unsurprisingly, this broke some systems, and so the check was removed
      entirely in the following commit:
      
        73970188 ("x86, efi: remove attribute check from setup_efi_pci")
      
      It is debatable whether this check should have been included in the
      first place, since the option ROM image provided to the UEFI driver by
      the firmware may be different from the one that is actually present in
      the card's flash ROM, and so whatever PciIo->RomImage points at should
      be preferred regardless of whether the attribute is set.
      
      As this was the only use of the attributes field, we can remove
      the call to PciIo->Attributes() entirely, which is especially
      nice because its prototype involves uint64_t type by-value
      arguments which the EFI mixed mode has trouble dealing with.
      
      Any mixed mode system with PCI is likely to be affected.
      Tested-by: NWilfried Klaebe <linux-kernel@lebenslange-mailadresse.de>
      Tested-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20180711090235.9327-2-ard.biesheuvel@linaro.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      e2967018
  22. 03 7月, 2018 2 次提交
    • B
      x86/boot/KASLR: Skip specified number of 1GB huge pages when doing physical randomization (KASLR) · 747ff626
      Baoquan He 提交于
      When KASLR is enabled then 1GB huge pages allocations might regress
      sporadically.
      
      To reproduce on a KVM guest with 4GB RAM:
      
      - add the following options to the kernel command-line:
      
         'default_hugepagesz=1G hugepagesz=1G hugepages=1'
      
      - boot the guest and check number of 1GB pages reserved:
      
          # grep HugePages_Total /proc/meminfo
      
      - sporadically, every couple of bootups the output of this
        command shows that when booting with "nokaslr" HugePages_Total is always 1,
        while booting without "nokaslr" sometimes HugePages_Total is set as 0
        (that is, reserving the 1GB page failed).
      
      Note that you may need to boot a few times to trigger the issue,
      because it's somewhat non-deterministic.
      
      The root cause is that kernel may be put into the only good 1GB huge page
      in the [0x40000000, 0x7fffffff] physical range randomly.
      
      Below is the dmesg output snippet from the KVM guest. We can see that only
      [0x40000000, 0x7fffffff] region is good 1GB huge page,
      [0x100000000, 0x13fffffff] will be touched by the memblock top-down allocation:
      
      [...] e820: BIOS-provided physical RAM map:
      [...] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
      [...] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
      [...] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
      [...] BIOS-e820: [mem 0x0000000000100000-0x00000000bffdffff] usable
      [...] BIOS-e820: [mem 0x00000000bffe0000-0x00000000bfffffff] reserved
      [...] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
      [...] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
      [...] BIOS-e820: [mem 0x0000000100000000-0x000000013fffffff] usable
      
      Besides, on bare-metal machines with larger memory, one less 1GB huge page
      might be available with KASLR enabled. That too is because the kernel
      image might be randomized into those "good" 1GB huge pages.
      
      To fix this, firstly parse the kernel command-line to get how many 1GB huge
      pages are specified. Then try to skip the specified number of 1GB huge
      pages when decide which memory region kernel can be randomized into.
      
      Also change the name of handle_mem_memmap() as handle_mem_options()
      since it handles not only 'mem=' and 'memmap=', but also 'hugepagesxxx' now.
      Signed-off-by: NBaoquan He <bhe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: douly.fnst@cn.fujitsu.com
      Cc: fanc.fnst@cn.fujitsu.com
      Cc: indou.takao@jp.fujitsu.com
      Cc: keescook@chromium.org
      Cc: lcapitulino@redhat.com
      Cc: yasu.isimatu@gmail.com
      Link: http://lkml.kernel.org/r/20180625031656.12443-3-bhe@redhat.com
      [ Rewrote the changelog, fixed style problems in the code. ]
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      747ff626
    • B
      x86/boot/KASLR: Add two new functions for 1GB huge pages handling · 9b912485
      Baoquan He 提交于
      Introduce two new functions: parse_gb_huge_pages() and process_gb_huge_pages(),
      which handle a conflict between KASLR and huge pages of 1GB.
      
      These two functions will be used in the next patch:
      
      - parse_gb_huge_pages() is used to parse kernel command-line to get
        how many 1GB huge pages have been specified. A static global
        variable 'max_gb_huge_pages' is added to store the number.
      
      - process_gb_huge_pages() is used to skip as many 1GB huge pages
        as possible from the passed in memory region according to the
        specified number.
      Signed-off-by: NBaoquan He <bhe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: douly.fnst@cn.fujitsu.com
      Cc: fanc.fnst@cn.fujitsu.com
      Cc: indou.takao@jp.fujitsu.com
      Cc: keescook@chromium.org
      Cc: lcapitulino@redhat.com
      Cc: yasu.isimatu@gmail.com
      Link: http://lkml.kernel.org/r/20180625031656.12443-2-bhe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      9b912485
  23. 24 6月, 2018 1 次提交
    • A
      efi/x86: Fix incorrect invocation of PciIo->Attributes() · 2e6eb40c
      Ard Biesheuvel 提交于
      The following commit:
      
        2c3625cb ("efi/x86: Fold __setup_efi_pci32() and __setup_efi_pci64() into one function")
      
      ... merged the two versions of __setup_efi_pciXX(), without taking into
      account that the 32-bit version used a rather dodgy trick to pass an
      immediate 0 constant as argument for a uint64_t parameter.
      
      The issue is caused by the fact that on x86, UEFI protocol method calls
      are redirected via struct efi_config::call(), which is a variadic function,
      and so the compiler has to infer the types of the parameters from the
      arguments rather than from the prototype.
      
      As the 32-bit x86 calling convention passes arguments via the stack,
      passing the unqualified constant 0 twice is the same as passing 0ULL,
      which is why the 32-bit code in __setup_efi_pci32() contained the
      following call:
      
        status = efi_early->call(pci->attributes, pci,
                                 EfiPciIoAttributeOperationGet, 0, 0,
                                 &attributes);
      
      to invoke this UEFI protocol method:
      
        typedef
        EFI_STATUS
        (EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES) (
          IN  EFI_PCI_IO_PROTOCOL                     *This,
          IN  EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation,
          IN  UINT64                                  Attributes,
          OUT UINT64                                  *Result OPTIONAL
          );
      
      After the merge, we inadvertently ended up with this version for both
      32-bit and 64-bit builds, breaking the latter.
      
      So replace the two zeroes with the explicitly typed constant 0ULL,
      which works as expected on both 32-bit and 64-bit builds.
      
      Wilfried tested the 64-bit build, and I checked the generated assembly
      of a 32-bit build with and without this patch, and they are identical.
      Reported-by: NWilfried Klaebe <linux-kernel@lebenslange-mailadresse.de>
      Tested-by: NWilfried Klaebe <linux-kernel@lebenslange-mailadresse.de>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: hdegoede@redhat.com
      Cc: linux-efi@vger.kernel.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      2e6eb40c
  24. 06 6月, 2018 1 次提交
  25. 19 5月, 2018 3 次提交
  26. 16 5月, 2018 1 次提交