[PATCH v2 1/2] efi/libstub: enable apple-set-os for all apple devices

Atharva Tiwari posted 2 patches 1 week, 3 days ago
There is a newer version of this series
[PATCH v2 1/2] efi/libstub: enable apple-set-os for all apple devices
Posted by Atharva Tiwari 1 week, 3 days ago
Make apple-set-os run on all macs, as
apple-set-os is needed to use eGPUs and iGPU.

(tested on iMac20,1)

Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
---
 drivers/firmware/efi/libstub/x86-stub.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index cef32e2c82d8..60e1a41bfe5f 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -303,32 +303,20 @@ static const struct efi_smbios_record *get_table_record(u8 type)
 
 static bool apple_match_product_name(void)
 {
-	static const char type1_product_matches[][15] = {
-		"MacBookPro11,3",
-		"MacBookPro11,5",
-		"MacBookPro13,3",
-		"MacBookPro14,3",
-		"MacBookPro15,1",
-		"MacBookPro15,3",
-		"MacBookPro16,1",
-		"MacBookPro16,4",
-	};
 	const struct efi_smbios_type1_record *record;
-	const u8 *product;
+	const u8 *vendor;
 
 	record = (struct efi_smbios_type1_record *)
 			(efi_get_smbios_record(1) ?: get_table_record(1));
 	if (!record)
 		return false;
 
-	product = efi_get_smbios_string(record, product_name);
-	if (!product)
+	vendor = efi_get_smbios_string(record, manufacturer);
+	if (!vendor)
 		return false;
 
-	for (int i = 0; i < ARRAY_SIZE(type1_product_matches); i++) {
-		if (!strcmp(product, type1_product_matches[i]))
-			return true;
-	}
+	if (!strcmp(vendor, "Apple Inc."))
+		return true;
 
 	return false;
 }
-- 
2.43.0
Re: [PATCH v2 1/2] efi/libstub: enable apple-set-os for all apple devices
Posted by Lukas Wunner 1 week, 3 days ago
On Wed, Jan 28, 2026 at 02:58:37PM +0000, Atharva Tiwari wrote:
> Make apple-set-os run on all macs, as
> apple-set-os is needed to use eGPUs and iGPU.

As discussed previously, your patch will regress older MacBook Airs
which use SPI to access keyboard + trackpad if the set_os protocol
is invoked:

https://lore.kernel.org/all/ZoJPgSlZJ3ZlU2zL@wunner.de/

The last time this topic came up, I suggested counting the number of
GPUs instead of using the DMI quirk.  I even provided a patch but
nobody with an eGPU bothered to test it, so the thread fizzled out:

https://lore.kernel.org/all/Z6paeFrjdv7L3mtv@wunner.de/

Maybe you could give it a spin and verify if it fixes the issue for you?

Thanks,

Lukas
Re: [PATCH v2 1/2] efi/libstub: enable apple-set-os for all apple devices
Posted by Atharva Tiwari 6 days, 1 hour ago
> Maybe you could give it a spin and verify if it fixes the issue for you?

I tested it, and only tested to see if it booted.
now again i tested, and it seems my iGPU and eGPU wasnt detected?
and after futher debuging i found that setup_efi_pci only detected
dGPU, so using update_nr_gpus was useless.

and about the macbookair situation, i say we just exclude macbook from
enabling apple-set-os via a smbios quirk.
Re: [PATCH v2 1/2] efi/libstub: enable apple-set-os for all apple devices
Posted by Atharva Tiwari 1 week, 3 days ago
> As discussed previously, your patch will regress older MacBook Airs
> which use SPI to access keyboard + trackpad if the set_os protocol
> is invoked:
> 
> https://lore.kernel.org/all/ZoJPgSlZJ3ZlU2zL@wunner.de/
> 
> The last time this topic came up, I suggested counting the number of
> GPUs instead of using the DMI quirk.  I even provided a patch but
> nobody with an eGPU bothered to test it, so the thread fizzled out:
> 
> https://lore.kernel.org/all/Z6paeFrjdv7L3mtv@wunner.de/
> 
> Maybe you could give it a spin and verify if it fixes the issue for you?

I tested your patch, and well it works (you still need the 2nd patch to 
avoid a blank screen), but i can see how this will fail
like for example, with the iMacPro (only has dGPU) you would need 2 eGPUs
to turn on apple-set-os.

My opinion is, we disable apple-set-os using a dmi check on the 2013/2014
MacbookAir models.
Re: [PATCH v2 1/2] efi/libstub: enable apple-set-os for all apple devices
Posted by Lukas Wunner 1 week, 2 days ago
On Thu, Jan 29, 2026 at 04:37:59AM +0000, Atharva Tiwari wrote:
> > As discussed previously, your patch will regress older MacBook Airs
> > which use SPI to access keyboard + trackpad if the set_os protocol
> > is invoked:
> > 
> > https://lore.kernel.org/all/ZoJPgSlZJ3ZlU2zL@wunner.de/
> > 
> > The last time this topic came up, I suggested counting the number of
> > GPUs instead of using the DMI quirk.  I even provided a patch but
> > nobody with an eGPU bothered to test it, so the thread fizzled out:
> > 
> > https://lore.kernel.org/all/Z6paeFrjdv7L3mtv@wunner.de/
> > 
> > Maybe you could give it a spin and verify if it fixes the issue for you?
> 
> I tested your patch, and well it works (you still need the 2nd patch to 
> avoid a blank screen), but i can see how this will fail
> like for example, with the iMacPro (only has dGPU) you would need 2 eGPUs
> to turn on apple-set-os.

I don't quite follow.  The patch counts the number of GPUs and
uses the set_os protocol if there are at least 2 of them.
One dGPU + one eGPU = 2, so the protocol is used.

Am I missing something?

Thanks,

Lukas
Re: [PATCH v2 1/2] efi/libstub: enable apple-set-os for all apple devices
Posted by Atharva Tiwari 1 week, 2 days ago
> I don't quite follow.  The patch counts the number of GPUs and
> uses the set_os protocol if there are at least 2 of them.
> One dGPU + one eGPU = 2, so the protocol is used.
> 
> Am I missing something?

Well your not, and it was a mistake of me, which i apologize for.

but i still think a MacBookAir dmi check would be better, as
theoretically you can connect a eGPU to a 2013/2014 MacBookAir,
which would enable set-os, and will cause problems in applespi.c