[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 31/60] i386/cpu: introduce x86_confidential_guest_cpu_instance
From: |
Xiaoyao Li |
Subject: |
[PATCH v6 31/60] i386/cpu: introduce x86_confidential_guest_cpu_instance_init() |
Date: |
Tue, 5 Nov 2024 01:23:39 -0500 |
To allow execute confidential guest specific cpu init operations.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
Changes in v6:
- new patch;
---
target/i386/confidential-guest.h | 11 +++++++++++
target/i386/cpu.c | 10 ++++++++++
2 files changed, 21 insertions(+)
diff --git a/target/i386/confidential-guest.h b/target/i386/confidential-guest.h
index 7342d2843aa5..38169ed68e06 100644
--- a/target/i386/confidential-guest.h
+++ b/target/i386/confidential-guest.h
@@ -39,6 +39,7 @@ struct X86ConfidentialGuestClass {
/* <public> */
int (*kvm_type)(X86ConfidentialGuest *cg);
+ void (*cpu_instance_init)(X86ConfidentialGuest *cg, CPUState *cpu);
uint32_t (*mask_cpuid_features)(X86ConfidentialGuest *cg, uint32_t
feature, uint32_t index,
int reg, uint32_t value);
};
@@ -59,6 +60,16 @@ static inline int
x86_confidential_guest_kvm_type(X86ConfidentialGuest *cg)
}
}
+static inline void
x86_confidential_guest_cpu_instance_init(X86ConfidentialGuest *cg,
+ CPUState *cpu)
+{
+ X86ConfidentialGuestClass *klass = X86_CONFIDENTIAL_GUEST_GET_CLASS(cg);
+
+ if (klass->cpu_instance_init) {
+ klass->cpu_instance_init(cg, cpu);
+ }
+}
+
/**
* x86_confidential_guest_mask_cpuid_features:
*
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 3baa95481fbc..c7d65bbeab9b 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -35,6 +35,7 @@
#include "hw/qdev-properties.h"
#include "hw/i386/topology.h"
#ifndef CONFIG_USER_ONLY
+#include "confidential-guest.h"
#include "sysemu/reset.h"
#include "qapi/qapi-commands-machine-target.h"
#include "exec/address-spaces.h"
@@ -8157,6 +8158,15 @@ static void x86_cpu_post_initfn(Object *obj)
}
accel_cpu_instance_init(CPU(obj));
+
+#ifndef CONFIG_USER_ONLY
+ MachineState *ms = MACHINE(object_dynamic_cast(qdev_get_machine(),
+ TYPE_MACHINE));
+ if (ms && ms->cgs) {
+
x86_confidential_guest_cpu_instance_init(X86_CONFIDENTIAL_GUEST(ms->cgs),
+ (CPU(obj)));
+ }
+#endif
}
static void x86_cpu_init_default_topo(X86CPU *cpu)
--
2.34.1
- [PATCH v6 27/60] i386/tdx: Finalize TDX VM, (continued)
- [PATCH v6 27/60] i386/tdx: Finalize TDX VM, Xiaoyao Li, 2024/11/05
- [PATCH v6 29/60] i386/tdx: Handle KVM_SYSTEM_EVENT_TDX_FATAL, Xiaoyao Li, 2024/11/05
- [PATCH v6 24/60] i386/tdx: Setup the TD HOB list, Xiaoyao Li, 2024/11/05
- [PATCH v6 28/60] i386/tdx: Enable user exit on KVM_HC_MAP_GPA_RANGE, Xiaoyao Li, 2024/11/05
- [PATCH v6 30/60] i386/tdx: Wire TDX_REPORT_FATAL_ERROR with GuestPanic facility, Xiaoyao Li, 2024/11/05
- [PATCH v6 33/60] i386/cpu: introduce x86_confidenetial_guest_cpu_realizefn(), Xiaoyao Li, 2024/11/05
- [PATCH v6 31/60] i386/cpu: introduce x86_confidential_guest_cpu_instance_init(),
Xiaoyao Li <=
- [PATCH v6 32/60] i386/tdx: implement tdx_cpu_instance_init(), Xiaoyao Li, 2024/11/05
- [PATCH v6 38/60] i386/tdx: Disable SMM for TDX VMs, Xiaoyao Li, 2024/11/05
- [PATCH v6 34/60] i386/tdx: implement tdx_cpu_realizefn(), Xiaoyao Li, 2024/11/05
- [PATCH v6 39/60] i386/tdx: Disable PIC for TDX VMs, Xiaoyao Li, 2024/11/05
- [PATCH v6 40/60] hw/i386: add eoi_intercept_unsupported member to X86MachineState, Xiaoyao Li, 2024/11/05
- [PATCH v6 35/60] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f, Xiaoyao Li, 2024/11/05
- [PATCH v6 36/60] i386/tdx: Force exposing CPUID 0x1f, Xiaoyao Li, 2024/11/05