Skip to contentSkip to conversation

Start building drivers/attestation

PATCH New Jason Gunthorpe 2 participants 6 messages Dec 1

Subsystems (7)
Documentation x86 KVM Kselftest +3 more subsystems
lore
Share & tools
lore

Jason Gunthorpe

author maintainer
#0 lore raw

cover Start building drivers/attestation

Move tsm_report and tsm_mr, along with all their drivers, into drivers/attestation. There are no functional changes, but some modules are renamed to consistent attestation_* names.

This largely just moves drivers/virt/coco/* stuff to drivers/attestation and makes some adjustments to have per-arch subdirectories to hold all the stuff. virt/coco was OK when this was only going to be used inside confidential VMs, but with the new coming needs for bare metal and host support under the same umbrella it isn't a good place to build an entire subsystem.

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.

The existing drivers are all for the ROTs integrated into confidential VMs. AMD, Intel and ARM each have an attestation ROT linked to their respective implementations.

A following set of drivers, like ARM FIRME, will start to bring in non-TPM ROTs on bare metal systems. The kernel SPDM implementation will also live here and use the upcoming enhanced uAPI.

Eventually we hope to provide a kernel multiplexer so that in-kernel users, like IMA, can access any attestation measurement register instead of being hardwired to use only the TPM.

Several reorganization and cleanup passes will be needed after this to turn it into a well-formed subsystem.

Jason Gunthorpe (4):
attestation: Start the new subsystem using tsm_report and mr
attestation: Move the ARM Realm Token tsm_report driver
attestation: Move Intel TDX Guest tsm_report and mr driver
attestation: Move AMD SEV Guest tsm_report driver

 .../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                                   |  5 ++-
 arch/x86/coco/tdx/tdx.c                       |  8 ++---
 drivers/Kconfig                               |  2 ++
 drivers/Makefile                              |  2 ++
 drivers/attestation/Kconfig                   | 23 ++++++++++++
 drivers/attestation/Makefile                  |  9 +++++
 drivers/attestation/amd/Kconfig               | 15 ++++++++
 drivers/attestation/amd/Makefile              |  4 +++
 .../sev-guest => attestation/amd}/sev-guest.c |  2 +-
 drivers/attestation/arm/Kconfig               | 12 +++++++
 drivers/attestation/arm/Makefile              |  4 +++
 .../main.c => attestation/arm/cca-guest.c}    |  2 +-
 drivers/attestation/intel/Kconfig             | 13 +++++++
 drivers/attestation/intel/Makefile            |  4 +++
 .../intel}/tdx-guest.c                        |  4 +--
 .../{virt/coco/guest => attestation}/tsm-mr.c |  0
 .../report.c => attestation/tsm-report.c}     |  0
 drivers/virt/coco/Kconfig                     |  8 -----
 drivers/virt/coco/Makefile                    |  4 ---
 drivers/virt/coco/arm-cca-guest/Kconfig       | 11 ------
 drivers/virt/coco/arm-cca-guest/Makefile      |  4 ---
 drivers/virt/coco/guest/Kconfig               | 16 ---------
 drivers/virt/coco/guest/Makefile              |  4 ---
 drivers/virt/coco/sev-guest/Kconfig           | 13 -------
 drivers/virt/coco/sev-guest/Makefile          |  2 --
 drivers/virt/coco/tdx-guest/Kconfig           | 12 -------
 drivers/virt/coco/tdx-guest/Makefile          |  2 --
 samples/Kconfig                               |  3 +-
 tools/testing/selftests/tdx/config            |  2 +-
 34 files changed, 138 insertions(+), 114 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
 create mode 100644 drivers/attestation/amd/Kconfig
 create mode 100644 drivers/attestation/amd/Makefile
 rename drivers/{virt/coco/sev-guest => attestation/amd}/sev-guest.c (99%)
 create mode 100644 drivers/attestation/arm/Kconfig
 create mode 100644 drivers/attestation/arm/Makefile
 rename drivers/{virt/coco/arm-cca-guest/main.c => attestation/arm/cca-guest.c} (99%)
 create mode 100644 drivers/attestation/intel/Kconfig
 create mode 100644 drivers/attestation/intel/Makefile
 rename drivers/{virt/coco/tdx-guest => attestation/intel}/tdx-guest.c (99%)
 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/arm-cca-guest/Kconfig
 delete mode 100644 drivers/virt/coco/arm-cca-guest/Makefile
 delete mode 100644 drivers/virt/coco/guest/Kconfig
 delete mode 100644 drivers/virt/coco/guest/Makefile
 delete mode 100644 drivers/virt/coco/sev-guest/Kconfig
 delete mode 100644 drivers/virt/coco/sev-guest/Makefile
 delete mode 100644 drivers/virt/coco/tdx-guest/Kconfig
 delete mode 100644 drivers/virt/coco/tdx-guest/Makefile

base-commit: 08b2d931027c237d749c934bcad406a79818123b

Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH 1/4 attestation: Start the new subsystem using tsm_report and mr

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

---
 .../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
Documentation/ABI/testing/sysfs-devices-virtual-misc-tdx_guest +1 -1
index 8fca56c8c9dfe6..44f7e82cc316f5 100644
@@ -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
Documentation/driver-api/attestation.rst new file +36 -0
new file mode 100644
index 00000000000000..15092bea90f770
@@ -0,0 +1,36 @@
+.. SPDX-License-Identifier: GPL-2.0
+.. include:: <isonum.txt>
+
+=====================
+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:
Documentation/driver-api/coco/index.rst deleted +0 -10
deleted file mode 100644
index 783c8b033547ef..00000000000000
@@ -1,10 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0
-
-======================
-Confidential Computing
-======================
-
-.. toctree::
-   :maxdepth: 1
-
-   measurement-registers
Documentation/driver-api/coco/measurement-registers.rst deleted +0 -12
deleted file mode 100644
index 962a44efa2c027..00000000000000
@@ -1,12 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0
-.. include:: <isonum.txt>
-
-=====================
-Measurement Registers
-=====================
-
-.. kernel-doc:: include/linux/tsm-mr.h
-   :internal:
-
-.. kernel-doc:: drivers/virt/coco/guest/tsm-mr.c
-   :export:
Documentation/driver-api/index.rst +1 -1
index aaf5d76ed074ed..3f32af5ac8b91f 100644
@@ -80,9 +80,9 @@ Subsystem-specific APIs
 
    80211/index
    acpi/index
+   attestation
    backlight/lp855x-driver.rst
    clk
-   coco/index
    console
    crypto/index
    dmaengine/index
MAINTAINERS +2 -2
index e8059b3d7e6efb..841e21afde3d82 100644
@@ -28543,12 +28543,12 @@ L:	[email protected]
 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/
drivers/Kconfig +2 -0
index f2bed2ddeb6628..53b21efd02f649 100644
@@ -143,6 +143,8 @@ source "drivers/uio/Kconfig"
 
 source "drivers/vfio/Kconfig"
 
+source "drivers/attestation/Kconfig"
+
 source "drivers/virt/Kconfig"
 
 source "drivers/virtio/Kconfig"
drivers/Makefile +2 -0
index 0841ea851847e8..4b471559773114 100644
@@ -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/
drivers/attestation/Kconfig new file +17 -0
new file mode 100644
index 00000000000000..86672fa9477b20
@@ -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.
drivers/attestation/Makefile new file +5 -0
new file mode 100644
index 00000000000000..3f89f690089e8e
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+attestation-y := \
+	tsm-mr.o \
+	tsm-report.o
+obj-$(CONFIG_ATTESTATION) += attestation.o
drivers/attestation/tsm-mr.c renamed from drivers/virt/coco/guest/tsm-mr.c +0 -0
similarity index 100%
rename from drivers/virt/coco/guest/tsm-mr.c
rename to drivers/attestation/tsm-mr.c
drivers/attestation/tsm-report.c renamed from drivers/virt/coco/guest/report.c +0 -0
similarity index 100%
rename from drivers/virt/coco/guest/report.c
rename to drivers/attestation/tsm-report.c
drivers/virt/coco/Kconfig +0 -2
index f7691f64fbe32d..b8960a9e27df61 100644
@@ -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"
drivers/virt/coco/Makefile +0 -1
index b323b0ae4f82da..0dcad65fdc376e 100644
@@ -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/
drivers/virt/coco/arm-cca-guest/Kconfig +1 -1
index 0d4ce72e2d8622..cfd6e3d9730092 100644
@@ -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).
drivers/virt/coco/guest/Kconfig deleted +0 -16
deleted file mode 100644
index da570dc4bd4803..00000000000000
@@ -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
drivers/virt/coco/guest/Makefile deleted +0 -4
deleted file mode 100644
index 9ec4860bd213ae..00000000000000
@@ -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
drivers/virt/coco/sev-guest/Kconfig +1 -1
index a6405ab6c2c37c..f615fc9409c86f 100644
@@ -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,
drivers/virt/coco/tdx-guest/Kconfig +1 -2
index dbbdc14383b132..bfb7e6787ffc88 100644
@@ -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
samples/Kconfig +1 -2
index 00eed83c07dfcb..c4a6b6a7b2b427 100644
@@ -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
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH 2/4 attestation: Move the ARM Realm Token tsm_report driver

In reply to Jason Gunthorpe

drivers/virt/coco/arm-cca-guest/main.c is a bit broadly named, but it is the driver for the Root of Trust inside the RMM, which the guest accesses only through RSI calls.

This is commonly called the "Realm Token". It also has 4 measurement registers, but there is no driver for them in Linux yet.

Move it into drivers/attestation/arm/cca-guest.c.

The simple rename takes the arm_smccc_driver for SMC_RSI_ABI_VERSION along with it. This isn't going to work long term, but Yeoreum has some good ideas on how to split multi-function SMCCC interfaces into subsystem-specific drivers that will solve this.

---
 MAINTAINERS                                          |  1 -
 drivers/attestation/Kconfig                          |  4 ++++
 drivers/attestation/Makefile                         |  2 ++
 drivers/attestation/arm/Kconfig                      | 12 ++++++++++++
 drivers/attestation/arm/Makefile                     |  4 ++++
 .../main.c => attestation/arm/cca-guest.c}           |  2 +-
 drivers/virt/coco/Kconfig                            |  2 --
 drivers/virt/coco/Makefile                           |  1 -
 drivers/virt/coco/arm-cca-guest/Kconfig              | 11 -----------
 drivers/virt/coco/arm-cca-guest/Makefile             |  4 ----
 10 files changed, 23 insertions(+), 20 deletions(-)
 create mode 100644 drivers/attestation/arm/Kconfig
 create mode 100644 drivers/attestation/arm/Makefile
 rename drivers/{virt/coco/arm-cca-guest/main.c => attestation/arm/cca-guest.c} (99%)
 delete mode 100644 drivers/virt/coco/arm-cca-guest/Kconfig
 delete mode 100644 drivers/virt/coco/arm-cca-guest/Makefile
MAINTAINERS +0 -1
index 841e21afde3d82..e1bffcecea65cd 100644
@@ -4041,7 +4041,6 @@ F:	Documentation/ABI/testing/sysfs-firmware-cca
 F:	Documentation/arch/arm64/
 F:	arch/arm64/
 F:	drivers/firmware/arm_rmm/
-F:	drivers/virt/coco/arm-cca-guest/
 F:	drivers/virt/coco/pkvm-guest/
 F:	include/linux/arm-rmi-cmds.h
 F:	include/linux/arm-rsi-cmds.h
drivers/attestation/Kconfig +4 -0
index 86672fa9477b20..c71b6e1e5a501e 100644
@@ -15,3 +15,7 @@ menuconfig ATTESTATION
 	  uAPIs to get the information out to userspace.
 
 	  If you are unsure, say N.
+
+if ATTESTATION
+source "drivers/attestation/arm/Kconfig"
+endif # ATTESTATION
drivers/attestation/Makefile +2 -0
index 3f89f690089e8e..c48d12d31c6579 100644
@@ -3,3 +3,5 @@ attestation-y := \
 	tsm-mr.o \
 	tsm-report.o
 obj-$(CONFIG_ATTESTATION) += attestation.o
+
+obj-$(CONFIG_ATTESTATION_ARM_CCA_GUEST) += arm/
drivers/attestation/arm/Kconfig new file +12 -0
new file mode 100644
index 00000000000000..8c54374930b751
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config ATTESTATION_ARM_CCA_GUEST
+	tristate "Arm CCA Realm Token Attestation Driver"
+	depends on ARM_RMM_RSI
+	depends on HAVE_ARM_SMCCC_DISCOVERY
+	help
+	  Driver for the Realm Token provided by the Root of Trust inside
+	  the Realm Management Monitor (RMM) through an RSI.
+
+	  Reports are available in user-created directories under
+	  /sys/kernel/config/tsm/report/ with provider "arm_cca_guest".
+	  This driver does not expose TSM measurement registers.
drivers/attestation/arm/Makefile new file +4 -0
new file mode 100644
index 00000000000000..cf39145ac103f1
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+attestation_arm_cca_guest-y := cca-guest.o
+
+obj-$(CONFIG_ATTESTATION_ARM_CCA_GUEST) += attestation_arm_cca_guest.o
drivers/attestation/arm/cca-guest.c renamed from drivers/virt/coco/arm-cca-guest/main.c +1 -1
similarity index 99%
rename from drivers/virt/coco/arm-cca-guest/main.c
rename to drivers/attestation/arm/cca-guest.c
index f97f593da6e3d3..dfebaf36d05cea 100644
@@ -158,7 +158,7 @@ static int arm_cca_report_new(struct tsm_report *report, void *data)
 }
 
 static const struct tsm_report_ops arm_cca_tsm_report_ops = {
-	.name = KBUILD_MODNAME,
+	.name = "arm_cca_guest",
 	.report_new = arm_cca_report_new,
 };
 
drivers/virt/coco/Kconfig +0 -2
index b8960a9e27df61..cc5fa179f2e850 100644
@@ -11,8 +11,6 @@ source "drivers/virt/coco/pkvm-guest/Kconfig"
 source "drivers/virt/coco/sev-guest/Kconfig"
 
 source "drivers/virt/coco/tdx-guest/Kconfig"
-
-source "drivers/virt/coco/arm-cca-guest/Kconfig"
 endif
 
 source "drivers/virt/coco/tdx-host/Kconfig"
drivers/virt/coco/Makefile +0 -1
index 0dcad65fdc376e..acda2e49d5e173 100644
@@ -7,5 +7,4 @@ obj-$(CONFIG_ARM_PKVM_GUEST)	+= pkvm-guest/
 obj-$(CONFIG_SEV_GUEST)		+= sev-guest/
 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
drivers/virt/coco/arm-cca-guest/Kconfig deleted +0 -11
deleted file mode 100644
index cfd6e3d9730092..00000000000000
@@ -1,11 +0,0 @@
-config ARM_CCA_GUEST
-	tristate "Arm CCA Guest driver"
-	depends on ARM_RMM_RSI
-	depends on HAVE_ARM_SMCCC_DISCOVERY
-	depends on ATTESTATION
-	help
-	  The driver provides userspace interface to request and
-	  attestation report from the Realm Management Monitor(RMM).
-
-	  If you choose 'M' here, this module will be called
-	  arm-cca-guest.
drivers/virt/coco/arm-cca-guest/Makefile deleted +0 -4
deleted file mode 100644
index 7564f4fcc4a41a..00000000000000
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_ARM_CCA_GUEST) += arm-cca-guest.o
-
-arm-cca-guest-y += main.o
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH 3/4 attestation: Move Intel TDX Guest tsm_report and mr driver

In reply to Jason Gunthorpe

tdx-guest.c is the driver for the Root of Trust inside the TDX module accessed by the guest.

The Intel TDX spec supports two token formats and 4 measurement registers.

Move it into drivers/attestation/intel/tdx-guest.c.

Module autoloading continues to be triggered by the x86_cpu_id match mechanism.

---
 arch/x86/coco/tdx/tdx.c                             |  8 ++++----
 drivers/attestation/Kconfig                         |  1 +
 drivers/attestation/Makefile                        |  1 +
 drivers/attestation/intel/Kconfig                   | 13 +++++++++++++
 drivers/attestation/intel/Makefile                  |  4 ++++
 .../tdx-guest => attestation/intel}/tdx-guest.c     |  4 ++--
 drivers/virt/coco/Kconfig                           |  2 --
 drivers/virt/coco/Makefile                          |  1 -
 drivers/virt/coco/tdx-guest/Kconfig                 | 11 -----------
 drivers/virt/coco/tdx-guest/Makefile                |  2 --
 tools/testing/selftests/tdx/config                  |  2 +-
 11 files changed, 26 insertions(+), 23 deletions(-)
 create mode 100644 drivers/attestation/intel/Kconfig
 create mode 100644 drivers/attestation/intel/Makefile
 rename drivers/{virt/coco/tdx-guest => attestation/intel}/tdx-guest.c (99%)
 delete mode 100644 drivers/virt/coco/tdx-guest/Kconfig
 delete mode 100644 drivers/virt/coco/tdx-guest/Makefile
arch/x86/coco/tdx/tdx.c +4 -4
index 8bacbef62891fd..55124b201b3c1a 100644
@@ -139,7 +139,7 @@ int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport)
 
 	return 0;
 }
-EXPORT_SYMBOL_FOR_MODULES(tdx_mcall_get_report0, "tdx-guest");
+EXPORT_SYMBOL_FOR_MODULES(tdx_mcall_get_report0, "attestation_intel_tdx_guest");
 
 /**
  * tdx_mcall_extend_rtmr() - Wrapper to extend RTMR registers using
@@ -175,7 +175,7 @@ int tdx_mcall_extend_rtmr(u8 index, u8 *data)
 
 	return 0;
 }
-EXPORT_SYMBOL_FOR_MODULES(tdx_mcall_extend_rtmr, "tdx-guest");
+EXPORT_SYMBOL_FOR_MODULES(tdx_mcall_extend_rtmr, "attestation_intel_tdx_guest");
 
 /**
  * tdx_hcall_get_quote() - Wrapper to request TD Quote using GetQuote
@@ -196,7 +196,7 @@ u64 tdx_hcall_get_quote(void *buf, size_t size)
 	/* Since buf is a shared memory, set the shared (decrypted) bits */
 	return _tdx_hypercall(TDVMCALL_GET_QUOTE, cc_mkdec(virt_to_phys(buf)), size, 0, 0);
 }
-EXPORT_SYMBOL_FOR_MODULES(tdx_hcall_get_quote, "tdx-guest");
+EXPORT_SYMBOL_FOR_MODULES(tdx_hcall_get_quote, "attestation_intel_tdx_guest");
 
 /*
  * Ask the TDX module what the largest Quote on the host platform might be.
@@ -213,7 +213,7 @@ int tdx_get_max_quote_size(u64 *max_quote_size)
 
 	return 0;
 }
-EXPORT_SYMBOL_FOR_MODULES(tdx_get_max_quote_size, "tdx-guest");
+EXPORT_SYMBOL_FOR_MODULES(tdx_get_max_quote_size, "attestation_intel_tdx_guest");
 
 /*
  * The kernel cannot handle #VEs when accessing normal kernel memory. Ensure
drivers/attestation/Kconfig +1 -0
index c71b6e1e5a501e..d632503a55f85a 100644
@@ -18,4 +18,5 @@ menuconfig ATTESTATION
 
 if ATTESTATION
 source "drivers/attestation/arm/Kconfig"
+source "drivers/attestation/intel/Kconfig"
 endif # ATTESTATION
drivers/attestation/Makefile +1 -0
index c48d12d31c6579..e12162cb55e30b 100644
@@ -5,3 +5,4 @@ attestation-y := \
 obj-$(CONFIG_ATTESTATION) += attestation.o
 
 obj-$(CONFIG_ATTESTATION_ARM_CCA_GUEST) += arm/
+obj-$(CONFIG_ATTESTATION_INTEL_TDX_GUEST) += intel/
drivers/attestation/intel/Kconfig new file +13 -0
new file mode 100644
index 00000000000000..18a6a2b87e9188
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config ATTESTATION_INTEL_TDX_GUEST
+	tristate "Intel TDX Guest Attestation Driver"
+	depends on INTEL_TDX_GUEST
+	help
+	  Driver for the TDX guest signed quote from the Root of Trust inside
+	  the TDX module for confidential VMs. The quote includes 4 measurement
+	  registers.
+
+	  Reports are available in user-created directories under
+	  /sys/kernel/config/tsm/report/ with provider "tdx_guest".
+	  Measurement registers are exposed under
+	  /sys/devices/virtual/misc/tdx_guest/measurements/.
drivers/attestation/intel/Makefile new file +4 -0
new file mode 100644
index 00000000000000..43ba77b6bfa012
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+attestation_intel_tdx_guest-y := tdx-guest.o
+
+obj-$(CONFIG_ATTESTATION_INTEL_TDX_GUEST) += attestation_intel_tdx_guest.o
drivers/attestation/intel/tdx-guest.c renamed from drivers/virt/coco/tdx-guest/tdx-guest.c +2 -2
similarity index 99%
rename from drivers/virt/coco/tdx-guest/tdx-guest.c
rename to drivers/attestation/intel/tdx-guest.c
index 11d741da3b35f5..1ccc81f507141e 100644
@@ -403,7 +403,7 @@ static const struct attribute_group *tdx_attr_groups[] = {
 };
 
 static struct miscdevice tdx_misc_dev = {
-	.name = KBUILD_MODNAME,
+	.name = "tdx_guest",
 	.minor = MISC_DYNAMIC_MINOR,
 	.fops = &tdx_guest_fops,
 	.groups = tdx_attr_groups,
@@ -416,7 +416,7 @@ static const struct x86_cpu_id tdx_guest_ids[] = {
 MODULE_DEVICE_TABLE(x86cpu, tdx_guest_ids);
 
 static const struct tsm_report_ops tdx_tsm_ops = {
-	.name = KBUILD_MODNAME,
+	.name = "tdx_guest",
 	.report_new = tdx_report_new,
 	.report_attr_visible = tdx_report_attr_visible,
 	.report_bin_attr_visible = tdx_report_bin_attr_visible,
drivers/virt/coco/Kconfig +0 -2
index cc5fa179f2e850..5329f82c2b1e6d 100644
@@ -9,8 +9,6 @@ source "drivers/virt/coco/efi_secret/Kconfig"
 source "drivers/virt/coco/pkvm-guest/Kconfig"
 
 source "drivers/virt/coco/sev-guest/Kconfig"
-
-source "drivers/virt/coco/tdx-guest/Kconfig"
 endif
 
 source "drivers/virt/coco/tdx-host/Kconfig"
drivers/virt/coco/Makefile +0 -1
index acda2e49d5e173..ea4e27a5ce5040 100644
@@ -5,6 +5,5 @@
 obj-$(CONFIG_EFI_SECRET)	+= efi_secret/
 obj-$(CONFIG_ARM_PKVM_GUEST)	+= pkvm-guest/
 obj-$(CONFIG_SEV_GUEST)		+= sev-guest/
-obj-$(CONFIG_INTEL_TDX_GUEST)	+= tdx-guest/
 obj-$(CONFIG_INTEL_TDX_HOST)	+= tdx-host/
 obj-$(CONFIG_TSM) 		+= tsm-core.o
drivers/virt/coco/tdx-guest/Kconfig deleted +0 -11
deleted file mode 100644
index bfb7e6787ffc88..00000000000000
@@ -1,11 +0,0 @@
-config TDX_GUEST_DRIVER
-	tristate "TDX Guest driver"
-	depends on INTEL_TDX_GUEST
-	depends on ATTESTATION
-	help
-	  The driver provides userspace interface to communicate with
-	  the TDX module to request the TDX guest details like attestation
-	  report.
-
-	  To compile this driver as module, choose M here. The module will
-	  be called tdx-guest.
drivers/virt/coco/tdx-guest/Makefile deleted +0 -2
deleted file mode 100644
index 775cb463f9c876..00000000000000
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_TDX_GUEST_DRIVER) += tdx-guest.o
tools/testing/selftests/tdx/config +1 -1
index aa1edc829ab679..c5382d0cbcbad1 100644
@@ -1 +1 @@
-CONFIG_TDX_GUEST_DRIVER=y
+CONFIG_ATTESTATION_INTEL_TDX_GUEST=y
Signature · 1 line
2.43.0
author maintainer
#4 lore raw

PATCH 4/4 attestation: Move AMD SEV Guest tsm_report driver

In reply to Jason Gunthorpe

sev-guest.c is the driver for the Root of Trust inside the PSP accessed by confidential VMs.

It supports a direct access path and one that first goes through the Secure VM Service Module (SVSM) running at VM Privilege Level 0 (VMPL0). This allows the SVSM to mix its own data into the challenge, for instance to bind the vTPM's EK. It also supports both a new and an old report format.

Move it into drivers/attestation/amd/sev-guest.c.

Module autoloading still uses the platform_driver created by the arch code.

---
 drivers/attestation/Kconfig                       |  1 +
 drivers/attestation/Makefile                      |  1 +
 drivers/attestation/amd/Kconfig                   | 15 +++++++++++++++
 drivers/attestation/amd/Makefile                  |  4 ++++
 .../sev-guest => attestation/amd}/sev-guest.c     |  2 +-
 drivers/virt/coco/Kconfig                         |  2 --
 drivers/virt/coco/Makefile                        |  1 -
 drivers/virt/coco/sev-guest/Kconfig               | 13 -------------
 drivers/virt/coco/sev-guest/Makefile              |  2 --
 9 files changed, 22 insertions(+), 19 deletions(-)
 create mode 100644 drivers/attestation/amd/Kconfig
 create mode 100644 drivers/attestation/amd/Makefile
 rename drivers/{virt/coco/sev-guest => attestation/amd}/sev-guest.c (99%)
 delete mode 100644 drivers/virt/coco/sev-guest/Kconfig
 delete mode 100644 drivers/virt/coco/sev-guest/Makefile
drivers/attestation/Kconfig +1 -0
index d632503a55f85a..4312acc27fc47d 100644
@@ -17,6 +17,7 @@ menuconfig ATTESTATION
 	  If you are unsure, say N.
 
 if ATTESTATION
+source "drivers/attestation/amd/Kconfig"
 source "drivers/attestation/arm/Kconfig"
 source "drivers/attestation/intel/Kconfig"
 endif # ATTESTATION
drivers/attestation/Makefile +1 -0
index e12162cb55e30b..2c98a03013f983 100644
@@ -4,5 +4,6 @@ attestation-y := \
 	tsm-report.o
 obj-$(CONFIG_ATTESTATION) += attestation.o
 
+obj-$(CONFIG_ATTESTATION_AMD_SEV_GUEST) += amd/
 obj-$(CONFIG_ATTESTATION_ARM_CCA_GUEST) += arm/
 obj-$(CONFIG_ATTESTATION_INTEL_TDX_GUEST) += intel/
drivers/attestation/amd/Kconfig new file +15 -0
new file mode 100644
index 00000000000000..c3203d2f184f0c
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config ATTESTATION_AMD_SEV_GUEST
+	tristate "AMD SEV Guest Attestation Driver"
+	depends on AMD_MEM_ENCRYPT
+	help
+	  Driver for the SEV-SNP firmware to access the root of trust in the PSP
+	  for confidential VMs. This provides at least two kinds of signed
+	  reports using a GUID scheme to select them. There are no measurement
+	  registers.
+
+	  Reports are available in user-created directories under
+	  /sys/kernel/config/tsm/report/ with provider "sev_guest".
+
+	  The /dev/sev-guest misc device also provides report and derived-key
+	  ioctls. SVSM service reports and manifests use the TSM interface.
drivers/attestation/amd/Makefile new file +4 -0
new file mode 100644
index 00000000000000..2d2f5ca188813b
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+attestation_amd_sev_guest-y := sev-guest.o
+
+obj-$(CONFIG_ATTESTATION_AMD_SEV_GUEST) += attestation_amd_sev_guest.o
drivers/attestation/amd/sev-guest.c renamed from drivers/virt/coco/sev-guest/sev-guest.c +1 -1
similarity index 99%
rename from drivers/virt/coco/sev-guest/sev-guest.c
rename to drivers/attestation/amd/sev-guest.c
index 5fade6cc135727..2a32b5bbf198f7 100644
@@ -612,7 +612,7 @@ static bool sev_report_bin_attr_visible(int n)
 }
 
 static struct tsm_report_ops sev_tsm_report_ops = {
-	.name = KBUILD_MODNAME,
+	.name = "sev_guest",
 	.report_new = sev_report_new,
 	.report_attr_visible = sev_report_attr_visible,
 	.report_bin_attr_visible = sev_report_bin_attr_visible,
drivers/virt/coco/Kconfig +0 -2
index 5329f82c2b1e6d..bd226c6ddb3fde 100644
@@ -7,8 +7,6 @@ if VIRT_DRIVERS
 source "drivers/virt/coco/efi_secret/Kconfig"
 
 source "drivers/virt/coco/pkvm-guest/Kconfig"
-
-source "drivers/virt/coco/sev-guest/Kconfig"
 endif
 
 source "drivers/virt/coco/tdx-host/Kconfig"
drivers/virt/coco/Makefile +0 -1
index ea4e27a5ce5040..dee8fb922755f5 100644
@@ -4,6 +4,5 @@
 #
 obj-$(CONFIG_EFI_SECRET)	+= efi_secret/
 obj-$(CONFIG_ARM_PKVM_GUEST)	+= pkvm-guest/
-obj-$(CONFIG_SEV_GUEST)		+= sev-guest/
 obj-$(CONFIG_INTEL_TDX_HOST)	+= tdx-host/
 obj-$(CONFIG_TSM) 		+= tsm-core.o
drivers/virt/coco/sev-guest/Kconfig deleted +0 -13
deleted file mode 100644
index f615fc9409c86f..00000000000000
@@ -1,13 +0,0 @@
-config SEV_GUEST
-	tristate "AMD SEV Guest driver"
-	default m
-	depends on AMD_MEM_ENCRYPT
-	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,
-	  alter, drop or replay the messages sent. The driver provides
-	  userspace interface to communicate with the PSP to request the
-	  attestation report and more.
-
-	  If you choose 'M' here, this module will be called sev-guest.
drivers/virt/coco/sev-guest/Makefile deleted +0 -2
deleted file mode 100644
index 63d67c27723a60..00000000000000
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_SEV_GUEST) += sev-guest.o
Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH tsm 4/4] attestation: Move AMD SEV Guest tsm_report driver

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] attestation: sev-guest module rename breaks vmpck_id module parameter ABI - [Low] attestation…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] attestation: sev-guest module rename breaks vmpck_id module parameter ABI
- [Low] attestation: CONFIG_ATTESTATION_AMD_SEV_GUEST drops default m from SEV_GUEST
--

commit ca861c491d1af0016726a054ada60dd92452cdc8
Author: Jason Gunthorpe <[email protected]>

attestation: Move AMD SEV Guest tsm_report driver

This commit moves the AMD SEV guest driver from drivers/virt/coco/sev-guest/ to drivers/attestation/amd/ under the new CONFIG_ATTESTATION_AMD_SEV_GUEST option.

drivers/attestation/amd/Kconfig line 4

Quoted 10 lines
drivers/attestation/amd/Kconfig new file +4 -0
new file mode 100644
index 0000000000000..c3203d2f184f0
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config ATTESTATION_AMD_SEV_GUEST
+	tristate "AMD SEV Guest Attestation Driver"
+	depends on AMD_MEM_ENCRYPT

[Severity: Low]
Should ATTESTATION_AMD_SEV_GUEST preserve the "default m" that SEV_GUEST had? Without it, existing configs with AMD_MEM_ENCRYPT and ATTESTATION enabled will disable the SEV guest driver by default on olddefconfig.

[ ... ]

drivers/attestation/amd/Makefile line 4

Quoted 10 lines
drivers/attestation/amd/Makefile new file +4 -0
new file mode 100644
index 0000000000000..2d2f5ca188813
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+attestation_amd_sev_guest-y := sev-guest.o
+
+obj-$(CONFIG_ATTESTATION_AMD_SEV_GUEST) += attestation_amd_sev_guest.o

[Severity: Medium]
Does renaming the module from sev-guest to attestation_amd_sev_guest break the vmpck_id module parameter and module reloading?

sev-guest.c defines module_param(vmpck_id, int, 0444), and Documentation/virt/coco/sev-guest.rst tells users to recover from a wiped VMPCK by reloading the sev-guest driver with vmpck_id. Changing KBUILD_MODNAME without MODULE_PARAM_PREFIX or MODULE_ALIAS("sev-guest") moves the parameter from sev_guest.vmpck_id and /sys/module/sev_guest/parameters/vmpck_id to attestation_amd_sev_guest.vmpck_id and breaks "modprobe sev-guest".

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4