public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	mingo@redhat.com, bp@alien8.de, dave.hansen@intel.com,
	luto@kernel.org, peterz@infradead.org
Cc: sathyanarayanan.kuppuswamy@linux.intel.com, aarcange@redhat.com,
	ak@linux.intel.com, dan.j.williams@intel.com, david@redhat.com,
	hpa@zytor.com, jgross@suse.com, jmattson@google.com,
	joro@8bytes.org, jpoimboe@redhat.com, knsathya@kernel.org,
	pbonzini@redhat.com, sdeep@vmware.com, seanjc@google.com,
	tony.luck@intel.com, vkuznets@redhat.com, wanpengli@tencent.com,
	thomas.lendacky@amd.com, brijesh.singh@amd.com, x86@kernel.org,
	linux-kernel@vger.kernel.org,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Dave Hansen <dave.hansen@linux.intel.com>
Subject: Re: [PATCHv6 02/30] x86/tdx: Provide common base for SEAMCALL and TDCALL C wrappers
Date: Thu, 17 Mar 2022 00:33:58 +0100	[thread overview]
Message-ID: <87lex9321l.ffs@tglx> (raw)
In-Reply-To: <20220316020856.24435-3-kirill.shutemov@linux.intel.com>

Kirrill,

On Wed, Mar 16 2022 at 05:08, Kirill A. Shutemov wrote:
> Define an assembly macro that can be used to implement C wrapper for
> both TDCALL and SEAMCALL.
>

> TDCALL wrapper will be implemented using the macro later in the series.
> SEAMCALL wrapper is out-of-scope for the series and will be implemented
> as part of TDX host enabling.

This paragraph makes no sense in the changelog once it's merged. That's
a reviewer/maintainer info which wants to be below the ---

> +/*
> + * TDX_MODULE_CALL - common helper macro for both
> + *                 TDCALL and SEAMCALL instructions.
> + *
> + * TDCALL   - used by TDX guests to make requests to the
> + *            TDX module and hypercalls to the VMM.
> + * SEAMCALL - used by TDX hosts to make requests to the
> + *            TDX module.
> + *
> + * Both instruction are supported in Binutils >= 2.36.
> + */
> +#define tdcall		.byte 0x66,0x0f,0x01,0xcc
> +#define seamcall	.byte 0x66,0x0f,0x01,0xcf

Bah. I really hate this #define glue. The comment documents
TDX_MODULE_CALL. The defines for the instructions are a seperate
problem. So please move them above the whole thing with their own
comment.

> +.macro TDX_MODULE_CALL host:req
> +	/*
> +	 * R12 will be used as temporary storage for struct tdx_module_output
> +	 * pointer. Since R12-R15 registers are not used by TDCALL/SEAMCALL
> +	 * services supported by this function, it can be reused.
> +	 */
> +
> +	/* Callee saved, so preserve it */
> +	push %r12
> +
> +	/*
> +	 * Push output pointer to stack.
> +	 * After the operation, it will be fetched into R12 register.
> +	 */
> +	push %r9
> +
> +	/* Mangle function call ABI into TDCALL/SEAMCALL ABI: */
> +	/* Move Leaf ID to RAX */
> +	mov %rdi, %rax
> +	/* Move input 4 to R9 */
> +	mov %r8,  %r9
> +	/* Move input 3 to R8 */
> +	mov %rcx, %r8
> +	/* Move input 1 to RCX */
> +	mov %rsi, %rcx
> +	/* Leave input param 2 in RDX */
> +
> +	.if \host
> +	seamcall
> +	/*
> +	 * SEAMCALL instruction is essentially a VMExit from VMX root
> +	 * mode to SEAM VMX root mode.  VMfailInvalid (CF=1) indicates
> +	 * that the targeted SEAM firmware is not loaded or disabled,
> +	 * or P-SEAMLDR is busy with another SEAMCALL.  %rax is not
> +	 * changed in this case.
> +	 *
> +	 * Set %rax to TDX_SEAMCALL_VMFAILINVALID for VMfailInvalid.
> +	 * This value will never be used as actual SEAMCALL error code as
> +	 * it is from the Reserved status code class.
> +	 */
> +	jnc .Lno_vmfailinvalid
> +	mov $TDX_SEAMCALL_VMFAILINVALID, %rax
> +.Lno_vmfailinvalid:

Please add a new line between the label and the .else for readability sake.

> +	.else
> +	tdcall
> +	.endif
> +
> +	/*
> +	 * Fetch output pointer from stack to R12 (It is used
> +	 * as temporary storage)
> +	 */
> +	pop %r12
> +
> +	/*
> +	 * Since this function can be initiated without an output pointer,
> +	 * check if caller provided an output struct before storing output
> +	 * registers.

The function is a macro. It's not initiated, it's invoked. It always has
an output pointer in R12, but that can be NULL.

With those nitpicks addressed:

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

  reply	other threads:[~2022-03-16 23:34 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16  2:08 [PATCHv6 00/30] TDX Guest: TDX core support Kirill A. Shutemov
2022-03-16  2:08 ` [PATCHv6 01/30] x86/tdx: Detect running as a TDX guest in early boot Kirill A. Shutemov
2022-03-16 23:10   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 02/30] x86/tdx: Provide common base for SEAMCALL and TDCALL C wrappers Kirill A. Shutemov
2022-03-16 23:33   ` Thomas Gleixner [this message]
2022-03-16  2:08 ` [PATCHv6 03/30] x86/tdx: Add __tdx_module_call() and __tdx_hypercall() helper functions Kirill A. Shutemov
2022-03-16 23:43   ` Thomas Gleixner
2022-03-17 16:03   ` Borislav Petkov
2022-03-16  2:08 ` [PATCHv6 04/30] x86/tdx: Extend the confidential computing API to support TDX guests Kirill A. Shutemov
2022-03-17  0:01   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 05/30] x86/tdx: Exclude shared bit from __PHYSICAL_MASK Kirill A. Shutemov
2022-03-17  0:16   ` Thomas Gleixner
2022-03-17 13:58     ` Kirill A. Shutemov
2022-03-17 14:39       ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 06/30] x86/traps: Refactor exc_general_protection() Kirill A. Shutemov
2022-03-17  0:21   ` Thomas Gleixner
2022-03-17 14:05     ` Kirill A. Shutemov
2022-03-16  2:08 ` [PATCHv6 07/30] x86/traps: Add #VE support for TDX guest Kirill A. Shutemov
2022-03-17  0:48   ` Thomas Gleixner
2022-03-17 17:33     ` Kirill A. Shutemov
2022-03-17 18:18       ` Thomas Gleixner
2022-03-17 20:21       ` Peter Zijlstra
2022-03-17 20:32         ` Dave Hansen
2022-03-18 10:55           ` Peter Zijlstra
2022-03-18 13:03             ` Kirill A. Shutemov
2022-03-18 14:19         ` Thomas Gleixner
2022-03-18 15:34           ` Kirill A. Shutemov
2022-03-16  2:08 ` [PATCHv6 08/30] x86/tdx: Add HLT support for TDX guests Kirill A. Shutemov
2022-03-16  2:08 ` [PATCHv6 09/30] x86/tdx: Add MSR " Kirill A. Shutemov
2022-03-17 11:30   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 10/30] x86/tdx: Handle CPUID via #VE Kirill A. Shutemov
2022-03-17 11:32   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 11/30] x86/tdx: Handle in-kernel MMIO Kirill A. Shutemov
2022-03-16 21:53   ` Dave Hansen
2022-03-17 11:48     ` Thomas Gleixner
2022-03-17 11:35   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 12/30] x86/tdx: Detect TDX at early kernel decompression time Kirill A. Shutemov
2022-03-17 11:55   ` Thomas Gleixner
2022-03-17 18:04     ` Kirill A. Shutemov
2022-03-16  2:08 ` [PATCHv6 13/30] x86: Adjust types used in port I/O helpers Kirill A. Shutemov
2022-03-17 11:56   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 14/30] x86: Consolidate " Kirill A. Shutemov
2022-03-16  2:08 ` [PATCHv6 15/30] x86/boot: Port I/O: allow to hook up alternative helpers Kirill A. Shutemov
2022-03-16 22:02   ` Dave Hansen
2022-03-17 12:12   ` Thomas Gleixner
2022-03-17 20:10     ` Kirill A. Shutemov
2022-03-17 20:20       ` Dave Hansen
2022-03-17 20:23         ` Dave Hansen
2022-03-17 22:48           ` Kirill A. Shutemov
2022-03-18 14:20       ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 16/30] x86/boot: Port I/O: add decompression-time support for TDX Kirill A. Shutemov
2022-03-17 12:15   ` Thomas Gleixner
2022-03-17 20:15     ` Kirill A. Shutemov
2022-03-18 14:28       ` Thomas Gleixner
2022-03-18 15:36         ` Kirill A. Shutemov
2022-03-16  2:08 ` [PATCHv6 17/30] x86/tdx: Port I/O: add runtime hypercalls Kirill A. Shutemov
2022-03-17 12:25   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 18/30] x86/tdx: Port I/O: add early boot support Kirill A. Shutemov
2022-03-16  2:08 ` [PATCHv6 19/30] x86/tdx: Wire up KVM hypercalls Kirill A. Shutemov
2022-03-16  2:08 ` [PATCHv6 20/30] x86/boot: Add a trampoline for booting APs via firmware handoff Kirill A. Shutemov
2022-03-17 12:32   ` Thomas Gleixner
2022-03-17 12:44   ` Boris Petkov
2022-03-17 20:21     ` Kirill A. Shutemov
2022-03-18  9:55       ` Borislav Petkov
2022-03-16  2:08 ` [PATCHv6 21/30] x86/acpi, x86/boot: Add multiprocessor wake-up support Kirill A. Shutemov
2022-03-16 23:47   ` Dave Hansen
2022-03-17 12:44   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 22/30] x86/boot: Set CR0.NE early and keep it set during the boot Kirill A. Shutemov
2022-03-17 12:46   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 23/30] x86/boot: Avoid #VE during boot for TDX platforms Kirill A. Shutemov
2022-03-17 12:48   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 24/30] x86/topology: Disable CPU online/offline control for TDX guests Kirill A. Shutemov
2022-03-17 12:50   ` Thomas Gleixner
2022-03-17 20:47     ` Kirill A. Shutemov
2022-03-16  2:08 ` [PATCHv6 25/30] x86/tdx: Make pages shared in ioremap() Kirill A. Shutemov
2022-03-16 22:06   ` Dave Hansen
2022-03-17 14:33   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 26/30] x86/mm/cpa: Add support for TDX shared memory Kirill A. Shutemov
2022-03-17 14:56   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 27/30] x86/kvm: Make SWIOTLB buffer shared for TD guest Kirill A. Shutemov
2022-03-16 22:24   ` Dave Hansen
2022-03-16  2:08 ` [PATCHv6 28/30] x86/tdx: ioapic: Add shared bit for IOAPIC base address Kirill A. Shutemov
2022-03-17 15:00   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 29/30] ACPICA: Avoid cache flush inside virtual machines Kirill A. Shutemov
2022-03-16 22:13   ` Dave Hansen
2022-03-17 15:32     ` Dan Williams
2022-03-17 23:04     ` Kirill A. Shutemov
2022-03-17 15:23   ` Thomas Gleixner
2022-03-16  2:08 ` [PATCHv6 30/30] Documentation/x86: Document TDX kernel architecture Kirill A. Shutemov

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=87lex9321l.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=aarcange@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=brijesh.singh@amd.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=david@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=jpoimboe@redhat.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=knsathya@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=sdeep@vmware.com \
    --cc=seanjc@google.com \
    --cc=thomas.lendacky@amd.com \
    --cc=tony.luck@intel.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /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