1
0
Fork 0
alistair23-linux/arch/x86/boot
Ard Biesheuvel 2e6eb40ca5 efi/x86: Fix incorrect invocation of PciIo->Attributes()
The following commit:

  2c3625cb9f ("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: Wilfried Klaebe <linux-kernel@lebenslange-mailadresse.de>
Tested-by: Wilfried Klaebe <linux-kernel@lebenslange-mailadresse.de>
Signed-off-by: Ard 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: Ingo Molnar <mingo@kernel.org>
2018-06-24 09:05:58 +02:00
..
compressed efi/x86: Fix incorrect invocation of PciIo->Attributes() 2018-06-24 09:05:58 +02:00
tools License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
.gitignore x86/build: Add more generated files to the .gitignore file 2017-11-07 11:22:21 +01:00
Makefile x86/build: Factor out fdimage/isoimage generation commands to standalone script 2017-11-07 11:22:20 +01:00
a20.c x86, setup: "glove box" BIOS interrupts in the core boot code 2009-04-09 16:08:11 -07:00
apm.c x86, setup: "glove box" BIOS interrupts in the APM code 2009-04-09 16:08:11 -07:00
bioscall.S x86, boot: Move intcall() to the .inittext section 2014-01-04 14:29:08 -08:00
bitops.h x86, asm: use bool for bitops and other assembly outputs 2016-06-08 12:41:20 -07:00
boot.h x86/boot: Fix BSS corruption/overwrite bug in early x86 kernel startup 2017-04-20 10:05:23 +02:00
cmdline.c x86, boot: Pass cmd_line_ptr with unsigned long instead 2013-01-29 15:26:09 -08:00
code16gcc.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
copy.S x86/boot: Remove unused copy_*_gs() functions 2017-06-05 09:35:16 +02:00
cpu.c Revert "x86/boot: Fail the boot if !M486 and CPUID is missing" 2016-12-19 11:54:20 +01:00
cpucheck.c x86/boot: Detect 5-level paging support 2017-04-04 08:22:33 +02:00
cpuflags.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cpuflags.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ctype.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
early_serial_console.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
edd.c x86, boot: Create a separate string.h file to provide standard string functions 2014-03-19 15:43:45 -07:00
genimage.sh x86/build: Make isoimage work on Debian 2017-12-16 16:23:31 +01:00
header.S Merge branch 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-11-13 16:32:30 -08:00
install.sh kbuild: use INSTALLKERNEL to select customized installkernel script 2009-09-20 12:18:14 +02:00
main.c x86/boot: Obsolete the MCA sys_desc_table 2015-07-21 10:55:11 +02:00
memory.c x86/boot/e820: Separate the E820 ABI structures from the in-kernel structures 2017-01-29 13:39:32 +01:00
mkcpustr.c x86/cpufeature: Carve out X86_FEATURE_* 2016-01-30 11:22:17 +01:00
mtools.conf.in i386: move boot 2007-10-11 11:16:45 +02:00
pm.c x86: remove zImage support 2009-03-11 11:00:00 -07:00
pmjump.S x86, setup: move 32-bit code to .text32 2009-03-17 15:26:06 -07:00
printf.c x86/boot: Fix a sanity check in printf.c 2013-08-14 11:48:41 +02:00
regs.c x86, boot: Create a separate string.h file to provide standard string functions 2014-03-19 15:43:45 -07:00
setup.ld x86, boot: Define the 2.12 bzImage boot protocol 2013-01-27 15:56:37 -08:00
string.c x86/boot: #undef memcpy() et al in string.c 2017-07-25 11:13:55 +02:00
string.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tty.c x86, setup: reorganize the early console setup 2010-08-02 15:51:56 -07:00
version.c kbuild: move utsrelease.h to include/generated 2009-12-12 13:08:15 +01:00
vesa.h x86-boot: don't request VBE2 information 2008-03-07 16:39:14 +01:00
video-bios.c x86: fix usage of bios intcall() 2009-07-04 12:56:32 -07:00
video-mode.c x86/mm: Fix regression with huge pages on PAE 2015-12-04 09:14:27 +01:00
video-vesa.c x86, boot: Create a separate string.h file to provide standard string functions 2014-03-19 15:43:45 -07:00
video-vga.c x86: Use ARRAY_SIZE 2017-10-19 16:15:47 +02:00
video.c x86/mm: Fix regression with huge pages on PAE 2015-12-04 09:14:27 +01:00
video.h x86/boot/video: Move the 'video_segment' variable to video.c 2015-02-19 00:25:05 +01:00