PCI: Add warning about possible danger for pcie_bus_perf mode
RFC PATCH 1/1 PCI: Add warning about possible danger for pcie_bus_perf mode
During stability test, there was a bug that running 'mount' on a type of commercial NVME disk failed on an arm64 server and raised PCIe RAS error and panic the kernel later, when using "pci=pcie_bus_perf" kernel cmdline parameter.
The NVME device has MPS(Max Payload Size) capability of 256 bytes while its corresponding root port is capable of 512 bytes. When enabling PCIE_BUS_PERFORMANCE mode, its MPS and MRRS(Max Read Request Size) are both set to 256, while the root port's are both set to 512. But the NVME device doesn't comply with PCIe spec (v6.3), Section 7.5.3.4:
"Max_Read_Request_Size - This field sets the maximum Read Request size for the Function as a Requester. The Function must not generate Read Requests with a size exceeding the set value
"
that it sends out Memory Read request with length of 512 bytes, and when root port replies CplD packet with 512 bytes payload which exceeds device's MPS, PCIe RAS error is issued.
The problem can be reproduced on some arm64 server and Intel server.
This caused some data damage, and there were quite a few NVME cards of the same type damaged (though we are not sure these are directly related).
In this case, the kernel is innocent as it does make sure a device's MRRS setting is no larger than its MPS setting, while the device breaks PCIe spec. It could still be meaningful to warn about the possible danger.
--- include/linux/pci.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/linux/pci.h +12 -0
@@ -1192,6 +1192,18 @@ static inline int pci_has_flag(int flag) { return pci_flags & flag; }void pcie_bus_configure_settings (struct pci_bus *bus); +/* +* Note: For PCIE_BUS_PERFORMANCE mode, it could be dangerous for a device +* that doesn't completely comply with PCIe spec about MPS and MRRS setting, +* as it allows the device and its corresponding root port to have different +* MPS settings. +* +* Kernel already makes sure a device's MRRS setting is no larger than its +* MPS setting. But there is real world case that some commercial NVME device +* sends out Memory Read request with length bigger than its MRRS (equals to +* its MPS), and root port replies CplD packet with that bigger length, which +* triggers RAS/MCE errors on arm64 and x86 servers, causing data damage. +*/ enum pcie_bus_config_types {PCIE_BUS_TUNE_OFF ,/* Don't touch MPS at all */ PCIE_BUS_DEFAULT ,/* Ensure MPS matches upstream bridge */
Signature · 1 line
2.39.5 (Apple Git-154)
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 19 lines
During stability test, there was a bug that running 'mount' on a type of commercial NVME disk failed on an arm64 server and raised PCIe RAS error and panic the kernel later, when using "pci=pcie_bus_perf" kernel cmdline parameter.
The NVME device has MPS(Max Payload Size) capability of 256 bytes while its corresponding root port is capable of 512 bytes. When enabling
PCIE_BUS_PERFORMANCEmode, its MPS and MRRS(Max Read Request Size) are both set to 256, while the root port's are both set to 512. But the NVME device doesn't comply with PCIe spec (v6.3), Section 7.5.3.4:"
Max_Read_Request_Size- This field sets the maximum Read Request size for the Function as a Requester. The Function must not generate Read Requests with a size exceeding the set value
[ ... ]
setting is no larger than its MPS setting, while the device breaks PCIe spec. It could still be meaningful to warn about the possible danger.
Quoted 2 lines
Reported-by Anju Zheng <[email protected]>Signed-off-by Feng Tang <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1