[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 13/58] kvm: Introduce kvm_arch_pre_create_vcpu()
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH v2 13/58] kvm: Introduce kvm_arch_pre_create_vcpu() |
Date: |
Mon, 21 Aug 2023 09:55:48 +0100 |
User-agent: |
Mutt/2.2.9 (2022-11-12) |
On Fri, Aug 18, 2023 at 05:49:56AM -0400, Xiaoyao Li wrote:
> 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>
> ---
> accel/kvm/kvm-all.c | 12 ++++++++++++
> include/sysemu/kvm.h | 1 +
> 2 files changed, 13 insertions(+)
>
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index c9f3aab5e587..5071af917ae0 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -422,6 +422,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)
> +{
> + return 0;
> +}
> +
> int kvm_init_vcpu(CPUState *cpu, Error **errp)
> {
> KVMState *s = kvm_state;
> @@ -430,6 +435,13 @@ 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);
> + if (ret < 0) {
> + error_setg_errno(errp, -ret, "%s: kvm_arch_pre_create_vcpu() failed",
> + __func__);
Don't report generic error messages here, when kvm_arch_pre_create_vcpu
can provide a better error - pass the 'errp' into the kvm_arch_pre_create_vcpu
method.
> + 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 49c896d8a512..d89ec87072d7 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -371,6 +371,7 @@ int kvm_arch_put_registers(CPUState *cpu, int level);
>
> int kvm_arch_init(MachineState *ms, KVMState *s);
>
> +int kvm_arch_pre_create_vcpu(CPUState *cpu);
> int kvm_arch_init_vcpu(CPUState *cpu);
> int kvm_arch_destroy_vcpu(CPUState *cpu);
>
> --
> 2.34.1
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
- Re: [PATCH v2 07/58] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object, (continued)
- [PATCH v2 08/58] i386/tdx: Adjust the supported CPUID based on TDX restrictions, Xiaoyao Li, 2023/08/18
- [PATCH v2 09/58] i386/tdx: Update tdx_cpuid_lookup[].tdx_fixed0/1 by tdx_caps.cpuid_config[], Xiaoyao Li, 2023/08/18
- [PATCH v2 10/58] i386/tdx: Integrate tdx_caps->xfam_fixed0/1 into tdx_cpuid_lookup, Xiaoyao Li, 2023/08/18
- [PATCH v2 11/58] i386/tdx: Integrate tdx_caps->attrs_fixed0/1 to tdx_cpuid_lookup, Xiaoyao Li, 2023/08/18
- [PATCH v2 12/58] i386/kvm: Move architectural CPUID leaf generation to separate helper, Xiaoyao Li, 2023/08/18
- [PATCH v2 13/58] kvm: Introduce kvm_arch_pre_create_vcpu(), Xiaoyao Li, 2023/08/18
- [PATCH v2 15/58] i386/tdx: Add property sept-ve-disable for tdx-guest object, Xiaoyao Li, 2023/08/18
[PATCH v2 14/58] i386/tdx: Initialize TDX before creating TD vcpus, Xiaoyao Li, 2023/08/18
[PATCH v2 16/58] i386/tdx: Make sept_ve_disable set by default, Xiaoyao Li, 2023/08/18