Re: [PATCH v2 5/6] drm/vmwgfx: Use vmware_hypercall API

2023-12-05 Thread Alexey Makhalov



On 12/5/23 12:27 PM, Borislav Petkov wrote:

On Fri, Dec 01, 2023 at 03:24:51PM -0800, Alexey Makhalov wrote:

Switch from VMWARE_HYPERCALL macro to vmware_hypercall API.
Eliminate arch specific code.

drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h: implement arm64 variant
of vmware_hypercall here for now. The move of these functions to
arch/arm64/include/asm/vmware.h as well as removal of
drivers/gpu/drm/vmwgfx/vmwgfx_msg_{x86,arm64}.h header files will
be performed in the follow up patchset.

Same note as for patch 1 - no commit order in git.


Thanks for the review Borislav. I'll address your comments regarding 
description messages
in v3. It is going to be sent from @broadcom.com and may take some time 
to align with

corporate legal stuff.

--Alexey

--
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.




Re: [PATCH v2 5/6] drm/vmwgfx: Use vmware_hypercall API

2023-12-05 Thread Borislav Petkov
On Fri, Dec 01, 2023 at 03:24:51PM -0800, Alexey Makhalov wrote:
> Switch from VMWARE_HYPERCALL macro to vmware_hypercall API.
> Eliminate arch specific code.
> 
> drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h: implement arm64 variant
> of vmware_hypercall here for now. The move of these functions to
> arch/arm64/include/asm/vmware.h as well as removal of
> drivers/gpu/drm/vmwgfx/vmwgfx_msg_{x86,arm64}.h header files will
> be performed in the follow up patchset.

Same note as for patch 1 - no commit order in git.

-- 
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette



[PATCH v2 5/6] drm/vmwgfx: Use vmware_hypercall API

2023-12-01 Thread Alexey Makhalov
Switch from VMWARE_HYPERCALL macro to vmware_hypercall API.
Eliminate arch specific code.

drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h: implement arm64 variant
of vmware_hypercall here for now. The move of these functions to
arch/arm64/include/asm/vmware.h as well as removal of
drivers/gpu/drm/vmwgfx/vmwgfx_msg_{x86,arm64}.h header files will
be performed in the follow up patchset.

Signed-off-by: Alexey Makhalov 
Reviewed-by: Nadav Amit 
Reviewed-by: Zack Rusin 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c   | 173 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h | 197 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg_x86.h   | 185 
 3 files changed, 197 insertions(+), 358 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
index 2651fe0ef518..1f15990d3934 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -48,8 +48,6 @@
 
 #define RETRIES 3
 
-#define VMW_HYPERVISOR_MAGIC0x564D5868
-
 #define VMW_PORT_CMD_MSG30
 #define VMW_PORT_CMD_HB_MSG 0
 #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] =
  */
 static int vmw_open_channel(struct rpc_channel *channel, unsigned int protocol)
 {
-   unsigned long eax, ebx, ecx, edx, si = 0, di = 0;
+   u32 ecx, edx, esi, edi;
 
-   VMW_PORT(VMW_PORT_CMD_OPEN_CHANNEL,
-   (protocol | GUESTMSG_FLAG_COOKIE), si, di,
-   0,
-   VMW_HYPERVISOR_MAGIC,
-   eax, ebx, ecx, edx, si, di);
+   vmware_hypercall6(VMW_PORT_CMD_OPEN_CHANNEL,
+ (protocol | GUESTMSG_FLAG_COOKIE), 0,
+ &ecx, &edx, &esi, &edi);
 
if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0)
return -EINVAL;
 
channel->channel_id  = HIGH_WORD(edx);
-   channel->cookie_high = si;
-   channel->cookie_low  = di;
+   channel->cookie_high = esi;
+   channel->cookie_low  = edi;
 
return 0;
 }
@@ -133,17 +129,13 @@ static int vmw_open_channel(struct rpc_channel *channel, 
unsigned int protocol)
  */
 static int vmw_close_channel(struct rpc_channel *channel)
 {
-   unsigned long eax, ebx, ecx, edx, si, di;
-
-   /* Set up additional parameters */
-   si  = channel->cookie_high;
-   di  = channel->cookie_low;
+   u32 ecx;
 
-   VMW_PORT(VMW_PORT_CMD_CLOSE_CHANNEL,
-   0, si, di,
-   channel->channel_id << 16,
-   VMW_HYPERVISOR_MAGIC,
-   eax, ebx, ecx, edx, si, di);
+   vmware_hypercall5(VMW_PORT_CMD_CLOSE_CHANNEL,
+ 0, channel->channel_id << 16,
+ channel->cookie_high,
+ channel->cookie_low,
+ &ecx);
 
if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0)
return -EINVAL;
@@ -163,24 +155,18 @@ static int vmw_close_channel(struct rpc_channel *channel)
 static unsigned long vmw_port_hb_out(struct rpc_channel *channel,
 const char *msg, bool hb)
 {
-   unsigned long si, di, eax, ebx, ecx, edx;
+   u32 ebx, ecx;
unsigned long msg_len = strlen(msg);
 
/* HB port can't access encrypted memory. */
if (hb && !cc_platform_has(CC_ATTR_MEM_ENCRYPT)) {
-   unsigned long bp = channel->cookie_high;
-   u32 channel_id = (channel->channel_id << 16);
-
-   si = (uintptr_t) msg;
-   di = channel->cookie_low;
-
-   VMW_PORT_HB_OUT(
+   vmware_hypercall_hb_out(
(MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG,
-   msg_len, si, di,
-   VMWARE_HYPERVISOR_HB | channel_id |
-   VMWARE_HYPERVISOR_OUT,
-   VMW_HYPERVISOR_MAGIC, bp,
-   eax, ebx, ecx, edx, si, di);
+   msg_len,
+   channel->channel_id << 16,
+   (uintptr_t) msg, channel->cookie_low,
+   channel->cookie_high,
+   &ebx);
 
return ebx;
}
@@ -194,14 +180,13 @@ static unsigned long vmw_port_hb_out(struct rpc_channel 
*channel,
memcpy(&word, msg, bytes);
msg_len -= bytes;
msg += bytes;
-   si = channel->cookie_high;
-   di = channel->cookie_low;
-
-   VMW_PORT(VMW_PORT_CMD_MSG | (MSG_TYPE_SENDPAYLOAD << 16),
-word, si, di,
-channel->channel_id << 16,
-VMW_HYPERVISOR_MAGIC,
-eax, ebx, ecx, edx, si, di);
+
+   vmware_hypercall5(VMW_PORT_CMD_MSG |
+ (MSG_T