You've already forked linux-t2-patches
mirror of
https://github.com/t2linux/linux-t2-patches.git
synced 2026-04-30 13:52:11 -07:00
Use kernel parameter for apple-os
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
From 33029b7ba2235a4bb67e61063984869206ceb1e3 Mon Sep 17 00:00:00 2001
|
||||
From 6adb501c697cd0e3246e75237ee8e43eb5a92cc3 Mon Sep 17 00:00:00 2001
|
||||
From: Kerem Karabay <kekrby@gmail.com>
|
||||
Date: Thu, 5 Jan 2023 21:07:54 +0300
|
||||
Date: Thu, 23 Nov 2023 18:58:51 +0530
|
||||
Subject: [PATCH] efi: libstub: add support for the apple_set_os protocol
|
||||
|
||||
On dual GPU EFI Macs, the EFI stub needs to report that it is booting
|
||||
@@ -8,19 +8,61 @@ macOS in order to prevent the firmware from disabling the iGPU.
|
||||
|
||||
See also this patch for GRUB by Andreas Heider <andreas@heider.io>:
|
||||
https://lists.gnu.org/archive/html/grub-devel/2013-12/msg00442.html
|
||||
|
||||
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
|
||||
---
|
||||
drivers/firmware/efi/libstub/efistub.h | 13 +++++++++++++
|
||||
drivers/firmware/efi/libstub/x86-stub.c | 26 +++++++++++++++++++++++++
|
||||
include/linux/efi.h | 1 +
|
||||
3 files changed, 40 insertions(+)
|
||||
.../admin-guide/kernel-parameters.txt | 2 ++
|
||||
.../firmware/efi/libstub/efi-stub-helper.c | 3 ++
|
||||
drivers/firmware/efi/libstub/efistub.h | 15 ++++++++++
|
||||
drivers/firmware/efi/libstub/x86-stub.c | 28 +++++++++++++++++++
|
||||
include/linux/efi.h | 1 +
|
||||
5 files changed, 49 insertions(+)
|
||||
|
||||
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
|
||||
index 0a1731a0f..176d3641a 100644
|
||||
--- a/Documentation/admin-guide/kernel-parameters.txt
|
||||
+++ b/Documentation/admin-guide/kernel-parameters.txt
|
||||
@@ -399,6 +399,8 @@
|
||||
useful so that a dump capture kernel won't be
|
||||
shot down by NMI
|
||||
|
||||
+ apple_set_os [KNL] Report that macOS is being booted to the firmware
|
||||
+
|
||||
autoconf= [IPV6]
|
||||
See Documentation/networking/ipv6.rst.
|
||||
|
||||
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
|
||||
index bfa30625f..3d99acc1a 100644
|
||||
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
|
||||
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
|
||||
@@ -19,6 +19,7 @@
|
||||
bool efi_nochunk;
|
||||
bool efi_nokaslr = !IS_ENABLED(CONFIG_RANDOMIZE_BASE);
|
||||
bool efi_novamap;
|
||||
+bool efi_apple_set_os;
|
||||
|
||||
static bool efi_noinitrd;
|
||||
static bool efi_nosoftreserve;
|
||||
@@ -73,6 +74,8 @@ efi_status_t efi_parse_options(char const *cmdline)
|
||||
efi_loglevel = CONSOLE_LOGLEVEL_QUIET;
|
||||
} else if (!strcmp(param, "noinitrd")) {
|
||||
efi_noinitrd = true;
|
||||
+ } else if (!strcmp(param, "apple_set_os")) {
|
||||
+ efi_apple_set_os = true;
|
||||
} else if (IS_ENABLED(CONFIG_X86_64) && !strcmp(param, "no5lvl")) {
|
||||
efi_no5lvl = true;
|
||||
} else if (!strcmp(param, "efi") && val) {
|
||||
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
|
||||
index 54a2822cae77..78601b65f9c8 100644
|
||||
index 212687c30..2a53c5268 100644
|
||||
--- a/drivers/firmware/efi/libstub/efistub.h
|
||||
+++ b/drivers/firmware/efi/libstub/efistub.h
|
||||
@@ -824,6 +824,19 @@ union apple_properties_protocol {
|
||||
@@ -38,6 +38,7 @@ extern bool efi_nochunk;
|
||||
extern bool efi_nokaslr;
|
||||
extern int efi_loglevel;
|
||||
extern bool efi_novamap;
|
||||
+extern bool efi_apple_set_os;
|
||||
|
||||
extern const efi_system_table_t *efi_system_table;
|
||||
|
||||
@@ -825,6 +826,20 @@ union apple_properties_protocol {
|
||||
} mixed_mode;
|
||||
};
|
||||
|
||||
@@ -36,15 +78,16 @@ index 54a2822cae77..78601b65f9c8 100644
|
||||
+ u32 set_os_vendor;
|
||||
+ } mixed_mode;
|
||||
+};
|
||||
+
|
||||
+
|
||||
typedef u32 efi_tcg2_event_log_format;
|
||||
|
||||
#define INITRD_EVENT_TAG_ID 0x8F3B22ECU
|
||||
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
|
||||
index a0bfd31358ba..ec0100683d9f 100644
|
||||
index 9d5df683f..de899f592 100644
|
||||
--- a/drivers/firmware/efi/libstub/x86-stub.c
|
||||
+++ b/drivers/firmware/efi/libstub/x86-stub.c
|
||||
@@ -212,6 +212,30 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
|
||||
@@ -223,6 +223,31 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,24 +114,26 @@ index a0bfd31358ba..ec0100683d9f 100644
|
||||
+ efi_err("Failed to set OS version via apple_set_os\n");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+
|
||||
void efi_adjust_memory_range_protection(unsigned long start,
|
||||
unsigned long size)
|
||||
{
|
||||
@@ -322,6 +346,8 @@ static void setup_quirks(struct boot_params *boot_params,
|
||||
@@ -317,6 +342,9 @@ static void setup_quirks(struct boot_params *boot_params)
|
||||
if (!memcmp(fw_vendor, apple, sizeof(apple))) {
|
||||
if (IS_ENABLED(CONFIG_APPLE_PROPERTIES))
|
||||
retrieve_apple_device_properties(boot_params);
|
||||
+
|
||||
+ apple_set_os();
|
||||
+ if (efi_apple_set_os)
|
||||
+ apple_set_os();
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_EFI_DXE_MEM_ATTRIBUTES))
|
||||
diff --git a/include/linux/efi.h b/include/linux/efi.h
|
||||
index 571d1a6e1b74..21c066ce29d0 100644
|
||||
index 80b21d1c6..f1e58e027 100644
|
||||
--- a/include/linux/efi.h
|
||||
+++ b/include/linux/efi.h
|
||||
@@ -385,6 +385,7 @@ void efi_native_runtime_setup(void);
|
||||
@@ -387,6 +387,7 @@ void efi_native_runtime_setup(void);
|
||||
#define EFI_MEMORY_ATTRIBUTES_TABLE_GUID EFI_GUID(0xdcfa911d, 0x26eb, 0x469f, 0xa2, 0x20, 0x38, 0xb7, 0xdc, 0x46, 0x12, 0x20)
|
||||
#define EFI_CONSOLE_OUT_DEVICE_GUID EFI_GUID(0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
|
||||
#define APPLE_PROPERTIES_PROTOCOL_GUID EFI_GUID(0x91bd12fe, 0xf6c3, 0x44fb, 0xa5, 0xb7, 0x51, 0x22, 0xab, 0x30, 0x3a, 0xe0)
|
||||
@@ -97,5 +142,5 @@ index 571d1a6e1b74..21c066ce29d0 100644
|
||||
#define EFI_LOAD_FILE_PROTOCOL_GUID EFI_GUID(0x56ec3091, 0x954c, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
|
||||
#define EFI_LOAD_FILE2_PROTOCOL_GUID EFI_GUID(0x4006c0c1, 0xfcb3, 0x403e, 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d)
|
||||
--
|
||||
2.41.0
|
||||
2.34.1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user