[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211006202630.chblrhdqepsbtdaa@treble>
Date: Wed, 6 Oct 2021 13:26:30 -0700
From: Josh Poimboeuf <jpoimboe@...hat.com>
To: Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
x86@...nel.org, Paolo Bonzini <pbonzini@...hat.com>,
David Hildenbrand <david@...hat.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Juergen Gross <jgross@...e.com>, Deep Shah <sdeep@...are.com>,
VMware Inc <pv-drivers@...are.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>, Peter H Anvin <hpa@...or.com>,
Dave Hansen <dave.hansen@...el.com>,
Tony Luck <tony.luck@...el.com>,
Dan Williams <dan.j.williams@...el.com>,
Andi Kleen <ak@...ux.intel.com>,
Kirill Shutemov <kirill.shutemov@...ux.intel.com>,
Sean Christopherson <seanjc@...gle.com>,
Kuppuswamy Sathyanarayanan <knsathya@...nel.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8 11/11] x86/tdx: Handle CPUID via #VE
On Mon, Oct 04, 2021 at 07:52:05PM -0700, Kuppuswamy Sathyanarayanan wrote:
> +static u64 tdx_handle_cpuid(struct pt_regs *regs)
> +{
> + struct tdx_hypercall_output out = {0};
> + u64 ret;
> +
> + /*
> + * Emulate CPUID instruction via hypercall. More info about
> + * ABI can be found in TDX Guest-Host-Communication Interface
> + * (GHCI), section titled "VP.VMCALL<Instruction.CPUID>".
> + */
> + ret = _tdx_hypercall(EXIT_REASON_CPUID, regs->ax, regs->cx, 0, 0, &out);
> +
> + /*
> + * As per TDX GHCI CPUID ABI, r12-r15 registers contains contents of
> + * EAX, EBX, ECX, EDX registers after CPUID instruction execution.
> + * So copy the register contents back to pt_regs.
> + */
> + regs->ax = out.r12;
> + regs->bx = out.r13;
> + regs->cx = out.r14;
> + regs->dx = out.r15;
Does it still make sense to save the regs if _tdx_hypercall() returns an
error?
> +
> + return ret;
Also I'm wondering about error handling for all these _tdx_hypercall()
wrapper functions which are called by the #VE handler.
First, there are some inconsistencies in whether and how they return the
r10 error.
- _tdx_halt() warns and doesn't return anything.
- tdx_read_msr_safe() and tdx_write_msr_safe() convert all errors to -EIO.
- tdx_handle_cpuid() returns the raw vmcall error.
Second, as far as I can tell, the #VE handler doesn't check the actual
return code value, other than checking for non-zero. Should it at least
be printed in a warning?
--
Josh
Powered by blists - more mailing lists