From patchwork Fri Aug 23 08:13:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28Intel=29?= X-Patchwork-Id: 11110943 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6BBDD112C for ; Fri, 23 Aug 2019 08:13:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5420D22CEC for ; Fri, 23 Aug 2019 08:13:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5420D22CEC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 445886EC06; Fri, 23 Aug 2019 08:13:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pio-pvt-msa3.bahnhof.se (pio-pvt-msa3.bahnhof.se [79.136.2.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFBB66EC06 for ; Fri, 23 Aug 2019 08:13:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTP id 7872D3F2EF; Fri, 23 Aug 2019 10:13:48 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from pio-pvt-msa3.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa3.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XVTpd7kfe3Gs; Fri, 23 Aug 2019 10:13:47 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTPA id 1206E3F6E1; Fri, 23 Aug 2019 10:13:47 +0200 (CEST) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 9804A3601BA; Fri, 23 Aug 2019 10:13:45 +0200 (CEST) From: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28VMware=29?= To: linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] x86/vmware: Add a header file for hypercall definitions Date: Fri, 23 Aug 2019 10:13:14 +0200 Message-Id: <20190823081316.28478-3-thomas_os@shipmail.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190823081316.28478-1-thomas_os@shipmail.org> References: <20190823081316.28478-1-thomas_os@shipmail.org> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1566548026; bh=WtBbkNnAMop3WDhawZXyUZUBZ0lCBoFyNp4umI0liy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rgi+8dxtMyysJll6ti+xzZFdY8tFBArn/BiOEdfGEdArJy1KGP3JiCiDqq9Y6V/Yr nmfsKFJJ9t8APzD9QZ1AkymG1bjzhyM/IOIdJwPeOH3F+0Y7nHDeBO9Fo8FVIf8exj p7xwOiByuwuHwXKMCNnnL2PfX7a0xy7pPwyzsFeY= X-Mailman-Original-Authentication-Results: pio-pvt-msa3.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=Rgi+8dxt; dkim-atps=neutral X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Hellstrom , pv-drivers@vmware.com, x86@kernel.org, dri-devel@lists.freedesktop.org, Doug Covelli , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-graphics-maintainer@vmware.com, Thomas Gleixner Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thomas Hellstrom The new header is intended to be used by drivers using the backdoor. Follow the kvm example using alternatives self-patching to choose between vmcall, vmmcall and io instructions. Also define two new CPU feature flags to indicate hypervisor support for vmcall- and vmmcall instructions. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Cc: Signed-off-by: Thomas Hellstrom Reviewed-by: Doug Covelli --- MAINTAINERS | 1 + arch/x86/include/asm/cpufeatures.h | 2 ++ arch/x86/include/asm/vmware.h | 48 ++++++++++++++++++++++++++++++ arch/x86/kernel/cpu/vmware.c | 6 +++- 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 arch/x86/include/asm/vmware.h diff --git a/MAINTAINERS b/MAINTAINERS index c2d975da561f..5bf65a49fa19 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17203,6 +17203,7 @@ M: "VMware, Inc." 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 diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 998c2cc08363..55fa3b3f0bac 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_VMCALL ( 8*32+18) /* "" Hypervisor supports the VMCALL 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..4b220e2bb3e8 --- /dev/null +++ b/arch/x86/include/asm/vmware.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0 or MIT */ +#ifndef _ASM_X86_VMWARE_H +#define _ASM_X86_VMWARE_H + +#include +#include + +/* + * The hypercall definitions differ in the low word of the edx argument in + * the following way: The old port base interface uses the port number to + * distinguish between high- and low bandwidth versions. The new vmcall + * interface instead uses a set of flags to select bandwidth mode and + * transfer direction. New driver code should strictly use the new + * definition of edx content. + */ + +/* Old port-based version */ +#define VMWARE_HYPERVISOR_PORT "0x5658" +#define VMWARE_HYPERVISOR_PORT_HB "0x5659" + +/* Current vmcall / vmmcall version */ +#define VMWARE_HYPERVISOR_HB BIT(0) +#define VMWARE_HYPERVISOR_OUT BIT(1) + +/* The low bandwidth call. The low word of edx is presumed clear. */ +#define VMWARE_HYPERCALL \ + ALTERNATIVE_2("movw $" VMWARE_HYPERVISOR_PORT ", %%dx; inl (%%dx)", \ + "vmcall", X86_FEATURE_VMCALL, \ + "vmmcall", X86_FEATURE_VMW_VMMCALL) + +/* + * The high bandwidth out call. The low word of edx is presumed to have the + * HB and OUT bits set. + */ +#define VMWARE_HYPERCALL_HB_OUT \ + ALTERNATIVE_2("movw $" VMWARE_HYPERVISOR_PORT_HB ", %%dx; rep outsb", \ + "vmcall", X86_FEATURE_VMCALL, \ + "vmmcall", X86_FEATURE_VMW_VMMCALL) + +/* + * The high bandwidth in call. The low word of edx is presumed to have the + * HB bit set. + */ +#define VMWARE_HYPERCALL_HB_IN \ + ALTERNATIVE_2("movw $" VMWARE_HYPERVISOR_PORT_HB ", %%dx; rep insb", \ + "vmcall", X86_FEATURE_VMCALL, \ + "vmmcall", X86_FEATURE_VMW_VMMCALL) +#endif diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c index fcb84b1e099e..abaa1b27353c 100644 --- a/arch/x86/kernel/cpu/vmware.c +++ b/arch/x86/kernel/cpu/vmware.c @@ -31,6 +31,7 @@ #include #include #include +#include #undef pr_fmt #define pr_fmt(fmt) "vmware: " fmt @@ -41,7 +42,6 @@ #define CPUID_VMWARE_FEATURES_ECX_VMCALL BIT(1) #define VMWARE_HYPERVISOR_MAGIC 0x564D5868 -#define VMWARE_HYPERVISOR_PORT 0x5658 #define VMWARE_CMD_GETVERSION 10 #define VMWARE_CMD_GETHZ 45 @@ -165,6 +165,10 @@ static void __init vmware_set_capabilities(void) { setup_force_cpu_cap(X86_FEATURE_CONSTANT_TSC); setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE); + if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMCALL) + setup_force_cpu_cap(X86_FEATURE_VMCALL); + else if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMMCALL) + setup_force_cpu_cap(X86_FEATURE_VMW_VMMCALL); } static void __init vmware_platform_setup(void) From patchwork Fri Aug 23 08:13:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28Intel=29?= X-Patchwork-Id: 11110941 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 128571399 for ; Fri, 23 Aug 2019 08:13:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EACBD23402 for ; Fri, 23 Aug 2019 08:13:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EACBD23402 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 25D696EC05; Fri, 23 Aug 2019 08:13:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pio-pvt-msa1.bahnhof.se (pio-pvt-msa1.bahnhof.se [79.136.2.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 789A26EC05 for ; Fri, 23 Aug 2019 08:13:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTP id E31043F398; Fri, 23 Aug 2019 10:13:49 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from pio-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0iLQwW2pmq3U; Fri, 23 Aug 2019 10:13:49 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id A749D3F393; Fri, 23 Aug 2019 10:13:48 +0200 (CEST) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id EC9C3360333; Fri, 23 Aug 2019 10:13:46 +0200 (CEST) From: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28VMware=29?= To: linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] drm/vmwgfx: Update the backdoor call with support for new instructions Date: Fri, 23 Aug 2019 10:13:15 +0200 Message-Id: <20190823081316.28478-4-thomas_os@shipmail.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190823081316.28478-1-thomas_os@shipmail.org> References: <20190823081316.28478-1-thomas_os@shipmail.org> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1566548028; bh=dXqFbDvsXRKevM7HS4+7LJ8WrBiTmlMAJGuuYMFPIPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MGSUg4ySYAfDhcDYNYmQY4IuuNKSftmFZkx4ZP0q0brh+Up6r3g802I30Bzp01p5/ Saqy5/ZXbAXqp9AvGnL46jL7UMBiC2PkCQgK1P5z/yccqj3Q9Sr0NVkl+7y3jkJh1R uCecZo8XVg42AZ+s87tTgdHWwAgZ+oOgDiShIHGU= X-Mailman-Original-Authentication-Results: pio-pvt-msa1.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b="MGSUg4yS"; dkim-atps=neutral X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Hellstrom , pv-drivers@vmware.com, x86@kernel.org, dri-devel@lists.freedesktop.org, Doug Covelli , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-graphics-maintainer@vmware.com, Thomas Gleixner Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thomas Hellstrom Use the definition provided by include/asm/vmware.h Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Cc: Signed-off-by: Thomas Hellstrom Reviewed-by: Doug Covelli Acked-by: Dave Airlie --- drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 21 +++++++++-------- drivers/gpu/drm/vmwgfx/vmwgfx_msg.h | 35 +++++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c index 81a86c3b77bc..1281e52898ee 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c @@ -45,8 +45,6 @@ #define RETRIES 3 #define VMW_HYPERVISOR_MAGIC 0x564D5868 -#define VMW_HYPERVISOR_PORT 0x5658 -#define VMW_HYPERVISOR_HB_PORT 0x5659 #define VMW_PORT_CMD_MSG 30 #define VMW_PORT_CMD_HB_MSG 0 @@ -92,7 +90,7 @@ static int vmw_open_channel(struct rpc_channel *channel, unsigned int protocol) VMW_PORT(VMW_PORT_CMD_OPEN_CHANNEL, (protocol | GUESTMSG_FLAG_COOKIE), si, di, - VMW_HYPERVISOR_PORT, + 0, VMW_HYPERVISOR_MAGIC, eax, ebx, ecx, edx, si, di); @@ -125,7 +123,7 @@ static int vmw_close_channel(struct rpc_channel *channel) VMW_PORT(VMW_PORT_CMD_CLOSE_CHANNEL, 0, si, di, - (VMW_HYPERVISOR_PORT | (channel->channel_id << 16)), + channel->channel_id << 16, VMW_HYPERVISOR_MAGIC, eax, ebx, ecx, edx, si, di); @@ -159,7 +157,8 @@ static unsigned long vmw_port_hb_out(struct rpc_channel *channel, VMW_PORT_HB_OUT( (MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG, msg_len, si, di, - VMW_HYPERVISOR_HB_PORT | (channel->channel_id << 16), + VMWARE_HYPERVISOR_HB | (channel->channel_id << 16) | + VMWARE_HYPERVISOR_OUT, VMW_HYPERVISOR_MAGIC, bp, eax, ebx, ecx, edx, si, di); @@ -180,7 +179,7 @@ static unsigned long vmw_port_hb_out(struct rpc_channel *channel, VMW_PORT(VMW_PORT_CMD_MSG | (MSG_TYPE_SENDPAYLOAD << 16), word, si, di, - VMW_HYPERVISOR_PORT | (channel->channel_id << 16), + channel->channel_id << 16, VMW_HYPERVISOR_MAGIC, eax, ebx, ecx, edx, si, di); } @@ -212,7 +211,7 @@ static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply, VMW_PORT_HB_IN( (MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG, reply_len, si, di, - VMW_HYPERVISOR_HB_PORT | (channel->channel_id << 16), + VMWARE_HYPERVISOR_HB | (channel->channel_id << 16), VMW_HYPERVISOR_MAGIC, bp, eax, ebx, ecx, edx, si, di); @@ -229,7 +228,7 @@ static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply, VMW_PORT(VMW_PORT_CMD_MSG | (MSG_TYPE_RECVPAYLOAD << 16), MESSAGE_STATUS_SUCCESS, si, di, - VMW_HYPERVISOR_PORT | (channel->channel_id << 16), + channel->channel_id << 16, VMW_HYPERVISOR_MAGIC, eax, ebx, ecx, edx, si, di); @@ -268,7 +267,7 @@ static int vmw_send_msg(struct rpc_channel *channel, const char *msg) VMW_PORT(VMW_PORT_CMD_SENDSIZE, msg_len, si, di, - VMW_HYPERVISOR_PORT | (channel->channel_id << 16), + channel->channel_id << 16, VMW_HYPERVISOR_MAGIC, eax, ebx, ecx, edx, si, di); @@ -326,7 +325,7 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg, VMW_PORT(VMW_PORT_CMD_RECVSIZE, 0, si, di, - (VMW_HYPERVISOR_PORT | (channel->channel_id << 16)), + channel->channel_id << 16, VMW_HYPERVISOR_MAGIC, eax, ebx, ecx, edx, si, di); @@ -370,7 +369,7 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg, VMW_PORT(VMW_PORT_CMD_RECVSTATUS, MESSAGE_STATUS_SUCCESS, si, di, - (VMW_HYPERVISOR_PORT | (channel->channel_id << 16)), + channel->channel_id << 16, VMW_HYPERVISOR_MAGIC, eax, ebx, ecx, edx, si, di); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.h b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.h index 4907e50fb20a..f685c7071dec 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.h @@ -32,6 +32,7 @@ #ifndef _VMWGFX_MSG_H #define _VMWGFX_MSG_H +#include /** * Hypervisor-specific bi-directional communication channel. Should never @@ -44,7 +45,7 @@ * @in_ebx: [IN] Message Len, through EBX * @in_si: [IN] Input argument through SI, set to 0 if not used * @in_di: [IN] Input argument through DI, set ot 0 if not used - * @port_num: [IN] port number + [channel id] + * @flags: [IN] hypercall flags + [channel id] * @magic: [IN] hypervisor magic value * @eax: [OUT] value of EAX register * @ebx: [OUT] e.g. status from an HB message status command @@ -54,10 +55,10 @@ * @di: [OUT] */ #define VMW_PORT(cmd, in_ebx, in_si, in_di, \ - port_num, magic, \ + flags, magic, \ eax, ebx, ecx, edx, si, di) \ ({ \ - asm volatile ("inl %%dx, %%eax;" : \ + asm volatile (VMWARE_HYPERCALL : \ "=a"(eax), \ "=b"(ebx), \ "=c"(ecx), \ @@ -67,7 +68,7 @@ "a"(magic), \ "b"(in_ebx), \ "c"(cmd), \ - "d"(port_num), \ + "d"(flags), \ "S"(in_si), \ "D"(in_di) : \ "memory"); \ @@ -85,7 +86,7 @@ * @in_ecx: [IN] Message Len, through ECX * @in_si: [IN] Input argument through SI, set to 0 if not used * @in_di: [IN] Input argument through DI, set to 0 if not used - * @port_num: [IN] port number + [channel id] + * @flags: [IN] hypercall flags + [channel id] * @magic: [IN] hypervisor magic value * @bp: [IN] * @eax: [OUT] value of EAX register @@ -98,12 +99,12 @@ #ifdef __x86_64__ #define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \ - port_num, magic, bp, \ + flags, magic, bp, \ eax, ebx, ecx, edx, si, di) \ ({ \ asm volatile ("push %%rbp;" \ "mov %12, %%rbp;" \ - "rep outsb;" \ + VMWARE_HYPERCALL_HB_OUT \ "pop %%rbp;" : \ "=a"(eax), \ "=b"(ebx), \ @@ -114,7 +115,7 @@ "a"(magic), \ "b"(cmd), \ "c"(in_ecx), \ - "d"(port_num), \ + "d"(flags), \ "S"(in_si), \ "D"(in_di), \ "r"(bp) : \ @@ -123,12 +124,12 @@ #define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di, \ - port_num, magic, bp, \ + flags, magic, bp, \ eax, ebx, ecx, edx, si, di) \ ({ \ asm volatile ("push %%rbp;" \ "mov %12, %%rbp;" \ - "rep insb;" \ + VMWARE_HYPERCALL_HB_IN \ "pop %%rbp" : \ "=a"(eax), \ "=b"(ebx), \ @@ -139,7 +140,7 @@ "a"(magic), \ "b"(cmd), \ "c"(in_ecx), \ - "d"(port_num), \ + "d"(flags), \ "S"(in_si), \ "D"(in_di), \ "r"(bp) : \ @@ -157,13 +158,13 @@ * just pushed it. */ #define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \ - port_num, magic, bp, \ + flags, magic, bp, \ eax, ebx, ecx, edx, si, di) \ ({ \ asm volatile ("push %12;" \ "push %%ebp;" \ "mov 0x04(%%esp), %%ebp;" \ - "rep outsb;" \ + VMWARE_HYPERCALL_HB_OUT \ "pop %%ebp;" \ "add $0x04, %%esp;" : \ "=a"(eax), \ @@ -175,7 +176,7 @@ "a"(magic), \ "b"(cmd), \ "c"(in_ecx), \ - "d"(port_num), \ + "d"(flags), \ "S"(in_si), \ "D"(in_di), \ "m"(bp) : \ @@ -184,13 +185,13 @@ #define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di, \ - port_num, magic, bp, \ + flags, magic, bp, \ eax, ebx, ecx, edx, si, di) \ ({ \ asm volatile ("push %12;" \ "push %%ebp;" \ "mov 0x04(%%esp), %%ebp;" \ - "rep insb;" \ + VMWARE_HYPERCALL_HB_IN \ "pop %%ebp;" \ "add $0x04, %%esp;" : \ "=a"(eax), \ @@ -202,7 +203,7 @@ "a"(magic), \ "b"(cmd), \ "c"(in_ecx), \ - "d"(port_num), \ + "d"(flags), \ "S"(in_si), \ "D"(in_di), \ "m"(bp) : \ From patchwork Fri Aug 23 08:13:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28Intel=29?= X-Patchwork-Id: 11110945 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 58594112C for ; Fri, 23 Aug 2019 08:13:59 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 411E722CEC for ; Fri, 23 Aug 2019 08:13:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 411E722CEC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 59AB46EC07; Fri, 23 Aug 2019 08:13:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from ste-pvt-msa1.bahnhof.se (ste-pvt-msa1.bahnhof.se [213.80.101.70]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7A7F06EC06 for ; Fri, 23 Aug 2019 08:13:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTP id 0A61E3F68A; Fri, 23 Aug 2019 10:13:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from ste-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (ste-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T7PH3aOuLSRB; Fri, 23 Aug 2019 10:13:51 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 2BF323F451; Fri, 23 Aug 2019 10:13:51 +0200 (CEST) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 06B6C3601BA; Fri, 23 Aug 2019 10:13:48 +0200 (CEST) From: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28VMware=29?= To: linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] input/vmmouse: Update the backdoor call with support for new instructions Date: Fri, 23 Aug 2019 10:13:16 +0200 Message-Id: <20190823081316.28478-5-thomas_os@shipmail.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190823081316.28478-1-thomas_os@shipmail.org> References: <20190823081316.28478-1-thomas_os@shipmail.org> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1566548030; bh=bf3bgDS7rnVcI3U6BuhcDA3KRvdQihS9aNCGQctW+KM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q/eSAhtK5fOH1WxHIBN7ZKCCbO2XagE1WgIkDHvNQ+NX1Oa34XS4+yJ97+p1hjxTz P44NfsISI+g6WRdU3K9tXV4Dx9P2DF//58T51HnsvKLHA3QjA4c0xNOwWs7p3G8YQF x09Jx2U26C6iGjY0ojOfWWzaza3kDrPHxdy27aqo= X-Mailman-Original-Authentication-Results: ste-pvt-msa1.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=Q/eSAhtK; dkim-atps=neutral X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Hellstrom , Dmitry Torokhov , pv-drivers@vmware.com, x86@kernel.org, dri-devel@lists.freedesktop.org, Doug Covelli , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-graphics-maintainer@vmware.com, Thomas Gleixner Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thomas Hellstrom Use the definition provided by include/asm/vmware.h CC: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Cc: Signed-off-by: Thomas Hellstrom Reviewed-by: Doug Covelli Acked-by: Dmitry Torokhov --- drivers/input/mouse/vmmouse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c index 871e5b5ab129..148245c69be7 100644 --- a/drivers/input/mouse/vmmouse.c +++ b/drivers/input/mouse/vmmouse.c @@ -16,12 +16,12 @@ #include #include #include +#include #include "psmouse.h" #include "vmmouse.h" #define VMMOUSE_PROTO_MAGIC 0x564D5868U -#define VMMOUSE_PROTO_PORT 0x5658 /* * Main commands supported by the vmmouse hypervisor port. @@ -84,7 +84,7 @@ struct vmmouse_data { #define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4) \ ({ \ unsigned long __dummy1, __dummy2; \ - __asm__ __volatile__ ("inl %%dx" : \ + __asm__ __volatile__ (VMWARE_HYPERCALL : \ "=a"(out1), \ "=b"(out2), \ "=c"(out3), \ @@ -94,7 +94,7 @@ struct vmmouse_data { "a"(VMMOUSE_PROTO_MAGIC), \ "b"(in1), \ "c"(VMMOUSE_PROTO_CMD_##cmd), \ - "d"(VMMOUSE_PROTO_PORT) : \ + "d"(0) : \ "memory"); \ })