93 lines
3.2 KiB
Diff
93 lines
3.2 KiB
Diff
From 08b7b3ce573d25b6130c28620c51ac57532bd454 Mon Sep 17 00:00:00 2001
|
|
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
Date: Fri, 18 Jul 2025 18:03:45 +0200
|
|
Subject: [PATCH 033/115] i386/tdx: Implement tdx_kvm_init() to initialize TDX
|
|
VM context
|
|
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: [33/115] 1c018f800145aced56f1268aa0f70cbbe1ec4658 (bonzini/rhel-qemu-kvm)
|
|
|
|
Implement TDX specific ConfidentialGuestSupportClass::kvm_init()
|
|
callback, tdx_kvm_init().
|
|
|
|
Mark guest state is proctected for TDX VM. More TDX specific
|
|
initialization will be added later.
|
|
|
|
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.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-5-xiaoyao.li@intel.com
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
(cherry picked from commit 631a2ac5a4beab740b342367550562cd659b4c4a)
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
---
|
|
target/i386/kvm/kvm.c | 11 +----------
|
|
target/i386/kvm/tdx.c | 10 ++++++++++
|
|
2 files changed, 11 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
|
|
index d7c2dc3c71..12da34b9c5 100644
|
|
--- a/target/i386/kvm/kvm.c
|
|
+++ b/target/i386/kvm/kvm.c
|
|
@@ -3021,16 +3021,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
|
|
Error *local_err = NULL;
|
|
|
|
/*
|
|
- * Initialize SEV context, if required
|
|
- *
|
|
- * If no memory encryption is requested (ms->cgs == NULL) this is
|
|
- * a no-op.
|
|
- *
|
|
- * It's also a no-op if a non-SEV confidential guest support
|
|
- * mechanism is selected. SEV is the only mechanism available to
|
|
- * select on x86 at present, so this doesn't arise, but if new
|
|
- * mechanisms are supported in future (e.g. TDX), they'll need
|
|
- * their own initialization either here or elsewhere.
|
|
+ * Initialize confidential guest (SEV/TDX) context, if required
|
|
*/
|
|
if (ms->cgs) {
|
|
ret = confidential_guest_kvm_init(ms->cgs, &local_err);
|
|
diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
|
|
index d785c1f6d1..4ff9486081 100644
|
|
--- a/target/i386/kvm/tdx.c
|
|
+++ b/target/i386/kvm/tdx.c
|
|
@@ -12,9 +12,17 @@
|
|
#include "qemu/osdep.h"
|
|
#include "qom/object_interfaces.h"
|
|
|
|
+#include "hw/i386/x86.h"
|
|
#include "kvm_i386.h"
|
|
#include "tdx.h"
|
|
|
|
+static int tdx_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
|
|
+{
|
|
+ kvm_mark_guest_state_protected();
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static int tdx_kvm_type(X86ConfidentialGuest *cg)
|
|
{
|
|
/* Do the object check */
|
|
@@ -49,7 +57,9 @@ static void tdx_guest_finalize(Object *obj)
|
|
|
|
static void tdx_guest_class_init(ObjectClass *oc, void *data)
|
|
{
|
|
+ ConfidentialGuestSupportClass *klass = CONFIDENTIAL_GUEST_SUPPORT_CLASS(oc);
|
|
X86ConfidentialGuestClass *x86_klass = X86_CONFIDENTIAL_GUEST_CLASS(oc);
|
|
|
|
+ klass->kvm_init = tdx_kvm_init;
|
|
x86_klass->kvm_type = tdx_kvm_type;
|
|
}
|
|
--
|
|
2.50.1
|
|
|