[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 17/52] i386/tdx: Parse TDVF metadata for TDX VM
From: |
Xiaoyao Li |
Subject: |
[PATCH v7 17/52] i386/tdx: Parse TDVF metadata for TDX VM |
Date: |
Fri, 24 Jan 2025 08:20:13 -0500 |
After TDVF is loaded to bios MemoryRegion, it needs parse TDVF metadata.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/i386/pc_sysfw.c | 7 +++++++
target/i386/kvm/tdx-stub.c | 5 +++++
target/i386/kvm/tdx.c | 5 +++++
target/i386/kvm/tdx.h | 3 +++
4 files changed, 20 insertions(+)
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index 1eeb58ab37f9..821396c16e91 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -37,6 +37,7 @@
#include "hw/block/flash.h"
#include "system/kvm.h"
#include "target/i386/sev.h"
+#include "kvm/tdx.h"
#define FLASH_SECTOR_SIZE 4096
@@ -280,5 +281,11 @@ void x86_firmware_configure(hwaddr gpa, void *ptr, int
size)
}
sev_encrypt_flash(gpa, ptr, size, &error_fatal);
+ } else if (is_tdx_vm()) {
+ ret = tdx_parse_tdvf(ptr, size);
+ if (ret) {
+ error_report("failed to parse TDVF for TDX VM");
+ exit(1);
+ }
}
}
diff --git a/target/i386/kvm/tdx-stub.c b/target/i386/kvm/tdx-stub.c
index 2344433594ea..7748b6d0a446 100644
--- a/target/i386/kvm/tdx-stub.c
+++ b/target/i386/kvm/tdx-stub.c
@@ -8,3 +8,8 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)
{
return -EINVAL;
}
+
+int tdx_parse_tdvf(void *flash_ptr, int size)
+{
+ return -EINVAL;
+}
diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index f1c0553e6d4a..73f90b0a2217 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -370,6 +370,11 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)
return 0;
}
+int tdx_parse_tdvf(void *flash_ptr, int size)
+{
+ return tdvf_parse_metadata(&tdx_guest->tdvf, flash_ptr, size);
+}
+
static bool tdx_guest_get_sept_ve_disable(Object *obj, Error **errp)
{
TdxGuest *tdx = TDX_GUEST(obj);
diff --git a/target/i386/kvm/tdx.h b/target/i386/kvm/tdx.h
index b73461b8d8a3..28a03c2a7b82 100644
--- a/target/i386/kvm/tdx.h
+++ b/target/i386/kvm/tdx.h
@@ -8,6 +8,7 @@
#endif
#include "confidential-guest.h"
+#include "hw/i386/tdvf.h"
#define TYPE_TDX_GUEST "tdx-guest"
#define TDX_GUEST(obj) OBJECT_CHECK(TdxGuest, (obj), TYPE_TDX_GUEST)
@@ -32,6 +33,7 @@ typedef struct TdxGuest {
char *mrownerconfig; /* base64 encoded sha348 digest */
MemoryRegion *tdvf_mr;
+ TdxFirmware tdvf;
} TdxGuest;
#ifdef CONFIG_TDX
@@ -42,5 +44,6 @@ bool is_tdx_vm(void);
int tdx_pre_create_vcpu(CPUState *cpu, Error **errp);
void tdx_set_tdvf_region(MemoryRegion *tdvf_mr);
+int tdx_parse_tdvf(void *flash_ptr, int size);
#endif /* QEMU_I386_TDX_H */
--
2.34.1
- [PATCH v7 07/52] kvm: Introduce kvm_arch_pre_create_vcpu(), (continued)
- [PATCH v7 07/52] kvm: Introduce kvm_arch_pre_create_vcpu(), Xiaoyao Li, 2025/01/24
- [PATCH v7 09/52] i386/tdx: Add property sept-ve-disable for tdx-guest object, Xiaoyao Li, 2025/01/24
- [PATCH v7 08/52] i386/tdx: Initialize TDX before creating TD vcpus, Xiaoyao Li, 2025/01/24
- [PATCH v7 10/52] i386/tdx: Make sept_ve_disable set by default, Xiaoyao Li, 2025/01/24
- [PATCH v7 11/52] i386/tdx: Wire CPU features up with attributes of TD guest, Xiaoyao Li, 2025/01/24
- [PATCH v7 12/52] i386/tdx: Validate TD attributes, Xiaoyao Li, 2025/01/24
- [PATCH v7 13/52] i386/tdx: Set APIC bus rate to match with what TDX module enforces, Xiaoyao Li, 2025/01/24
- [PATCH v7 14/52] i386/tdx: Implement user specified tsc frequency, Xiaoyao Li, 2025/01/24
- [PATCH v7 15/52] i386/tdx: load TDVF for TD guest, Xiaoyao Li, 2025/01/24
- [PATCH v7 16/52] i386/tdvf: Introduce function to parse TDVF metadata, Xiaoyao Li, 2025/01/24
- [PATCH v7 17/52] i386/tdx: Parse TDVF metadata for TDX VM,
Xiaoyao Li <=
- [PATCH v7 18/52] i386/tdx: Don't initialize pc.rom for TDX VMs, Xiaoyao Li, 2025/01/24
- [PATCH v7 19/52] i386/tdx: Track mem_ptr for each firmware entry of TDVF, Xiaoyao Li, 2025/01/24
- [PATCH v7 20/52] i386/tdx: Track RAM entries for TDX VM, Xiaoyao Li, 2025/01/24
- [PATCH v7 21/52] headers: Add definitions from UEFI spec for volumes, resources, etc..., Xiaoyao Li, 2025/01/24
- [PATCH v7 22/52] i386/tdx: Setup the TD HOB list, Xiaoyao Li, 2025/01/24
- [PATCH v7 23/52] i386/tdx: Add TDVF memory via KVM_TDX_INIT_MEM_REGION, Xiaoyao Li, 2025/01/24
- [PATCH v7 24/52] i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcpu, Xiaoyao Li, 2025/01/24
- [PATCH v7 26/52] i386/tdx: Enable user exit on KVM_HC_MAP_GPA_RANGE, Xiaoyao Li, 2025/01/24
- [PATCH v7 29/52] i386/cpu: introduce x86_confidential_guest_cpu_instance_init(), Xiaoyao Li, 2025/01/24
- [PATCH v7 33/52] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM, Xiaoyao Li, 2025/01/24