* [PATCH v4 0/2] Add Apple T2 NHI device links
@ 2026-07-24 16:46 Atharva Tiwari
2026-07-24 16:46 ` [PATCH v4 1/2] treewide: Add a flag to detect the Apple T2 chip Atharva Tiwari
2026-07-24 16:46 ` [PATCH v4 2/2] thunderbolt: Add device links for Apple T2 NHI Atharva Tiwari
0 siblings, 2 replies; 5+ messages in thread
From: Atharva Tiwari @ 2026-07-24 16:46 UTC (permalink / raw)
Cc: Atharva Tiwari, Bjorn Helgaas, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Andreas Noever,
Mika Westerberg, Yehezkel Bernat, Hans de Goede,
Ilpo Järvinen, Jarkko Sakkinen, Mimi Zohar, Roberto Sassu,
Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris,
Serge E. Hallyn, linux-pci, linux-kernel, linux-usb,
platform-driver-x86, linux-integrity, keyrings,
linux-security-module
This series adds a cached flag to detect Apple T2 systems, then uses it
to create device links for the Thunderbolt NHI.
Changes in v4:
- Limited TRP check to T2 Icelake systems only
- Optimized has_apple_t2_chip check
- Included pci.h to drivers/thunderbolt/tb.c
- Used __free(pci_dev_put) to avoid label
Changes in v3:
- Fix build errors with non-x86 machines
- Used __initconst for apple_t2_devices
- Removed UEFI_QUIRK_SKIP_CERT as its unused now
- Used IS_ENABLED(CONFIG_ACPI) in tb_apple_add_links for the T2 part
- Removed !bid check to remove warning with -Waddress
Changes in v2:
- Used a less generic name for has_t2_chip
- Used DMI instead of PCI for has_apple_t2_chip to avoid PCI problems
- Initialized ret in tb_apple_add_links
Link to v3:
https://lore.kernel.org/all/20260721063412.11588-1-atharvatiwarilinuxdev@gmail.com/
Link to v2:
https://lore.kernel.org/all/20260721054506.11871-1-atharvatiwarilinuxdev@gmail.com/
Link to v1:
https://lore.kernel.org/all/20260719180308.1398-1-atharvatiwarilinuxdev@gmail.com/
Atharva Tiwari (2):
treewide: Add a flag to detect the Apple T2 chip
thunderbolt: Add device links for Apple T2 NHI
arch/x86/kernel/quirks.c | 37 ++++++++++++
drivers/thunderbolt/tb.c | 58 ++++++++++++++++++-
include/linux/platform_data/x86/apple.h | 5 ++
.../platform_certs/keyring_handler.h | 8 ---
security/integrity/platform_certs/load_uefi.c | 38 +++---------
5 files changed, 106 insertions(+), 40 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 1/2] treewide: Add a flag to detect the Apple T2 chip
2026-07-24 16:46 [PATCH v4 0/2] Add Apple T2 NHI device links Atharva Tiwari
@ 2026-07-24 16:46 ` Atharva Tiwari
2026-07-24 16:53 ` sashiko-bot
2026-07-24 16:46 ` [PATCH v4 2/2] thunderbolt: Add device links for Apple T2 NHI Atharva Tiwari
1 sibling, 1 reply; 5+ messages in thread
From: Atharva Tiwari @ 2026-07-24 16:46 UTC (permalink / raw)
Cc: Atharva Tiwari, Bjorn Helgaas, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Andreas Noever,
Mika Westerberg, Yehezkel Bernat, Hans de Goede,
Ilpo Järvinen, Jarkko Sakkinen, Mimi Zohar, Roberto Sassu,
Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris,
Serge E. Hallyn, linux-pci, linux-kernel, linux-usb,
platform-driver-x86, linux-integrity, keyrings,
linux-security-module
Add a flag to detect Apple T2 chips on Intel Macs.
Cache the result to avoid repeated checks. That will
be used in upcoming patches.
Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
---
arch/x86/kernel/quirks.c | 37 ++++++++++++++++++
include/linux/platform_data/x86/apple.h | 5 +++
.../platform_certs/keyring_handler.h | 8 ----
security/integrity/platform_certs/load_uefi.c | 38 ++++---------------
4 files changed, 50 insertions(+), 38 deletions(-)
diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index a92f18db9610..6651e5d4d106 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -664,8 +664,45 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras
bool x86_apple_machine;
EXPORT_SYMBOL(x86_apple_machine);
+bool has_apple_t2_chip;
+EXPORT_SYMBOL(has_apple_t2_chip);
+
+static const char * const __initconst apple_t2_models[] = {
+ "MacBookPro15,1",
+ "MacBookPro15,2",
+ "MacBookPro15,3",
+ "MacBookPro15,4",
+ "MacBookPro16,1",
+ "MacBookPro16,2",
+ "MacBookPro16,3",
+ "MacBookPro16,4",
+ "MacBookAir8,1",
+ "MacBookAir8,2",
+ "MacBookAir9,1",
+ "Macmini8,1",
+ "MacPro7,1",
+ "iMac20,1",
+ "iMac20,2",
+ "iMacPro1,1",
+};
+
void __init early_platform_quirks(void)
{
x86_apple_machine = dmi_match(DMI_SYS_VENDOR, "Apple Inc.") ||
dmi_match(DMI_SYS_VENDOR, "Apple Computer, Inc.");
+
+ if (x86_apple_machine) {
+ const char *product_name = dmi_get_system_info(DMI_PRODUCT_NAME);
+ int i;
+
+ if (!product_name)
+ return;
+
+ for (i = 0; i < ARRAY_SIZE(apple_t2_models); i++) {
+ if (!strcmp(product_name, apple_t2_models[i])) {
+ has_apple_t2_chip = true;
+ break;
+ }
+ }
+ }
}
diff --git a/include/linux/platform_data/x86/apple.h b/include/linux/platform_data/x86/apple.h
index 079e816c3c21..47b27dceab18 100644
--- a/include/linux/platform_data/x86/apple.h
+++ b/include/linux/platform_data/x86/apple.h
@@ -6,8 +6,13 @@
* x86_apple_machine - whether the machine is an x86 Apple Macintosh
*/
extern bool x86_apple_machine;
+/**
+ * has_apple_t2_chip - whether the machine has the Apple T2 chip
+ */
+extern bool has_apple_t2_chip;
#else
#define x86_apple_machine false
+#define has_apple_t2_chip false
#endif
#endif
diff --git a/security/integrity/platform_certs/keyring_handler.h b/security/integrity/platform_certs/keyring_handler.h
index f92895cc50f6..a355f4400179 100644
--- a/security/integrity/platform_certs/keyring_handler.h
+++ b/security/integrity/platform_certs/keyring_handler.h
@@ -45,11 +45,3 @@ efi_element_handler_t get_handler_for_code_signing_keys(const efi_guid_t *sig_ty
efi_element_handler_t get_handler_for_dbx(const efi_guid_t *sig_type);
#endif
-
-#ifndef UEFI_QUIRK_SKIP_CERT
-#define UEFI_QUIRK_SKIP_CERT(vendor, product) \
- .matches = { \
- DMI_MATCH(DMI_BOARD_VENDOR, vendor), \
- DMI_MATCH(DMI_PRODUCT_NAME, product), \
- },
-#endif
diff --git a/security/integrity/platform_certs/load_uefi.c b/security/integrity/platform_certs/load_uefi.c
index c0d6948446c3..b4096d4c828d 100644
--- a/security/integrity/platform_certs/load_uefi.c
+++ b/security/integrity/platform_certs/load_uefi.c
@@ -3,42 +3,16 @@
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/cred.h>
-#include <linux/dmi.h>
#include <linux/err.h>
#include <linux/efi.h>
#include <linux/slab.h>
#include <linux/ima.h>
+#include <linux/platform_data/x86/apple.h>
#include <keys/asymmetric-type.h>
#include <keys/system_keyring.h>
#include "../integrity.h"
#include "keyring_handler.h"
-/*
- * On T2 Macs reading the db and dbx efi variables to load UEFI Secure Boot
- * certificates causes occurrence of a page fault in Apple's firmware and
- * a crash disabling EFI runtime services. The following quirk skips reading
- * these variables.
- */
-static const struct dmi_system_id uefi_skip_cert[] = {
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro15,1") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro15,2") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro15,3") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro15,4") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro16,1") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro16,2") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro16,3") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro16,4") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir8,1") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir8,2") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir9,1") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "Macmini8,1") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacPro7,1") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "iMac20,1") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "iMac20,2") },
- { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "iMacPro1,1") },
- { }
-};
-
/*
* Look to see if a UEFI variable called MokIgnoreDB exists and return true if
* it does.
@@ -165,10 +139,14 @@ static int __init load_uefi_certs(void)
unsigned long dbsize = 0, dbxsize = 0, mokxsize = 0;
efi_status_t status;
int rc = 0;
- const struct dmi_system_id *dmi_id;
- dmi_id = dmi_first_match(uefi_skip_cert);
- if (dmi_id) {
+ /*
+ * On T2 Macs reading the db and dbx efi variables to load UEFI Secure Boot
+ * certificates causes occurrence of a page fault in Apple's firmware and
+ * a crash disabling EFI runtime services. The following quirk skips reading
+ * these variables.
+ */
+ if (has_apple_t2_chip) {
pr_err("Reading UEFI Secure Boot Certs is not supported on T2 Macs.\n");
return false;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 2/2] thunderbolt: Add device links for Apple T2 NHI
2026-07-24 16:46 [PATCH v4 0/2] Add Apple T2 NHI device links Atharva Tiwari
2026-07-24 16:46 ` [PATCH v4 1/2] treewide: Add a flag to detect the Apple T2 chip Atharva Tiwari
@ 2026-07-24 16:46 ` Atharva Tiwari
2026-07-24 17:05 ` sashiko-bot
1 sibling, 1 reply; 5+ messages in thread
From: Atharva Tiwari @ 2026-07-24 16:46 UTC (permalink / raw)
Cc: Atharva Tiwari, Andre Eikmeyer, Bjorn Helgaas, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Andreas Noever, Mika Westerberg, Yehezkel Bernat, Hans de Goede,
Ilpo Järvinen, Jarkko Sakkinen, Mimi Zohar, Roberto Sassu,
Dmitry Kasatkin, Eric Snowberg, Paul Moore, James Morris,
Serge E. Hallyn, linux-pci, linux-kernel, linux-usb,
platform-driver-x86, linux-integrity, keyrings,
linux-security-module
From: Andre Eikmeyer <andre@negmaster.com>
Icelake Thunderbolt NHI on T2 Macs (2018-2020). The NHI and its
associated PCIe root ports all sit directly on the root complex
with no upstream port. Apple's ACPI tables name Thunderbolt root
ports as TRP0, TRP1, etc. Find them and create device links back
to the NHI so that PCIe tunnels can be re-established after sleep.
And on other Thunderbolt NHI's, like Titan Ridge, the default method
is used to add device links.
Co-developed-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
Signed-off-by: Andre Eikmeyer <andre@negmaster.com>
---
drivers/thunderbolt/tb.c | 58 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index c69c323e6952..625451ff3ea0 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -6,9 +6,11 @@
* Copyright (C) 2019, Intel Corporation
*/
+#include <linux/acpi.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/delay.h>
+#include <linux/pci.h>
#include <linux/pm_runtime.h>
#include <linux/platform_data/x86/apple.h>
@@ -3305,21 +3307,73 @@ static const struct tb_cm_ops tb_cm_ops = {
static bool tb_apple_add_links(struct tb_nhi *nhi)
{
struct pci_dev *upstream, *pdev;
- bool ret;
+ bool ret = false;
if (!x86_apple_machine)
return false;
+ /* On T2 Macs with Icelake thunderbolt NHI's.
+ * the root ports are stored in ACPI as TRP0,
+ * TRP1, etc. Find them and create device links
+ * so that PCIe tunnels can be re-established after
+ * sleep.
+ */
+#if IS_ENABLED(CONFIG_ACPI)
+ if (has_apple_t2_chip && (nhi->pdev->device == PCI_DEVICE_ID_INTEL_ICL_NHI0 ||
+ nhi->pdev->device == PCI_DEVICE_ID_INTEL_ICL_NHI1)) {
+ struct acpi_device *adev;
+ unsigned int slot, func;
+ const struct device_link *link;
+ const char *bid;
+
+ for (slot = 0; slot < 32; slot++) {
+ for (func = 0; func < 8; func++) {
+ struct pci_dev *current_pdev __free(pci_dev_put) =
+ pci_get_slot(nhi->pdev->bus, PCI_DEVFN(slot, func));
+ if (!current_pdev)
+ continue;
+
+ if (!pci_is_pcie(current_pdev) || pci_pcie_type(current_pdev) !=
+ PCI_EXP_TYPE_ROOT_PORT)
+ continue;
+
+ adev = ACPI_COMPANION(¤t_pdev->dev);
+ if (!adev)
+ continue;
+
+ bid = acpi_device_bid(adev);
+ if (strncmp(bid, "TRP", 3) != 0)
+ continue;
+
+ link = device_link_add(¤t_pdev->dev, &nhi->pdev->dev,
+ DL_FLAG_AUTOREMOVE_SUPPLIER |
+ DL_FLAG_PM_RUNTIME);
+ if (link) {
+ dev_dbg(&nhi->pdev->dev, "created link from %s\n",
+ dev_name(¤t_pdev->dev));
+ ret = true;
+ } else {
+ dev_warn(&nhi->pdev->dev,
+ "device link creation from %s failed\n",
+ dev_name(¤t_pdev->dev));
+ }
+ }
+ }
+ return ret;
+ }
+#endif
+
switch (nhi->pdev->device) {
case PCI_DEVICE_ID_INTEL_LIGHT_RIDGE:
case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C:
case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI:
case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI:
+ case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_NHI:
+ case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_NHI:
break;
default:
return false;
}
-
upstream = pci_upstream_bridge(nhi->pdev);
while (upstream) {
if (!pci_is_pcie(upstream))
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4 1/2] treewide: Add a flag to detect the Apple T2 chip
2026-07-24 16:46 ` [PATCH v4 1/2] treewide: Add a flag to detect the Apple T2 chip Atharva Tiwari
@ 2026-07-24 16:53 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-07-24 16:53 UTC (permalink / raw)
To: Atharva Tiwari; +Cc: linux-pci
> Add a flag to detect Apple T2 chips on Intel Macs.
> Cache the result to avoid repeated checks. That will
> be used in upcoming patches.
>
> Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724164641.2239-1-atharvatiwarilinuxdev@gmail.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 2/2] thunderbolt: Add device links for Apple T2 NHI
2026-07-24 16:46 ` [PATCH v4 2/2] thunderbolt: Add device links for Apple T2 NHI Atharva Tiwari
@ 2026-07-24 17:05 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-07-24 17:05 UTC (permalink / raw)
To: Atharva Tiwari; +Cc: linux-pci
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Lockless traversal of the PCI bus devices list exposes the driver to a use-after-free race during concurrent hotplug or sysfs device removal.
--
--- Patch [2]: [PATCH v4 2/2] thunderbolt: Add device links for Apple T2 NHI ---
commit ee5a1e7f9e85d72f9c6e9327c898de2f33a51e3d
Author: Andre Eikmeyer <andre@negmaster.com>
thunderbolt: Add device links for Apple T2 NHI
This commit adds device links for the Icelake Thunderbolt NHI on Apple T2
Macs. It finds the root ports (TRP0, TRP1, etc.) in ACPI and creates device
links to ensure PCIe tunnels can be re-established after sleep.
> diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
> index c69c323e6952a..625451ff3ea08 100644
> --- a/drivers/thunderbolt/tb.c
> +++ b/drivers/thunderbolt/tb.c
[ ... ]
> @@ -3305,21 +3307,73 @@ static const struct tb_cm_ops tb_cm_ops = {
> static bool tb_apple_add_links(struct tb_nhi *nhi)
> {
> struct pci_dev *upstream, *pdev;
> - bool ret;
> + bool ret = false;
>
> if (!x86_apple_machine)
> return false;
[ ... ]
> upstream = pci_upstream_bridge(nhi->pdev);
> while (upstream) {
> if (!pci_is_pcie(upstream))
[Severity: High]
This isn't a bug introduced by this patch, but while reviewing this function
I noticed a pre-existing issue further down in tb_apple_add_links():
for_each_pci_bridge(pdev, upstream->subordinate) {
const struct device_link *link;
if (!pci_is_pcie(pdev))
continue;
Could traversing upstream->subordinate without holding the pci_bus_sem read
lock lead to list corruption or a use-after-free?
If a user concurrently writes to /sys/bus/pci/devices/.../remove for one of
the downstream ports while the Thunderbolt host controller is probing,
pci_remove_bus_device() could delete the device from the list via
list_del(&dev->bus_list) while this lockless traversal is happening.
The newly added T2 Mac path safely avoids this by using pci_get_slot(),
which handles the locking internally. Would it make sense to acquire
pci_bus_sem for the older architecture paths as well?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724164641.2239-1-atharvatiwarilinuxdev@gmail.com?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-24 17:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 16:46 [PATCH v4 0/2] Add Apple T2 NHI device links Atharva Tiwari
2026-07-24 16:46 ` [PATCH v4 1/2] treewide: Add a flag to detect the Apple T2 chip Atharva Tiwari
2026-07-24 16:53 ` sashiko-bot
2026-07-24 16:46 ` [PATCH v4 2/2] thunderbolt: Add device links for Apple T2 NHI Atharva Tiwari
2026-07-24 17:05 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox