Skip to content

Commit

Permalink
drm/vmwgfx: Update the backdoor call with support for new instructions
Browse files Browse the repository at this point in the history
Use the definition provided by include/asm/vmware.h

Signed-off-by: Thomas Hellstrom <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Reviewed-by: Doug Covelli <[email protected]>
Acked-by: Dave Airlie <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: [email protected]
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: [email protected]
Cc: Thomas Gleixner <[email protected]>
Cc: VMware Graphics <[email protected]>
Cc: x86-ml <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
thomashvmw authored and suryasaimadhu committed Aug 28, 2019
1 parent b4dd4f6 commit 6abe377
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
21 changes: 10 additions & 11 deletions drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,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
Expand Down Expand Up @@ -93,7 +91,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);

Expand Down Expand Up @@ -126,7 +124,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);

Expand Down Expand Up @@ -160,7 +158,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);

Expand All @@ -181,7 +180,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);
}
Expand Down Expand Up @@ -213,7 +212,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);

Expand All @@ -230,7 +229,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);

Expand Down Expand Up @@ -269,7 +268,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);

Expand Down Expand Up @@ -327,7 +326,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);

Expand Down Expand Up @@ -371,7 +370,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);

Expand Down
35 changes: 18 additions & 17 deletions drivers/gpu/drm/vmwgfx/vmwgfx_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#ifndef _VMWGFX_MSG_H
#define _VMWGFX_MSG_H

#include <asm/vmware.h>

/**
* Hypervisor-specific bi-directional communication channel. Should never
Expand All @@ -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
Expand All @@ -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), \
Expand All @@ -67,7 +68,7 @@
"a"(magic), \
"b"(in_ebx), \
"c"(cmd), \
"d"(port_num), \
"d"(flags), \
"S"(in_si), \
"D"(in_di) : \
"memory"); \
Expand All @@ -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
Expand All @@ -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), \
Expand All @@ -114,7 +115,7 @@
"a"(magic), \
"b"(cmd), \
"c"(in_ecx), \
"d"(port_num), \
"d"(flags), \
"S"(in_si), \
"D"(in_di), \
"r"(bp) : \
Expand All @@ -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), \
Expand All @@ -139,7 +140,7 @@
"a"(magic), \
"b"(cmd), \
"c"(in_ecx), \
"d"(port_num), \
"d"(flags), \
"S"(in_si), \
"D"(in_di), \
"r"(bp) : \
Expand All @@ -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), \
Expand All @@ -175,7 +176,7 @@
"a"(magic), \
"b"(cmd), \
"c"(in_ecx), \
"d"(port_num), \
"d"(flags), \
"S"(in_si), \
"D"(in_di), \
"m"(bp) : \
Expand All @@ -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), \
Expand All @@ -202,7 +203,7 @@
"a"(magic), \
"b"(cmd), \
"c"(in_ecx), \
"d"(port_num), \
"d"(flags), \
"S"(in_si), \
"D"(in_di), \
"m"(bp) : \
Expand Down

0 comments on commit 6abe377

Please sign in to comment.