linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Thomas Hellström (VMware)" <thomas_os@shipmail.org>
To: linux-kernel@vger.kernel.org, pv-drivers@vmware.com
Cc: Thomas Hellstrom <thellstrom@vmware.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Doug Covelli <dcovelli@vmware.com>
Subject: [PATCH 2/4] x86/vmware: Add a header file for hypercall definitions
Date: Sun, 18 Aug 2019 16:33:14 +0200	[thread overview]
Message-ID: <20190818143316.4906-3-thomas_os@shipmail.org> (raw)
In-Reply-To: <20190818143316.4906-1-thomas_os@shipmail.org>

From: Thomas Hellstrom <thellstrom@vmware.com>

This is intended to be used by drivers using the backdoor, and
we follow the kvm example using alternatives self-patching to
choose between vmcall, vmmcall and inl instructions.

This patch defines two new x86 cpu feature flags.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: <x86@kernel.org>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Doug Covelli <dcovelli@vmware.com>
---
 MAINTAINERS                        |  1 +
 arch/x86/include/asm/cpufeatures.h |  2 ++
 arch/x86/include/asm/vmware.h      | 13 +++++++++++++
 3 files changed, 16 insertions(+)
 create mode 100644 arch/x86/include/asm/vmware.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 1bd7b9c2d146..412206747270 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17203,6 +17203,7 @@ M:	"VMware, Inc." <pv-drivers@vmware.com>
 L:	virtualization@lists.linux-foundation.org
 S:	Supported
 F:	arch/x86/kernel/cpu/vmware.c
+F:	arch/x86/include/asm/vmware.h
 
 VMWARE PVRDMA DRIVER
 M:	Adit Ranadive <aditr@vmware.com>
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 998c2cc08363..69cecc3bc9cb 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -232,6 +232,8 @@
 #define X86_FEATURE_VMMCALL		( 8*32+15) /* Prefer VMMCALL to VMCALL */
 #define X86_FEATURE_XENPV		( 8*32+16) /* "" Xen paravirtual guest */
 #define X86_FEATURE_EPT_AD		( 8*32+17) /* Intel Extended Page Table access-dirty bit */
+#define X86_FEATURE_VMW_VMCALL		( 8*32+18) /* VMware prefers VMCALL hypercall instruction */
+#define X86_FEATURE_VMW_VMMCALL		( 8*32+19) /* VMware prefers VMMCALL hypercall instruction */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
 #define X86_FEATURE_FSGSBASE		( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
diff --git a/arch/x86/include/asm/vmware.h b/arch/x86/include/asm/vmware.h
new file mode 100644
index 000000000000..22d2dbfba90f
--- /dev/null
+++ b/arch/x86/include/asm/vmware.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 or MIT */
+#ifndef _ASM_X86_VMWARE_H
+#define _ASM_X86_VMWARE_H
+
+#include <asm/cpufeatures.h>
+#include <asm/alternative.h>
+
+#define VMWARE_HYPERCALL \
+	ALTERNATIVE_2(".byte 0xed", \
+		      ".byte 0x0f, 0x01, 0xc1", X86_FEATURE_VMW_VMCALL,	\
+		      ".byte 0x0f, 0x01, 0xd9", X86_FEATURE_VMW_VMMCALL)
+
+#endif
-- 
2.20.1


  parent reply	other threads:[~2019-08-18 14:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-18 14:33 [PATCH 0/4] Add support for updated vmware hypercall instruction Thomas Hellström (VMware)
2019-08-18 14:33 ` [PATCH 1/4] x86/vmware: Update platform detection code for VMCALL/VMMCALL hypercalls Thomas Hellström (VMware)
2019-08-18 19:20   ` Thomas Gleixner
2019-08-18 19:46     ` Thomas Hellström (VMware)
2019-08-20 17:18     ` [Pv-drivers] " Darren Hart
2019-08-18 14:33 ` Thomas Hellström (VMware) [this message]
2019-08-18 20:19   ` [PATCH 2/4] x86/vmware: Add a header file for hypercall definitions Borislav Petkov
2019-08-18 20:39     ` Borislav Petkov
2019-08-18 22:28     ` Thomas Hellström (VMware)
2019-08-19  6:25       ` Borislav Petkov
2019-08-19  7:49         ` Thomas Hellström (VMware)
2019-08-20 11:32   ` Peter Zijlstra
2019-08-20 13:34     ` Thomas Hellström (VMware)
2019-08-20 13:42       ` Thomas Gleixner
2019-08-20 19:19         ` Thomas Hellström (VMware)
2019-08-20 19:23           ` Thomas Gleixner
2019-08-18 14:33 ` [PATCH 3/4] drm/vmwgfx: Update the backdoor call with support for new instructions Thomas Hellström (VMware)
2019-08-18 14:33 ` [PATCH 4/4] input/vmmouse: " Thomas Hellström (VMware)
2019-08-21  5:09   ` Dmitry Torokhov
2019-08-21 15:48     ` Thomas Hellström (VMware)
2019-08-21 16:03       ` Dmitry Torokhov
2019-08-18 18:09 ` [PATCH 0/4] Add support for updated vmware hypercall instruction Borislav Petkov
2019-08-18 19:02   ` Thomas Hellström (VMware)
2019-08-18 19:37     ` 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=20190818143316.4906-3-thomas_os@shipmail.org \
    --to=thomas_os@shipmail.org \
    --cc=bp@alien8.de \
    --cc=dcovelli@vmware.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pv-drivers@vmware.com \
    --cc=tglx@linutronix.de \
    --cc=thellstrom@vmware.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;
as well as URLs for NNTP newsgroup(s).