[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 23/66] kvm: Introduce kvm_arch_pre_create_vcpu()
From: |
Xiaoyao Li |
Subject: |
[PATCH v4 23/66] kvm: Introduce kvm_arch_pre_create_vcpu() |
Date: |
Wed, 24 Jan 2024 22:22:45 -0500 |
Introduce kvm_arch_pre_create_vcpu(), to perform arch-dependent
work prior to create any vcpu. This is for i386 TDX because it needs
call TDX_INIT_VM before creating any vcpu.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
---
Changes in v3:
- pass @errp to kvm_arch_pre_create_vcpu(); (Per Daniel)
---
accel/kvm/kvm-all.c | 10 ++++++++++
include/sysemu/kvm.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index def2b46b9de2..7b177e3ee7c5 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -418,6 +418,11 @@ static int kvm_get_vcpu(KVMState *s, unsigned long vcpu_id)
return kvm_vm_ioctl(s, KVM_CREATE_VCPU, (void *)vcpu_id);
}
+int __attribute__ ((weak)) kvm_arch_pre_create_vcpu(CPUState *cpu, Error
**errp)
+{
+ return 0;
+}
+
int kvm_init_vcpu(CPUState *cpu, Error **errp)
{
KVMState *s = kvm_state;
@@ -426,6 +431,11 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp)
trace_kvm_init_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu));
+ ret = kvm_arch_pre_create_vcpu(cpu, errp);
+ if (ret < 0) {
+ goto err;
+ }
+
ret = kvm_get_vcpu(s, kvm_arch_vcpu_id(cpu));
if (ret < 0) {
error_setg_errno(errp, -ret, "kvm_init_vcpu: kvm_get_vcpu failed
(%lu)",
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 0e88958190a4..2f6592859ac6 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -341,6 +341,7 @@ int kvm_arch_get_default_type(MachineState *ms);
int kvm_arch_init(MachineState *ms, KVMState *s);
+int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp);
int kvm_arch_init_vcpu(CPUState *cpu);
int kvm_arch_destroy_vcpu(CPUState *cpu);
--
2.34.1
- [PATCH v4 13/66] target/i386: Introduce kvm_confidential_guest_init(), (continued)
- [PATCH v4 13/66] target/i386: Introduce kvm_confidential_guest_init(), Xiaoyao Li, 2024/01/24
- [PATCH v4 15/66] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES, Xiaoyao Li, 2024/01/24
- [PATCH v4 14/66] i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context, Xiaoyao Li, 2024/01/24
- [PATCH v4 16/66] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object, Xiaoyao Li, 2024/01/24
- [PATCH v4 18/66] i386/tdx: Make Intel-PT unsupported for TD guest, Xiaoyao Li, 2024/01/24
- [PATCH v4 17/66] i386/tdx: Adjust the supported CPUID based on TDX restrictions, Xiaoyao Li, 2024/01/24
- [PATCH v4 19/66] i386/tdx: Update tdx_cpuid_lookup[].tdx_fixed0/1 by tdx_caps.cpuid_config[], Xiaoyao Li, 2024/01/24
- [PATCH v4 20/66] i386/tdx: Integrate tdx_caps->xfam_fixed0/1 into tdx_cpuid_lookup, Xiaoyao Li, 2024/01/24
- [PATCH v4 21/66] i386/tdx: Integrate tdx_caps->attrs_fixed0/1 to tdx_cpuid_lookup, Xiaoyao Li, 2024/01/24
- [PATCH v4 22/66] i386/kvm: Move architectural CPUID leaf generation to separate helper, Xiaoyao Li, 2024/01/24
- [PATCH v4 23/66] kvm: Introduce kvm_arch_pre_create_vcpu(),
Xiaoyao Li <=
- [PATCH v4 24/66] i386/tdx: Initialize TDX before creating TD vcpus, Xiaoyao Li, 2024/01/24
- [PATCH v4 25/66] i386/tdx: Add property sept-ve-disable for tdx-guest object, Xiaoyao Li, 2024/01/24
- [PATCH v4 27/66] i386/tdx: Wire CPU features up with attributes of TD guest, Xiaoyao Li, 2024/01/24
- [PATCH v4 28/66] i386/tdx: Validate TD attributes, Xiaoyao Li, 2024/01/24
- [PATCH v4 26/66] i386/tdx: Make sept_ve_disable set by default, Xiaoyao Li, 2024/01/24
- [PATCH v4 29/66] i386/tdx: Support user configurable mrconfigid/mrowner/mrownerconfig, Xiaoyao Li, 2024/01/24
- [PATCH v4 30/66] i386/tdx: Implement user specified tsc frequency, Xiaoyao Li, 2024/01/24
- [PATCH v4 31/66] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM, Xiaoyao Li, 2024/01/24
- [PATCH v4 32/66] kvm/memory: Introduce the infrastructure to set the default shared/private value, Xiaoyao Li, 2024/01/24
- [PATCH v4 34/66] kvm/tdx: Don't complain when converting vMMIO region to shared, Xiaoyao Li, 2024/01/24