Skip to contentSkip to conversation

PCI/AER: Skip unmasking Advisory Non-Fatal Errors on T2 SEP

PATCH Applied Aditya Garg 4 participants 5 messages Oct 10 – Oct 12

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI/AER: Skip unmasking Advisory Non-Fatal Errors on T2 SEP

Jason reported that since commit eddba19b8b5f ("PCI/AER: Support Advisory Non-Fatal Errors"), the Macs with Apple T2 Security Chip were powering off a few seconds after every boot. He also found the PCI Device 106b:1802, which corresponds to the Apple T2 Secure Enclave Processor was misbehaving and the most likely reason is that the device is ANFE incompatible due to Apple's custom hardware.

Since its highly unlikely that Apple will release a firmware update to support ANFE, introduce a quirk as suggested by Lukas to blacklist the T2 SEP from ANFE.

---
 drivers/pci/pcie/aer.c  |  3 ++-
 drivers/pci/quirks.c    | 12 ++++++++++++
 include/linux/pci.h     |  1 +
 include/linux/pci_ids.h |  1 +
 4 files changed, 16 insertions(+), 1 deletion(-)
drivers/pci/pcie/aer.c +2 -1
index 922a726a5..cab195f7c 100644
@@ -428,7 +428,8 @@ void pci_aer_init(struct pci_dev *dev)
 	 * Advisory Non-Fatal Errors are masked by default (PCIe r7.0, sec
 	 * 7.8.4.6).
 	 */
-	if (pcie_aer_is_native(dev) && dev->devcap & PCI_EXP_DEVCAP_RBER)
+	if (pcie_aer_is_native(dev) && dev->devcap & PCI_EXP_DEVCAP_RBER &&
+		!dev->no_aer_anfe)
 		pci_clear_and_set_config_dword(dev,
 					       dev->aer_cap + PCI_ERR_COR_MASK,
 					       PCI_ERR_COR_ADV_NFAT, 0);
drivers/pci/quirks.c +12 -0
index de9bbccda..acca89532 100644
@@ -6422,4 +6422,16 @@ static void pci_mask_replay_timer_timeout(struct pci_dev *pdev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9750, pci_mask_replay_timer_timeout);
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9755, pci_mask_replay_timer_timeout);
+
+/*
+ * Unmasking Advisory Non-Fatal Errors on Apple T2 Secure Enclave
+ * processor leads to the Mac shutting down spontaneously. Avoid
+ * doing that.
+ */
+static void quirk_no_aer_anfe(struct pci_dev *dev)
+{
+	dev->no_aer_anfe = 1;
+}
+
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_T2_SEP, quirk_no_aer_anfe);
 #endif
include/linux/pci.h +1 -0
index d31a8d107..83ffa5058 100644
@@ -514,6 +514,7 @@ struct pci_dev {
 	unsigned int	rom_bar_overlap:1;	/* ROM BAR disable broken */
 	unsigned int	rom_attr_enabled:1;	/* Display of ROM attribute enabled? */
 	unsigned int	non_mappable_bars:1;	/* BARs can't be mapped by CPU or peers */
+	unsigned int	no_aer_anfe:1;		/* Don't unmask Advisory Non-Fatal Errors */
 	pci_dev_flags_t dev_flags;
 	atomic_t	enable_cnt;	/* pci_enable_device has been called */
 
include/linux/pci_ids.h +1 -0
index 63774ae2b..103024f74 100644
@@ -1007,6 +1007,7 @@
 #define PCI_DEVICE_ID_APPLE_IPID2_FW	0x006a
 #define PCI_DEVICE_ID_APPLE_IPID2_GMAC	0x006b
 #define PCI_DEVICE_ID_APPLE_TIGON3	0x1645
+#define PCI_DEVICE_ID_APPLE_T2_SEP	0x1802
 
 #define PCI_VENDOR_ID_YAMAHA		0x1073
 #define PCI_DEVICE_ID_YAMAHA_724	0x0004
Signature · 1 line
2.55.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines

Jason reported that since commit eddba19b8b5f ("PCI/AER: Support Advisory Non-Fatal Errors"), the Macs with Apple T2 Security Chip were powering off a few seconds after every boot. He also found the PCI Device 106b:1802, which corresponds to the Apple T2 Secure Enclave Processor was misbehaving and the most likely reason is that the device is ANFE incompatible due to Apple's custom hardware.

Since its highly unlikely that Apple will release a firmware update to support ANFE, introduce a quirk as suggested by Lukas to blacklist the T2 SEP from ANFE.

Quoted 5 lines

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Aditya Garg
Quoted 6 lines · Aditya Garg

Jason reported that since commit eddba19b8b5f ("PCI/AER: Support Advisory Non-Fatal Errors"), the Macs with Apple T2 Security Chip were powering off a few seconds after every boot. He also found the PCI Device 106b:1802, which corresponds to the Apple T2 Secure Enclave Processor was misbehaving and the most likely reason is that the device is ANFE incompatible due to Apple's custom hardware.

Nit: Not sure what "misbehaving" means beyond the sudden power-off?

drivers/pci/pcie/aer.c void pci_aer_init(struct pci_dev *dev) · line 435

Quoted 11 lines

+++ b/drivers/pci/pcie/aer.c

drivers/pci/pcie/aer.c +2 -1
@@ -428,7 +428,8 @@ void pci_aer_init(struct pci_dev *dev)
 	 * Advisory Non-Fatal Errors are masked by default (PCIe r7.0, sec
 	 * 7.8.4.6).
 	 */
-	if (pcie_aer_is_native(dev) && dev->devcap & PCI_EXP_DEVCAP_RBER)
+	if (pcie_aer_is_native(dev) && dev->devcap & PCI_EXP_DEVCAP_RBER &&
+		!dev->no_aer_anfe)
 		pci_clear_and_set_config_dword(dev,
 					       dev->aer_cap + PCI_ERR_COR_MASK,
 					       PCI_ERR_COR_ADV_NFAT, 0);

Nit: The "!dev->no_aer_anfe" is not aligned with the opening brace.

It's probably not necessary to respin for the nits alone because Bjorn may resolve them when applying the patch.

#3 lore raw
In reply to Aditya Garg
Quoted 11 lines · Aditya Garg

Jason reported that since commit eddba19b8b5f ("PCI/AER: Support Advisory Non-Fatal Errors"), the Macs with Apple T2 Security Chip were powering off a few seconds after every boot. He also found the PCI Device 106b:1802, which corresponds to the Apple T2 Secure Enclave Processor was misbehaving and the most likely reason is that the device is ANFE incompatible due to Apple's custom hardware.

Since its highly unlikely that Apple will release a firmware update to support ANFE, introduce a quirk as suggested by Lukas to blacklist the T2 SEP from ANFE.

Quoted 5 lines

Applied to pci/for-linus for v7.3, thank you!

I aligned the "!dev->no_aer_anfe" test as Lukas suggested and took a stab at the "misbehaving" comment:

Jason reported that since commit eddba19b8b5f ("PCI/AER: Support Advisory Non-Fatal Errors"), the Macs with Apple T2 Security Chip were powering off a few seconds after every boot. He also found that the power-off only happens when Advisory Non-Fatal Errors are unmasked on the PCI Device 106b:1802, the Apple T2 Secure Enclave Processor.

I'll be happy to revise this if we can make it clearer or more specific.

Quoted 69 lines
---
 drivers/pci/pcie/aer.c  |  3 ++-
 drivers/pci/quirks.c    | 12 ++++++++++++
 include/linux/pci.h     |  1 +
 include/linux/pci_ids.h |  1 +
 4 files changed, 16 insertions(+), 1 deletion(-)
drivers/pci/pcie/aer.c +2 -1
index 922a726a5..cab195f7c 100644
@@ -428,7 +428,8 @@ void pci_aer_init(struct pci_dev *dev)
 	 * Advisory Non-Fatal Errors are masked by default (PCIe r7.0, sec
 	 * 7.8.4.6).
 	 */
-	if (pcie_aer_is_native(dev) && dev->devcap & PCI_EXP_DEVCAP_RBER)
+	if (pcie_aer_is_native(dev) && dev->devcap & PCI_EXP_DEVCAP_RBER &&
+		!dev->no_aer_anfe)
 		pci_clear_and_set_config_dword(dev,
 					       dev->aer_cap + PCI_ERR_COR_MASK,
 					       PCI_ERR_COR_ADV_NFAT, 0);
drivers/pci/quirks.c +12 -0
index de9bbccda..acca89532 100644
@@ -6422,4 +6422,16 @@ static void pci_mask_replay_timer_timeout(struct pci_dev *pdev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9750, pci_mask_replay_timer_timeout);
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9755, pci_mask_replay_timer_timeout);
+
+/*
+ * Unmasking Advisory Non-Fatal Errors on Apple T2 Secure Enclave
+ * processor leads to the Mac shutting down spontaneously. Avoid
+ * doing that.
+ */
+static void quirk_no_aer_anfe(struct pci_dev *dev)
+{
+	dev->no_aer_anfe = 1;
+}
+
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_T2_SEP, quirk_no_aer_anfe);
 #endif
include/linux/pci.h +1 -0
index d31a8d107..83ffa5058 100644
@@ -514,6 +514,7 @@ struct pci_dev {
 	unsigned int	rom_bar_overlap:1;	/* ROM BAR disable broken */
 	unsigned int	rom_attr_enabled:1;	/* Display of ROM attribute enabled? */
 	unsigned int	non_mappable_bars:1;	/* BARs can't be mapped by CPU or peers */
+	unsigned int	no_aer_anfe:1;		/* Don't unmask Advisory Non-Fatal Errors */
 	pci_dev_flags_t dev_flags;
 	atomic_t	enable_cnt;	/* pci_enable_device has been called */
 
include/linux/pci_ids.h +1 -0
index 63774ae2b..103024f74 100644
@@ -1007,6 +1007,7 @@
 #define PCI_DEVICE_ID_APPLE_IPID2_FW	0x006a
 #define PCI_DEVICE_ID_APPLE_IPID2_GMAC	0x006b
 #define PCI_DEVICE_ID_APPLE_TIGON3	0x1645
+#define PCI_DEVICE_ID_APPLE_T2_SEP	0x1802
 
 #define PCI_VENDOR_ID_YAMAHA		0x1073
 #define PCI_DEVICE_ID_YAMAHA_724	0x0004
Signature · 1 line
2.55.0
#4 lore raw
Quoted 12 lines · Bjorn Helgaas
Quoted 11 lines · Aditya Garg

Jason reported that since commit eddba19b8b5f ("PCI/AER: Support Advisory Non-Fatal Errors"), the Macs with Apple T2 Security Chip were powering off a few seconds after every boot. He also found the PCI Device 106b:1802, which corresponds to the Apple T2 Secure Enclave Processor was misbehaving and the most likely reason is that the device is ANFE incompatible due to Apple's custom hardware.

Since its highly unlikely that Apple will release a firmware update to support ANFE, introduce a quirk as suggested by Lukas to blacklist the T2 SEP from ANFE.

Quoted 7 lines
Quoted 5 lines

Applied to pci/for-linus for v7.3, thank you!

Replaced by Jason's very similar but slightly earlier patch at
https://patch.msgid.link/CABZrw2H+3yt2Y7xiq6OyAWaJM7P9ox-2nJxoQuJMwoJHLgi+YQ@mail.gmail.com/

Quoted 81 lines

I aligned the "!dev->no_aer_anfe" test as Lukas suggested and took a stab at the "misbehaving" comment:

Jason reported that since commit eddba19b8b5f ("PCI/AER: Support Advisory Non-Fatal Errors"), the Macs with Apple T2 Security Chip were powering off a few seconds after every boot. He also found that the power-off only happens when Advisory Non-Fatal Errors are unmasked on the PCI Device 106b:1802, the Apple T2 Secure Enclave Processor.

I'll be happy to revise this if we can make it clearer or more specific.

Quoted 69 lines
---
 drivers/pci/pcie/aer.c  |  3 ++-
 drivers/pci/quirks.c    | 12 ++++++++++++
 include/linux/pci.h     |  1 +
 include/linux/pci_ids.h |  1 +
 4 files changed, 16 insertions(+), 1 deletion(-)
drivers/pci/pcie/aer.c +2 -1
index 922a726a5..cab195f7c 100644
@@ -428,7 +428,8 @@ void pci_aer_init(struct pci_dev *dev)
 	 * Advisory Non-Fatal Errors are masked by default (PCIe r7.0, sec
 	 * 7.8.4.6).
 	 */
-	if (pcie_aer_is_native(dev) && dev->devcap & PCI_EXP_DEVCAP_RBER)
+	if (pcie_aer_is_native(dev) && dev->devcap & PCI_EXP_DEVCAP_RBER &&
+		!dev->no_aer_anfe)
 		pci_clear_and_set_config_dword(dev,
 					       dev->aer_cap + PCI_ERR_COR_MASK,
 					       PCI_ERR_COR_ADV_NFAT, 0);
drivers/pci/quirks.c +12 -0
index de9bbccda..acca89532 100644
@@ -6422,4 +6422,16 @@ static void pci_mask_replay_timer_timeout(struct pci_dev *pdev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9750, pci_mask_replay_timer_timeout);
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9755, pci_mask_replay_timer_timeout);
+
+/*
+ * Unmasking Advisory Non-Fatal Errors on Apple T2 Secure Enclave
+ * processor leads to the Mac shutting down spontaneously. Avoid
+ * doing that.
+ */
+static void quirk_no_aer_anfe(struct pci_dev *dev)
+{
+	dev->no_aer_anfe = 1;
+}
+
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_T2_SEP, quirk_no_aer_anfe);
 #endif
include/linux/pci.h +1 -0
index d31a8d107..83ffa5058 100644
@@ -514,6 +514,7 @@ struct pci_dev {
 	unsigned int	rom_bar_overlap:1;	/* ROM BAR disable broken */
 	unsigned int	rom_attr_enabled:1;	/* Display of ROM attribute enabled? */
 	unsigned int	non_mappable_bars:1;	/* BARs can't be mapped by CPU or peers */
+	unsigned int	no_aer_anfe:1;		/* Don't unmask Advisory Non-Fatal Errors */
 	pci_dev_flags_t dev_flags;
 	atomic_t	enable_cnt;	/* pci_enable_device has been called */
 
include/linux/pci_ids.h +1 -0
index 63774ae2b..103024f74 100644
@@ -1007,6 +1007,7 @@
 #define PCI_DEVICE_ID_APPLE_IPID2_FW	0x006a
 #define PCI_DEVICE_ID_APPLE_IPID2_GMAC	0x006b
 #define PCI_DEVICE_ID_APPLE_TIGON3	0x1645
+#define PCI_DEVICE_ID_APPLE_T2_SEP	0x1802
 
 #define PCI_VENDOR_ID_YAMAHA		0x1073
 #define PCI_DEVICE_ID_YAMAHA_724	0x0004
Signature · 1 line
2.55.0