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. Signed-off-by: Jason Gunthorpe --- 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 diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index 8bacbef62891fd..55124b201b3c1a 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -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 diff --git a/drivers/attestation/Kconfig b/drivers/attestation/Kconfig index c71b6e1e5a501e..d632503a55f85a 100644 --- a/drivers/attestation/Kconfig +++ b/drivers/attestation/Kconfig @@ -18,4 +18,5 @@ menuconfig ATTESTATION if ATTESTATION source "drivers/attestation/arm/Kconfig" +source "drivers/attestation/intel/Kconfig" endif # ATTESTATION diff --git a/drivers/attestation/Makefile b/drivers/attestation/Makefile index c48d12d31c6579..e12162cb55e30b 100644 --- a/drivers/attestation/Makefile +++ b/drivers/attestation/Makefile @@ -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/ diff --git a/drivers/attestation/intel/Kconfig b/drivers/attestation/intel/Kconfig new file mode 100644 index 00000000000000..18a6a2b87e9188 --- /dev/null +++ b/drivers/attestation/intel/Kconfig @@ -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/. diff --git a/drivers/attestation/intel/Makefile b/drivers/attestation/intel/Makefile new file mode 100644 index 00000000000000..43ba77b6bfa012 --- /dev/null +++ b/drivers/attestation/intel/Makefile @@ -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 diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/attestation/intel/tdx-guest.c 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 --- a/drivers/virt/coco/tdx-guest/tdx-guest.c +++ b/drivers/attestation/intel/tdx-guest.c @@ -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, diff --git a/drivers/virt/coco/Kconfig b/drivers/virt/coco/Kconfig index cc5fa179f2e850..5329f82c2b1e6d 100644 --- a/drivers/virt/coco/Kconfig +++ b/drivers/virt/coco/Kconfig @@ -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" diff --git a/drivers/virt/coco/Makefile b/drivers/virt/coco/Makefile index acda2e49d5e173..ea4e27a5ce5040 100644 --- a/drivers/virt/coco/Makefile +++ b/drivers/virt/coco/Makefile @@ -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 diff --git a/drivers/virt/coco/tdx-guest/Kconfig b/drivers/virt/coco/tdx-guest/Kconfig deleted file mode 100644 index bfb7e6787ffc88..00000000000000 --- a/drivers/virt/coco/tdx-guest/Kconfig +++ /dev/null @@ -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. diff --git a/drivers/virt/coco/tdx-guest/Makefile b/drivers/virt/coco/tdx-guest/Makefile deleted file mode 100644 index 775cb463f9c876..00000000000000 --- a/drivers/virt/coco/tdx-guest/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_TDX_GUEST_DRIVER) += tdx-guest.o diff --git a/tools/testing/selftests/tdx/config b/tools/testing/selftests/tdx/config index aa1edc829ab679..c5382d0cbcbad1 100644 --- a/tools/testing/selftests/tdx/config +++ b/tools/testing/selftests/tdx/config @@ -1 +1 @@ -CONFIG_TDX_GUEST_DRIVER=y +CONFIG_ATTESTATION_INTEL_TDX_GUEST=y -- 2.43.0