Skip to content

Commit 6abe377

Browse files
thomashvmwsuryasaimadhu
authored andcommitted
drm/vmwgfx: Update the backdoor call with support for new instructions
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]
1 parent b4dd4f6 commit 6abe377

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_msg.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
#define RETRIES 3
4747

4848
#define VMW_HYPERVISOR_MAGIC 0x564D5868
49-
#define VMW_HYPERVISOR_PORT 0x5658
50-
#define VMW_HYPERVISOR_HB_PORT 0x5659
5149

5250
#define VMW_PORT_CMD_MSG 30
5351
#define VMW_PORT_CMD_HB_MSG 0
@@ -93,7 +91,7 @@ static int vmw_open_channel(struct rpc_channel *channel, unsigned int protocol)
9391

9492
VMW_PORT(VMW_PORT_CMD_OPEN_CHANNEL,
9593
(protocol | GUESTMSG_FLAG_COOKIE), si, di,
96-
VMW_HYPERVISOR_PORT,
94+
0,
9795
VMW_HYPERVISOR_MAGIC,
9896
eax, ebx, ecx, edx, si, di);
9997

@@ -126,7 +124,7 @@ static int vmw_close_channel(struct rpc_channel *channel)
126124

127125
VMW_PORT(VMW_PORT_CMD_CLOSE_CHANNEL,
128126
0, si, di,
129-
(VMW_HYPERVISOR_PORT | (channel->channel_id << 16)),
127+
channel->channel_id << 16,
130128
VMW_HYPERVISOR_MAGIC,
131129
eax, ebx, ecx, edx, si, di);
132130

@@ -160,7 +158,8 @@ static unsigned long vmw_port_hb_out(struct rpc_channel *channel,
160158
VMW_PORT_HB_OUT(
161159
(MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG,
162160
msg_len, si, di,
163-
VMW_HYPERVISOR_HB_PORT | (channel->channel_id << 16),
161+
VMWARE_HYPERVISOR_HB | (channel->channel_id << 16) |
162+
VMWARE_HYPERVISOR_OUT,
164163
VMW_HYPERVISOR_MAGIC, bp,
165164
eax, ebx, ecx, edx, si, di);
166165

@@ -181,7 +180,7 @@ static unsigned long vmw_port_hb_out(struct rpc_channel *channel,
181180

182181
VMW_PORT(VMW_PORT_CMD_MSG | (MSG_TYPE_SENDPAYLOAD << 16),
183182
word, si, di,
184-
VMW_HYPERVISOR_PORT | (channel->channel_id << 16),
183+
channel->channel_id << 16,
185184
VMW_HYPERVISOR_MAGIC,
186185
eax, ebx, ecx, edx, si, di);
187186
}
@@ -213,7 +212,7 @@ static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply,
213212
VMW_PORT_HB_IN(
214213
(MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG,
215214
reply_len, si, di,
216-
VMW_HYPERVISOR_HB_PORT | (channel->channel_id << 16),
215+
VMWARE_HYPERVISOR_HB | (channel->channel_id << 16),
217216
VMW_HYPERVISOR_MAGIC, bp,
218217
eax, ebx, ecx, edx, si, di);
219218

@@ -230,7 +229,7 @@ static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply,
230229

231230
VMW_PORT(VMW_PORT_CMD_MSG | (MSG_TYPE_RECVPAYLOAD << 16),
232231
MESSAGE_STATUS_SUCCESS, si, di,
233-
VMW_HYPERVISOR_PORT | (channel->channel_id << 16),
232+
channel->channel_id << 16,
234233
VMW_HYPERVISOR_MAGIC,
235234
eax, ebx, ecx, edx, si, di);
236235

@@ -269,7 +268,7 @@ static int vmw_send_msg(struct rpc_channel *channel, const char *msg)
269268

270269
VMW_PORT(VMW_PORT_CMD_SENDSIZE,
271270
msg_len, si, di,
272-
VMW_HYPERVISOR_PORT | (channel->channel_id << 16),
271+
channel->channel_id << 16,
273272
VMW_HYPERVISOR_MAGIC,
274273
eax, ebx, ecx, edx, si, di);
275274

@@ -327,7 +326,7 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg,
327326

328327
VMW_PORT(VMW_PORT_CMD_RECVSIZE,
329328
0, si, di,
330-
(VMW_HYPERVISOR_PORT | (channel->channel_id << 16)),
329+
channel->channel_id << 16,
331330
VMW_HYPERVISOR_MAGIC,
332331
eax, ebx, ecx, edx, si, di);
333332

@@ -371,7 +370,7 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg,
371370

372371
VMW_PORT(VMW_PORT_CMD_RECVSTATUS,
373372
MESSAGE_STATUS_SUCCESS, si, di,
374-
(VMW_HYPERVISOR_PORT | (channel->channel_id << 16)),
373+
channel->channel_id << 16,
375374
VMW_HYPERVISOR_MAGIC,
376375
eax, ebx, ecx, edx, si, di);
377376

drivers/gpu/drm/vmwgfx/vmwgfx_msg.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#ifndef _VMWGFX_MSG_H
3333
#define _VMWGFX_MSG_H
3434

35+
#include <asm/vmware.h>
3536

3637
/**
3738
* Hypervisor-specific bi-directional communication channel. Should never
@@ -44,7 +45,7 @@
4445
* @in_ebx: [IN] Message Len, through EBX
4546
* @in_si: [IN] Input argument through SI, set to 0 if not used
4647
* @in_di: [IN] Input argument through DI, set ot 0 if not used
47-
* @port_num: [IN] port number + [channel id]
48+
* @flags: [IN] hypercall flags + [channel id]
4849
* @magic: [IN] hypervisor magic value
4950
* @eax: [OUT] value of EAX register
5051
* @ebx: [OUT] e.g. status from an HB message status command
@@ -54,10 +55,10 @@
5455
* @di: [OUT]
5556
*/
5657
#define VMW_PORT(cmd, in_ebx, in_si, in_di, \
57-
port_num, magic, \
58+
flags, magic, \
5859
eax, ebx, ecx, edx, si, di) \
5960
({ \
60-
asm volatile ("inl %%dx, %%eax;" : \
61+
asm volatile (VMWARE_HYPERCALL : \
6162
"=a"(eax), \
6263
"=b"(ebx), \
6364
"=c"(ecx), \
@@ -67,7 +68,7 @@
6768
"a"(magic), \
6869
"b"(in_ebx), \
6970
"c"(cmd), \
70-
"d"(port_num), \
71+
"d"(flags), \
7172
"S"(in_si), \
7273
"D"(in_di) : \
7374
"memory"); \
@@ -85,7 +86,7 @@
8586
* @in_ecx: [IN] Message Len, through ECX
8687
* @in_si: [IN] Input argument through SI, set to 0 if not used
8788
* @in_di: [IN] Input argument through DI, set to 0 if not used
88-
* @port_num: [IN] port number + [channel id]
89+
* @flags: [IN] hypercall flags + [channel id]
8990
* @magic: [IN] hypervisor magic value
9091
* @bp: [IN]
9192
* @eax: [OUT] value of EAX register
@@ -98,12 +99,12 @@
9899
#ifdef __x86_64__
99100

100101
#define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \
101-
port_num, magic, bp, \
102+
flags, magic, bp, \
102103
eax, ebx, ecx, edx, si, di) \
103104
({ \
104105
asm volatile ("push %%rbp;" \
105106
"mov %12, %%rbp;" \
106-
"rep outsb;" \
107+
VMWARE_HYPERCALL_HB_OUT \
107108
"pop %%rbp;" : \
108109
"=a"(eax), \
109110
"=b"(ebx), \
@@ -114,7 +115,7 @@
114115
"a"(magic), \
115116
"b"(cmd), \
116117
"c"(in_ecx), \
117-
"d"(port_num), \
118+
"d"(flags), \
118119
"S"(in_si), \
119120
"D"(in_di), \
120121
"r"(bp) : \
@@ -123,12 +124,12 @@
123124

124125

125126
#define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di, \
126-
port_num, magic, bp, \
127+
flags, magic, bp, \
127128
eax, ebx, ecx, edx, si, di) \
128129
({ \
129130
asm volatile ("push %%rbp;" \
130131
"mov %12, %%rbp;" \
131-
"rep insb;" \
132+
VMWARE_HYPERCALL_HB_IN \
132133
"pop %%rbp" : \
133134
"=a"(eax), \
134135
"=b"(ebx), \
@@ -139,7 +140,7 @@
139140
"a"(magic), \
140141
"b"(cmd), \
141142
"c"(in_ecx), \
142-
"d"(port_num), \
143+
"d"(flags), \
143144
"S"(in_si), \
144145
"D"(in_di), \
145146
"r"(bp) : \
@@ -157,13 +158,13 @@
157158
* just pushed it.
158159
*/
159160
#define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \
160-
port_num, magic, bp, \
161+
flags, magic, bp, \
161162
eax, ebx, ecx, edx, si, di) \
162163
({ \
163164
asm volatile ("push %12;" \
164165
"push %%ebp;" \
165166
"mov 0x04(%%esp), %%ebp;" \
166-
"rep outsb;" \
167+
VMWARE_HYPERCALL_HB_OUT \
167168
"pop %%ebp;" \
168169
"add $0x04, %%esp;" : \
169170
"=a"(eax), \
@@ -175,7 +176,7 @@
175176
"a"(magic), \
176177
"b"(cmd), \
177178
"c"(in_ecx), \
178-
"d"(port_num), \
179+
"d"(flags), \
179180
"S"(in_si), \
180181
"D"(in_di), \
181182
"m"(bp) : \
@@ -184,13 +185,13 @@
184185

185186

186187
#define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di, \
187-
port_num, magic, bp, \
188+
flags, magic, bp, \
188189
eax, ebx, ecx, edx, si, di) \
189190
({ \
190191
asm volatile ("push %12;" \
191192
"push %%ebp;" \
192193
"mov 0x04(%%esp), %%ebp;" \
193-
"rep insb;" \
194+
VMWARE_HYPERCALL_HB_IN \
194195
"pop %%ebp;" \
195196
"add $0x04, %%esp;" : \
196197
"=a"(eax), \
@@ -202,7 +203,7 @@
202203
"a"(magic), \
203204
"b"(cmd), \
204205
"c"(in_ecx), \
205-
"d"(port_num), \
206+
"d"(flags), \
206207
"S"(in_si), \
207208
"D"(in_di), \
208209
"m"(bp) : \

0 commit comments

Comments
 (0)