efi/x86: Prevent reentrant firmware calls in mixed mode
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 20 Jul 2018 01:47:18 +0000 (10:47 +0900)
committerIngo Molnar <mingo@kernel.org>
Sun, 22 Jul 2018 12:13:42 +0000 (14:13 +0200)
commit83a0a2ea0b991927e42984be220329e776ce7137
treefdff0c9c76bbf2e850677c7f0c4c0f1022dd5783
parent61f0d55569463a1af897117ff47d202b0ccb2e24
efi/x86: Prevent reentrant firmware calls in mixed mode

The UEFI spec does not permit runtime services to be called
reentrantly, and so it is up to the OS to provide proper locking
around such calls.

For the native case, this was fixed a long time ago, but for the
mixed mode case, no locking is done whatsoever. Note that the calls
are made with preemption and interrupts disabled, so only SMP
configurations are affected by this issue.

So add a spinlock and grab it when invoking a UEFI runtime service
in mixed mode. We will also need to provide non-blocking versions
of SetVariable() and QueryVariableInfo(), so add those as well.

Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20180720014726.24031-2-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/platform/efi/efi_64.c