* [PATCH] thunderbolt: Always generate the host router UUID
@ 2026-12-03 17:18 Mario Limonciello
2026-12-03 18:37 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Mario Limonciello @ 2026-12-03 17:18 UTC (permalink / raw)
To: Andreas Noever, Mika Westerberg, Yehezkel Bernat
Cc: Sanath S, linux-usb, linux-kernel, Mario Limonciello
The software connection manager derives the UUID of the host router
from its UID (or the fused link controller UUID on older Thunderbolt
hardware) with the upper two words filled with ones to match what ICM
does. The USB4 spec however requires the Domain UUID used in
inter-domain communication to be generated according to ISO/IEC 9834-8,
and the host router UID is not guaranteed to be unique either.
If the IDs are not unique then when two of these hosts are connected
together each side sees its own UUID in the inter-domain UUID response,
treats the link as a loop and never bonds the lanes, which caps the
host-to-host link at a single lane.
Always generate a random UUID for the host router instead. Device
routers keep the UID-derived UUID so that their unique_id stays stable
across boots and matches what ICM reports.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/thunderbolt/switch.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 8899fea713ac2..6cedaf5351bd9 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -2872,7 +2872,17 @@ static int tb_switch_set_uuid(struct tb_switch *sw)
if (sw->uuid)
return 0;
- if (tb_switch_is_usb4(sw)) {
+ if (!tb_route(sw)) {
+ /*
+ * USB4 spec requires the Domain UUID to be generated
+ * according to ISO/IEC 9834-8 so never derive it from the
+ * host router UID. The UID is not guaranteed to be unique
+ * either (it can be left unprogrammed) and if two hosts end
+ * up with the same UUID the inter-domain link is mistaken
+ * for a loop and lanes are never bonded.
+ */
+ generate_random_uuid((u8 *)uuid);
+ } else if (tb_switch_is_usb4(sw)) {
ret = usb4_switch_read_uid(sw, &sw->uid);
if (ret)
return ret;
---
base-commit: b8a56745a38d34f9db9723f7d0ef8ab10c0eabc5
change-id: 20261203-thunderbolt-fb97fb283a60
Best regards,
--
Mario Limonciello <mario.limonciello@amd.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] thunderbolt: Always generate the host router UUID
2026-12-03 17:18 [PATCH] thunderbolt: Always generate the host router UUID Mario Limonciello
@ 2026-12-03 18:37 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-03 18:37 UTC (permalink / raw)
To: Mario Limonciello; +Cc: linux-usb
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] thunderbolt: tb_switch_set_uuid() randomizes ICM host router
UUIDs
- [Medium] thunderbolt: random host UUID breaks ICM NVM auth status
cache and PM
- [Medium] thunderbolt: random host sw->uuid breaks unique_id ABI and
tbnet MACs
--
commit a31a94f0079a9a603cbe4c84d45d8948d7a02f23
Author: Mario Limonciello <mario.limonciello@amd.com>
thunderbolt: Always generate the host router UUID
This commit changes tb_switch_set_uuid() to generate a random UUID for host
routers instead of deriving it from the router UID or link controller
registers, while keeping the existing derivation for device routers.
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index 8899fea713ac2..6cedaf5351bd9 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -2872,7 +2872,17 @@ static int tb_switch_set_uuid(struct tb_switch *sw)
> if (sw->uuid)
> return 0;
>
> - if (tb_switch_is_usb4(sw)) {
> + if (!tb_route(sw)) {
> + /*
> + * USB4 spec requires the Domain UUID to be generated
> + * according to ISO/IEC 9834-8 so never derive it from the
> + * host router UID. The UID is not guaranteed to be unique
> + * either (it can be left unprogrammed) and if two hosts end
> + * up with the same UUID the inter-domain link is mistaken
> + * for a loop and lanes are never bonded.
> + */
> + generate_random_uuid((u8 *)uuid);
> + } else if (tb_switch_is_usb4(sw)) {
[Severity: High]
Does this randomize sw->uuid on ICM host routers where icm->set_uuid is
NULL?
On Falcon Ridge, Alpine Ridge, Titan Ridge, and Maple Ridge controllers,
icm_start() calls tb_switch_add() with sw->uuid unset, so
tb_switch_set_uuid() now generates a new UUID on every probe and power
cycle.
When host NVM authentication fails in nvm_authenticate_host_dma_port(),
nvm_set_auth_status() caches the failure under sw->uuid before power
cycling. After re-probe with a new UUID, nvm_get_auth_status() in
tb_switch_add_dma_port() misses the cache and skips post_nvm_auth().
That permanently leaks the PCIe root port runtime PM reference taken by
nhi_pci_start_dma_port(), hides the failure status in nvm_authenticate,
and leaks the nvm_auth_status_cache entry.
Under ICM, tb_xdp_handle_request() also answers XDomain UUID_REQUEST with
tb->root_switch->uuid, which now disagrees with firmware's xd->local_uuid
and makes tb_xdp_properties_response() return ERROR_UNKNOWN_DOMAIN.
Guarding this branch with !tb_switch_is_icm(sw) avoids affecting ICM.
[Severity: Medium]
Can generating a fresh random sw->uuid across power cycles break
__nvm_get_auth_status() lookups on ICM host routers?
__nvm_get_auth_status() keys nvm_auth_status_cache by sw->uuid, so both
immediate and deferred host NVM authentication failures lose their cached
status after dma_port_power_cycle() re-enumerates the router with a new
UUID.
This leaves nvm_authenticate_show() reporting 0x0, leaks the cached
nvm_auth_status entry, and leaks the PCIe root port runtime PM reference
from nhi_pci_start_dma_port(). Storing the software connection manager
Domain UUID separately on struct tb would avoid touching ICM host UUIDs.
[Severity: Medium]
Should the random Domain UUID be kept separate from sw->uuid so host
router unique_id and thunderbolt-net MAC addresses stay stable across
boots?
unique_id_show() exposes sw->uuid directly as
/sys/bus/thunderbolt/devices/<domain>-0/unique_id, which now changes on
every boot and driver reload. That contradicts
Documentation/ABI/testing/sysfs-bus-thunderbolt, which documents unique_id
as hardware-register or DROM/UID derived and is not updated here.
In addition, tb_scan_xdomain() copies tb->root_switch->uuid into
xd->local_uuid, and tbnet_generate_mac() hashes it for the thunderbolt-net
MAC address. Randomizing sw->uuid causes those MAC addresses to change on
every boot, breaking persistent MAC-based network configuration.
Because only tb_scan_xdomain() and tb_xdp_handle_request() use the host
Domain UUID for inter-domain traffic, storing a dedicated Domain UUID on
struct tb would preserve both the documented unique_id ABI and stable
thunderbolt-net MACs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-thunderbolt-v1-1-347b359ad963@amd.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 18:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 17:18 [PATCH] thunderbolt: Always generate the host router UUID Mario Limonciello
2026-12-03 18:37 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox