linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Makhalov <alexey.makhalov@broadcom.com>
To: "H. Peter Anvin" <hpa@zytor.com>,
	Dave Hansen <dave.hansen@intel.com>,
	linux-kernel@vger.kernel.org, virtualization@lists.linux.dev,
	bp@alien8.de, dave.hansen@linux.intel.com, mingo@redhat.com,
	tglx@linutronix.de
Cc: x86@kernel.org, netdev@vger.kernel.org, richardcochran@gmail.com,
	linux-input@vger.kernel.org, dmitry.torokhov@gmail.com,
	zackr@vmware.com, linux-graphics-maintainer@vmware.com,
	pv-drivers@vmware.com, namit@vmware.com, timothym@vmware.com,
	akaher@vmware.com, jsipek@vmware.com,
	dri-devel@lists.freedesktop.org, daniel@ffwll.ch,
	airlied@gmail.com, tzimmermann@suse.de, mripard@kernel.org,
	maarten.lankhorst@linux.intel.com, horms@kernel.org,
	kirill.shutemov@linux.intel.com
Subject: Re: [PATCH v6 7/7] x86/vmware: Add TDX hypercall support
Date: Mon, 22 Jan 2024 16:04:33 -0800	[thread overview]
Message-ID: <c01cecef-db06-49d8-aa2e-548908c65861@broadcom.com> (raw)
In-Reply-To: <4CF87BC4-E8C8-4584-A275-5A985D5A18A1@zytor.com>



On 1/22/24 10:28 AM, H. Peter Anvin wrote:
> On January 22, 2024 8:32:22 AM PST, Dave Hansen <dave.hansen@intel.com> wrote:
>> On 1/9/24 00:40, Alexey Makhalov wrote:
>>> +#ifdef CONFIG_INTEL_TDX_GUEST
>>> +unsigned long vmware_tdx_hypercall(unsigned long cmd,
>>> +				   struct tdx_module_args *args)
>>> +{
>>> +	if (!hypervisor_is_type(X86_HYPER_VMWARE))
>>> +		return ULONG_MAX;
>>> +
>>> +	if (cmd & ~VMWARE_CMD_MASK) {
>>> +		pr_warn_once("Out of range command %lx\n", cmd);
>>> +		return ULONG_MAX;
>>> +	}
>>> +
>>> +	args->r10 = VMWARE_TDX_VENDOR_LEAF;
>>> +	args->r11 = VMWARE_TDX_HCALL_FUNC;
>>> +	args->r12 = VMWARE_HYPERVISOR_MAGIC;
>>> +	args->r13 = cmd;
>>> +	args->r15 = 0; /* CPL */
>>> +
>>> +	__tdx_hypercall(args);
>>> +
>>> +	return args->r12;
>>> +}
>>> +EXPORT_SYMBOL_GPL(vmware_tdx_hypercall);
>>> +#endif
>>
>> This is the kind of wrapper that I was hoping for.  Thanks.
>>
>> Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
>>
> 
> I'm slightly confused by this TBH.
> 
> Why are the arguments passed in as a structure, which is modified by the wrapper to boot? This is analogous to a system call interface.
> 
> Furthermore, this is an out-of-line function; it should never be called with !X86_HYPER_VMWARE or you are introducing overhead for other hypervisors; I believe a pr_warn_once() is in order at least, just as you have for the out-of-range test.
> 

This patch series introduces vmware_hypercall family of functions 
similar to kvm_hypercall. Similarity: both vmware and kvm 
implementations are static inline functions and both of them use 
__tdx_hypercall (global not exported symbol). Difference: kvm_hypercall 
functions are used _only_ within the kernel, but vmware_hypercall are 
also used by modules.
Exporting __tdx_hypercall function is an original Dave's concern.
So we ended up with exporting wrapper, not generic, but VMware specific 
with added checks against arbitrary use.
vmware_tdx_hypercall is not designed for !X86_HYPER_VMWARE callers. But 
such a calls are not forbidden.
Arguments in a structure is an API for __tdx_hypercall(). Input and 
output argument handling are done by vmware_hypercall callers, while 
VMware specific dress up is inside the wrapper.

Peter, do you think code comments are required to make it clear for the 
reader?



  reply	other threads:[~2024-01-23  0:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09  8:40 [PATCH v6 0/7] VMware hypercalls enhancements Alexey Makhalov
2024-01-09  8:40 ` [PATCH v6 1/7] x86/vmware: Move common macros to vmware.h Alexey Makhalov
2024-01-09  8:40 ` [PATCH v6 2/7] x86/vmware: Introduce VMware hypercall API Alexey Makhalov
2024-01-09  8:40 ` [PATCH v6 3/7] ptp/vmware: Use " Alexey Makhalov
2024-01-09  8:40 ` [PATCH v6 4/7] input/vmmouse: " Alexey Makhalov
2024-01-09  8:40 ` [PATCH v6 5/7] drm/vmwgfx: " Alexey Makhalov
2024-01-09  8:40 ` [PATCH v6 6/7] x86/vmware: Undefine VMWARE_HYPERCALL Alexey Makhalov
2024-01-09  8:40 ` [PATCH v6 7/7] x86/vmware: Add TDX hypercall support Alexey Makhalov
2024-01-22 16:32   ` Dave Hansen
2024-01-22 18:28     ` H. Peter Anvin
2024-01-23  0:04       ` Alexey Makhalov [this message]
2024-01-23  0:17         ` H. Peter Anvin
2024-01-26  0:55           ` Alexey Makhalov
2024-01-09 10:21 ` [PATCH v6 0/7] VMware hypercalls enhancements Borislav Petkov

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=c01cecef-db06-49d8-aa2e-548908c65861@broadcom.com \
    --to=alexey.makhalov@broadcom.com \
    --cc=airlied@gmail.com \
    --cc=akaher@vmware.com \
    --cc=bp@alien8.de \
    --cc=daniel@ffwll.ch \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=horms@kernel.org \
    --cc=hpa@zytor.com \
    --cc=jsipek@vmware.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-graphics-maintainer@vmware.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mingo@redhat.com \
    --cc=mripard@kernel.org \
    --cc=namit@vmware.com \
    --cc=netdev@vger.kernel.org \
    --cc=pv-drivers@vmware.com \
    --cc=richardcochran@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=timothym@vmware.com \
    --cc=tzimmermann@suse.de \
    --cc=virtualization@lists.linux.dev \
    --cc=x86@kernel.org \
    --cc=zackr@vmware.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;
as well as URLs for NNTP newsgroup(s).