[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f3cb69d2b7558403f2798631ad67bea2e0d95a2f.camel@intel.com>
Date: Tue, 14 Feb 2023 21:02:18 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "peterz@...radead.org" <peterz@...radead.org>
CC: "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"Hansen, Dave" <dave.hansen@...el.com>,
"Luck, Tony" <tony.luck@...el.com>,
"david@...hat.com" <david@...hat.com>,
"ak@...ux.intel.com" <ak@...ux.intel.com>,
"Wysocki, Rafael J" <rafael.j.wysocki@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Christopherson,, Sean" <seanjc@...gle.com>,
"Chatre, Reinette" <reinette.chatre@...el.com>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"Yamahata, Isaku" <isaku.yamahata@...el.com>,
"kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"bagasdotme@...il.com" <bagasdotme@...il.com>,
"Shahar, Sagi" <sagis@...gle.com>,
"imammedo@...hat.com" <imammedo@...hat.com>,
"Gao, Chao" <chao.gao@...el.com>,
"Brown, Len" <len.brown@...el.com>,
"sathyanarayanan.kuppuswamy@...ux.intel.com"
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
"Huang, Ying" <ying.huang@...el.com>,
"Williams, Dan J" <dan.j.williams@...el.com>
Subject: Re: [PATCH v9 05/18] x86/virt/tdx: Add SEAMCALL infrastructure
On Tue, 2023-02-14 at 13:42 +0100, Peter Zijlstra wrote:
> On Tue, Feb 14, 2023 at 12:59:12AM +1300, Kai Huang wrote:
> > +/*
> > + * Wrapper of __seamcall() to convert SEAMCALL leaf function error code
> > + * to kernel error code. @seamcall_ret and @out contain the SEAMCALL
> > + * leaf function return code and the additional output respectively if
> > + * not NULL.
> > + */
> > +static int __always_unused seamcall(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9,
> > + u64 *seamcall_ret,
> > + struct tdx_module_output *out)
> > +{
> > + int cpu, ret = 0;
> > + u64 sret;
> > +
> > + /* Need a stable CPU id for printing error message */
> > + cpu = get_cpu();
> > +
> > + sret = __seamcall(fn, rcx, rdx, r8, r9, out);
> > +
> > + /* Save SEAMCALL return code if the caller wants it */
> > + if (seamcall_ret)
> > + *seamcall_ret = sret;
> > +
> > + /* SEAMCALL was successful */
> > + if (!sret)
> > + goto out;
>
> I'm thinking you want if (likely(!sret)), here. That whole switch thing
> should end up in cold storage.
>
Thanks Peter. Will do.
> > +
> > + switch (sret) {
> > + case TDX_SEAMCALL_GP:
> > + /*
> > + * tdx_enable() has already checked that BIOS has
> > + * enabled TDX at the very beginning before going
> > + * forward. It's likely a firmware bug if the
> > + * SEAMCALL still caused #GP.
> > + */
> > + pr_err_once("[firmware bug]: TDX is not enabled by BIOS.\n");
> > + ret = -ENODEV;
> > + break;
> > + case TDX_SEAMCALL_VMFAILINVALID:
> > + pr_err_once("TDX module is not loaded.\n");
> > + ret = -ENODEV;
> > + break;
> > + case TDX_SEAMCALL_UD:
> > + pr_err_once("SEAMCALL failed: CPU %d is not in VMX operation.\n",
> > + cpu);
> > + ret = -EINVAL;
> > + break;
> > + default:
> > + pr_err_once("SEAMCALL failed: CPU %d: leaf %llu, error 0x%llx.\n",
> > + cpu, fn, sret);
> > + if (out)
> > + pr_err_once("additional output: rcx 0x%llx, rdx 0x%llx, r8 0x%llx, r9 0x%llx, r10 0x%llx, r11 0x%llx.\n",
> > + out->rcx, out->rdx, out->r8,
> > + out->r9, out->r10, out->r11);
> > + ret = -EIO;
> > + }
> > +out:
> > + put_cpu();
> > + return ret;
> > +}
>
Powered by blists - more mailing lists