Create a basic starting point for drivers/attestation by moving the tsm_report and tsm_mr core code into drivers/attestation and revising the Documentation. The attestation subsystem is intended to support drivers for all Roots of Trust (ROTs), both local to the CPU and on-device ROTs accessed through SPDM. A well-known example of a ROT is a Trusted Platform Module, though many different specifications for much simpler ROTs now exist. In general, a ROT is a HW device that securely holds a private key, can generate signed evidence reflecting its current state, and often includes a measurement register system to create a tamper-proof log signed by its private key. Sophisticated ROTs may also provide functions like sealing. ROTs have become a significant security technology in the server space. They are used to ensure the supply chain has not been tampered with and to confirm directly that devices are running the expected, untampered firmware and software. tsm_report and tsm_mr each implement half of a ROT. tsm_mr allows manipulating the measurement registers that tsm_report produces signed evidence over. As things are restructured there will be one driver for the ROT, and the two uAPIs of report and mr will continue forward using that single driver. Ultimately the subsystem should encompass at least the following devices: * A simplified TPM interface for quote and PCR extend * AMD CC VM signed reports * ARM CCA VM signed reports and REM measurement registers * ARM FIRME bare metal signed reports * Caliptra open source ROT * Intel TDX CC VM signed reports and RTMR measurement registers * SPDM protocol over PCIe DOE and other transports in bare metal * "SPDM" evidence inside a CC guest using a TDISP device Signed-off-by: Jason Gunthorpe --- .../sysfs-devices-virtual-misc-tdx_guest | 2 +- Documentation/driver-api/attestation.rst | 36 +++++++++++++++++++ Documentation/driver-api/coco/index.rst | 10 ------ .../driver-api/coco/measurement-registers.rst | 12 ------- Documentation/driver-api/index.rst | 2 +- MAINTAINERS | 4 +-- drivers/Kconfig | 2 ++ drivers/Makefile | 2 ++ drivers/attestation/Kconfig | 17 +++++++++ drivers/attestation/Makefile | 5 +++ .../{virt/coco/guest => attestation}/tsm-mr.c | 0 .../report.c => attestation/tsm-report.c} | 0 drivers/virt/coco/Kconfig | 2 -- drivers/virt/coco/Makefile | 1 - drivers/virt/coco/arm-cca-guest/Kconfig | 2 +- drivers/virt/coco/guest/Kconfig | 16 --------- drivers/virt/coco/guest/Makefile | 4 --- drivers/virt/coco/sev-guest/Kconfig | 2 +- drivers/virt/coco/tdx-guest/Kconfig | 3 +- samples/Kconfig | 3 +- 20 files changed, 70 insertions(+), 55 deletions(-) create mode 100644 Documentation/driver-api/attestation.rst delete mode 100644 Documentation/driver-api/coco/index.rst delete mode 100644 Documentation/driver-api/coco/measurement-registers.rst create mode 100644 drivers/attestation/Kconfig create mode 100644 drivers/attestation/Makefile rename drivers/{virt/coco/guest => attestation}/tsm-mr.c (100%) rename drivers/{virt/coco/guest/report.c => attestation/tsm-report.c} (100%) delete mode 100644 drivers/virt/coco/guest/Kconfig delete mode 100644 drivers/virt/coco/guest/Makefile diff --git a/Documentation/ABI/testing/sysfs-devices-virtual-misc-tdx_guest b/Documentation/ABI/testing/sysfs-devices-virtual-misc-tdx_guest index 8fca56c8c9dfe6..44f7e82cc316f5 100644 --- a/Documentation/ABI/testing/sysfs-devices-virtual-misc-tdx_guest +++ b/Documentation/ABI/testing/sysfs-devices-virtual-misc-tdx_guest @@ -14,7 +14,7 @@ Description: https://www.intel.com/content/www/us/en/developer/tools/trust-domain-extensions/documentation.html#architecture See also: - https://docs.kernel.org/driver-api/coco/measurement-registers.html + https://docs.kernel.org/driver-api/attestation.html What: /sys/devices/virtual/misc/tdx_guest/measurements/mrconfigid Date: April, 2025 diff --git a/Documentation/driver-api/attestation.rst b/Documentation/driver-api/attestation.rst new file mode 100644 index 00000000000000..15092bea90f770 --- /dev/null +++ b/Documentation/driver-api/attestation.rst @@ -0,0 +1,36 @@ +.. SPDX-License-Identifier: GPL-2.0 +.. include:: + +===================== +Attestation Subsystem +===================== + +Attestation subsystem is intended to support drivers for all Roots of Trust +(ROTs), both local to the CPU and on-device ROTs accessed through SPDM. A well +known example of a ROT is a Trusted Platform Module, though many different +specifications for much simpler ROTs exist now. + +In general a ROT is a HW device that securely holds a private key, can generate +a signed evidence reflecting its current state and often includes a measurement +register system to create a tamper proof log signed by its private key. +Sophisticated ROTs may also provide functions like sealing. + +ROTs have become a significant security technology in the server space. They are +used to ensure the supply chain has not been tampered with and confirm directly +that devices are running expected untampered firmware and software. + +Measurement Registers +===================== + +"Measurement Registers" (called a PCR in the TPM standards) are used for +creating a tamper proof log. The register stores the current top of something +like a Merkle Tree which chains cryptographic hash functions together to reflect +the current content of a dynamically growing log. When the ROT generates signed +evidence it will sign this value which allows verifying that the associated log +is unchanged. + +.. kernel-doc:: include/linux/tsm-mr.h + :internal: + +.. kernel-doc:: drivers/attestation/tsm-mr.c + :export: diff --git a/Documentation/driver-api/coco/index.rst b/Documentation/driver-api/coco/index.rst deleted file mode 100644 index 783c8b033547ef..00000000000000 --- a/Documentation/driver-api/coco/index.rst +++ /dev/null @@ -1,10 +0,0 @@ -.. SPDX-License-Identifier: GPL-2.0 - -====================== -Confidential Computing -====================== - -.. toctree:: - :maxdepth: 1 - - measurement-registers diff --git a/Documentation/driver-api/coco/measurement-registers.rst b/Documentation/driver-api/coco/measurement-registers.rst deleted file mode 100644 index 962a44efa2c027..00000000000000 --- a/Documentation/driver-api/coco/measurement-registers.rst +++ /dev/null @@ -1,12 +0,0 @@ -.. SPDX-License-Identifier: GPL-2.0 -.. include:: - -===================== -Measurement Registers -===================== - -.. kernel-doc:: include/linux/tsm-mr.h - :internal: - -.. kernel-doc:: drivers/virt/coco/guest/tsm-mr.c - :export: diff --git a/Documentation/driver-api/index.rst b/Documentation/driver-api/index.rst index aaf5d76ed074ed..3f32af5ac8b91f 100644 --- a/Documentation/driver-api/index.rst +++ b/Documentation/driver-api/index.rst @@ -80,9 +80,9 @@ Subsystem-specific APIs 80211/index acpi/index + attestation backlight/lp855x-driver.rst clk - coco/index console crypto/index dmaengine/index diff --git a/MAINTAINERS b/MAINTAINERS index e8059b3d7e6efb..841e21afde3d82 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -28543,12 +28543,12 @@ L: linux-coco@lists.linux.dev S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/tsm/linux.git F: Documentation/ABI/testing/configfs-tsm-report -F: Documentation/driver-api/coco/ +F: Documentation/driver-api/attestation.rst F: Documentation/driver-api/pci/tsm.rst +F: drivers/attestation/ F: drivers/crypto/ccp/sev-dev-tio.* F: drivers/crypto/ccp/sev-dev-tsm.c F: drivers/pci/tsm.c -F: drivers/virt/coco/guest/ F: drivers/virt/coco/tsm-core.c F: include/linux/*tsm*.h F: samples/tsm-mr/ diff --git a/drivers/Kconfig b/drivers/Kconfig index f2bed2ddeb6628..53b21efd02f649 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -143,6 +143,8 @@ source "drivers/uio/Kconfig" source "drivers/vfio/Kconfig" +source "drivers/attestation/Kconfig" + source "drivers/virt/Kconfig" source "drivers/virtio/Kconfig" diff --git a/drivers/Makefile b/drivers/Makefile index 0841ea851847e8..4b471559773114 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -159,6 +159,8 @@ obj-$(CONFIG_REMOTEPROC) += remoteproc/ obj-$(CONFIG_RPMSG) += rpmsg/ obj-$(CONFIG_SOUNDWIRE) += soundwire/ +obj-$(CONFIG_ATTESTATION) += attestation/ + # Virtualization drivers obj-y += virt/ obj-$(CONFIG_HYPERV) += hv/ diff --git a/drivers/attestation/Kconfig b/drivers/attestation/Kconfig new file mode 100644 index 00000000000000..86672fa9477b20 --- /dev/null +++ b/drivers/attestation/Kconfig @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only + +menuconfig ATTESTATION + tristate "Attestation and root of trust devices" + select CONFIGFS_FS + select CRYPTO_HASH_INFO + help + Attestation and root of trust (RoT) devices include a range of + hardware used in machine attestation. Typically, this hardware + protects a private key and can generate signed evidence to report + its state. A root of trust often has measurement registers used to + create a tamper-proof log. + + The subsystem supports drivers for devices of this class and provides + uAPIs to get the information out to userspace. + + If you are unsure, say N. diff --git a/drivers/attestation/Makefile b/drivers/attestation/Makefile new file mode 100644 index 00000000000000..3f89f690089e8e --- /dev/null +++ b/drivers/attestation/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 +attestation-y := \ + tsm-mr.o \ + tsm-report.o +obj-$(CONFIG_ATTESTATION) += attestation.o diff --git a/drivers/virt/coco/guest/tsm-mr.c b/drivers/attestation/tsm-mr.c similarity index 100% rename from drivers/virt/coco/guest/tsm-mr.c rename to drivers/attestation/tsm-mr.c diff --git a/drivers/virt/coco/guest/report.c b/drivers/attestation/tsm-report.c similarity index 100% rename from drivers/virt/coco/guest/report.c rename to drivers/attestation/tsm-report.c diff --git a/drivers/virt/coco/Kconfig b/drivers/virt/coco/Kconfig index f7691f64fbe32d..b8960a9e27df61 100644 --- a/drivers/virt/coco/Kconfig +++ b/drivers/virt/coco/Kconfig @@ -13,8 +13,6 @@ source "drivers/virt/coco/sev-guest/Kconfig" source "drivers/virt/coco/tdx-guest/Kconfig" source "drivers/virt/coco/arm-cca-guest/Kconfig" - -source "drivers/virt/coco/guest/Kconfig" endif source "drivers/virt/coco/tdx-host/Kconfig" diff --git a/drivers/virt/coco/Makefile b/drivers/virt/coco/Makefile index b323b0ae4f82da..0dcad65fdc376e 100644 --- a/drivers/virt/coco/Makefile +++ b/drivers/virt/coco/Makefile @@ -9,4 +9,3 @@ obj-$(CONFIG_INTEL_TDX_GUEST) += tdx-guest/ obj-$(CONFIG_INTEL_TDX_HOST) += tdx-host/ obj-$(CONFIG_ARM_CCA_GUEST) += arm-cca-guest/ obj-$(CONFIG_TSM) += tsm-core.o -obj-$(CONFIG_TSM_GUEST) += guest/ diff --git a/drivers/virt/coco/arm-cca-guest/Kconfig b/drivers/virt/coco/arm-cca-guest/Kconfig index 0d4ce72e2d8622..cfd6e3d9730092 100644 --- a/drivers/virt/coco/arm-cca-guest/Kconfig +++ b/drivers/virt/coco/arm-cca-guest/Kconfig @@ -2,7 +2,7 @@ config ARM_CCA_GUEST tristate "Arm CCA Guest driver" depends on ARM_RMM_RSI depends on HAVE_ARM_SMCCC_DISCOVERY - select TSM_REPORTS + depends on ATTESTATION help The driver provides userspace interface to request and attestation report from the Realm Management Monitor(RMM). diff --git a/drivers/virt/coco/guest/Kconfig b/drivers/virt/coco/guest/Kconfig deleted file mode 100644 index da570dc4bd4803..00000000000000 --- a/drivers/virt/coco/guest/Kconfig +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# -# Confidential computing shared guest collateral -# -config TSM_GUEST - bool - -config TSM_REPORTS - select TSM_GUEST - select CONFIGFS_FS - tristate - -config TSM_MEASUREMENTS - select TSM_GUEST - select CRYPTO_HASH_INFO - bool diff --git a/drivers/virt/coco/guest/Makefile b/drivers/virt/coco/guest/Makefile deleted file mode 100644 index 9ec4860bd213ae..00000000000000 --- a/drivers/virt/coco/guest/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_TSM_REPORTS) += tsm_report.o -tsm_report-y := report.o -obj-$(CONFIG_TSM_MEASUREMENTS) += tsm-mr.o diff --git a/drivers/virt/coco/sev-guest/Kconfig b/drivers/virt/coco/sev-guest/Kconfig index a6405ab6c2c37c..f615fc9409c86f 100644 --- a/drivers/virt/coco/sev-guest/Kconfig +++ b/drivers/virt/coco/sev-guest/Kconfig @@ -2,7 +2,7 @@ config SEV_GUEST tristate "AMD SEV Guest driver" default m depends on AMD_MEM_ENCRYPT - select TSM_REPORTS + depends on ATTESTATION help SEV-SNP firmware provides the guest a mechanism to communicate with the PSP without risk from a malicious hypervisor who wishes to read, diff --git a/drivers/virt/coco/tdx-guest/Kconfig b/drivers/virt/coco/tdx-guest/Kconfig index dbbdc14383b132..bfb7e6787ffc88 100644 --- a/drivers/virt/coco/tdx-guest/Kconfig +++ b/drivers/virt/coco/tdx-guest/Kconfig @@ -1,8 +1,7 @@ config TDX_GUEST_DRIVER tristate "TDX Guest driver" depends on INTEL_TDX_GUEST - select TSM_REPORTS - select TSM_MEASUREMENTS + depends on ATTESTATION help The driver provides userspace interface to communicate with the TDX module to request the TDX guest details like attestation diff --git a/samples/Kconfig b/samples/Kconfig index 00eed83c07dfcb..c4a6b6a7b2b427 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -195,10 +195,9 @@ config SAMPLE_TIMER config SAMPLE_TSM_MR tristate "TSM measurement sample" + depends on ATTESTATION select CRYPTO_LIB_SHA256 select CRYPTO_LIB_SHA512 - select TSM_MEASUREMENTS - select VIRT_DRIVERS help Build a sample module that emulates MRs (Measurement Registers) and exposes them to user mode applications through the TSM sysfs -- 2.43.0