4848
4949#define RETRIES 3
5050
51- #define VMW_HYPERVISOR_MAGIC 0x564D5868
52-
5351#define VMW_PORT_CMD_MSG 30
5452#define VMW_PORT_CMD_HB_MSG 0
5553#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] =
104102 */
105103static int vmw_open_channel (struct rpc_channel * channel , unsigned int protocol )
106104{
107- unsigned long eax , ebx , ecx , edx , si = 0 , di = 0 ;
105+ u32 ecx , edx , esi , edi ;
108106
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 );
114110
115111 if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 )
116112 return - EINVAL ;
117113
118114 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 ;
121117
122118 return 0 ;
123119}
@@ -133,17 +129,13 @@ static int vmw_open_channel(struct rpc_channel *channel, unsigned int protocol)
133129 */
134130static int vmw_close_channel (struct rpc_channel * channel )
135131{
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 ;
141133
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 );
147139
148140 if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 )
149141 return - EINVAL ;
@@ -163,24 +155,18 @@ static int vmw_close_channel(struct rpc_channel *channel)
163155static unsigned long vmw_port_hb_out (struct rpc_channel * channel ,
164156 const char * msg , bool hb )
165157{
166- unsigned long si , di , eax , ebx , ecx , edx ;
158+ u32 ebx , ecx ;
167159 unsigned long msg_len = strlen (msg );
168160
169161 /* HB port can't access encrypted memory. */
170162 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 (
178164 (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 );
184170
185171 return ebx ;
186172 }
@@ -194,14 +180,13 @@ static unsigned long vmw_port_hb_out(struct rpc_channel *channel,
194180 memcpy (& word , msg , bytes );
195181 msg_len -= bytes ;
196182 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 );
205190 }
206191
207192 return ecx ;
@@ -220,22 +205,17 @@ static unsigned long vmw_port_hb_out(struct rpc_channel *channel,
220205static unsigned long vmw_port_hb_in (struct rpc_channel * channel , char * reply ,
221206 unsigned long reply_len , bool hb )
222207{
223- unsigned long si , di , eax , ebx , ecx , edx ;
208+ u32 ebx , ecx , edx ;
224209
225210 /* HB port can't access encrypted memory */
226211 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 (
234213 (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 );
239219
240220 return ebx ;
241221 }
@@ -245,14 +225,13 @@ static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply,
245225 while (reply_len ) {
246226 unsigned int bytes = min_t (unsigned long , reply_len , 4 );
247227
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 );
256235
257236 if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 )
258237 break ;
@@ -276,22 +255,18 @@ static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply,
276255 */
277256static int vmw_send_msg (struct rpc_channel * channel , const char * msg )
278257{
279- unsigned long eax , ebx , ecx , edx , si , di ;
258+ u32 ebx , ecx ;
280259 size_t msg_len = strlen (msg );
281260 int retries = 0 ;
282261
283262 while (retries < RETRIES ) {
284263 retries ++ ;
285264
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 );
295270
296271 if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 ) {
297272 /* Expected success. Give up. */
@@ -329,7 +304,7 @@ STACK_FRAME_NON_STANDARD(vmw_send_msg);
329304static int vmw_recv_msg (struct rpc_channel * channel , void * * msg ,
330305 size_t * msg_len )
331306{
332- unsigned long eax , ebx , ecx , edx , si , di ;
307+ u32 ebx , ecx , edx ;
333308 char * reply ;
334309 size_t reply_len ;
335310 int retries = 0 ;
@@ -341,15 +316,11 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg,
341316 while (retries < RETRIES ) {
342317 retries ++ ;
343318
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 );
353324
354325 if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 ) {
355326 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,
384355
385356 reply [reply_len ] = '\0' ;
386357
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 );
397364
398365 if ((HIGH_WORD (ecx ) & MESSAGE_STATUS_SUCCESS ) == 0 ) {
399366 kfree (reply );
@@ -652,13 +619,7 @@ static inline void reset_ppn_array(PPN64 *arr, size_t size)
652619 */
653620static inline void hypervisor_ppn_reset_all (void )
654621{
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 );
662623}
663624
664625/**
@@ -669,13 +630,7 @@ static inline void hypervisor_ppn_reset_all(void)
669630 */
670631static inline void hypervisor_ppn_add (PPN64 pfn )
671632{
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 );
679634}
680635
681636/**
@@ -686,13 +641,7 @@ static inline void hypervisor_ppn_add(PPN64 pfn)
686641 */
687642static inline void hypervisor_ppn_remove (PPN64 pfn )
688643{
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 );
696645}
697646
698647#if IS_ENABLED (CONFIG_DRM_VMWGFX_MKSSTATS )
0 commit comments