117 lines
3.6 KiB
Diff
117 lines
3.6 KiB
Diff
From 2a27aea7e254e3828051e68a4c369068eacfb09e Mon Sep 17 00:00:00 2001
|
|
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
Date: Fri, 18 Jul 2025 18:03:46 +0200
|
|
Subject: [PATCH 047/115] i386/tdx: Parse TDVF metadata for TDX VM
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
RH-MergeRequest: 391: TDX support, including attestation and device assignment
|
|
RH-Jira: RHEL-15710 RHEL-20798 RHEL-49728
|
|
RH-Acked-by: Yash Mankad <None>
|
|
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
RH-Commit: [47/115] bf2f78d0bbeb0b720e00b1593d02aeeaf46eb13e (bonzini/rhel-qemu-kvm)
|
|
|
|
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>
|
|
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
|
|
Link: https://lore.kernel.org/r/20250508150002.689633-19-xiaoyao.li@intel.com
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
(cherry picked from commit cb5d65a854e58abeb705a2ce14cc3eb28973c606)
|
|
Signed-off-by: Paolo Bonzini <pbonzini@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 e6271e1020..7436a4f33e 100644
|
|
--- a/hw/i386/pc_sysfw.c
|
|
+++ b/hw/i386/pc_sysfw.c
|
|
@@ -37,6 +37,7 @@
|
|
#include "hw/block/flash.h"
|
|
#include "sysemu/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 2344433594..7748b6d0a4 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 2522f2030d..71be3bd28d 100644
|
|
--- a/target/i386/kvm/tdx.c
|
|
+++ b/target/i386/kvm/tdx.c
|
|
@@ -382,6 +382,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 b73461b8d8..28a03c2a7b 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.50.1
|
|
|