Skip to content

Commit f331e76

Browse files
HkBkHsuryasaimadhu
authored andcommitted
x86/platform/UV: Use efi_runtime_lock to serialise BIOS calls
Calls into UV firmware must be protected against concurrency, expose the efi_runtime_lock to the UV platform, and use it to serialise UV BIOS calls. Signed-off-by: Hedi Berriche <hedi.berriche@hpe.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Russ Anderson <rja@hpe.com> Reviewed-by: Dimitri Sivanich <sivanich@hpe.com> Reviewed-by: Mike Travis <mike.travis@hpe.com> Cc: Andy Shevchenko <andy@infradead.org> Cc: Bhupesh Sharma <bhsharma@redhat.com> Cc: Darren Hart <dvhart@infradead.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: linux-efi <linux-efi@vger.kernel.org> Cc: platform-driver-x86@vger.kernel.org Cc: stable@vger.kernel.org # v4.9+ Cc: Steve Wahl <steve.wahl@hpe.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: x86-ml <x86@kernel.org> Link: https://lkml.kernel.org/r/20190213193413.25560-5-hedi.berriche@hpe.com
1 parent 8cd8f0c commit f331e76

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

arch/x86/include/asm/uv/bios.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ enum {
4848
BIOS_STATUS_SUCCESS = 0,
4949
BIOS_STATUS_UNIMPLEMENTED = -ENOSYS,
5050
BIOS_STATUS_EINVAL = -EINVAL,
51-
BIOS_STATUS_UNAVAIL = -EBUSY
51+
BIOS_STATUS_UNAVAIL = -EBUSY,
52+
BIOS_STATUS_ABORT = -EINTR,
5253
};
5354

5455
/* Address map parameters */
@@ -167,4 +168,9 @@ extern long system_serial_number;
167168

168169
extern struct kobject *sgi_uv_kobj; /* /sys/firmware/sgi_uv */
169170

171+
/*
172+
* EFI runtime lock; cf. firmware/efi/runtime-wrappers.c for details
173+
*/
174+
extern struct semaphore __efi_uv_runtime_lock;
175+
170176
#endif /* _ASM_X86_UV_BIOS_H */

arch/x86/platform/uv/bios_uv.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
struct uv_systab *uv_systab;
3131

32-
s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5)
32+
static s64 __uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3,
33+
u64 a4, u64 a5)
3334
{
3435
struct uv_systab *tab = uv_systab;
3536
s64 ret;
@@ -51,6 +52,19 @@ s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5)
5152

5253
return ret;
5354
}
55+
56+
s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5)
57+
{
58+
s64 ret;
59+
60+
if (down_interruptible(&__efi_uv_runtime_lock))
61+
return BIOS_STATUS_ABORT;
62+
63+
ret = __uv_bios_call(which, a1, a2, a3, a4, a5);
64+
up(&__efi_uv_runtime_lock);
65+
66+
return ret;
67+
}
5468
EXPORT_SYMBOL_GPL(uv_bios_call);
5569

5670
s64 uv_bios_call_irqsave(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3,
@@ -59,10 +73,15 @@ s64 uv_bios_call_irqsave(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3,
5973
unsigned long bios_flags;
6074
s64 ret;
6175

76+
if (down_interruptible(&__efi_uv_runtime_lock))
77+
return BIOS_STATUS_ABORT;
78+
6279
local_irq_save(bios_flags);
63-
ret = uv_bios_call(which, a1, a2, a3, a4, a5);
80+
ret = __uv_bios_call(which, a1, a2, a3, a4, a5);
6481
local_irq_restore(bios_flags);
6582

83+
up(&__efi_uv_runtime_lock);
84+
6685
return ret;
6786
}
6887

drivers/firmware/efi/runtime-wrappers.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ void efi_call_virt_check_flags(unsigned long flags, const char *call)
146146
*/
147147
static DEFINE_SEMAPHORE(efi_runtime_lock);
148148

149+
/*
150+
* Expose the EFI runtime lock to the UV platform
151+
*/
152+
#ifdef CONFIG_X86_UV
153+
extern struct semaphore __efi_uv_runtime_lock __alias(efi_runtime_lock);
154+
#endif
155+
149156
/*
150157
* Calls the appropriate efi_runtime_service() with the appropriate
151158
* arguments.

0 commit comments

Comments
 (0)