Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Tony Lindgren <tony.lindgren@linux.intel.com>
To: Chenyi Qiang <chenyi.qiang@intel.com>
Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>,
	seanjc@google.com, pbonzini@redhat.com, kvm@vger.kernel.org,
	kai.huang@intel.com, isaku.yamahata@gmail.com,
	xiaoyao.li@intel.com, linux-kernel@vger.kernel.org,
	Isaku Yamahata <isaku.yamahata@intel.com>
Subject: Re: [PATCH 14/25] KVM: TDX: initialize VM with TDX specific parameters
Date: Thu, 5 Sep 2024 12:31:26 +0300	[thread overview]
Message-ID: <Ztl6bg2vfah35Zlj@tlindgre-MOBL1> (raw)
In-Reply-To: <dd48cb68-1051-48ec-ae29-874c2a77f30f@intel.com>

On Tue, Sep 03, 2024 at 04:04:47PM +0800, Chenyi Qiang wrote:
> 
> 
> On 9/3/2024 1:44 PM, Tony Lindgren wrote:
> > On Tue, Sep 03, 2024 at 10:58:11AM +0800, Chenyi Qiang wrote:
> >> On 8/13/2024 6:48 AM, Rick Edgecombe wrote:
> >>> From: Isaku Yamahata <isaku.yamahata@intel.com>
> >>> @@ -543,10 +664,23 @@ static int __tdx_td_init(struct kvm *kvm)
> >>>  		}
> >>>  	}
> >>>  
> >>> -	/*
> >>> -	 * Note, TDH_MNG_INIT cannot be invoked here.  TDH_MNG_INIT requires a dedicated
> >>> -	 * ioctl() to define the configure CPUID values for the TD.
> >>> -	 */
> >>> +	err = tdh_mng_init(kvm_tdx, __pa(td_params), &rcx);
> >>> +	if ((err & TDX_SEAMCALL_STATUS_MASK) == TDX_OPERAND_INVALID) {
> >>> +		/*
> >>> +		 * Because a user gives operands, don't warn.
> >>> +		 * Return a hint to the user because it's sometimes hard for the
> >>> +		 * user to figure out which operand is invalid.  SEAMCALL status
> >>> +		 * code includes which operand caused invalid operand error.
> >>> +		 */
> >>> +		*seamcall_err = err;
> >>
> >> I'm wondering if we could return or output more hint (i.e. the value of
> >> rcx) in the case of invalid operand. For example, if seamcall returns
> >> with INVALID_OPERAND_CPUID_CONFIG, rcx will contain the CPUID
> >> leaf/sub-leaf info.
> > 
> > Printing a decriptive error here would be nice when things go wrong.
> > Probably no need to return that information.
> > 
> > Sounds like you have a patch already in mind though :) Care to post a
> > patch against the current kvm-coco branch? If not, I can do it after all
> > the obvious comment changes are out of the way.
> 
> According to the comment above, this patch wants to return the hint to
> user as the user gives operands. I'm still uncertain if we should follow
> this to return value in some way or special-case the
> INVALID_OPERAND_CPUID_CONFIG like:
> 
> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index c00c73b2ad4c..dd6e3149ff5a 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
> @@ -2476,8 +2476,14 @@ static int __tdx_td_init(struct kvm *kvm, struct
> td_params *td_params,
>                  * Return a hint to the user because it's sometimes hard
> for the
>                  * user to figure out which operand is invalid.
> SEAMCALL status
>                  * code includes which operand caused invalid operand error.
> +                *
> +                * TDX_OPERAND_INVALID_CPUID_CONFIG contains more info
> +                * in rcx (i.e. leaf/sub-leaf), warn it to help figure
> +                * out the invalid CPUID config.
>                  */
>                 *seamcall_err = err;
> +               if (err == (TDX_OPERAND_INVALID |
> TDX_OPERAND_ID_CPUID_CONFIG))
> +                       pr_tdx_error_1(TDH_MNG_INIT, err, rcx);
>                 ret = -EINVAL;
>                 goto teardown;
>         } else if (WARN_ON_ONCE(err)) {
> diff --git a/arch/x86/kvm/vmx/tdx_errno.h b/arch/x86/kvm/vmx/tdx_errno.h
> index f9dbb3a065cc..311c3f03d398 100644
> --- a/arch/x86/kvm/vmx/tdx_errno.h
> +++ b/arch/x86/kvm/vmx/tdx_errno.h
> @@ -30,6 +30,7 @@
>   * detail information
>   */
>  #define TDX_OPERAND_ID_RCX                     0x01
> +#define TDX_OPERAND_ID_CPUID_CONFIG            0x45
>  #define TDX_OPERAND_ID_TDR                     0x80
>  #define TDX_OPERAND_ID_SEPT                    0x92
>  #define TDX_OPERAND_ID_TD_EPOCH                        0xa9
> 

OK yes that should take care of the issue, I doubt that this can be
automatically be handled by the caller even a better error code
was returned.

Regards,

Tony

  reply	other threads:[~2024-09-05  9:31 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240812224820.34826-1-rick.p.edgecombe@intel.com>
     [not found] ` <20240812224820.34826-19-rick.p.edgecombe@intel.com>
2024-08-28 14:34   ` [PATCH 18/25] KVM: TDX: Do TDX specific vcpu initialization Edgecombe, Rick P
2024-09-03  5:34     ` Tony Lindgren
     [not found]   ` <20240813080009.zowu3woyffwlyazu@yy-desk-7060>
2024-09-03  5:23     ` Tony Lindgren
2024-10-09 15:01     ` Adrian Hunter
2024-10-16 17:42       ` Edgecombe, Rick P
2024-10-18  2:21         ` Xiaoyao Li
2024-10-18 14:20           ` Edgecombe, Rick P
2024-10-21  8:35             ` Xiaoyao Li
2024-10-26  1:12               ` Edgecombe, Rick P
     [not found] ` <20240812224820.34826-4-rick.p.edgecombe@intel.com>
     [not found]   ` <45cecaa1-d118-4465-98ae-8f63eb166c84@linux.intel.com>
2024-08-29  5:24     ` [PATCH 03/25] KVM: TDX: Add TDX "architectural" error codes Tony Lindgren
2024-08-30  5:52       ` Tony Lindgren
2024-09-10 16:22         ` Paolo Bonzini
2024-09-11  5:58           ` Tony Lindgren
     [not found] ` <20240812224820.34826-15-rick.p.edgecombe@intel.com>
2024-08-29  6:27   ` [PATCH 14/25] KVM: TDX: initialize VM with TDX specific parameters Yan Zhao
2024-09-02 10:31     ` Tony Lindgren
2024-09-05  6:59       ` Yan Zhao
2024-09-05  9:27         ` Tony Lindgren
2024-09-06  4:05           ` Yan Zhao
2024-09-06  4:32             ` Tony Lindgren
2024-09-06 13:52               ` Wang, Wei W
2024-09-03  2:58   ` Chenyi Qiang
2024-09-03  5:44     ` Tony Lindgren
2024-09-03  8:04       ` Chenyi Qiang
2024-09-05  9:31         ` Tony Lindgren [this message]
2024-10-01 20:45           ` Edgecombe, Rick P
2024-10-02 23:39   ` Edgecombe, Rick P
     [not found] ` <20240812224820.34826-18-rick.p.edgecombe@intel.com>
     [not found]   ` <4fcff880-30e2-44f8-aa45-6444a3eaa398@suse.com>
2024-08-29  5:00     ` [PATCH 17/25] KVM: TDX: create/free TDX vcpu structure Tony Lindgren
2024-08-29  6:41   ` Yan Zhao
     [not found]   ` <c03df364-4cce-4c7e-b9db-191f7b10ca70@linux.intel.com>
2024-09-02 10:50     ` Tony Lindgren
     [not found] ` <20240812224820.34826-3-rick.p.edgecombe@intel.com>
2024-08-29 13:25   ` [PATCH 02/25] KVM: TDX: Define TDX architectural definitions Xiaoyao Li
2024-08-29 19:46     ` Edgecombe, Rick P
2024-08-30  1:29       ` Xiaoyao Li
2024-08-30  4:45         ` Tony Lindgren
2024-09-10 16:21       ` Paolo Bonzini
2024-09-10 17:49         ` Sean Christopherson
     [not found] ` <20240812224820.34826-6-rick.p.edgecombe@intel.com>
     [not found]   ` <ZruKrWWDtB+E3kwr@ls.amr.corp.intel.com>
     [not found]     ` <61b550ed-c5d1-44a6-89de-cfa04ddd59c8@intel.com>
     [not found]       ` <Zrv649ijpYchVlyL@ls.amr.corp.intel.com>
2024-08-30  5:56         ` [PATCH 05/25] KVM: TDX: Add helper functions to print TDX SEAMCALL error Tony Lindgren
     [not found] ` <20240812224820.34826-9-rick.p.edgecombe@intel.com>
     [not found]   ` <ZruLs4+EE5xHCAcp@ls.amr.corp.intel.com>
2024-08-30  6:00     ` [PATCH 08/25] KVM: TDX: Add place holder for TDX VM specific mem_enc_op ioctl Tony Lindgren
     [not found] ` <20240812224820.34826-10-rick.p.edgecombe@intel.com>
     [not found]   ` <42d844c9-2a17-4cb0-8710-328e7774b4d4@linux.intel.com>
2024-08-30  6:59     ` [PATCH 09/25] KVM: TDX: Get system-wide info about TDX module on initialization Tony Lindgren
     [not found]   ` <Zr21XioOyi0CZ+FV@yilunxu-OptiPlex-7050>
2024-08-30  7:21     ` Tony Lindgren
2024-09-02  1:25       ` Xu Yilun
2024-09-02  5:05         ` Tony Lindgren
     [not found] ` <20240812224820.34826-14-rick.p.edgecombe@intel.com>
     [not found]   ` <Zr8AYgZfInrwpAND@yilunxu-OptiPlex-7050>
2024-08-30  9:26     ` [PATCH 13/25] KVM: TDX: create/destroy VM structure Tony Lindgren
     [not found]   ` <e7c16241-100a-4830-9628-65edb44ca78d@suse.com>
     [not found]     ` <850ef710eac95a5c36863c94e1b31a8090eb8a2a.camel@intel.com>
     [not found]       ` <ZsV9qouTem-ynGJA@tlindgre-MOBL1>
     [not found]         ` <0e283ec8bfee66c01f49529f924a0a8c43d22657.camel@intel.com>
2024-08-30  9:40           ` Tony Lindgren
2024-09-02  9:22     ` Tony Lindgren
     [not found] ` <20240812224820.34826-7-rick.p.edgecombe@intel.com>
2024-08-30 18:45   ` [PATCH 06/25] x86/virt/tdx: Export TDX KeyID information Dave Hansen
2024-08-30 19:16     ` Edgecombe, Rick P
2024-08-30 21:18       ` Dave Hansen
2024-09-10 16:26         ` Paolo Bonzini
     [not found] ` <20240812224820.34826-11-rick.p.edgecombe@intel.com>
     [not found]   ` <b8ed694f-3ab1-453c-b14b-25113defbdb6@suse.com>
2024-08-29  4:51     ` [PATCH 10/25] KVM: TDX: Initialize KVM supported capabilities when module setup Tony Lindgren
2024-09-10 17:15       ` Paolo Bonzini
2024-09-11 11:04         ` Tony Lindgren
2024-10-10  8:25           ` Xiaoyao Li
2024-10-10  9:49             ` Tony Lindgren
     [not found]   ` <ZsKg2fIjo41T0VTH@linux.bj.intel.com>
2024-08-29 13:28     ` Xiaoyao Li
     [not found]   ` <ZrrSMaAxyqMBcp8a@chao-email>
2024-08-30  8:34     ` Tony Lindgren
2024-09-10 16:58       ` Paolo Bonzini
2024-09-11 11:07         ` Tony Lindgren
     [not found]     ` <185d2a6c0317fe74fdb449df62dbafcb922a74f3.camel@intel.com>
2024-08-30  8:44       ` Tony Lindgren
2024-09-03 16:53     ` Edgecombe, Rick P
2024-09-04 11:58   ` Nikolay Borisov
2024-09-05 13:36     ` Xiaoyao Li
2024-09-12  8:04       ` Nikolay Borisov
2024-09-12  8:37         ` Xiaoyao Li
2024-09-12  8:43           ` Nikolay Borisov
2024-09-12  9:07             ` Xiaoyao Li
2024-09-12 15:12               ` Edgecombe, Rick P
2024-09-12 15:18                 ` Nikolay Borisov
     [not found] ` <20240812224820.34826-2-rick.p.edgecombe@intel.com>
2024-09-10 16:00   ` [PATCH 01/25] KVM: TDX: Add placeholders for TDX VM/vCPU structures Paolo Bonzini
     [not found] ` <20240812224820.34826-8-rick.p.edgecombe@intel.com>
2024-09-10 16:27   ` [PATCH 07/25] KVM: TDX: Add helper functions to allocate/free TDX private host key id Paolo Bonzini
2024-09-10 16:39     ` Edgecombe, Rick P
2024-09-10 16:42       ` Paolo Bonzini
2024-09-10 16:43         ` Edgecombe, Rick P
     [not found] ` <20240812224820.34826-16-rick.p.edgecombe@intel.com>
2024-09-10 17:23   ` [PATCH 15/25] KVM: TDX: Make pmu_intel.c ignore guest TD case Paolo Bonzini
2024-10-01 10:23     ` Tony Lindgren
     [not found] ` <20240812224820.34826-23-rick.p.edgecombe@intel.com>
2024-09-10 17:31   ` [PATCH 22/25] KVM: TDX: Use guest physical address to configure EPT level and GPAW Paolo Bonzini
2024-10-10  9:13   ` Xiaoyao Li
2024-10-10 10:36     ` Tony Lindgren
     [not found] ` <20240812224820.34826-24-rick.p.edgecombe@intel.com>
2024-09-10 17:33   ` [PATCH 23/25] KVM: x86/mmu: Taking guest pa into consideration when calculate tdp level Paolo Bonzini
     [not found] ` <20240812224820.34826-25-rick.p.edgecombe@intel.com>
     [not found]   ` <ZsLR8RxAsTT8yTUo@yilunxu-OptiPlex-7050>
2024-09-03  7:51     ` [PATCH 24/25] KVM: x86: Filter directly configurable TDX CPUID bits Tony Lindgren
2024-09-10 17:36   ` Paolo Bonzini
     [not found] ` <20240812224820.34826-26-rick.p.edgecombe@intel.com>
2024-09-10 17:52   ` [PATCH 25/25] KVM: x86: Add CPUID bits missing from KVM_GET_SUPPORTED_CPUID Paolo Bonzini
2024-09-12  7:48     ` Xiaoyao Li
2024-09-12 14:09       ` Paolo Bonzini
2024-09-12 14:45         ` Xiaoyao Li
2024-09-12 14:48           ` Paolo Bonzini
2024-09-12 15:26             ` Xiaoyao Li
2024-09-12 16:42             ` Sean Christopherson
2024-09-12 18:29               ` Paolo Bonzini
2024-09-12 18:41                 ` Sean Christopherson
2024-09-13  3:54                   ` Xiaoyao Li
2024-09-12 18:42                 ` Edgecombe, Rick P
2024-09-13  3:57               ` Xiaoyao Li
2024-09-12 15:07         ` Edgecombe, Rick P
2024-09-12 15:37           ` Paolo Bonzini
2024-09-12 16:38             ` Edgecombe, Rick P
     [not found] ` <20240812224820.34826-13-rick.p.edgecombe@intel.com>
     [not found]   ` <ZsKdFu9KTdoLJEBV@linux.bj.intel.com>
2024-08-30  8:53     ` [PATCH 12/25] KVM: TDX: Allow userspace to configure maximum vCPUs for TDX guests Tony Lindgren
2024-09-30  2:14   ` Xiaoyao Li
     [not found] ` <20240812224820.34826-22-rick.p.edgecombe@intel.com>
     [not found]   ` <a52010f2-d71c-47ee-aa56-b74fd716ec7b@suse.com>
     [not found]     ` <2f9dd848f8ea5092a206906aa99928c2fa47389d.camel@intel.com>
     [not found]       ` <40fe0a1d-9ab8-4662-a781-002d70a1587b@suse.com>
2024-08-27 20:40         ` [PATCH 21/25] KVM: x86: Introduce KVM_TDX_GET_CPUID Edgecombe, Rick P
     [not found]   ` <ZsK1JRf1amTEAW6q@linux.bj.intel.com>
2024-09-03  6:21     ` Tony Lindgren
2024-09-10 17:27       ` Paolo Bonzini
     [not found]   ` <ZsLRyk5F9SRgafIO@yilunxu-OptiPlex-7050>
2024-09-03  7:19     ` Tony Lindgren
2024-09-10 17:29       ` Paolo Bonzini
2024-09-11 11:11         ` Tony Lindgren
2024-09-30  6:26   ` Xiaoyao Li
2024-09-30 16:22     ` Edgecombe, Rick P

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=Ztl6bg2vfah35Zlj@tlindgre-MOBL1 \
    --to=tony.lindgren@linux.intel.com \
    --cc=chenyi.qiang@intel.com \
    --cc=isaku.yamahata@gmail.com \
    --cc=isaku.yamahata@intel.com \
    --cc=kai.huang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=xiaoyao.li@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