Start building drivers/attestation
Subsystems (7)
Jason Gunthorpe
maintainercover 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/Makefilebase-commit: 08b2d931027c237d749c934bcad406a79818123b
Signature · 1 line
2.43.0
Jason Gunthorpe
maintainerPATCH 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/MakefileDocumentation/ABI/testing/sysfs-devices-virtual-misc-tdx_guest +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
drivers/attestation/tsm-report.c renamed from drivers/virt/coco/guest/report.c +0 -0
drivers/virt/coco/Kconfig +0 -2
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Jason Gunthorpe
maintainerPATCH 2/4 attestation: Move the ARM Realm Token tsm_report driver
In reply to Jason Gunthorpedrivers/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/MakefileMAINTAINERS +0 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Jason Gunthorpe
maintainerPATCH 3/4 attestation: Move Intel TDX Guest tsm_report and mr driver
In reply to Jason Gunthorpetdx-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/Makefilearch/x86/coco/tdx/tdx.c +4 -4
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1 +1 @@ -CONFIG_TDX_GUEST_DRIVER=y +CONFIG_ATTESTATION_INTEL_TDX_GUEST=y
Signature · 1 line
2.43.0
Jason Gunthorpe
maintainerPATCH 4/4 attestation: Move AMD SEV Guest tsm_report driver
In reply to Jason Gunthorpesev-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/Makefiledrivers/attestation/Kconfig +1 -0
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_SEV_GUEST) += sev-guest.o
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [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@@ -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@@ -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