public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/efistub: Add options for forcing Apple set_os protocol
@ 2024-12-28 20:21 Lleyton Gray
  2024-12-29  9:59 ` Lukas Wunner
  2025-02-09 16:13 ` Aditya Garg
  0 siblings, 2 replies; 15+ messages in thread
From: Lleyton Gray @ 2024-12-28 20:21 UTC (permalink / raw)
  Cc: gargaditya08, Lleyton Gray, Jonathan Corbet, Ard Biesheuvel,
	Paul E. McKenney, Andrew Morton, Thomas Huth, Steven Rostedt,
	Xiongwei Song, Jeremy Linton, Ilias Apalodimas,
	Kuppuswamy Sathyanarayanan, Jonathan Marek, Kirill A. Shutemov,
	Kees Cook, Borislav Petkov (AMD), linux-doc, linux-kernel,
	linux-efi

commit 71e49eccdca6 ("x86/efistub: Call Apple set_os protocol on dual GPU
Intel Macs") calls the Apple set_os protocol, but only on T2 Macbook Pro
models. This causes issues on other T2 models when an egpu is used.
Add two options which allow force enabling or disabling usage of the
protocol to fix.

Signed-off-by: Lleyton Gray <lleyton@fyralabs.com>
---
 Documentation/admin-guide/kernel-parameters.txt | 7 ++++++-
 drivers/firmware/efi/libstub/efi-stub-helper.c  | 6 ++++++
 drivers/firmware/efi/libstub/efistub.h          | 2 ++
 drivers/firmware/efi/libstub/x86-stub.c         | 3 ++-
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 1518343bbe22..1d1b88c57c44 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1447,7 +1447,8 @@
 	efi=		[EFI,EARLY]
 			Format: { "debug", "disable_early_pci_dma",
 				  "nochunk", "noruntime", "nosoftreserve",
-				  "novamap", "no_disable_early_pci_dma" }
+				  "novamap", "no_disable_early_pci_dma",
+				  "enable_apple_set_os", "disable_apple_set_os" }
 			debug: enable misc debug output.
 			disable_early_pci_dma: disable the busmaster bit on all
 			PCI bridges while in the EFI boot stub.
@@ -1464,6 +1465,10 @@
 			novamap: do not call SetVirtualAddressMap().
 			no_disable_early_pci_dma: Leave the busmaster bit set
 			on all PCI bridges while in the EFI boot stub
+			enable_apple_set_os: Report that macOS is being booted
+			to the firmware, even if the device is not a dual GPU Mac.
+			disable_apple_set_os: Disable reporting that macOS is being booted
+			to the firmware, even if the device is a dual GPU Mac.
 
 	efi_no_storage_paranoia [EFI,X86,EARLY]
 			Using this parameter you can use more than 50% of
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index de659f6a815f..c33bb98bf79d 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -20,6 +20,8 @@
 bool efi_nochunk;
 bool efi_nokaslr = !IS_ENABLED(CONFIG_RANDOMIZE_BASE);
 bool efi_novamap;
+bool efi_enable_apple_set_os;
+bool efi_disable_apple_set_os;
 
 static bool efi_noinitrd;
 static bool efi_nosoftreserve;
@@ -95,6 +97,10 @@ efi_status_t efi_parse_options(char const *cmdline)
 				efi_disable_pci_dma = true;
 			if (parse_option_str(val, "no_disable_early_pci_dma"))
 				efi_disable_pci_dma = false;
+			if (parse_option_str(val, "enable_apple_set_os"))
+				efi_enable_apple_set_os = true;
+			if (parse_option_str(val, "disable_apple_set_os"))
+				efi_disable_apple_set_os = true;
 			if (parse_option_str(val, "debug"))
 				efi_loglevel = CONSOLE_LOGLEVEL_DEBUG;
 		} else if (!strcmp(param, "video") &&
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 685098f9626f..3be4b5393812 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -39,6 +39,8 @@ extern bool efi_nokaslr;
 extern int efi_loglevel;
 extern int efi_mem_encrypt;
 extern bool efi_novamap;
+extern bool efi_enable_apple_set_os;
+extern bool efi_disable_apple_set_os;
 extern const efi_system_table_t *efi_system_table;
 
 typedef union efi_dxe_services_table efi_dxe_services_table_t;
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index f8e465da344d..566118195f92 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -265,7 +265,8 @@ static void apple_set_os(void)
 	} *set_os;
 	efi_status_t status;
 
-	if (!efi_is_64bit() || !apple_match_product_name())
+	if (efi_disable_apple_set_os || !efi_is_64bit() ||
+		!efi_enable_apple_set_os && !apple_match_product_name())
 		return;
 
 	status = efi_bs_call(locate_protocol, &APPLE_SET_OS_PROTOCOL_GUID, NULL,
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [PATCH] x86/efistub: Add options for forcing Apple set_os protocol
@ 2025-02-10 10:51 Aditya Garg
  0 siblings, 0 replies; 15+ messages in thread
From: Aditya Garg @ 2025-02-10 10:51 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Lleyton Gray, Jonathan Corbet, Paul E. McKenney, Andrew Morton,
	Thomas Huth, Steven Rostedt, Xiongwei Song, Jeremy Linton,
	Ilias Apalodimas, Kuppuswamy Sathyanarayanan, Jonathan Marek,
	Kirill A. Shutemov, Kees Cook, Borislav Petkov,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-efi@vger.kernel.org, Lukas Wunner



> On 10 Feb 2025, at 4:11 PM, Ard Biesheuvel <ardb@kernel.org> wrote:
> 
> Hi Aditya,
> 
>> On Sun, 9 Feb 2025 at 17:13, Aditya Garg <gargaditya08@live.com> wrote:
>> Hi all
> 
> Please don't top post.
> 
>> I managed to get feedbacks regarding eGPUs on older non T2 MacBooks, and can confirm that apple-set-os is needed there as well.
> 
> This is rather vague. Where did you get this feedback, and what
> systems does it cover?
> 
> Also, this is not about being able to switch to the integrated GPU to
> drive the built-in panel, but for driving an external GPU connected to
> a different screen altogether. AIUI, this has never worked on these
> systems, right? So why is this important now, for 10 year old
> Macbooks?
> 
>> I was wondering if we can reach a conclusion for this case here.
> 
> I'd prefer to address this in a different way: instead of fixing this
> in the Linux kernel for the handful of systems that need this (and
> that will upgrade to v6.15 or later to get this fix), why not use a
> separate boot-time EFI app to call the protocol. That way, it works
> with existing kernels too, and no changes are needed to Linux.
Fair enough, let's close this thing then.

Thanks
Aditya

> https://paste.debian.net/1349311/

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-02-13  4:56 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-28 20:21 [PATCH] x86/efistub: Add options for forcing Apple set_os protocol Lleyton Gray
2024-12-29  9:59 ` Lukas Wunner
2024-12-29 10:08   ` Ard Biesheuvel
2024-12-29 10:38     ` Lukas Wunner
2024-12-29 18:22       ` Ard Biesheuvel
2024-12-30  3:09         ` Lleyton Gray
2025-02-10 19:25           ` Lukas Wunner
     [not found]           ` <PN3PR01MB7728B4C94846673A5FFACE29B80B2@PN3PR01MB7728.INDPRD01.PROD.OUTLOOK.COM>
2025-02-10 19:58             ` Lukas Wunner
2025-02-11 16:05               ` Aditya Garg
2025-02-13  4:56                 ` Lukas Wunner
2025-02-10 20:09             ` Lukas Wunner
2025-02-11  5:45               ` Aditya Garg
2025-02-09 16:13 ` Aditya Garg
2025-02-10 10:40   ` Ard Biesheuvel
  -- strict thread matches above, loose matches on Subject: below --
2025-02-10 10:51 Aditya Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox