]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.6/efi-libstub-add-generic-support-for-parsing-mem_encrypt.patch
2900ab98006973b8229529ecc91d8c2971e1e75a
[thirdparty/kernel/stable-queue.git] / queue-6.6 / efi-libstub-add-generic-support-for-parsing-mem_encrypt.patch
1 From 7205f06e847422b66c1506eee01b9998ffc75d76 Mon Sep 17 00:00:00 2001
2 From: Ard Biesheuvel <ardb@kernel.org>
3 Date: Tue, 27 Feb 2024 16:19:13 +0100
4 Subject: efi/libstub: Add generic support for parsing mem_encrypt=
5
6 From: Ard Biesheuvel <ardb@kernel.org>
7
8 commit 7205f06e847422b66c1506eee01b9998ffc75d76 upstream.
9
10 Parse the mem_encrypt= command line parameter from the EFI stub if
11 CONFIG_ARCH_HAS_MEM_ENCRYPT=y, so that it can be passed to the early
12 boot code by the arch code in the stub.
13
14 This avoids the need for the core kernel to do any string parsing very
15 early in the boot.
16
17 Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
18 Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
19 Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
20 Link: https://lore.kernel.org/r/20240227151907.387873-16-ardb+git@google.com
21 Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 ---
24 drivers/firmware/efi/libstub/efi-stub-helper.c | 8 ++++++++
25 drivers/firmware/efi/libstub/efistub.h | 2 +-
26 2 files changed, 9 insertions(+), 1 deletion(-)
27
28 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c
29 +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
30 @@ -24,6 +24,8 @@ static bool efi_noinitrd;
31 static bool efi_nosoftreserve;
32 static bool efi_disable_pci_dma = IS_ENABLED(CONFIG_EFI_DISABLE_PCI_DMA);
33
34 +int efi_mem_encrypt;
35 +
36 bool __pure __efi_soft_reserve_enabled(void)
37 {
38 return !efi_nosoftreserve;
39 @@ -75,6 +77,12 @@ efi_status_t efi_parse_options(char cons
40 efi_noinitrd = true;
41 } else if (IS_ENABLED(CONFIG_X86_64) && !strcmp(param, "no5lvl")) {
42 efi_no5lvl = true;
43 + } else if (IS_ENABLED(CONFIG_ARCH_HAS_MEM_ENCRYPT) &&
44 + !strcmp(param, "mem_encrypt") && val) {
45 + if (parse_option_str(val, "on"))
46 + efi_mem_encrypt = 1;
47 + else if (parse_option_str(val, "off"))
48 + efi_mem_encrypt = -1;
49 } else if (!strcmp(param, "efi") && val) {
50 efi_nochunk = parse_option_str(val, "nochunk");
51 efi_novamap |= parse_option_str(val, "novamap");
52 --- a/drivers/firmware/efi/libstub/efistub.h
53 +++ b/drivers/firmware/efi/libstub/efistub.h
54 @@ -37,8 +37,8 @@ extern bool efi_no5lvl;
55 extern bool efi_nochunk;
56 extern bool efi_nokaslr;
57 extern int efi_loglevel;
58 +extern int efi_mem_encrypt;
59 extern bool efi_novamap;
60 -
61 extern const efi_system_table_t *efi_system_table;
62
63 typedef union efi_dxe_services_table efi_dxe_services_table_t;