Skip to content

Thunderbolt security levels and NVM firmware upgrade

Mika Westerberg lkml 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest27 patches 9 repliesIn review
  2. v327 patches 28 repliesSuperseded
  3. v227 patches 15 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v124 patches81 repliesSuperseded

Changes in v4 from the cover letter

- Rename tb_switch_find_vsec_cap() to tb_switch_find_vse_cap() to be consistent with PCI where VSEC stands for Vendor Specific Extended Capability.
- Rename TB_VSEC_CAP_* to TB_VSE_CAP accordingly.
- Add missing call to mutex_destroy() for tb->lock
- Disable host NVM upgrade when in native mode
- Add SoB from Andreas

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/27thunderbolt: Use const buffer pointer in write operationsdrivers/thunderbolt/ctl.c drivers/thunderbolt/ctl.h drivers/thunderbolt/tb.h+7 -70 replies
2/27thunderbolt: No need to read UID of the root switch on resumedrivers/thunderbolt/switch.c+18 -111 reply
3/27thunderbolt: Do not try to read UID if DROM offset is read as 0drivers/thunderbolt/eeprom.c+3 -00 replies
4/27thunderbolt: Do not warn about newer DROM versionsdrivers/thunderbolt/eeprom.c+1 -10 replies
5/27thunderbolt: Add MSI-X supportdrivers/thunderbolt/ctl.c drivers/thunderbolt/nhi.c drivers/thunderbolt/nhi.h +1 more+198 -360 replies
6/27thunderbolt: Rework capability handlingdrivers/thunderbolt/cap.c drivers/thunderbolt/switch.c drivers/thunderbolt/tb.c +3 more+142 -1020 replies
7/27thunderbolt: Allow passing NULL to tb_ctl_free()drivers/thunderbolt/ctl.c+4 -00 replies
8/27thunderbolt: Introduce thunderbolt bus and connection managerdrivers/thunderbolt/Makefile drivers/thunderbolt/domain.c drivers/thunderbolt/nhi.c +3 more+377 -1210 replies
9/27thunderbolt: Convert switch to a deviceDocumentation/ABI/testing/sysfs-bus-thunderbolt drivers/thunderbolt/eeprom.c drivers/thunderbolt/switch.c +2 more+303 -670 replies
10/27thunderbolt: Fail switch adding operation if reading DROM failsdrivers/thunderbolt/switch.c+5 -20 replies
11/27thunderbolt: Do not fail if DROM data CRC32 is invaliddrivers/thunderbolt/eeprom.c+1 -20 replies
12/27thunderbolt: Refactor and fix parsing of port drom entriesdrivers/thunderbolt/eeprom.c+16 -160 replies
13/27thunderbolt: Read vendor and device name from DROMDocumentation/ABI/testing/sysfs-bus-thunderbolt drivers/thunderbolt/eeprom.c drivers/thunderbolt/switch.c +1 more+72 -00 replies
14/27thunderbolt: Move control channel messages to tb_msgs.hdrivers/thunderbolt/ctl.c drivers/thunderbolt/ctl.h drivers/thunderbolt/tb_msgs.h+109 -910 replies
15/27thunderbolt: Expose get_route() to other filesdrivers/thunderbolt/ctl.c drivers/thunderbolt/ctl.h+11 -120 replies
16/27thunderbolt: Expose make_header() to other filesdrivers/thunderbolt/ctl.c drivers/thunderbolt/ctl.h+15 -150 replies
17/27thunderbolt: Let the connection manager handle all notificationsdrivers/thunderbolt/ctl.c drivers/thunderbolt/ctl.h drivers/thunderbolt/domain.c +2 more+103 -380 replies
18/27thunderbolt: Rework control channel to be more reliabledrivers/thunderbolt/ctl.c drivers/thunderbolt/ctl.h drivers/thunderbolt/tb.h+473 -710 replies
19/27thunderbolt: Add new Thunderbolt PCI IDsdrivers/thunderbolt/nhi.c drivers/thunderbolt/nhi.h drivers/thunderbolt/switch.c+42 -50 replies
20/27thunderbolt: Add support for NHI mailboxdrivers/thunderbolt/nhi.c drivers/thunderbolt/nhi.h drivers/thunderbolt/nhi_regs.h+85 -00 replies
21/27thunderbolt: Store Thunderbolt generation in the switch structuredrivers/thunderbolt/switch.c drivers/thunderbolt/tb.h+40 -170 replies
22/27thunderbolt: Add support for DMA configuration based mailboxdrivers/thunderbolt/Makefile drivers/thunderbolt/dma_port.c drivers/thunderbolt/dma_port.h +3 more+644 -20 replies
23/27thunderbolt: Do not touch the hardware if the NHI is gone on resumedrivers/thunderbolt/nhi.c drivers/thunderbolt/nhi.h+15 -00 replies
24/27thunderbolt: Add support for Internal Connection Manager (ICM)Documentation/ABI/testing/sysfs-bus-thunderbolt drivers/thunderbolt/Kconfig drivers/thunderbolt/Makefile +9 more+1805 -120 replies
25/27thunderbolt: Add support for host and device NVM firmware upgradeDocumentation/ABI/testing/sysfs-bus-thunderbolt drivers/thunderbolt/Kconfig drivers/thunderbolt/domain.c +5 more+706 -230 replies
26/27thunderbolt: Add documentation how Thunderbolt bus can be usedDocumentation/admin-guide/index.rst Documentation/admin-guide/thunderbolt.rst+200 -00 replies
27/27MAINTAINERS: Add maintainers for Thunderbolt driverMAINTAINERS+3 -00 replies

Reviews trailers per patch

26 of 27 patches have a Reviewed-by or Acked-by.

PatchYehezkel BernatMichael JametAndy ShevchenkoGreg Kroah-HartmanChristian Kellner
SeriesT-b
1/27R-b R-b R-b R-b
2/27R-b
3/27R-b R-b R-b
4/27R-b R-b R-b
5/27R-b R-b
6/27R-b R-b R-b
7/27
8/27R-b R-b R-b
9/27R-b R-b R-b
10/27R-b R-b R-b
11/27R-b R-b R-b
12/27R-b
13/27R-b R-b
14/27R-b R-b R-b
15/27R-b R-b R-b
16/27R-b R-b R-b
17/27R-b R-b R-b
18/27R-b R-b R-b
19/27R-b R-b
20/27R-b R-b
21/27R-b R-b R-b
22/27R-b R-b
23/27R-b R-b R-b
24/27R-b R-b
25/27R-b R-b
26/27R-b R-b R-b
27/27R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v4 thread

Cover letter [PATCH v4 00/27] Thunderbolt security levels and NVM firmware upgrade

Hi,

This is fourth version of the patch series adding support for Thunderbolt security levels and NVM firmware upgrade. PCs running Intel Falcon Ridge or newer need these in order to connect devices if the security level is set to "user(SL1) or secure(SL2)" from BIOS.

The security levels were added to to prevent DMA attacks when PCIe is tunneled over Thunderbolt fabric where IOMMU is not available or cannot be enabled for different reasons.

This series converts the Thunderbolt driver to a Linux bus and makes each Thunderbolt device (aka Thunderbolt switch or router or endpoint) a Linux device which is connected to that bus addressed by their routing string (this is the addressing Thunderbolt uses).

With these patches the user can authorize devices using sysfs attributes like (following USB):

  # echo 1 > /sys/bus/thunderbolt/devices/0-1/authorized

If the BIOS security level is set to "secure" and the device supports secure connect on the first connect the device is uploaded a random key:

# key=$(openssl rand -hex 32)

  # echo $key > /sys/bus/thunderbolt/devices/0-1/key
  # echo 1 > /sys/bus/thunderbolt/devices/0-1/authorized

Next time the device is plugged in the user can verify (challenge) the device using the same key:

  # echo $key > /sys/bus/thunderbolt/devices/0-1/key
  # echo 2 > /sys/bus/thunderbolt/devices/0-1/authorized

The device identification information is found below each device sysfs node and includes following attributes:

device - Device ID
device_name - Name of the device
vendor - Vendor ID
vendor_name - Name of the vendor
unique_id - Unique ID string identifying this particular device

In addition these patches add support for upgrading NVM firmware running on a host or device by running something like:

  # dd if=KYK_TBT_FW_0018.bin of=/sys/bus/thunderbolt/devices/0-0/nvm_non_active0/nvmem
  # echo 1 > /sys/bus/thunderbolt/devices/0-0/nvm_authenticate

More information how to use the Thunderbolt bus can be found in patch [26/27].

Where Internal Connection Manager (ICM) firmware is available and usable, we use it in the driver. This also includes newer Apple Macbooks with Alpine Ridge. For older Macbooks the driver works as before but in addition the Thunderbolt bus is available there as well (including possibility to upgrade NVM firmware of connected devices).

Note for Macs the Linux native PCIe hotplug support does not work well with the Thunderbolt PCIe topologies where there is need to put all available resources to the PCIe downstream port where the PCIe chain is extended. This is something we need to fix. In the mean time is a way to work it around by passing "pci=hpbussize=10,hpmemsize=2M" or so to the kernel command line.

We are currently porting Amir's network driver on top of the Thunderbolt bus.

The previous version (v3) of the series can be found in:

https://lwn.net/Articles/724465/

Changes from v3:
- Rename tb_switch_find_vsec_cap() to tb_switch_find_vse_cap() to be consistent with PCI where VSEC stands for Vendor Specific Extended Capability.
- Rename TB_VSEC_CAP_* to TB_VSE_CAP accordingly.
- Add missing call to mutex_destroy() for tb->lock
- Disable host NVM upgrade when in native mode
- Add SoB from Andreas

Greg, I did not add your ack for the two patches (9 and 26) you acked because I think you are going to add your SoB to the series anyway when you apply the series. Let me know if you want me to add them. Thanks.

Lukas Wunner (1):
thunderbolt: Refactor and fix parsing of port drom entries

Mika Westerberg (26):
thunderbolt: Use const buffer pointer in write operations
thunderbolt: No need to read UID of the root switch on resume
thunderbolt: Do not try to read UID if DROM offset is read as 0
thunderbolt: Do not warn about newer DROM versions
thunderbolt: Add MSI-X support
thunderbolt: Rework capability handling
thunderbolt: Allow passing NULL to tb_ctl_free()
thunderbolt: Introduce thunderbolt bus and connection manager
thunderbolt: Convert switch to a device
thunderbolt: Fail switch adding operation if reading DROM fails
thunderbolt: Do not fail if DROM data CRC32 is invalid
thunderbolt: Read vendor and device name from DROM
thunderbolt: Move control channel messages to tb_msgs.h
thunderbolt: Expose get_route() to other files
thunderbolt: Expose make_header() to other files
thunderbolt: Let the connection manager handle all notifications
thunderbolt: Rework control channel to be more reliable
thunderbolt: Add new Thunderbolt PCI IDs
thunderbolt: Add support for NHI mailbox
thunderbolt: Store Thunderbolt generation in the switch structure
thunderbolt: Add support for DMA configuration based mailbox
thunderbolt: Do not touch the hardware if the NHI is gone on resume
thunderbolt: Add support for Internal Connection Manager (ICM)
thunderbolt: Add support for host and device NVM firmware upgrade
thunderbolt: Add documentation how Thunderbolt bus can be used
MAINTAINERS: Add maintainers for Thunderbolt driver

 Documentation/ABI/testing/sysfs-bus-thunderbolt |  110 +++
 Documentation/admin-guide/index.rst             |    1 +
 Documentation/admin-guide/thunderbolt.rst       |  199 ++++
 MAINTAINERS                                     |    3 +
 drivers/thunderbolt/Kconfig                     |   13 +-
 drivers/thunderbolt/Makefile                    |    2 +-
 drivers/thunderbolt/cap.c                       |  169 ++--
 drivers/thunderbolt/ctl.c                       |  665 +++++++++----
 drivers/thunderbolt/ctl.h                       |  105 +-
 drivers/thunderbolt/dma_port.c                  |  524 ++++++++++
 drivers/thunderbolt/dma_port.h                  |   34 +
 drivers/thunderbolt/domain.c                    |  456 +++++++++
 drivers/thunderbolt/eeprom.c                    |  119 ++-
 drivers/thunderbolt/icm.c                       | 1089 +++++++++++++++++++++
 drivers/thunderbolt/nhi.c                       |  306 +++++-
 drivers/thunderbolt/nhi.h                       |   93 +-
 drivers/thunderbolt/nhi_regs.h                  |   27 +
 drivers/thunderbolt/switch.c                    | 1178 +++++++++++++++++++++--
 drivers/thunderbolt/tb.c                        |  240 +++--
 drivers/thunderbolt/tb.h                        |  251 ++++-
 drivers/thunderbolt/tb_msgs.h                   |  260 +++++
 drivers/thunderbolt/tb_regs.h                   |   50 +-
 drivers/thunderbolt/tunnel_pci.c                |   17 +-
 23 files changed, 5329 insertions(+), 582 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-thunderbolt
 create mode 100644 Documentation/admin-guide/thunderbolt.rst
 create mode 100644 drivers/thunderbolt/dma_port.c
 create mode 100644 drivers/thunderbolt/dma_port.h
 create mode 100644 drivers/thunderbolt/domain.c
 create mode 100644 drivers/thunderbolt/icm.c
 create mode 100644 drivers/thunderbolt/tb_msgs.h
Signature · 1 line
2.11.0