public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: seanjc@google.com, Yan Zhao <yan.y.zhao@intel.com>,
	Rick Edgecombe <rick.p.edgecombe@intel.com>,
	Isaku Yamahata <isaku.yamahata@intel.com>
Subject: Re: [PATCH 23/30] KVM: TDX: initialize VM with TDX specific parameters
Date: Tue, 25 Feb 2025 18:28:15 +0100	[thread overview]
Message-ID: <ae3eb42e-295f-420e-9857-013629d55aa6@redhat.com> (raw)
In-Reply-To: <1a959b69-5256-4c6e-8287-d36bf2b9339c@intel.com>

On 2/21/25 03:31, Xiaoyao Li wrote:
> On 2/21/2025 1:05 AM, Paolo Bonzini wrote:
> 
> ...
> 
>> @@ -403,8 +412,9 @@ int tdx_vm_init(struct kvm *kvm)
>>        */
>>       kvm->max_vcpus = min_t(int, kvm->max_vcpus, num_present_cpus());
>> -    /* Place holder for TDX specific logic. */
>> -    return __tdx_td_init(kvm);
> 
> it moves __tdx_td_init() from KVM_CRAETE_VM->tdx_vm_init() to ...
> 
>> +    kvm_tdx->state = TD_STATE_UNINITIALIZED;
>> +
>> +    return 0;
>>   }
> 
>> +static int tdx_td_init(struct kvm *kvm, struct kvm_tdx_cmd *cmd)
>> +{

...

>> +    ret = setup_tdparams(kvm, td_params, init_vm);
>> +    if (ret)
>> +        goto out;
>> +
>> +    ret = __tdx_td_init(kvm, td_params, &cmd->hw_error);
> 
> ... KVM_TDX_INIT_VM, which moves the keyid allocation, TDR/TDCS page 
> allocation and other works from KVM_CREATE_VM to KVM_TDX_INIT_VM as well.
> 
> I'm not sure if it is intentional, or by accident. There is no 
> mentioning and justfication of it.

Until this patch there was no KVM_TDX_INIT_VM ioctl, so there was no 
separation between uninitialized and initialized TDs - the TD was 
already initialized right after KVM_CREATE_VM.

I can adjust a bit the commit message.

Paolo

>> +    if (ret)
>> +        goto out;
>> +
>> +    kvm_tdx->tsc_offset = td_tdcs_exec_read64(kvm_tdx, 
>> TD_TDCS_EXEC_TSC_OFFSET);
>> +    kvm_tdx->attributes = td_params->attributes;
>> +    kvm_tdx->xfam = td_params->xfam;
>> +
>> +    kvm_tdx->state = TD_STATE_INITIALIZED;
>> +out:
>> +    /* kfree() accepts NULL. */
>> +    kfree(init_vm);
>> +    kfree(td_params);
>> +
>> +    return ret;
>> +}
>> +
>>   int tdx_vm_ioctl(struct kvm *kvm, void __user *argp)
>>   {
>>       struct kvm_tdx_cmd tdx_cmd;
>> @@ -647,6 +882,9 @@ int tdx_vm_ioctl(struct kvm *kvm, void __user *argp)
>>       case KVM_TDX_CAPABILITIES:
>>           r = tdx_get_capabilities(&tdx_cmd);
>>           break;
>> +    case KVM_TDX_INIT_VM:
>> +        r = tdx_td_init(kvm, &tdx_cmd);
>> +        break;
>>       default:
>>           r = -EINVAL;
>>           goto out;
> 
> 


  reply	other threads:[~2025-02-25 17:28 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-20 17:05 [PATCH v3 00/30] TDX initialization + vCPU/VM creation Paolo Bonzini
2025-02-20 17:05 ` [PATCH 01/30] x86/virt/tdx: Add SEAMCALL wrappers for TDX KeyID management Paolo Bonzini
2025-02-20 17:05 ` [PATCH 02/30] x86/virt/tdx: Add SEAMCALL wrappers for TDX TD creation Paolo Bonzini
2025-02-20 17:05 ` [PATCH 03/30] x86/virt/tdx: Add SEAMCALL wrappers for TDX vCPU creation Paolo Bonzini
2025-02-20 17:05 ` [PATCH 04/30] x86/virt/tdx: Add SEAMCALL wrappers for TDX page cache management Paolo Bonzini
2025-02-20 17:05 ` [PATCH 05/30] x86/virt/tdx: Add SEAMCALL wrappers for TDX VM/vCPU field access Paolo Bonzini
2025-02-20 17:05 ` [PATCH 06/30] x86/virt/tdx: Add SEAMCALL wrappers for TDX flush operations Paolo Bonzini
2025-02-20 17:05 ` [PATCH 07/30] x86/virt/tdx: allocate tdx_sys_info in static memory Paolo Bonzini
2025-02-20 21:59   ` Huang, Kai
2025-02-20 23:37   ` Edgecombe, Rick P
2025-02-20 17:05 ` [PATCH 08/30] x86/virt/tdx: Read essential global metadata for KVM Paolo Bonzini
2025-02-20 17:05 ` [PATCH 09/30] x86/virt/tdx: Add tdx_guest_keyid_alloc/free() to alloc and free TDX guest KeyID Paolo Bonzini
2025-02-20 17:05 ` [PATCH 10/30] KVM: Export hardware virtualization enabling/disabling functions Paolo Bonzini
2025-02-20 17:05 ` [PATCH 11/30] KVM: VMX: Refactor VMX module init/exit functions Paolo Bonzini
2025-02-20 21:55   ` Huang, Kai
2025-02-20 17:05 ` [PATCH 12/30] KVM: VMX: Initialize TDX during KVM module load Paolo Bonzini
2025-02-20 23:27   ` Huang, Kai
2025-02-24 18:57     ` Paolo Bonzini
2025-02-24 21:31       ` Huang, Kai
2025-02-20 17:05 ` [PATCH 13/30] KVM: TDX: Get TDX global information Paolo Bonzini
2025-02-21  0:12   ` Huang, Kai
2025-02-20 17:05 ` [PATCH 14/30] KVM: TDX: Add placeholders for TDX VM/vCPU structures Paolo Bonzini
2025-02-20 17:05 ` [PATCH 15/30] KVM: TDX: Define TDX architectural definitions Paolo Bonzini
2025-02-20 17:05 ` [PATCH 16/30] KVM: TDX: Add TDX "architectural" error codes Paolo Bonzini
2025-02-20 17:05 ` [PATCH 17/30] KVM: TDX: Add helper functions to print TDX SEAMCALL error Paolo Bonzini
2025-02-20 17:05 ` [PATCH 18/30] KVM: TDX: Add place holder for TDX VM specific mem_enc_op ioctl Paolo Bonzini
2025-02-25 10:50   ` Huang, Kai
2025-02-20 17:05 ` [PATCH 19/30] KVM: TDX: Get system-wide info about TDX module on initialization Paolo Bonzini
2025-02-20 17:05 ` [PATCH 20/30] KVM: TDX: create/destroy VM structure Paolo Bonzini
2025-02-21  0:55   ` Sean Christopherson
2025-02-21  1:08     ` Sean Christopherson
2025-02-22  0:30       ` Edgecombe, Rick P
2025-02-22  1:38         ` Sean Christopherson
2025-02-24  8:32           ` Yan Zhao
2025-02-21 11:04     ` Yan Zhao
2025-02-21 19:43       ` Sean Christopherson
2025-02-21 12:25   ` Yan Zhao
2025-02-25 16:24   ` Xiaoyao Li
2025-02-20 17:05 ` [PATCH 21/30] KVM: TDX: Support per-VM KVM_CAP_MAX_VCPUS extension check Paolo Bonzini
2025-02-20 17:05 ` [PATCH 22/30] KVM: x86: expose cpuid_entry2_find for TDX Paolo Bonzini
2025-02-20 17:05 ` [PATCH 23/30] KVM: TDX: initialize VM with TDX specific parameters Paolo Bonzini
2025-02-21  2:31   ` Xiaoyao Li
2025-02-25 17:28     ` Paolo Bonzini [this message]
2025-02-20 17:05 ` [PATCH 24/30] KVM: TDX: Make pmu_intel.c ignore guest TD case Paolo Bonzini
2025-02-20 17:05 ` [PATCH 25/30] KVM: TDX: Don't offline the last cpu of one package when there's TDX guest Paolo Bonzini
2025-02-20 17:06 ` [PATCH 26/30] KVM: TDX: create/free TDX vcpu structure Paolo Bonzini
2025-02-20 17:06 ` [PATCH 27/30] KVM: TDX: Do TDX specific vcpu initialization Paolo Bonzini
2025-02-20 17:06 ` [PATCH 28/30] KVM: x86: Introduce KVM_TDX_GET_CPUID Paolo Bonzini
2025-02-20 17:06 ` [PATCH 29/30] KVM: x86/mmu: Taking guest pa into consideration when calculate tdp level Paolo Bonzini
2025-02-20 17:06 ` [PATCH 30/30] KVM: TDX: Register TDX host key IDs to cgroup misc controller Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae3eb42e-295f-420e-9857-013629d55aa6@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=isaku.yamahata@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=xiaoyao.li@intel.com \
    --cc=yan.y.zhao@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox