Commit 249872f5 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull PCIe Link Encryption and Device Authentication from Dan Williams:
 "New PCI infrastructure and one architecture implementation for PCIe
  link encryption establishment via platform firmware services.

  This work is the result of multiple vendors coming to consensus on
  some core infrastructure (thanks Alexey, Yilun, and Aneesh!), and
  three vendor implementations, although only one is included in this
  pull. The PCI core changes have an ack from Bjorn, the crypto/ccp/
  changes have an ack from Tom, and the iommu/amd/ changes have an ack
  from Joerg.

  PCIe link encryption is made possible by the soup of acronyms
  mentioned in the shortlog below. Link Integrity and Data Encryption
  (IDE) is a protocol for installing keys in the transmitter and
  receiver at each end of a link. That protocol is transported over Data
  Object Exchange (DOE) mailboxes using PCI configuration requests.

  The aspect that makes this a "platform firmware service" is that the
  key provisioning and protocol is coordinated through a Trusted
  Execution Envrionment (TEE) Security Manager (TSM). That is either
  firmware running in a coprocessor (AMD SEV-TIO), or quasi-hypervisor
  software (Intel TDX Connect / ARM CCA) running in a protected CPU
  mode.

  Now, the only reason to ask a TSM to run this protocol and install the
  keys rather than have a Linux driver do the same is so that later, a
  confidential VM can ask the TSM directly "can you certify this
  device?".

  That precludes host Linux from provisioning its own keys, because host
  Linux is outside the trust domain for the VM. It also turns out that
  all architectures, save for one, do not publish a mechanism for an OS
  to establish keys in the root port. So "TSM-established link
  encryption" is the only cross-architecture path for this capability
  for the foreseeable future.

  This unblocks the other arch implementations to follow in v6.20/v7.0,
  once they clear some other dependencies, and it unblocks the next
  phase of work to implement the end-to-end flow of confidential device
  assignment. The PCIe specification calls this end-to-end flow Trusted
  Execution Environment (TEE) Device Interface Security Protocol
  (TDISP).

  In the meantime, Linux gets a link encryption facility which has
  practical benefits along the same lines as memory encryption. It
  authenticates devices via certificates and may protect against
  interposer attacks trying to capture clear-text PCIe traffic.

  Summary:

   - Introduce the PCI/TSM core for the coordination of device
     authentication, link encryption and establishment (IDE), and later
     management of the device security operational states (TDISP).
     Notify the new TSM core layer of PCI device arrival and departure

   - Add a low level TSM driver for the link encryption establishment
     capabilities of the AMD SEV-TIO architecture

   - Add a library of helpers TSM drivers to use for IDE establishment
     and the DOE transport

   - Add skeleton support for 'bind' and 'guest_request' operations in
     support of TDISP"

* tag 'tsm-for-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/devsec/tsm: (23 commits)
  crypto/ccp: Fix CONFIG_PCI=n build
  virt: Fix Kconfig warning when selecting TSM without VIRT_DRIVERS
  crypto/ccp: Implement SEV-TIO PCIe IDE (phase1)
  iommu/amd: Report SEV-TIO support
  psp-sev: Assign numbers to all status codes and add new
  ccp: Make snp_reclaim_pages and __sev_do_cmd_locked public
  PCI/TSM: Add 'dsm' and 'bound' attributes for dependent functions
  PCI/TSM: Add pci_tsm_guest_req() for managing TDIs
  PCI/TSM: Add pci_tsm_bind() helper for instantiating TDIs
  PCI/IDE: Initialize an ID for all IDE streams
  PCI/IDE: Add Address Association Register setup for downstream MMIO
  resource: Introduce resource_assigned() for discerning active resources
  PCI/TSM: Drop stub for pci_tsm_doe_transfer()
  drivers/virt: Drop VIRT_DRIVERS build dependency
  PCI/TSM: Report active IDE streams
  PCI/IDE: Report available IDE streams
  PCI/IDE: Add IDE establishment helpers
  PCI: Establish document for PCI host bridge sysfs attributes
  PCI: Add PCIe Device 3 Extended Capability enumeration
  PCI/TSM: Establish Secure Sessions and Link Encryption
  ...
parents fbff9496 7dfbe9a6
Loading
Loading
Loading
Loading
+81 −0
Original line number Diff line number Diff line
@@ -621,3 +621,84 @@ Description:
		number extended capability. The file is read only and due to
		the possible sensitivity of accessible serial numbers, admin
		only.

What:		/sys/bus/pci/devices/.../tsm/
Contact:	linux-coco@lists.linux.dev
Description:
		This directory only appears if a physical device function
		supports authentication (PCIe CMA-SPDM), interface security
		(PCIe TDISP), and is accepted for secure operation by the
		platform TSM driver. This attribute directory appears
		dynamically after the platform TSM driver loads. So, only after
		the /sys/class/tsm/tsm0 device arrives can tools assume that
		devices without a tsm/ attribute directory will never have one;
		before that, the security capabilities of the device relative to
		the platform TSM are unknown. See
		Documentation/ABI/testing/sysfs-class-tsm.

What:		/sys/bus/pci/devices/.../tsm/connect
Contact:	linux-coco@lists.linux.dev
Description:
		(RW) Write the name of a TSM (TEE Security Manager) device from
		/sys/class/tsm to this file to establish a connection with the
		device.  This typically includes an SPDM (DMTF Security
		Protocols and Data Models) session over PCIe DOE (Data Object
		Exchange) and may also include PCIe IDE (Integrity and Data
		Encryption) establishment. Reads from this attribute return the
		name of the connected TSM or the empty string if not
		connected. A TSM device signals its readiness to accept PCI
		connection via a KOBJ_CHANGE event.

What:		/sys/bus/pci/devices/.../tsm/disconnect
Contact:	linux-coco@lists.linux.dev
Description:
		(WO) Write the name of the TSM device that was specified
		to 'connect' to teardown the connection.

What:		/sys/bus/pci/devices/.../tsm/dsm
Contact:	linux-coco@lists.linux.dev
Description:	(RO) Return PCI device name of this device's DSM (Device
		Security Manager). When a device is in the connected state it
		indicates that the platform TSM (TEE Security Manager) has made
		a secure-session connection with a device's DSM. A DSM is always
		physical function 0 and when the device supports TDISP (TEE
		Device Interface Security Protocol) its managed functions also
		populate this tsm/dsm attribute. The managed functions of a DSM
		are SR-IOV (Single Root I/O Virtualization) virtual functions,
		non-zero functions of a multi-function device, or downstream
		endpoints depending on whether the DSM is an SR-IOV physical
		function, function0 of a multi-function device, or an upstream
		PCIe switch port. This is a "link" TSM attribute, see
		Documentation/ABI/testing/sysfs-class-tsm.

What:		/sys/bus/pci/devices/.../tsm/bound
Contact:	linux-coco@lists.linux.dev
Description:	(RO) Return the device name of the TSM when the device is in a
		TDISP (TEE Device Interface Security Protocol) operational state
		(LOCKED, RUN, or ERROR, not UNLOCKED). Bound devices consume
		platform TSM resources and depend on the device's configuration
		(e.g. BME (Bus Master Enable) and MSE (Memory Space Enable)
		among other settings) to remain stable for the duration of the
		bound state. This attribute is only visible for devices that
		support TDISP operation, and it is only populated after
		successful connect and TSM bind. The TSM bind operation is
		initiated by VFIO/IOMMUFD. This is a "link" TSM attribute, see
		Documentation/ABI/testing/sysfs-class-tsm.

What:		/sys/bus/pci/devices/.../authenticated
Contact:	linux-pci@vger.kernel.org
Description:
		When the device's tsm/ directory is present device
		authentication (PCIe CMA-SPDM) and link encryption (PCIe IDE)
		are handled by the platform TSM (TEE Security Manager). When the
		tsm/ directory is not present this attribute reflects only the
		native CMA-SPDM authentication state with the kernel's
		certificate store.

		If the attribute is not present, it indicates that
		authentication is unsupported by the device, or the TSM has no
		available authentication methods for the device.

		When present and the tsm/ attribute directory is present, the
		authenticated attribute is an alias for the device 'connect'
		state. See the 'tsm/connect' attribute for more details.
+19 −0
Original line number Diff line number Diff line
What:		/sys/class/tsm/tsmN
Contact:	linux-coco@lists.linux.dev
Description:
		"tsmN" is a device that represents the generic attributes of a
		platform TEE Security Manager.  It is typically a child of a
		platform enumerated TSM device. /sys/class/tsm/tsmN/uevent
		signals when the PCI layer is able to support establishment of
		link encryption and other device-security features coordinated
		through a platform tsm.

What:		/sys/class/tsm/tsmN/streamH.R.E
Contact:	linux-pci@vger.kernel.org
Description:
		(RO) When a host bridge has established a secure connection via
		the platform TSM, symlink appears. The primary function of this
		is have a system global review of TSM resource consumption
		across host bridges. The link points to the endpoint PCI device
		and matches the same link published by the host bridge. See
		Documentation/ABI/testing/sysfs-devices-pci-host-bridge.
+45 −0
Original line number Diff line number Diff line
What:		/sys/devices/pciDDDD:BB
		/sys/devices/.../pciDDDD:BB
Contact:	linux-pci@vger.kernel.org
Description:
		A PCI host bridge device parents a PCI bus device topology. PCI
		controllers may also parent host bridges. The DDDD:BB format
		conveys the PCI domain (ACPI segment) number and root bus number
		(in hexadecimal) of the host bridge. Note that the domain number
		may be larger than the 16-bits that the "DDDD" format implies
		for emulated host-bridges.

What:		pciDDDD:BB/firmware_node
Contact:	linux-pci@vger.kernel.org
Description:
		(RO) Symlink to the platform firmware device object "companion"
		of the host bridge. For example, an ACPI device with an _HID of
		PNP0A08 (/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00). See
		/sys/devices/pciDDDD:BB entry for details about the DDDD:BB
		format.

What:		pciDDDD:BB/streamH.R.E
Contact:	linux-pci@vger.kernel.org
Description:
		(RO) When a platform has established a secure connection, PCIe
		IDE, between two Partner Ports, this symlink appears. A stream
		consumes a Stream ID slot in each of the Host bridge (H), Root
		Port (R) and Endpoint (E).  The link points to the Endpoint PCI
		device in the Selective IDE Stream pairing. Specifically, "R"
		and "E" represent the assigned Selective IDE Stream Register
		Block in the Root Port and Endpoint, and "H" represents a
		platform specific pool of stream resources shared by the Root
		Ports in a host bridge. See /sys/devices/pciDDDD:BB entry for
		details about the DDDD:BB format.

What:		pciDDDD:BB/available_secure_streams
Contact:	linux-pci@vger.kernel.org
Description:
		(RO) When a host bridge has Root Ports that support PCIe IDE
		(link encryption and integrity protection) there may be a
		limited number of Selective IDE Streams that can be used for
		establishing new end-to-end secure links. This attribute
		decrements upon secure link setup, and increments upon secure
		link teardown. The in-use stream count is determined by counting
		stream symlinks. See /sys/devices/pciDDDD:BB entry for details
		about the DDDD:BB format.
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ The Linux PCI driver implementer's API guide

   pci
   p2pdma
   tsm

.. only::  subproject and html

+21 −0
Original line number Diff line number Diff line
.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>

========================================================
PCI Trusted Execution Environment Security Manager (TSM)
========================================================

Subsystem Interfaces
====================

.. kernel-doc:: include/linux/pci-ide.h
   :internal:

.. kernel-doc:: drivers/pci/ide.c
   :export:

.. kernel-doc:: include/linux/pci-tsm.h
   :internal:

.. kernel-doc:: drivers/pci/tsm.c
   :export:
Loading