48
48
49
49
#define RETRIES 3
50
50
51
- #define VMW_HYPERVISOR_MAGIC 0x564D5868
52
-
53
51
#define VMW_PORT_CMD_MSG 30
54
52
#define VMW_PORT_CMD_HB_MSG 0
55
53
#define VMW_PORT_CMD_OPEN_CHANNEL (MSG_TYPE_OPEN << 16 | VMW_PORT_CMD_MSG)
@@ -104,20 +102,18 @@ static const char* const mksstat_kern_name_desc[MKSSTAT_KERN_COUNT][2] =
104
102
*/
105
103
static int vmw_open_channel (struct rpc_channel * channel , unsigned int protocol )
106
104
{
107
- unsigned long eax , ebx , ecx , edx , si = 0 , di = 0 ;
105
+ u32 ecx , edx , esi , edi ;
108
106
109
- VMW_PORT (VMW_PORT_CMD_OPEN_CHANNEL ,
110
- (protocol | GUESTMSG_FLAG_COOKIE ), si , di ,
111
- 0 ,
112
- VMW_HYPERVISOR_MAGIC ,
113
- eax , ebx , ecx , edx , si , di );
107
+ vmware_hypercall6 (VMW_PORT_CMD_OPEN_CHANNEL ,
108
+ (protocol | GUESTMSG_FLAG_COOKIE ), 0 ,
109
+ & ecx , & edx , & esi , & edi );
114
110
115
111
if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 )
116
112
return - EINVAL ;
117
113
118
114
channel -> channel_id = HIGH_WORD (edx );
119
- channel -> cookie_high = si ;
120
- channel -> cookie_low = di ;
115
+ channel -> cookie_high = esi ;
116
+ channel -> cookie_low = edi ;
121
117
122
118
return 0 ;
123
119
}
@@ -133,17 +129,13 @@ static int vmw_open_channel(struct rpc_channel *channel, unsigned int protocol)
133
129
*/
134
130
static int vmw_close_channel (struct rpc_channel * channel )
135
131
{
136
- unsigned long eax , ebx , ecx , edx , si , di ;
137
-
138
- /* Set up additional parameters */
139
- si = channel -> cookie_high ;
140
- di = channel -> cookie_low ;
132
+ u32 ecx ;
141
133
142
- VMW_PORT (VMW_PORT_CMD_CLOSE_CHANNEL ,
143
- 0 , si , di ,
144
- channel -> channel_id << 16 ,
145
- VMW_HYPERVISOR_MAGIC ,
146
- eax , ebx , ecx , edx , si , di );
134
+ vmware_hypercall5 (VMW_PORT_CMD_CLOSE_CHANNEL ,
135
+ 0 , channel -> channel_id << 16 ,
136
+ channel -> cookie_high ,
137
+ channel -> cookie_low ,
138
+ & ecx );
147
139
148
140
if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 )
149
141
return - EINVAL ;
@@ -163,24 +155,18 @@ static int vmw_close_channel(struct rpc_channel *channel)
163
155
static unsigned long vmw_port_hb_out (struct rpc_channel * channel ,
164
156
const char * msg , bool hb )
165
157
{
166
- unsigned long si , di , eax , ebx , ecx , edx ;
158
+ u32 ebx , ecx ;
167
159
unsigned long msg_len = strlen (msg );
168
160
169
161
/* HB port can't access encrypted memory. */
170
162
if (hb && !cc_platform_has (CC_ATTR_MEM_ENCRYPT )) {
171
- unsigned long bp = channel -> cookie_high ;
172
- u32 channel_id = (channel -> channel_id << 16 );
173
-
174
- si = (uintptr_t ) msg ;
175
- di = channel -> cookie_low ;
176
-
177
- VMW_PORT_HB_OUT (
163
+ vmware_hypercall_hb_out (
178
164
(MESSAGE_STATUS_SUCCESS << 16 ) | VMW_PORT_CMD_HB_MSG ,
179
- msg_len , si , di ,
180
- VMWARE_HYPERVISOR_HB | channel_id |
181
- VMWARE_HYPERVISOR_OUT ,
182
- VMW_HYPERVISOR_MAGIC , bp ,
183
- eax , ebx , ecx , edx , si , di );
165
+ msg_len ,
166
+ channel -> channel_id << 16 ,
167
+ ( uintptr_t ) msg , channel -> cookie_low ,
168
+ channel -> cookie_high ,
169
+ & ebx );
184
170
185
171
return ebx ;
186
172
}
@@ -194,14 +180,13 @@ static unsigned long vmw_port_hb_out(struct rpc_channel *channel,
194
180
memcpy (& word , msg , bytes );
195
181
msg_len -= bytes ;
196
182
msg += bytes ;
197
- si = channel -> cookie_high ;
198
- di = channel -> cookie_low ;
199
-
200
- VMW_PORT (VMW_PORT_CMD_MSG | (MSG_TYPE_SENDPAYLOAD << 16 ),
201
- word , si , di ,
202
- channel -> channel_id << 16 ,
203
- VMW_HYPERVISOR_MAGIC ,
204
- eax , ebx , ecx , edx , si , di );
183
+
184
+ vmware_hypercall5 (VMW_PORT_CMD_MSG |
185
+ (MSG_TYPE_SENDPAYLOAD << 16 ),
186
+ word , channel -> channel_id << 16 ,
187
+ channel -> cookie_high ,
188
+ channel -> cookie_low ,
189
+ & ecx );
205
190
}
206
191
207
192
return ecx ;
@@ -220,22 +205,17 @@ static unsigned long vmw_port_hb_out(struct rpc_channel *channel,
220
205
static unsigned long vmw_port_hb_in (struct rpc_channel * channel , char * reply ,
221
206
unsigned long reply_len , bool hb )
222
207
{
223
- unsigned long si , di , eax , ebx , ecx , edx ;
208
+ u32 ebx , ecx , edx ;
224
209
225
210
/* HB port can't access encrypted memory */
226
211
if (hb && !cc_platform_has (CC_ATTR_MEM_ENCRYPT )) {
227
- unsigned long bp = channel -> cookie_low ;
228
- u32 channel_id = (channel -> channel_id << 16 );
229
-
230
- si = channel -> cookie_high ;
231
- di = (uintptr_t ) reply ;
232
-
233
- VMW_PORT_HB_IN (
212
+ vmware_hypercall_hb_in (
234
213
(MESSAGE_STATUS_SUCCESS << 16 ) | VMW_PORT_CMD_HB_MSG ,
235
- reply_len , si , di ,
236
- VMWARE_HYPERVISOR_HB | channel_id ,
237
- VMW_HYPERVISOR_MAGIC , bp ,
238
- eax , ebx , ecx , edx , si , di );
214
+ reply_len ,
215
+ channel -> channel_id << 16 ,
216
+ channel -> cookie_high ,
217
+ (uintptr_t ) reply , channel -> cookie_low ,
218
+ & ebx );
239
219
240
220
return ebx ;
241
221
}
@@ -245,14 +225,13 @@ static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply,
245
225
while (reply_len ) {
246
226
unsigned int bytes = min_t (unsigned long , reply_len , 4 );
247
227
248
- si = channel -> cookie_high ;
249
- di = channel -> cookie_low ;
250
-
251
- VMW_PORT (VMW_PORT_CMD_MSG | (MSG_TYPE_RECVPAYLOAD << 16 ),
252
- MESSAGE_STATUS_SUCCESS , si , di ,
253
- channel -> channel_id << 16 ,
254
- VMW_HYPERVISOR_MAGIC ,
255
- eax , ebx , ecx , edx , si , di );
228
+ vmware_hypercall7 (VMW_PORT_CMD_MSG |
229
+ (MSG_TYPE_RECVPAYLOAD << 16 ),
230
+ MESSAGE_STATUS_SUCCESS ,
231
+ channel -> channel_id << 16 ,
232
+ channel -> cookie_high ,
233
+ channel -> cookie_low ,
234
+ & ebx , & ecx , & edx );
256
235
257
236
if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 )
258
237
break ;
@@ -276,22 +255,18 @@ static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply,
276
255
*/
277
256
static int vmw_send_msg (struct rpc_channel * channel , const char * msg )
278
257
{
279
- unsigned long eax , ebx , ecx , edx , si , di ;
258
+ u32 ebx , ecx ;
280
259
size_t msg_len = strlen (msg );
281
260
int retries = 0 ;
282
261
283
262
while (retries < RETRIES ) {
284
263
retries ++ ;
285
264
286
- /* Set up additional parameters */
287
- si = channel -> cookie_high ;
288
- di = channel -> cookie_low ;
289
-
290
- VMW_PORT (VMW_PORT_CMD_SENDSIZE ,
291
- msg_len , si , di ,
292
- channel -> channel_id << 16 ,
293
- VMW_HYPERVISOR_MAGIC ,
294
- eax , ebx , ecx , edx , si , di );
265
+ vmware_hypercall5 (VMW_PORT_CMD_SENDSIZE ,
266
+ msg_len , channel -> channel_id << 16 ,
267
+ channel -> cookie_high ,
268
+ channel -> cookie_low ,
269
+ & ecx );
295
270
296
271
if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 ) {
297
272
/* Expected success. Give up. */
@@ -329,7 +304,7 @@ STACK_FRAME_NON_STANDARD(vmw_send_msg);
329
304
static int vmw_recv_msg (struct rpc_channel * channel , void * * msg ,
330
305
size_t * msg_len )
331
306
{
332
- unsigned long eax , ebx , ecx , edx , si , di ;
307
+ u32 ebx , ecx , edx ;
333
308
char * reply ;
334
309
size_t reply_len ;
335
310
int retries = 0 ;
@@ -341,15 +316,11 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg,
341
316
while (retries < RETRIES ) {
342
317
retries ++ ;
343
318
344
- /* Set up additional parameters */
345
- si = channel -> cookie_high ;
346
- di = channel -> cookie_low ;
347
-
348
- VMW_PORT (VMW_PORT_CMD_RECVSIZE ,
349
- 0 , si , di ,
350
- channel -> channel_id << 16 ,
351
- VMW_HYPERVISOR_MAGIC ,
352
- eax , ebx , ecx , edx , si , di );
319
+ vmware_hypercall7 (VMW_PORT_CMD_RECVSIZE ,
320
+ 0 , channel -> channel_id << 16 ,
321
+ channel -> cookie_high ,
322
+ channel -> cookie_low ,
323
+ & ebx , & ecx , & edx );
353
324
354
325
if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 ) {
355
326
DRM_ERROR ("Failed to get reply size for host message.\n" );
@@ -384,16 +355,12 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg,
384
355
385
356
reply [reply_len ] = '\0' ;
386
357
387
-
388
- /* Ack buffer */
389
- si = channel -> cookie_high ;
390
- di = channel -> cookie_low ;
391
-
392
- VMW_PORT (VMW_PORT_CMD_RECVSTATUS ,
393
- MESSAGE_STATUS_SUCCESS , si , di ,
394
- channel -> channel_id << 16 ,
395
- VMW_HYPERVISOR_MAGIC ,
396
- eax , ebx , ecx , edx , si , di );
358
+ vmware_hypercall5 (VMW_PORT_CMD_RECVSTATUS ,
359
+ MESSAGE_STATUS_SUCCESS ,
360
+ channel -> channel_id << 16 ,
361
+ channel -> cookie_high ,
362
+ channel -> cookie_low ,
363
+ & ecx );
397
364
398
365
if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 ) {
399
366
kfree (reply );
@@ -652,13 +619,7 @@ static inline void reset_ppn_array(PPN64 *arr, size_t size)
652
619
*/
653
620
static inline void hypervisor_ppn_reset_all (void )
654
621
{
655
- unsigned long eax , ebx , ecx , edx , si = 0 , di = 0 ;
656
-
657
- VMW_PORT (VMW_PORT_CMD_MKSGS_RESET ,
658
- 0 , si , di ,
659
- 0 ,
660
- VMW_HYPERVISOR_MAGIC ,
661
- eax , ebx , ecx , edx , si , di );
622
+ vmware_hypercall1 (VMW_PORT_CMD_MKSGS_RESET , 0 );
662
623
}
663
624
664
625
/**
@@ -669,13 +630,7 @@ static inline void hypervisor_ppn_reset_all(void)
669
630
*/
670
631
static inline void hypervisor_ppn_add (PPN64 pfn )
671
632
{
672
- unsigned long eax , ebx , ecx , edx , si = 0 , di = 0 ;
673
-
674
- VMW_PORT (VMW_PORT_CMD_MKSGS_ADD_PPN ,
675
- (unsigned long )pfn , si , di ,
676
- 0 ,
677
- VMW_HYPERVISOR_MAGIC ,
678
- eax , ebx , ecx , edx , si , di );
633
+ vmware_hypercall1 (VMW_PORT_CMD_MKSGS_ADD_PPN , (unsigned long )pfn );
679
634
}
680
635
681
636
/**
@@ -686,13 +641,7 @@ static inline void hypervisor_ppn_add(PPN64 pfn)
686
641
*/
687
642
static inline void hypervisor_ppn_remove (PPN64 pfn )
688
643
{
689
- unsigned long eax , ebx , ecx , edx , si = 0 , di = 0 ;
690
-
691
- VMW_PORT (VMW_PORT_CMD_MKSGS_REMOVE_PPN ,
692
- (unsigned long )pfn , si , di ,
693
- 0 ,
694
- VMW_HYPERVISOR_MAGIC ,
695
- eax , ebx , ecx , edx , si , di );
644
+ vmware_hypercall1 (VMW_PORT_CMD_MKSGS_REMOVE_PPN , (unsigned long )pfn );
696
645
}
697
646
698
647
#if IS_ENABLED (CONFIG_DRM_VMWGFX_MKSSTATS )
0 commit comments