Skip to contentSkip to conversation

x86: Add VMWare Host Communication Macros

PATCH In review Sinclair Yeh 6 participants 65 messages Dec 1, 2015 – Mar 31, 2016 2 messages not in the archive

Subsystems (8)
lore
Share & tools
lore
#1 lore raw

PATCH 1/6 x86: Add VMWare Host Communication Macros

In reply to a message not in the archive

These macros will be used by multiple VMWare modules for handling host communication.

v2:
* Keeping only the minimal common platform defines
* added vmware_platform() check function

v3:
* Added new field to handle different hypervisor magic values

---
 arch/x86/include/asm/vmware.h | 110 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)
 create mode 100644 arch/x86/include/asm/vmware.h
arch/x86/include/asm/vmware.h new file +110 -0
new file mode 100644
index 0000000..32bf99b
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2015, VMware, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ * Based on code from vmware.c and vmmouse.c.
+ * Author:
+ *   Sinclair Yeh <[email protected]>
+ */
+#ifndef _ASM_X86_VMWARE_H
+#define _ASM_X86_VMWARE_H
+
+
+/**
+ * Hypervisor-specific bi-directional communication channel.  Should never
+ * execute on bare metal hardware.  The caller must make sure to check for
+ * supported hypervisor before using these macros.
+ *
+ * Several of the parameters are both input and output and must be initialized.
+ *
+ * @in1: [IN] Message Len or Message Cmd (HB)
+ * @in2: [IN] Message Len (HB) or Message Cmd
+ * @port_num: [IN] port number + [channel id]
+ * @magic: [IN] hypervisor magic value
+ * @eax: [OUT] value of EAX register
+ * @ebx: [OUT] e.g. status from an HB message status command
+ * @ecx: [OUT] e.g. status from a non-HB message status command
+ * @edx: [OUT] e.g. channel id
+ * @si: [INOUT] set to 0 if not used
+ * @di: [INOUT] set to 0 if not used
+ * @bp: [INOUT] set to 0 if not used
+ */
+#define VMW_PORT(in1, in2, port_num, magic, eax, ebx, ecx, edx, si, di) \
+({                                                                      \
+	__asm__ __volatile__ ("inl %%dx" :                              \
+		"=a"(eax),                                              \
+		"=b"(ebx),                                              \
+		"=c"(ecx),                                              \
+		"=d"(edx),                                              \
+		"=S"(si),                                               \
+		"=D"(di) :                                              \
+		"a"(magic),                                             \
+		"b"(in1),                                               \
+		"c"(in2),                                               \
+		"d"(port_num),                                          \
+		"S"(si),                                                \
+		"D"(di) :                                               \
+		"memory");                                              \
+})
+
+
+#define VMW_PORT_HB_OUT(in1, in2, port_num, magic,      \
+			eax, ebx, ecx, edx, si, di, bp) \
+({                                                      \
+	__asm__ __volatile__ ("movq %13, %%rbp;"        \
+		"cld; rep outsb; "                      \
+		"movq %%rbp, %6" :                      \
+		"=a"(eax),                              \
+		"=b"(ebx),                              \
+		"=c"(ecx),                              \
+		"=d"(edx),                              \
+		"=S"(si),                               \
+		"=D"(di),                               \
+		"=r"(bp) :                              \
+		"a"(magic),                             \
+		"b"(in1),                               \
+		"c"(in2),                               \
+		"d"(port_num),                          \
+		"S"(si),                                \
+		"D"(di),                                \
+		"r"(bp) :                               \
+		"memory", "cc");                        \
+})
+
+
+#define VMW_PORT_HB_IN(in1, in2, port_num, magic,            \
+		       eax, ebx, ecx, edx, si, di, bp)       \
+({                                                           \
+	__asm__ __volatile__ ("push %%rbp; movq %13, %%rbp;" \
+		"cld; rep insb; "                            \
+		"movq %%rbp, %6;pop %%rbp" :                 \
+		"=a"(eax),                                   \
+		"=b"(ebx),                                   \
+		"=c"(ecx),                                   \
+		"=d"(edx),                                   \
+		"=S"(si),                                    \
+		"=D"(di),                                    \
+		"=r"(bp) :                                   \
+		"a"(magic),                                  \
+		"b"(in1),                                    \
+		"c"(in2),                                    \
+		"d"(port_num),                               \
+		"S"(si),                                     \
+		"D"(di),                                     \
+		"r"(bp) :                                    \
+		"memory", "cc");                             \
+})
+
+
+#endif
+
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/6 x86: Update vmware.c to use the common VMW_PORT macros

v2:
Instead of replacing all existing instances of VMWARE_PORT with VMW_PORT, update VMWARE_PORT to use the new VMW_PORT.

v3:
Using updated VMWARE_PORT() macro, which needs hypervisor magic in the parameter

---
 arch/x86/kernel/cpu/vmware.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/vmware.c +9 -7
index 628a059..1837f66 100644
@@ -26,6 +26,7 @@
 #include <asm/div64.h>
 #include <asm/x86_init.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #define CPUID_VMWARE_INFO_LEAF	0x40000000
 #define VMWARE_HYPERVISOR_MAGIC	0x564D5868
@@ -37,13 +38,14 @@
 #define VMWARE_PORT_CMD_LEGACY_X2APIC	3
 #define VMWARE_PORT_CMD_VCPU_RESERVED	31
 
-#define VMWARE_PORT(cmd, eax, ebx, ecx, edx)				\
-	__asm__("inl (%%dx)" :						\
-			"=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) :	\
-			"0"(VMWARE_HYPERVISOR_MAGIC),			\
-			"1"(VMWARE_PORT_CMD_##cmd),			\
-			"2"(VMWARE_HYPERVISOR_PORT), "3"(UINT_MAX) :	\
-			"memory");
+#define VMWARE_PORT(cmd, eax, ebx, ecx, edx)				  \
+({									  \
+	unsigned long __si = 0, __di = 0;                                 \
+	VMW_PORT(UINT_MAX, VMWARE_PORT_CMD_##cmd, VMWARE_HYPERVISOR_PORT, \
+		 VMWARE_HYPERVISOR_MAGIC,                                 \
+		 eax, ebx, ecx, edx, __si, __di);                         \
+})
+
 
 static inline int __vmware_platform(void)
 {
Signature · 1 line
1.9.1
#29 lore raw

PATCH 4/6 Input: Remove vmmouse port reservation

In reply to Sinclair Yeh

Port reservation is not required. Furthermore, this port is shared by other VMware services for host-side communication.

---
 drivers/input/mouse/vmmouse.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/input/mouse/vmmouse.c +1 -18
index d34e3e4..9109d54 100644
@@ -347,16 +347,10 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
 		return -ENXIO;
 	}
 
-	if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {
-		psmouse_dbg(psmouse, "VMMouse port in use.\n");
-		return -EBUSY;
-	}
-
 	/* Check if the device is present */
 	response = ~VMMOUSE_PROTO_MAGIC;
 	VMMOUSE_CMD(GETVERSION, 0, version, response, dummy1, dummy2);
 	if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU) {
-		release_region(VMMOUSE_PROTO_PORT, 4);
 		return -ENXIO;
 	}
 
@@ -366,8 +360,6 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
 		psmouse->model = version;
 	}
 
-	release_region(VMMOUSE_PROTO_PORT, 4);
-
 	return 0;
 }
 
@@ -386,7 +378,6 @@ static void vmmouse_disconnect(struct psmouse *psmouse)
 	psmouse_reset(psmouse);
 	input_unregister_device(priv->abs_dev);
 	kfree(priv);
-	release_region(VMMOUSE_PROTO_PORT, 4);
 }
 
 /**
@@ -430,15 +421,10 @@ int vmmouse_init(struct psmouse *psmouse)
 	struct input_dev *rel_dev = psmouse->dev, *abs_dev;
 	int error;
 
-	if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {
-		psmouse_dbg(psmouse, "VMMouse port in use.\n");
-		return -EBUSY;
-	}
-
 	psmouse_reset(psmouse);
 	error = vmmouse_enable(psmouse);
 	if (error)
-		goto release_region;
+		return error;
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	abs_dev = input_allocate_device();
@@ -493,8 +479,5 @@ init_fail:
 	kfree(priv);
 	psmouse->private = NULL;
 
-release_region:
-	release_region(VMMOUSE_PROTO_PORT, 4);
-
 	return error;
 }
Signature · 1 line
1.9.1
#35 lore raw

PATCH 6/6 VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to Sinclair Yeh
---
 drivers/misc/vmw_balloon.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)
drivers/misc/vmw_balloon.c +12 -17
index ffb5634..90a0d07 100644
@@ -43,6 +43,7 @@
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
@@ -142,23 +143,17 @@ enum vmwballoon_capabilities {
 
 #define VMW_BALLOON_SUCCESS_WITH_CAPABILITIES	(0x03000000)
 
-#define VMWARE_BALLOON_CMD(cmd, data, result)			\
-({								\
-	unsigned long __status, __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :			\
-		"=a"(__status),					\
-		"=c"(__dummy1),					\
-		"=d"(__dummy2),					\
-		"=b"(result) :					\
-		"0"(VMW_BALLOON_HV_MAGIC),			\
-		"1"(VMW_BALLOON_CMD_##cmd),			\
-		"2"(VMW_BALLOON_HV_PORT),			\
-		"3"(data) :					\
-		"memory");					\
-	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	\
-		result = __dummy1;				\
-	result &= -1UL;						\
-	__status & -1UL;					\
+#define VMWARE_BALLOON_CMD(cmd, data, result)			   \
+({								   \
+	unsigned long __status, __dummy1, __dummy2;		   \
+	unsigned long __si = 0, __di = 0;			   \
+	VMW_PORT(data, VMW_BALLOON_CMD_##cmd, VMW_BALLOON_HV_PORT, \
+		 VMW_BALLOON_HV_MAGIC,				   \
+		 __status, result, __dummy1, __dummy2, __si, __di);\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	   \
+		result = __dummy1;				   \
+	result &= -1UL;						   \
+	__status & -1UL;					   \
 })
 
 #ifdef CONFIG_DEBUG_FS
Signature · 1 line
1.9.1
#34 lore raw

PATCH 5/6 x86: Remove address from the vmware.c header

In reply to Sinclair Yeh

We should no longer have mailing address of Free Software Foundation in the copyright header. Since this patch series touches this file, taking this opportunity to fix the header.

---
 arch/x86/kernel/cpu/vmware.c | 4 ----
 1 file changed, 4 deletions(-)
arch/x86/kernel/cpu/vmware.c +0 -4
index 1837f66..850a940 100644
@@ -15,10 +15,6 @@
  * NON INFRINGEMENT.  See the GNU General Public License for more
  * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
  */
 
 #include <linux/dmi.h>
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/6 Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

---
 drivers/input/mouse/vmmouse.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/input/mouse/vmmouse.c +7 -15
index e272f06..d34e3e4 100644
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #include "psmouse.h"
 #include "vmmouse.h"
@@ -84,21 +85,12 @@ struct vmmouse_data {
  * implementing the vmmouse protocol. Should never execute on
  * bare metal hardware.
  */
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)	\
-({							\
-	unsigned long __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :		\
-		"=a"(out1),				\
-		"=b"(out2),				\
-		"=c"(out3),				\
-		"=d"(out4),				\
-		"=S"(__dummy1),				\
-		"=D"(__dummy2) :			\
-		"a"(VMMOUSE_PROTO_MAGIC),		\
-		"b"(in1),				\
-		"c"(VMMOUSE_PROTO_CMD_##cmd),		\
-		"d"(VMMOUSE_PROTO_PORT) :		\
-		"memory");		                \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)		   \
+({								   \
+	unsigned long __dummy1 = 0, __dummy2 = 0;		   \
+	VMW_PORT(in1, VMMOUSE_PROTO_CMD_##cmd, VMMOUSE_PROTO_PORT, \
+		 VMMOUSE_PROTO_MAGIC,				   \
+		 out1, out2, out3, out4, __dummy1, __dummy2);      \
 })
 
 /**
Signature · 1 line
1.9.1
#33 lore raw

PATCH 4/6 Input: Remove vmmouse port reservation

In reply to Sinclair Yeh

Port reservation is not required. Furthermore, this port is shared by other VMware services for host-side communication.

---
 drivers/input/mouse/vmmouse.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/input/mouse/vmmouse.c +1 -18
index d34e3e4..9109d54 100644
@@ -347,16 +347,10 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
 		return -ENXIO;
 	}
 
-	if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {
-		psmouse_dbg(psmouse, "VMMouse port in use.\n");
-		return -EBUSY;
-	}
-
 	/* Check if the device is present */
 	response = ~VMMOUSE_PROTO_MAGIC;
 	VMMOUSE_CMD(GETVERSION, 0, version, response, dummy1, dummy2);
 	if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU) {
-		release_region(VMMOUSE_PROTO_PORT, 4);
 		return -ENXIO;
 	}
 
@@ -366,8 +360,6 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
 		psmouse->model = version;
 	}
 
-	release_region(VMMOUSE_PROTO_PORT, 4);
-
 	return 0;
 }
 
@@ -386,7 +378,6 @@ static void vmmouse_disconnect(struct psmouse *psmouse)
 	psmouse_reset(psmouse);
 	input_unregister_device(priv->abs_dev);
 	kfree(priv);
-	release_region(VMMOUSE_PROTO_PORT, 4);
 }
 
 /**
@@ -430,15 +421,10 @@ int vmmouse_init(struct psmouse *psmouse)
 	struct input_dev *rel_dev = psmouse->dev, *abs_dev;
 	int error;
 
-	if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {
-		psmouse_dbg(psmouse, "VMMouse port in use.\n");
-		return -EBUSY;
-	}
-
 	psmouse_reset(psmouse);
 	error = vmmouse_enable(psmouse);
 	if (error)
-		goto release_region;
+		return error;
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	abs_dev = input_allocate_device();
@@ -493,8 +479,5 @@ init_fail:
 	kfree(priv);
 	psmouse->private = NULL;
 
-release_region:
-	release_region(VMMOUSE_PROTO_PORT, 4);
-
 	return error;
 }
Signature · 1 line
1.9.1
#40 lore raw

PATCH 6/6 VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to Sinclair Yeh
---
 drivers/misc/vmw_balloon.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)
drivers/misc/vmw_balloon.c +12 -17
index ffb5634..90a0d07 100644
@@ -43,6 +43,7 @@
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
@@ -142,23 +143,17 @@ enum vmwballoon_capabilities {
 
 #define VMW_BALLOON_SUCCESS_WITH_CAPABILITIES	(0x03000000)
 
-#define VMWARE_BALLOON_CMD(cmd, data, result)			\
-({								\
-	unsigned long __status, __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :			\
-		"=a"(__status),					\
-		"=c"(__dummy1),					\
-		"=d"(__dummy2),					\
-		"=b"(result) :					\
-		"0"(VMW_BALLOON_HV_MAGIC),			\
-		"1"(VMW_BALLOON_CMD_##cmd),			\
-		"2"(VMW_BALLOON_HV_PORT),			\
-		"3"(data) :					\
-		"memory");					\
-	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	\
-		result = __dummy1;				\
-	result &= -1UL;						\
-	__status & -1UL;					\
+#define VMWARE_BALLOON_CMD(cmd, data, result)			   \
+({								   \
+	unsigned long __status, __dummy1, __dummy2;		   \
+	unsigned long __si = 0, __di = 0;			   \
+	VMW_PORT(data, VMW_BALLOON_CMD_##cmd, VMW_BALLOON_HV_PORT, \
+		 VMW_BALLOON_HV_MAGIC,				   \
+		 __status, result, __dummy1, __dummy2, __si, __di);\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	   \
+		result = __dummy1;				   \
+	result &= -1UL;						   \
+	__status & -1UL;					   \
 })
 
 #ifdef CONFIG_DEBUG_FS
Signature · 1 line
1.9.1
maintainer
#4 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh
Quoted 47 lines · Sinclair Yeh

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

---
 drivers/input/mouse/vmmouse.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/input/mouse/vmmouse.c +1 -8
index e272f06..d34e3e4 100644
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #include "psmouse.h"
 #include "vmmouse.h"
@@ -84,21 +85,12 @@ struct vmmouse_data {
  * implementing the vmmouse protocol. Should never execute on
  * bare metal hardware.
  */
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)	\
-({							\
-	unsigned long __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :		\
-		"=a"(out1),				\
-		"=b"(out2),				\
-		"=c"(out3),				\
-		"=d"(out4),				\

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 10 lines
drivers/input/mouse/vmmouse.c +3 -7
-		"=S"(__dummy1),				\
-		"=D"(__dummy2) :			\
-		"a"(VMMOUSE_PROTO_MAGIC),		\
-		"b"(in1),				\
-		"c"(VMMOUSE_PROTO_CMD_##cmd),		\
-		"d"(VMMOUSE_PROTO_PORT) :		\
-		"memory");		                \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)		   \
+({								   \
+	unsigned long __dummy1 = 0, __dummy2 = 0;		   \

Why do we need to initialize dummies?

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 95

Quoted 5 lines
drivers/input/mouse/vmmouse.c +3 -0
+	VMW_PORT(in1, VMMOUSE_PROTO_CMD_##cmd, VMMOUSE_PROTO_PORT, \
+		 VMMOUSE_PROTO_MAGIC,				   \
+		 out1, out2, out3, out4, __dummy1, __dummy2);      \
 })
 

Thanks.

Signature · 1 line
Dmitry
maintainer
#5 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh
Quoted 47 lines · Sinclair Yeh

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

---
 drivers/input/mouse/vmmouse.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/input/mouse/vmmouse.c +1 -8
index e272f06..d34e3e4 100644
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #include "psmouse.h"
 #include "vmmouse.h"
@@ -84,21 +85,12 @@ struct vmmouse_data {
  * implementing the vmmouse protocol. Should never execute on
  * bare metal hardware.
  */
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)	\
-({							\
-	unsigned long __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :		\
-		"=a"(out1),				\
-		"=b"(out2),				\
-		"=c"(out3),				\
-		"=d"(out4),				\

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 10 lines
drivers/input/mouse/vmmouse.c +3 -7
-		"=S"(__dummy1),				\
-		"=D"(__dummy2) :			\
-		"a"(VMMOUSE_PROTO_MAGIC),		\
-		"b"(in1),				\
-		"c"(VMMOUSE_PROTO_CMD_##cmd),		\
-		"d"(VMMOUSE_PROTO_PORT) :		\
-		"memory");		                \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)		   \
+({								   \
+	unsigned long __dummy1 = 0, __dummy2 = 0;		   \

Why do we need to initialize dummies?

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 95

Quoted 5 lines
drivers/input/mouse/vmmouse.c +3 -0
+	VMW_PORT(in1, VMMOUSE_PROTO_CMD_##cmd, VMMOUSE_PROTO_PORT, \
+		 VMMOUSE_PROTO_MAGIC,				   \
+		 out1, out2, out3, out4, __dummy1, __dummy2);      \
 })
 

Thanks.

Signature · 1 line
Dmitry
maintainer
#30 lore raw

Re: [PATCH 4/6] Input: Remove vmmouse port reservation

In reply to Sinclair Yeh

Hi Sinclair,

Quoted 1 line · Sinclair Yeh

Port reservation is not required.

You need to expand on why we do not need to reserve port.

Quoted 2 lines

Furthermore, this port is shared
by other VMware services for host-side communication.

What services would that be? Do they reserve the port?

Thanks.

Signature · 1 line
Dmitry
#6 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Dmitry Torokhov

Hi,

Quoted 52 lines · Dmitry Torokhov
Quoted 51 lines · Sinclair Yeh

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

---
 drivers/input/mouse/vmmouse.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/input/mouse/vmmouse.c +1 -12
index e272f06..d34e3e4 100644
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #include "psmouse.h"
 #include "vmmouse.h"
@@ -84,21 +85,12 @@ struct vmmouse_data {
  * implementing the vmmouse protocol. Should never execute on
  * bare metal hardware.
  */
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)	\
-({							\
-	unsigned long __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :		\
-		"=a"(out1),				\
-		"=b"(out2),				\
-		"=c"(out3),				\
-		"=d"(out4),				\
-		"=S"(__dummy1),				\
-		"=D"(__dummy2) :			\
-		"a"(VMMOUSE_PROTO_MAGIC),		\
-		"b"(in1),				\
Quoted 8 lines

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 6 lines
drivers/input/mouse/vmmouse.c +3 -3
-		"c"(VMMOUSE_PROTO_CMD_##cmd),		\
-		"d"(VMMOUSE_PROTO_PORT) :		\
-		"memory");		                \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)		   \
+({								   \
+	unsigned long __dummy1 = 0, __dummy2 = 0;		   \

Why do we need to initialize dummies?

Because for some commands those parameters to VMW_PORT() can be both input and outout. So it's safer to initialize them to 0. Since they can potentially be an output, we can't make them a constant.

Quoted 11 lines

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 95

Quoted 6 lines
drivers/input/mouse/vmmouse.c +3 -0
+	VMW_PORT(in1, VMMOUSE_PROTO_CMD_##cmd, VMMOUSE_PROTO_PORT, \
+		 VMMOUSE_PROTO_MAGIC,				   \
+		 out1, out2, out3, out4, __dummy1, __dummy2);      \
 })
 

Thanks.

Signature · 1 line
Dmitry
#41 lore raw
In reply to Sinclair Yeh

Hey Sinclair,

Quoted 9 lines · Sinclair Yeh

+/**
+ * Hypervisor-specific bi-directional communication channel. Should never
+ * execute on bare metal hardware. The caller must make sure to check for
+ * supported hypervisor before using these macros.
+ *
+ * Several of the parameters are both input and output and must be initialized.
+ *
+ * @in1: [IN] Message Len or Message Cmd (HB)
+ * @in2: [IN] Message Len (HB) or Message Cmd

Can you make in1 always be the "Message Cmd" and in2 always be the "Message len"?

arch/x86/include/asm/vmware.h line 44

Quoted 13 lines

+ * @port_num: [IN] port number + [channel id]
+ * @magic: [IN] hypervisor magic value
+ * @eax: [OUT] value of EAX register
+ * @ebx: [OUT] e.g. status from an HB message status command
+ * @ecx: [OUT] e.g. status from a non-HB message status command
+ * @edx: [OUT] e.g. channel id
+ * @si: [INOUT] set to 0 if not used
+ * @di: [INOUT] set to 0 if not used
+ * @bp: [INOUT] set to 0 if not used
+ */

arch/x86/include/asm/vmware.h new file +3 -0
+#define VMW_PORT(in1, in2, port_num, magic, eax, ebx, ecx, edx, si, di) \
+({                                                                      \
+	__asm__ __volatile__ ("inl %%dx" :                              \

Are those '\' aligned in the code?

arch/x86/include/asm/vmware.h line 64

Quoted 5 lines
arch/x86/include/asm/vmware.h new file +5 -0
+
+#define VMW_PORT_HB_OUT(in1, in2, port_num, magic,      \
+			eax, ebx, ecx, edx, si, di, bp) \
+({                                                      \
+	__asm__ __volatile__ ("movq %13, %%rbp;"        \

Same here.

arch/x86/include/asm/vmware.h line 88

Quoted 5 lines
arch/x86/include/asm/vmware.h new file +5 -0
+
+#define VMW_PORT_HB_IN(in1, in2, port_num, magic,            \
+		       eax, ebx, ecx, edx, si, di, bp)       \
+({                                                           \
+	__asm__ __volatile__ ("push %%rbp; movq %13, %%rbp;" \

Same.

Xavier

#42 lore raw
In reply to Sinclair Yeh

Hey Sinclair,

Quoted 9 lines · Sinclair Yeh

+/**
+ * Hypervisor-specific bi-directional communication channel. Should never
+ * execute on bare metal hardware. The caller must make sure to check for
+ * supported hypervisor before using these macros.
+ *
+ * Several of the parameters are both input and output and must be initialized.
+ *
+ * @in1: [IN] Message Len or Message Cmd (HB)
+ * @in2: [IN] Message Len (HB) or Message Cmd

Can you make in1 always be the "Message Cmd" and in2 always be the "Message len"?

arch/x86/include/asm/vmware.h line 44

Quoted 13 lines

+ * @port_num: [IN] port number + [channel id]
+ * @magic: [IN] hypervisor magic value
+ * @eax: [OUT] value of EAX register
+ * @ebx: [OUT] e.g. status from an HB message status command
+ * @ecx: [OUT] e.g. status from a non-HB message status command
+ * @edx: [OUT] e.g. channel id
+ * @si: [INOUT] set to 0 if not used
+ * @di: [INOUT] set to 0 if not used
+ * @bp: [INOUT] set to 0 if not used
+ */

arch/x86/include/asm/vmware.h new file +3 -0
+#define VMW_PORT(in1, in2, port_num, magic, eax, ebx, ecx, edx, si, di) \
+({                                                                      \
+	__asm__ __volatile__ ("inl %%dx" :                              \

Are those '\' aligned in the code?

arch/x86/include/asm/vmware.h line 64

Quoted 5 lines
arch/x86/include/asm/vmware.h new file +5 -0
+
+#define VMW_PORT_HB_OUT(in1, in2, port_num, magic,      \
+			eax, ebx, ecx, edx, si, di, bp) \
+({                                                      \
+	__asm__ __volatile__ ("movq %13, %%rbp;"        \

Same here.

arch/x86/include/asm/vmware.h line 88

Quoted 5 lines
arch/x86/include/asm/vmware.h new file +5 -0
+
+#define VMW_PORT_HB_IN(in1, in2, port_num, magic,            \
+		       eax, ebx, ecx, edx, si, di, bp)       \
+({                                                           \
+	__asm__ __volatile__ ("push %%rbp; movq %13, %%rbp;" \

Same.

Xavier

#26 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Dmitry Torokhov

Hi,

Quoted 52 lines · Dmitry Torokhov
Quoted 51 lines · Sinclair Yeh

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

---
 drivers/input/mouse/vmmouse.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/input/mouse/vmmouse.c +1 -12
index e272f06..d34e3e4 100644
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #include "psmouse.h"
 #include "vmmouse.h"
@@ -84,21 +85,12 @@ struct vmmouse_data {
  * implementing the vmmouse protocol. Should never execute on
  * bare metal hardware.
  */
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)	\
-({							\
-	unsigned long __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :		\
-		"=a"(out1),				\
-		"=b"(out2),				\
-		"=c"(out3),				\
-		"=d"(out4),				\
-		"=S"(__dummy1),				\
-		"=D"(__dummy2) :			\
-		"a"(VMMOUSE_PROTO_MAGIC),		\
-		"b"(in1),				\
Quoted 8 lines

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 6 lines
drivers/input/mouse/vmmouse.c +3 -3
-		"c"(VMMOUSE_PROTO_CMD_##cmd),		\
-		"d"(VMMOUSE_PROTO_PORT) :		\
-		"memory");		                \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)		   \
+({								   \
+	unsigned long __dummy1 = 0, __dummy2 = 0;		   \

Why do we need to initialize dummies?

Because for some commands those parameters to VMW_PORT() can be both input and outout. So it's safer to initialize them to 0. Since they can potentially be an output, we can't make them a constant.

Quoted 11 lines

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 95

Quoted 6 lines
drivers/input/mouse/vmmouse.c +3 -0
+	VMW_PORT(in1, VMMOUSE_PROTO_CMD_##cmd, VMMOUSE_PROTO_PORT, \
+		 VMMOUSE_PROTO_MAGIC,				   \
+		 out1, out2, out3, out4, __dummy1, __dummy2);      \
 })
 

Thanks.

Signature · 1 line
Dmitry
Acked-by on v1 6/6
#36 lore raw

Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to Sinclair Yeh

Hey Sinclair,

drivers/misc/vmw_balloon.c enum vmwballoon_capabilities { · line 157

Quoted 12 lines · Sinclair Yeh
drivers/misc/vmw_balloon.c +11 -0
+#define VMWARE_BALLOON_CMD(cmd, data, result)			   \
+({								   \
+	unsigned long __status, __dummy1, __dummy2;		   \
+	unsigned long __si = 0, __di = 0;			   \
+	VMW_PORT(data, VMW_BALLOON_CMD_##cmd, VMW_BALLOON_HV_PORT, \
+		 VMW_BALLOON_HV_MAGIC,				   \
+		 __status, result, __dummy1, __dummy2, __si, __di);\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	   \
+		result = __dummy1;				   \
+	result &= -1UL;						   \
+	__status & -1UL;					   \
 })

You need to indent the '\' with tabs only, and it looks like spaces are present here (which is also why they don't look aligned).

Other than that I'm good with this:

Xavier

Acked-by on v1 6/6
#37 lore raw

Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to Sinclair Yeh

Hey Sinclair,

drivers/misc/vmw_balloon.c enum vmwballoon_capabilities { · line 157

Quoted 12 lines · Sinclair Yeh
drivers/misc/vmw_balloon.c +11 -0
+#define VMWARE_BALLOON_CMD(cmd, data, result)			   \
+({								   \
+	unsigned long __status, __dummy1, __dummy2;		   \
+	unsigned long __si = 0, __di = 0;			   \
+	VMW_PORT(data, VMW_BALLOON_CMD_##cmd, VMW_BALLOON_HV_PORT, \
+		 VMW_BALLOON_HV_MAGIC,				   \
+		 __status, result, __dummy1, __dummy2, __si, __di);\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	   \
+		result = __dummy1;				   \
+	result &= -1UL;						   \
+	__status & -1UL;					   \
 })

You need to indent the '\' with tabs only, and it looks like spaces are present here (which is also why they don't look aligned).

Other than that I'm good with this:

Xavier

maintainer
#7 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh
Quoted 64 lines · Sinclair Yeh

Hi,

Quoted 52 lines · Dmitry Torokhov
Quoted 51 lines · Sinclair Yeh

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

---
 drivers/input/mouse/vmmouse.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/input/mouse/vmmouse.c +1 -12
index e272f06..d34e3e4 100644
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #include "psmouse.h"
 #include "vmmouse.h"
@@ -84,21 +85,12 @@ struct vmmouse_data {
  * implementing the vmmouse protocol. Should never execute on
  * bare metal hardware.
  */
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
Quoted 8 lines

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 6 lines
drivers/input/mouse/vmmouse.c +3 -3
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

Thanks.

Signature · 1 line
Dmitry
maintainer
#8 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh
Quoted 64 lines · Sinclair Yeh

Hi,

Quoted 52 lines · Dmitry Torokhov
Quoted 51 lines · Sinclair Yeh

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

---
 drivers/input/mouse/vmmouse.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/input/mouse/vmmouse.c +1 -12
index e272f06..d34e3e4 100644
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #include "psmouse.h"
 #include "vmmouse.h"
@@ -84,21 +85,12 @@ struct vmmouse_data {
  * implementing the vmmouse protocol. Should never execute on
  * bare metal hardware.
  */
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
Quoted 8 lines

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 6 lines
drivers/input/mouse/vmmouse.c +3 -3
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

Thanks.

Signature · 1 line
Dmitry
#43 lore raw
In reply to Sinclair Yeh

arch/x86/include/asm/vmware.h line 44

Quoted 4 lines · Sinclair Yeh

These macros will be used by multiple VMWare modules for handling host communication.

arch/x86/include/asm/vmware.h new file +1 -0
+	__asm__ __volatile__ ("inl %%dx" :                              \

This is odd at best; the standard assembly form of this instruction is:

	inl (%dx),%eax

Also, we don't need the underscored forms of asm and volatile for kernel code.

arch/x86/include/asm/vmware.h line 66

Quoted 3 lines
arch/x86/include/asm/vmware.h new file +3 -0
+	__asm__ __volatile__ ("movq %13, %%rbp;"        \
+		"cld; rep outsb; "                      \
+		"movq %%rbp, %6" :                      \

cld shouldn't be necessary here, DF=0 is part of the normal ABI environment.

You also don't save/restore %rbp here, but you do below? Seems very odd.

It might be better do so something like:

+#define VMW_PORT_HB_OUT(in1, in2, port_num, magic, \
+ eax, ebx, ecx, edx, si, di, bp) \
+({ \
+ __asm__ __volatile__ ("xchgq %6, %%rbp;" \

+		"cld; rep outsb; "                      \
+		"xchgq %%rbp, %6" :                     \
+		"=a"(eax),                              \
+		"=b"(ebx),                              \
+		"=c"(ecx),                              \
+		"=d"(edx),                              \
+		"+S"(si),                               \
+		"+D"(di),                               \
+		"+r"(bp) :                              \
+		"a"(magic),                             \
+		"b"(in1),                               \
+		"c"(in2),                               \
+		"d"(port_num) :                         \
+		"memory", "cc");                        \

+})

#44 lore raw
In reply to Sinclair Yeh

arch/x86/include/asm/vmware.h line 44

Quoted 4 lines · Sinclair Yeh

These macros will be used by multiple VMWare modules for handling host communication.

arch/x86/include/asm/vmware.h new file +1 -0
+	__asm__ __volatile__ ("inl %%dx" :                              \

This is odd at best; the standard assembly form of this instruction is:

	inl (%dx),%eax

Also, we don't need the underscored forms of asm and volatile for kernel code.

arch/x86/include/asm/vmware.h line 66

Quoted 3 lines
arch/x86/include/asm/vmware.h new file +3 -0
+	__asm__ __volatile__ ("movq %13, %%rbp;"        \
+		"cld; rep outsb; "                      \
+		"movq %%rbp, %6" :                      \

cld shouldn't be necessary here, DF=0 is part of the normal ABI environment.

You also don't save/restore %rbp here, but you do below? Seems very odd.

It might be better do so something like:

+#define VMW_PORT_HB_OUT(in1, in2, port_num, magic, \
+ eax, ebx, ecx, edx, si, di, bp) \
+({ \
+ __asm__ __volatile__ ("xchgq %6, %%rbp;" \

+		"cld; rep outsb; "                      \
+		"xchgq %%rbp, %6" :                     \
+		"=a"(eax),                              \
+		"=b"(ebx),                              \
+		"=c"(ecx),                              \
+		"=d"(edx),                              \
+		"+S"(si),                               \
+		"+D"(di),                               \
+		"+r"(bp) :                              \
+		"a"(magic),                             \
+		"b"(in1),                               \
+		"c"(in2),                               \
+		"d"(port_num) :                         \
+		"memory", "cc");                        \

+})

#9 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Dmitry Torokhov

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

drivers/input/mouse/vmmouse.c +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 10 lines
drivers/input/mouse/vmmouse.c +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

The second reason is this organization makes some on-going future development easier.

Hope this helps.

Sinclair

#31 lore raw

Re: [PATCH 4/6] Input: Remove vmmouse port reservation

In reply to Dmitry Torokhov

Hi,

Quoted 6 lines · Dmitry Torokhov

Hi Sinclair,

Quoted 1 line · Sinclair Yeh

Port reservation is not required.

You need to expand on why we do not need to reserve port.

Thomas gave me this input earlier, too, so I added the one liner.

There was a long discussion on accessing the port a few years ago:
https://lkml.org/lkml/2008/9/24/512

Quoted 5 lines
Quoted 3 lines

Furthermore, this port is shared
by other VMware services for host-side communication.

What services would that be? Do they reserve the port?

This port is used by quite a few guest-to-host communication capabilities, e.g. getting configuration, logging, etc. Currently multiple kernel modules, and one or more priviledged guest user mode app, e.g. open-vmware-tools, use this port without reservation.

After some internal discussions, it was determined that no reservation is required when accessing the port in this manner.

Do you want me to put the above in the commit message?

Quoted 5 lines

Thanks.

Signature · 1 line
Dmitry
#38 lore raw

Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to Xavier Deguillard

Thanks! Done.

Quoted 24 lines · Xavier Deguillard

Hey Sinclair,

drivers/misc/vmw_balloon.c enum vmwballoon_capabilities { · line 157

Quoted 12 lines · Sinclair Yeh
drivers/misc/vmw_balloon.c +11 -0
+#define VMWARE_BALLOON_CMD(cmd, data, result)			   \
+({								   \
+	unsigned long __status, __dummy1, __dummy2;		   \
+	unsigned long __si = 0, __di = 0;			   \
+	VMW_PORT(data, VMW_BALLOON_CMD_##cmd, VMW_BALLOON_HV_PORT, \
+		 VMW_BALLOON_HV_MAGIC,				   \
+		 __status, result, __dummy1, __dummy2, __si, __di);\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	   \
+		result = __dummy1;				   \
+	result &= -1UL;						   \
+	__status & -1UL;					   \
 })

You need to indent the '\' with tabs only, and it looks like spaces are present here (which is also why they don't look aligned).

Other than that I'm good with this:

Xavier

#39 lore raw

Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to Xavier Deguillard

Thanks! Done.

Quoted 24 lines · Xavier Deguillard

Hey Sinclair,

drivers/misc/vmw_balloon.c enum vmwballoon_capabilities { · line 157

Quoted 12 lines · Sinclair Yeh
drivers/misc/vmw_balloon.c +11 -0
+#define VMWARE_BALLOON_CMD(cmd, data, result)			   \
+({								   \
+	unsigned long __status, __dummy1, __dummy2;		   \
+	unsigned long __si = 0, __di = 0;			   \
+	VMW_PORT(data, VMW_BALLOON_CMD_##cmd, VMW_BALLOON_HV_PORT, \
+		 VMW_BALLOON_HV_MAGIC,				   \
+		 __status, result, __dummy1, __dummy2, __si, __di);\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	   \
+		result = __dummy1;				   \
+	result &= -1UL;						   \
+	__status & -1UL;					   \
 })

You need to indent the '\' with tabs only, and it looks like spaces are present here (which is also why they don't look aligned).

Other than that I'm good with this:

Xavier

maintainer
#32 lore raw

Re: [PATCH 4/6] Input: Remove vmmouse port reservation

In reply to Sinclair Yeh
Quoted 19 lines · Sinclair Yeh

Hi,

Quoted 6 lines · Dmitry Torokhov

Hi Sinclair,

Quoted 1 line · Sinclair Yeh

Port reservation is not required.

You need to expand on why we do not need to reserve port.

Thomas gave me this input earlier, too, so I added the one liner.

There was a long discussion on accessing the port a few years ago:
https://lkml.org/lkml/2008/9/24/512

Quoted 4 lines
Quoted 3 lines

Furthermore, this port is shared
by other VMware services for host-side communication.

Quoted 6 lines
Quoted 1 line

What services would that be? Do they reserve the port?

This port is used by quite a few guest-to-host communication capabilities, e.g. getting configuration, logging, etc. Currently multiple kernel modules, and one or more priviledged guest user mode app, e.g. open-vmware-tools, use this port without reservation.

Ah, I forgot that vmmouse does not have a dedicated port...

Quoted 5 lines

After some internal discussions, it was determined that no reservation is required when accessing the port in this manner.

Do you want me to put the above in the commit message?

Not about the bit about "internal discussions", but the rest - yes please.

Signature · 1 line
Dmitry
maintainer
#10 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh
Quoted 39 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

drivers/input/mouse/vmmouse.c +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 10 lines
drivers/input/mouse/vmmouse.c +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

Quoted 4 lines

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

At the cost of wasting cycles though :(.

Oh well, it is not like we are polling the backdoor here, so if you do not care about a few wasted cycles I don't have to either ;)

Quoted 7 lines

The second reason is this organization makes some on-going future development easier.

Hope this helps.

Sinclair

Signature · 1 line
Dmitry
maintainer
#11 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh
Quoted 39 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

drivers/input/mouse/vmmouse.c +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 10 lines
drivers/input/mouse/vmmouse.c +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

Quoted 4 lines

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

At the cost of wasting cycles though :(.

Oh well, it is not like we are polling the backdoor here, so if you do not care about a few wasted cycles I don't have to either ;)

Quoted 7 lines

The second reason is this organization makes some on-going future development easier.

Hope this helps.

Sinclair

Signature · 1 line
Dmitry
#27 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh
Quoted 7 lines · Sinclair Yeh

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

Why are these here and not below the --- line?

And no changelog text at all? Not acceptable :(

greg k-h

#28 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh
Quoted 7 lines · Sinclair Yeh

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

Why are these here and not below the --- line?

And no changelog text at all? Not acceptable :(

greg k-h

#12 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh
Quoted 39 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

drivers/input/mouse/vmmouse.c +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 10 lines
drivers/input/mouse/vmmouse.c +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

Quoted 4 lines

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Quoted 2 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

thanks,

greg k-h

#13 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

Quoted 40 lines · Greg Kroah-Hartman
Quoted 39 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 29 lines
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines

*/

drivers/input/mouse/vmmouse.c +0 -12
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
Quoted 8 lines

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 6 lines
drivers/input/mouse/vmmouse.c +3 -3
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

Quoted 7 lines
Quoted 4 lines

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Maybe it's because I didn't CC you on the rest of the series. I wasn't sure what the proper distribution list is for each part.

This new macro is also used in arch/x86/kernel/cpu/vmware.c and vmw_balloon.c

Quoted 8 lines
Quoted 3 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

So the intent of this series is to centralize similar lines of inline assembly code that are currently used by 3 different kernel modules to a central place. The new vmware.h [patch 0/6] becomes the one header to include for common guest-host communication needs.

Quoted 3 lines

thanks,

greg k-h

#23 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Greg Kroah-Hartman
Quoted 40 lines · Greg Kroah-Hartman
Quoted 39 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 29 lines
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines

*/

drivers/input/mouse/vmmouse.c +0 -12
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
Quoted 8 lines

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 6 lines
drivers/input/mouse/vmmouse.c +3 -3
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

Quoted 7 lines
Quoted 4 lines

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Maybe it's because I didn't CC you on the rest of the series. I wasn't sure what the proper distribution list is for each part.

This new macro is also used in arch/x86/kernel/cpu/vmware.c and vmw_balloon.c

Quoted 8 lines
Quoted 3 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

So the intent of this series is to centralize similar lines of inline assembly code that are currently used by 3 different kernel modules to a central place. The new vmware.h [patch 0/6] becomes the one header to include for common guest-host communication needs.

Quoted 3 lines

thanks,

greg k-h

#24 lore raw

Re: [Linux-graphics-maintainer] [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Greg Kroah-Hartman
Quoted 35 lines · Greg Kroah-Hartman
Quoted 34 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 26 lines
Quoted 20 lines
Quoted 12 lines
Quoted 12 lines

*/

drivers/input/mouse/vmmouse.c +0 -11
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
Quoted 8 lines

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 7 lines
drivers/input/mouse/vmmouse.c +3 -4
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

Quoted 7 lines
Quoted 4 lines

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

IMO, this makes a lot of sense because we now get a single definition of VMW_PORT in the platform code that a developer can refer to to understand things like 32-64 bit compatibilty, and usage conditions and it also forces the developer to adopt the good practice of clearing currently unused input variables rather than to leave them undefined. In addition, if something needs to be changed we have one single place to change rather than a lot of places scattered all over various kernel modules.

Things that we (I) previously, for example, didn't get quite right in the vmmouse module despite spending a considerable amount of time on the subject.

Thanks,
Thomas

#25 lore raw

Re: [Linux-graphics-maintainer] [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Greg Kroah-Hartman
Quoted 35 lines · Greg Kroah-Hartman
Quoted 34 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 26 lines
Quoted 20 lines
Quoted 12 lines
Quoted 12 lines

*/

drivers/input/mouse/vmmouse.c +0 -11
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
Quoted 8 lines

drivers/input/mouse/vmmouse.c struct vmmouse_data { · line 90

Quoted 7 lines
drivers/input/mouse/vmmouse.c +3 -4
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

Quoted 7 lines
Quoted 4 lines

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

IMO, this makes a lot of sense because we now get a single definition of VMW_PORT in the platform code that a developer can refer to to understand things like 32-64 bit compatibilty, and usage conditions and it also forces the developer to adopt the good practice of clearing currently unused input variables rather than to leave them undefined. In addition, if something needs to be changed we have one single place to change rather than a lot of places scattered all over various kernel modules.

Things that we (I) previously, for example, didn't get quite right in the vmmouse module despite spending a considerable amount of time on the subject.

Thanks,
Thomas

#14 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh
Quoted 46 lines · Sinclair Yeh
Quoted 45 lines · Greg Kroah-Hartman
Quoted 43 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

(quoted diff) +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

Review

Quoted 10 lines
(quoted diff) +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

Quoted 5 lines
Quoted 2 lines

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Maybe it's because I didn't CC you on the rest of the series. I wasn't sure what the proper distribution list is for each part.

Use scripts/get_maintainer.pl, that's what it is there for. A number of those patches should go through me, if not all of them, if you want them merged...

Quoted 3 lines

This new macro is also used in arch/x86/kernel/cpu/vmware.c and vmw_balloon.c

And it's used inconsistantly in those patches (you don't set the dummy variables to 0 in all of them...) Now maybe that's just how the asm functions work, but it's not very obvious as to why this is at all.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

Quoted 4 lines

So the intent of this series is to centralize similar lines of inline assembly code that are currently used by 3 different kernel modules to a central place. The new vmware.h [patch 0/6] becomes the one header to include for common guest-host communication needs.

Why can't it go into vmw_vmci_defs.h instead, or your other .h file, why create yet-another-.h-file for your bus? You already have 2, this would make it 3, which seems like a lot...

thanks,

greg k-h

#15 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

Quoted 73 lines · Greg Kroah-Hartman
Quoted 46 lines · Sinclair Yeh
Quoted 45 lines · Greg Kroah-Hartman
Quoted 43 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

(quoted diff) +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

Review

Quoted 10 lines
(quoted diff) +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

Quoted 5 lines
Quoted 2 lines

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Maybe it's because I didn't CC you on the rest of the series. I wasn't sure what the proper distribution list is for each part.

Use scripts/get_maintainer.pl, that's what it is there for. A number of those patches should go through me, if not all of them, if you want them merged...

Quoted 3 lines

This new macro is also used in arch/x86/kernel/cpu/vmware.c and vmw_balloon.c

And it's used inconsistantly in those patches (you don't set the dummy variables to 0 in all of them...) Now maybe that's just how the asm functions work, but it's not very obvious as to why this is at all.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

Quoted 8 lines
Quoted 4 lines

So the intent of this series is to centralize similar lines of inline assembly code that are currently used by 3 different kernel modules to a central place. The new vmware.h [patch 0/6] becomes the one header to include for common guest-host communication needs.

Why can't it go into vmw_vmci_defs.h instead, or your other .h file, why create yet-another-.h-file for your bus? You already have 2, this would make it 3, which seems like a lot...

Ok, thanks. Let me see if it make sense to use one of the existing 2 files. Either way, I'll respin this series to include all the comments so far.

Quoted 4 lines

thanks,

greg k-h

#16 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Greg Kroah-Hartman
Quoted 73 lines · Greg Kroah-Hartman
Quoted 46 lines · Sinclair Yeh
Quoted 45 lines · Greg Kroah-Hartman
Quoted 43 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

(quoted diff) +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

Review

Quoted 10 lines
(quoted diff) +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

Quoted 5 lines
Quoted 2 lines

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Maybe it's because I didn't CC you on the rest of the series. I wasn't sure what the proper distribution list is for each part.

Use scripts/get_maintainer.pl, that's what it is there for. A number of those patches should go through me, if not all of them, if you want them merged...

Quoted 3 lines

This new macro is also used in arch/x86/kernel/cpu/vmware.c and vmw_balloon.c

And it's used inconsistantly in those patches (you don't set the dummy variables to 0 in all of them...) Now maybe that's just how the asm functions work, but it's not very obvious as to why this is at all.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

Quoted 8 lines
Quoted 4 lines

So the intent of this series is to centralize similar lines of inline assembly code that are currently used by 3 different kernel modules to a central place. The new vmware.h [patch 0/6] becomes the one header to include for common guest-host communication needs.

Why can't it go into vmw_vmci_defs.h instead, or your other .h file, why create yet-another-.h-file for your bus? You already have 2, this would make it 3, which seems like a lot...

Ok, thanks. Let me see if it make sense to use one of the existing 2 files. Either way, I'll respin this series to include all the comments so far.

Quoted 4 lines

thanks,

greg k-h

maintainer
#17 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Greg Kroah-Hartman
Quoted 73 lines · Greg Kroah-Hartman
Quoted 46 lines · Sinclair Yeh
Quoted 45 lines · Greg Kroah-Hartman
Quoted 43 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

(quoted diff) +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

Review

Quoted 10 lines
(quoted diff) +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

Quoted 5 lines
Quoted 2 lines

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Maybe it's because I didn't CC you on the rest of the series. I wasn't sure what the proper distribution list is for each part.

Use scripts/get_maintainer.pl, that's what it is there for. A number of those patches should go through me, if not all of them, if you want them merged...

Quoted 3 lines

This new macro is also used in arch/x86/kernel/cpu/vmware.c and vmw_balloon.c

And it's used inconsistantly in those patches (you don't set the dummy variables to 0 in all of them...) Now maybe that's just how the asm functions work, but it's not very obvious as to why this is at all.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

Quoted 8 lines
Quoted 4 lines

So the intent of this series is to centralize similar lines of inline assembly code that are currently used by 3 different kernel modules to a central place. The new vmware.h [patch 0/6] becomes the one header to include for common guest-host communication needs.

Why can't it go into vmw_vmci_defs.h instead, or your other .h file, why create yet-another-.h-file for your bus? You already have 2, this would make it 3, which seems like a lot...

Umm, you are not saying that vmmouse should include vmci header file(s), are you? Because the 2 are unrelated and vmci does not use the hypervisor port to communicate with host IIRC.

Thanks.

Signature · 1 line
Dmitry
#18 lore raw

Re: [Linux-graphics-maintainer] [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

Quoted 66 lines · Dmitry Torokhov
Quoted 65 lines · Greg Kroah-Hartman
Quoted 36 lines · Sinclair Yeh
Quoted 35 lines · Greg Kroah-Hartman
Quoted 34 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 26 lines
Quoted 20 lines
Quoted 12 lines
Quoted 12 lines

*/

(quoted diff) +0 -11
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
Quoted 8 lines

Review

Quoted 7 lines
(quoted diff) +3 -4
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Maybe it's because I didn't CC you on the rest of the series. I wasn't sure what the proper distribution list is for each part.

Use scripts/get_maintainer.pl, that's what it is there for. A number of those patches should go through me, if not all of them, if you want them merged...

Quoted 2 lines

This new macro is also used in arch/x86/kernel/cpu/vmware.c and vmw_balloon.c

And it's used inconsistantly in those patches (you don't set the dummy variables to 0 in all of them...) Now maybe that's just how the asm functions work, but it's not very obvious as to why this is at all.

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

So the intent of this series is to centralize similar lines of inline assembly code that are currently used by 3 different kernel modules to a central place. The new vmware.h [patch 0/6] becomes the one header to include for common guest-host communication needs.

Quoted 6 lines
Quoted 3 lines

Why can't it go into vmw_vmci_defs.h instead, or your other .h file, why create yet-another-.h-file for your bus? You already have 2, this would make it 3, which seems like a lot...

Umm, you are not saying that vmmouse should include vmci header file(s), are you? Because the 2 are unrelated and vmci does not use the hypervisor port to communicate with host IIRC.

Also the platform setup code uses the hypervisor port, so it's a natural place for the macro defines.

/Thomas

Quoted 3 lines

Thanks.

#19 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Dmitry Torokhov
Quoted 79 lines · Dmitry Torokhov
Quoted 78 lines · Greg Kroah-Hartman
Quoted 46 lines · Sinclair Yeh
Quoted 45 lines · Greg Kroah-Hartman
Quoted 43 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

(quoted diff) +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

Review

Quoted 10 lines
(quoted diff) +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

Quoted 5 lines
Quoted 2 lines

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Maybe it's because I didn't CC you on the rest of the series. I wasn't sure what the proper distribution list is for each part.

Use scripts/get_maintainer.pl, that's what it is there for. A number of those patches should go through me, if not all of them, if you want them merged...

Quoted 3 lines

This new macro is also used in arch/x86/kernel/cpu/vmware.c and vmw_balloon.c

And it's used inconsistantly in those patches (you don't set the dummy variables to 0 in all of them...) Now maybe that's just how the asm functions work, but it's not very obvious as to why this is at all.

Quoted 12 lines
Quoted 7 lines
Quoted 2 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

So the intent of this series is to centralize similar lines of inline assembly code that are currently used by 3 different kernel modules to a central place. The new vmware.h [patch 0/6] becomes the one header to include for common guest-host communication needs.

Quoted 7 lines
Quoted 3 lines

Why can't it go into vmw_vmci_defs.h instead, or your other .h file, why create yet-another-.h-file for your bus? You already have 2, this would make it 3, which seems like a lot...

Umm, you are not saying that vmmouse should include vmci header file(s), are you? Because the 2 are unrelated and vmci does not use the hypervisor port to communicate with host IIRC.

vmmouse should include some type of "vmware bus" .h file, if it's not the vmw_* files, what are they for? My point being, I didn't see the need to add another .h file when we should probably already have one for this bus, right?

thanks,

greg k-h

maintainer
#20 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

Quoted 84 lines · Greg Kroah-Hartman
Quoted 83 lines · Dmitry Torokhov
Quoted 81 lines · Greg Kroah-Hartman
Quoted 46 lines · Sinclair Yeh
Quoted 45 lines · Greg Kroah-Hartman
Quoted 43 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

(quoted diff) +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

Review

Quoted 10 lines
(quoted diff) +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

Quoted 5 lines
Quoted 2 lines

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Maybe it's because I didn't CC you on the rest of the series. I wasn't sure what the proper distribution list is for each part.

Use scripts/get_maintainer.pl, that's what it is there for. A number of those patches should go through me, if not all of them, if you want them merged...

Quoted 3 lines

This new macro is also used in arch/x86/kernel/cpu/vmware.c and vmw_balloon.c

And it's used inconsistantly in those patches (you don't set the dummy variables to 0 in all of them...) Now maybe that's just how the asm functions work, but it's not very obvious as to why this is at all.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

Quoted 4 lines

So the intent of this series is to centralize similar lines of inline assembly code that are currently used by 3 different kernel modules to a central place. The new vmware.h [patch 0/6] becomes the one header to include for common guest-host communication needs.

Why can't it go into vmw_vmci_defs.h instead, or your other .h file, why create yet-another-.h-file for your bus? You already have 2, this would make it 3, which seems like a lot...

Quoted 6 lines
Quoted 3 lines

Umm, you are not saying that vmmouse should include vmci header file(s), are you? Because the 2 are unrelated and vmci does not use the hypervisor port to communicate with host IIRC.

vmmouse should include some type of "vmware bus" .h file, if it's not the vmw_* files, what are they for?

I see:

dtor@dtor-ws:~/kernel/work$ ls include/linux/vmw*
include/linux/vmw_vmci_api.h  include/linux/vmw_vmci_defs.h

so they are for VMCI.

Quoted 3 lines

My point being, I didn't see the
need to add another .h file when we should probably already have one for this bus, right?

You keep saying "bus" and I am confused. There is not really a bus there as (unfortunately) VMware did not come with a unified interface for host/guest communication, but rather let each group come up with their own way of doing things. So we have vmmouse and, as I was reminded, userspace agent using one virtual IO port to communicate, vmballoon is using another IO port, pvscsi, vmxnet3 and vmci are virtual PCI devices and Thomas can tell more about vmwgfx as I never looked at it closely.

So if we want to consolidate the hypervisor port accessors (which I am not entirely convinced is worthwhile as the set of arguments/returned values/registers used depends on command sent through the port and these unified macros now require unneeded initializations of dummy variables) then we indeed need a new header.

Thanks.

Signature · 1 line
Dmitry
maintainer
#21 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Greg Kroah-Hartman
Quoted 84 lines · Greg Kroah-Hartman
Quoted 83 lines · Dmitry Torokhov
Quoted 81 lines · Greg Kroah-Hartman
Quoted 46 lines · Sinclair Yeh
Quoted 45 lines · Greg Kroah-Hartman
Quoted 43 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

(quoted diff) +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

Review

Quoted 10 lines
(quoted diff) +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

Quoted 5 lines
Quoted 2 lines

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Maybe it's because I didn't CC you on the rest of the series. I wasn't sure what the proper distribution list is for each part.

Use scripts/get_maintainer.pl, that's what it is there for. A number of those patches should go through me, if not all of them, if you want them merged...

Quoted 3 lines

This new macro is also used in arch/x86/kernel/cpu/vmware.c and vmw_balloon.c

And it's used inconsistantly in those patches (you don't set the dummy variables to 0 in all of them...) Now maybe that's just how the asm functions work, but it's not very obvious as to why this is at all.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

Quoted 4 lines

So the intent of this series is to centralize similar lines of inline assembly code that are currently used by 3 different kernel modules to a central place. The new vmware.h [patch 0/6] becomes the one header to include for common guest-host communication needs.

Why can't it go into vmw_vmci_defs.h instead, or your other .h file, why create yet-another-.h-file for your bus? You already have 2, this would make it 3, which seems like a lot...

Quoted 6 lines
Quoted 3 lines

Umm, you are not saying that vmmouse should include vmci header file(s), are you? Because the 2 are unrelated and vmci does not use the hypervisor port to communicate with host IIRC.

vmmouse should include some type of "vmware bus" .h file, if it's not the vmw_* files, what are they for?

I see:

dtor@dtor-ws:~/kernel/work$ ls include/linux/vmw*
include/linux/vmw_vmci_api.h  include/linux/vmw_vmci_defs.h

so they are for VMCI.

Quoted 3 lines

My point being, I didn't see the
need to add another .h file when we should probably already have one for this bus, right?

You keep saying "bus" and I am confused. There is not really a bus there as (unfortunately) VMware did not come with a unified interface for host/guest communication, but rather let each group come up with their own way of doing things. So we have vmmouse and, as I was reminded, userspace agent using one virtual IO port to communicate, vmballoon is using another IO port, pvscsi, vmxnet3 and vmci are virtual PCI devices and Thomas can tell more about vmwgfx as I never looked at it closely.

So if we want to consolidate the hypervisor port accessors (which I am not entirely convinced is worthwhile as the set of arguments/returned values/registers used depends on command sent through the port and these unified macros now require unneeded initializations of dummy variables) then we indeed need a new header.

Thanks.

Signature · 1 line
Dmitry
#22 lore raw

Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Greg Kroah-Hartman
Quoted 84 lines · Greg Kroah-Hartman
Quoted 83 lines · Dmitry Torokhov
Quoted 81 lines · Greg Kroah-Hartman
Quoted 46 lines · Sinclair Yeh
Quoted 45 lines · Greg Kroah-Hartman
Quoted 43 lines · Sinclair Yeh

Hi,

Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Sinclair Yeh

Hi,

<snip>

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 9 lines

*/

(quoted diff) +0 -8
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)      \
-({                                                 \
-   unsigned long __dummy1, __dummy2;               \
-   __asm__ __volatile__ ("inl %%dx" :              \
-           "=a"(out1),                             \
-           "=b"(out2),                             \
-           "=c"(out3),                             \
-           "=d"(out4),                             \

Review

Quoted 10 lines
(quoted diff) +3 -7
-           "=S"(__dummy1),                         \
-           "=D"(__dummy2) :                        \
-           "a"(VMMOUSE_PROTO_MAGIC),               \
-           "b"(in1),                               \
-           "c"(VMMOUSE_PROTO_CMD_##cmd),           \
-           "d"(VMMOUSE_PROTO_PORT) :               \
-           "memory");                              \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)                 \
+({                                                            \
+   unsigned long __dummy1 = 0, __dummy2 = 0;                  \

Why do we need to initialize dummies?

Quoted 7 lines
Quoted 2 lines

Because for some commands those parameters to VMW_PORT() can be both input and outout.

The vmmouse commands do not use them as input though, so it seems we are simply wasting CPU cycles setting them to 0 just because we are using the new VMW_PORT here. Why do we need to switch? What is the benefit of doing this?

There are two reasons. One is to make the code more readable and maintainable. Rather than having mostly similar inline assembly code sprinkled across multiple modules, we can just use the macros and document that.

Quoted 5 lines
Quoted 2 lines

But the macro is only used here, and the variables aren't used at all, so it makes no sense in this file.

Maybe it's because I didn't CC you on the rest of the series. I wasn't sure what the proper distribution list is for each part.

Use scripts/get_maintainer.pl, that's what it is there for. A number of those patches should go through me, if not all of them, if you want them merged...

Quoted 3 lines

This new macro is also used in arch/x86/kernel/cpu/vmware.c and vmw_balloon.c

And it's used inconsistantly in those patches (you don't set the dummy variables to 0 in all of them...) Now maybe that's just how the asm functions work, but it's not very obvious as to why this is at all.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

The second reason is this organization makes some on-going future development easier.

We don't plan for "future" development other than a single patch series, as we have no idea what that development is, nor if it will really happen. You can always change this file later if you need to, nothing is keeping that from happening.

Quoted 4 lines

So the intent of this series is to centralize similar lines of inline assembly code that are currently used by 3 different kernel modules to a central place. The new vmware.h [patch 0/6] becomes the one header to include for common guest-host communication needs.

Why can't it go into vmw_vmci_defs.h instead, or your other .h file, why create yet-another-.h-file for your bus? You already have 2, this would make it 3, which seems like a lot...

Quoted 8 lines
Quoted 3 lines

Umm, you are not saying that vmmouse should include vmci header file(s), are you? Because the 2 are unrelated and vmci does not use the hypervisor port to communicate with host IIRC.

vmmouse should include some type of "vmware bus" .h file, if it's not the vmw_* files, what are they for? My point being, I didn't see the need to add another .h file when we should probably already have one for this bus, right?

I had a brief chat with Thomas on this, and he added to Dmitry's reply earlier.

The two existing *.h files are for the VMCI driver, and the new macros are used by the platform code and also other drivers like vmw_balloon and vmmouse.

It makes more sense to create a new vmware.h file in arch/x86/include/asm

Sinclair

#45 lore raw
In reply to H. Peter Anvin

Thanks Peter.

Quoted 9 lines · H. Peter Anvin

arch/x86/include/asm/vmware.h line 44

Quoted 4 lines · Sinclair Yeh

These macros will be used by multiple VMWare modules for handling host communication.

arch/x86/include/asm/vmware.h new file +1 -0
+	__asm__ __volatile__ ("inl %%dx" :                              \

This is odd at best; the standard assembly form of this instruction is:

	inl (%dx),%eax

Ok, I'm not sure why this worked and compiled before. Fixed.

Quoted 11 lines

Also, we don't need the underscored forms of asm and volatile for kernel code.

arch/x86/include/asm/vmware.h line 66

Quoted 3 lines
arch/x86/include/asm/vmware.h new file +3 -0
+	__asm__ __volatile__ ("movq %13, %%rbp;"        \
+		"cld; rep outsb; "                      \
+		"movq %%rbp, %6" :                      \

cld shouldn't be necessary here, DF=0 is part of the normal ABI environment.

You also don't save/restore %rbp here, but you do below? Seems very odd.

Good catch. Fixed.

Quoted 12 lines

It might be better do so something like:

arch/x86/include/asm/vmware.h new file +9 -0
+#define VMW_PORT_HB_OUT(in1, in2, port_num, magic,     \
+			eax, ebx, ecx, edx, si, di, bp) \
+({                                                     \
+	__asm__ __volatile__ ("xchgq %6, %%rbp;"        \
+		"cld; rep outsb; "                      \
+		"xchgq %%rbp, %6" :                     \
+		"=a"(eax),                              \
+		"=b"(ebx),                              \
+		"=c"(ecx),                              \

arch/x86/include/asm/vmware.h line 82

Quoted 10 lines
arch/x86/include/asm/vmware.h new file +10 -0
+		"=d"(edx),                              \
+		"+S"(si),                               \
+		"+D"(di),                               \
+		"+r"(bp) :                              \
+		"a"(magic),                             \
+		"b"(in1),                               \
+		"c"(in2),                               \
+		"d"(port_num) :                         \
+		"memory", "cc");                        \
+})

This is great. Changed.

Updated patch set incoming.

Sinclair

#47 lore raw

PATCH 1/6 x86: Add VMWare Host Communication Macros

In reply to a message not in the archive

These macros will be used by multiple VMWare modules for handling host communication.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Alok Kataria <[email protected]>
Cc Xavier Deguillard <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

---

v2:
* Keeping only the minimal common platform defines
* added vmware_platform() check function

v3:
* Added new field to handle different hypervisor magic values

v4:
* Make it so that "cmd" is always the first parameter for both High-Bandwidh and non-High-Bandwidth version of the macro
* Addressed comments from H. Peter Anvin on the assembly code

---
 arch/x86/include/asm/vmware.h | 126 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 arch/x86/include/asm/vmware.h
arch/x86/include/asm/vmware.h new file +126 -0
new file mode 100644
index 0000000..ad359e0
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2015, VMware, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ * Based on code from vmware.c and vmmouse.c.
+ * Author:
+ *   Sinclair Yeh <[email protected]>
+ */
+#ifndef _ASM_X86_VMWARE_H
+#define _ASM_X86_VMWARE_H
+
+
+/**
+ * Hypervisor-specific bi-directional communication channel.  Should never
+ * execute on bare metal hardware.  The caller must make sure to check for
+ * supported hypervisor before using these macros.
+ *
+ * The last two parameters are both input and output and must be initialized.
+ *
+ * @cmd: [IN] Message Cmd
+ * @in1: [IN] Message Len
+ * @port_num: [IN] port number + [channel id]
+ * @magic: [IN] hypervisor magic value
+ * @eax: [OUT] value of EAX register
+ * @ebx: [OUT] e.g. status from an HB message status command
+ * @ecx: [OUT] e.g. status from a non-HB message status command
+ * @edx: [OUT] e.g. channel id
+ * @si: [INOUT] set to 0 if not used
+ * @di: [INOUT] set to 0 if not used
+ */
+#define VMW_PORT(cmd, in1, port_num, magic, eax, ebx, ecx, edx, si, di)	\
+({									\
+	asm volatile ("inl %%dx, %%eax;" :				\
+		"=a"(eax),						\
+		"=b"(ebx),						\
+		"=c"(ecx),						\
+		"=d"(edx),						\
+		"=S"(si),						\
+		"=D"(di) :						\
+		"a"(magic),						\
+		"b"(in1),						\
+		"c"(cmd),						\
+		"d"(port_num),						\
+		"S"(si),						\
+		"D"(di) :						\
+		"memory");						\
+})
+
+
+/**
+ * Hypervisor-specific bi-directional communication channel.  Should never
+ * execute on bare metal hardware.  The caller must make sure to check for
+ * supported hypervisor before using these macros.
+ *
+ * The last 3 parameters are both input and output and must be initialized.
+ *
+ * @cmd: [IN] Message Cmd
+ * @in1: [IN] Message Len
+ * @port_num: [IN] port number + [channel id]
+ * @magic: [IN] hypervisor magic value
+ * @eax: [OUT] value of EAX register
+ * @ebx: [OUT] e.g. status from an HB message status command
+ * @ecx: [OUT] e.g. status from a non-HB message status command
+ * @edx: [OUT] e.g. channel id
+ * @si: [INOUT] set to 0 if not used
+ * @di: [INOUT] set to 0 if not used
+ * @bp: [INOUT] set to 0 if not used
+ */
+#define VMW_PORT_HB_OUT(cmd, in1, port_num, magic,	\
+			eax, ebx, ecx, edx, si, di, bp)	\
+({							\
+	asm volatile ("push %%rbp;"			\
+		"xchgq %6, %%rbp;"			\
+		"rep outsb;"				\
+		"xchgq %%rbp, %6;"			\
+		"pop %%rbp;" :				\
+		"=a"(eax),				\
+		"=b"(ebx),				\
+		"=c"(ecx),				\
+		"=d"(edx),				\
+		"+S"(si),				\
+		"+D"(di),				\
+		"+r"(bp) :				\
+		"a"(magic),				\
+		"b"(cmd),				\
+		"c"(in1),				\
+		"d"(port_num) :				\
+		"memory", "cc");			\
+})
+
+
+#define VMW_PORT_HB_IN(cmd, in1, port_num, magic,		\
+		       eax, ebx, ecx, edx, si, di, bp)		\
+({								\
+	asm volatile ("push %%rbp;"				\
+		"xchgq %6, %%rbp;"				\
+		"rep insb;"					\
+		"xchgq %%rbp, %6;"				\
+		"pop %%rbp" :					\
+		"=a"(eax),					\
+		"=b"(ebx),					\
+		"=c"(ecx),					\
+		"=d"(edx),					\
+		"+S"(si),					\
+		"+D"(di),					\
+		"+r"(bp) :					\
+		"a"(magic),					\
+		"b"(cmd),					\
+		"c"(in1),					\
+		"d"(port_num) :					\
+		"memory", "cc");				\
+})
+
+
+#endif
+
Signature · 1 line
1.9.1
#49 lore raw

PATCH 3/6 Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to a message not in the archive

Updated the VMMOUSE macro to use the new VMW_PORT macro. Doing this instead of replacing all existing instances of VMWMOUSE to minimize code change.

---

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

v4:
Swapped parameters 1 and 2 when calling VMW_PORT because the macro has been updated

---
 drivers/input/mouse/vmmouse.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/input/mouse/vmmouse.c +7 -15
index e272f06..ddb152c 100644
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #include "psmouse.h"
 #include "vmmouse.h"
@@ -84,21 +85,12 @@ struct vmmouse_data {
  * implementing the vmmouse protocol. Should never execute on
  * bare metal hardware.
  */
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)	\
-({							\
-	unsigned long __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :		\
-		"=a"(out1),				\
-		"=b"(out2),				\
-		"=c"(out3),				\
-		"=d"(out4),				\
-		"=S"(__dummy1),				\
-		"=D"(__dummy2) :			\
-		"a"(VMMOUSE_PROTO_MAGIC),		\
-		"b"(in1),				\
-		"c"(VMMOUSE_PROTO_CMD_##cmd),		\
-		"d"(VMMOUSE_PROTO_PORT) :		\
-		"memory");		                \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)		   \
+({								   \
+	unsigned long __dummy1 = 0, __dummy2 = 0;		   \
+	VMW_PORT(VMMOUSE_PROTO_CMD_##cmd, in1, VMMOUSE_PROTO_PORT, \
+		 VMMOUSE_PROTO_MAGIC,				   \
+		 out1, out2, out3, out4, __dummy1, __dummy2);      \
 })
 
 /**
Signature · 1 line
1.9.1
#51 lore raw

PATCH 5/6 x86: Remove address from the vmware.c header

In reply to a message not in the archive

We should no longer have mailing address of Free Software Foundation in the copyright header. Since this patch series touches this file, taking this opportunity to fix the header.

---
 arch/x86/kernel/cpu/vmware.c | 4 ----
 1 file changed, 4 deletions(-)
arch/x86/kernel/cpu/vmware.c +0 -4
index 67c429d..c157c4b 100644
@@ -15,10 +15,6 @@
  * NON INFRINGEMENT.  See the GNU General Public License for more
  * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
  */
 
 #include <linux/dmi.h>
Signature · 1 line
1.9.1
#52 lore raw

PATCH 6/6 VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to a message not in the archive

Updated VMWARE_BALLOON_CMD to use the common VMW_PORT macro. Doing this rather than replacing all instances of VMWARE_BALLOON_CMD to minimize code change.

---
v1
Swapped parameters 1 and 2 to VMW_PORT because the macro has been updated

---
 drivers/misc/vmw_balloon.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)
drivers/misc/vmw_balloon.c +12 -17
index ffb5634..f8f60ca 100644
@@ -43,6 +43,7 @@
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
@@ -142,23 +143,17 @@ enum vmwballoon_capabilities {
 
 #define VMW_BALLOON_SUCCESS_WITH_CAPABILITIES	(0x03000000)
 
-#define VMWARE_BALLOON_CMD(cmd, data, result)			\
-({								\
-	unsigned long __status, __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :			\
-		"=a"(__status),					\
-		"=c"(__dummy1),					\
-		"=d"(__dummy2),					\
-		"=b"(result) :					\
-		"0"(VMW_BALLOON_HV_MAGIC),			\
-		"1"(VMW_BALLOON_CMD_##cmd),			\
-		"2"(VMW_BALLOON_HV_PORT),			\
-		"3"(data) :					\
-		"memory");					\
-	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	\
-		result = __dummy1;				\
-	result &= -1UL;						\
-	__status & -1UL;					\
+#define VMWARE_BALLOON_CMD(cmd, data, result)			   \
+({								   \
+	unsigned long __status, __dummy1, __dummy2;		   \
+	unsigned long __si = 0, __di = 0;			   \
+	VMW_PORT(VMW_BALLOON_CMD_##cmd, data, VMW_BALLOON_HV_PORT, \
+		 VMW_BALLOON_HV_MAGIC,				   \
+		 __status, result, __dummy1, __dummy2, __si, __di);\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	   \
+		result = __dummy1;				   \
+	result &= -1UL;						   \
+	__status & -1UL;					   \
 })
 
 #ifdef CONFIG_DEBUG_FS
Signature · 1 line
1.9.1
#50 lore raw

PATCH 4/6 Input: Remove vmmouse port reservation

In reply to a message not in the archive

This port is used by quite a few guest-to-host communication capabilities, e.g. getting configuration, logging, etc. Currently multiple kernel modules, and one or more priviledged guest user mode app, e.g. open-vm-tools, use this port without reservation.

It was determined that no reservation is required when accessing the port in this manner.

---
 drivers/input/mouse/vmmouse.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/input/mouse/vmmouse.c +1 -18
index ddb152c..e881c87 100644
@@ -347,16 +347,10 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
 		return -ENXIO;
 	}
 
-	if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {
-		psmouse_dbg(psmouse, "VMMouse port in use.\n");
-		return -EBUSY;
-	}
-
 	/* Check if the device is present */
 	response = ~VMMOUSE_PROTO_MAGIC;
 	VMMOUSE_CMD(GETVERSION, 0, version, response, dummy1, dummy2);
 	if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU) {
-		release_region(VMMOUSE_PROTO_PORT, 4);
 		return -ENXIO;
 	}
 
@@ -366,8 +360,6 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
 		psmouse->model = version;
 	}
 
-	release_region(VMMOUSE_PROTO_PORT, 4);
-
 	return 0;
 }
 
@@ -386,7 +378,6 @@ static void vmmouse_disconnect(struct psmouse *psmouse)
 	psmouse_reset(psmouse);
 	input_unregister_device(priv->abs_dev);
 	kfree(priv);
-	release_region(VMMOUSE_PROTO_PORT, 4);
 }
 
 /**
@@ -430,15 +421,10 @@ int vmmouse_init(struct psmouse *psmouse)
 	struct input_dev *rel_dev = psmouse->dev, *abs_dev;
 	int error;
 
-	if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {
-		psmouse_dbg(psmouse, "VMMouse port in use.\n");
-		return -EBUSY;
-	}
-
 	psmouse_reset(psmouse);
 	error = vmmouse_enable(psmouse);
 	if (error)
-		goto release_region;
+		return error;
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	abs_dev = input_allocate_device();
@@ -493,8 +479,5 @@ init_fail:
 	kfree(priv);
 	psmouse->private = NULL;
 
-release_region:
-	release_region(VMMOUSE_PROTO_PORT, 4);
-
 	return error;
 }
Signature · 1 line
1.9.1
#48 lore raw

PATCH 2/6 x86: Update vmware.c to use the common VMW_PORT macros

In reply to a message not in the archive

Updated the VMWARE_PORT macro to use the new VMW_PORT macro. Doing this instead of replacing all existing instances of VMWARE_PORT to minimize code change.

---

v2:
Instead of replacing all existing instances of VMWARE_PORT with VMW_PORT, update VMWARE_PORT to use the new VMW_PORT.

v3:
Using updated VMWARE_PORT() macro, which needs hypervisor magic in the parameter

v4:
Swapped the first and second parameters because VMW_PORT has changed.

---
 arch/x86/kernel/cpu/vmware.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/vmware.c +9 -7
index 628a059..67c429d 100644
@@ -26,6 +26,7 @@
 #include <asm/div64.h>
 #include <asm/x86_init.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #define CPUID_VMWARE_INFO_LEAF	0x40000000
 #define VMWARE_HYPERVISOR_MAGIC	0x564D5868
@@ -37,13 +38,14 @@
 #define VMWARE_PORT_CMD_LEGACY_X2APIC	3
 #define VMWARE_PORT_CMD_VCPU_RESERVED	31
 
-#define VMWARE_PORT(cmd, eax, ebx, ecx, edx)				\
-	__asm__("inl (%%dx)" :						\
-			"=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) :	\
-			"0"(VMWARE_HYPERVISOR_MAGIC),			\
-			"1"(VMWARE_PORT_CMD_##cmd),			\
-			"2"(VMWARE_HYPERVISOR_PORT), "3"(UINT_MAX) :	\
-			"memory");
+#define VMWARE_PORT(cmd, eax, ebx, ecx, edx)				  \
+({									  \
+	unsigned long __si = 0, __di = 0;                                 \
+	VMW_PORT(VMWARE_PORT_CMD_##cmd, UINT_MAX, VMWARE_HYPERVISOR_PORT, \
+		 VMWARE_HYPERVISOR_MAGIC,                                 \
+		 eax, ebx, ecx, edx, __si, __di);                         \
+})
+
 
 static inline int __vmware_platform(void)
 {
Signature · 1 line
1.9.1
#53 lore raw

PATCH 6/6 VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to a message not in the archive

Updated VMWARE_BALLOON_CMD to use the common VMW_PORT macro. Doing this rather than replacing all instances of VMWARE_BALLOON_CMD to minimize code change.

---
v1
Swapped parameters 1 and 2 to VMW_PORT because the macro has been updated

---
 drivers/misc/vmw_balloon.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)
drivers/misc/vmw_balloon.c +12 -17
index ffb5634..f8f60ca 100644
@@ -43,6 +43,7 @@
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
@@ -142,23 +143,17 @@ enum vmwballoon_capabilities {
 
 #define VMW_BALLOON_SUCCESS_WITH_CAPABILITIES	(0x03000000)
 
-#define VMWARE_BALLOON_CMD(cmd, data, result)			\
-({								\
-	unsigned long __status, __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :			\
-		"=a"(__status),					\
-		"=c"(__dummy1),					\
-		"=d"(__dummy2),					\
-		"=b"(result) :					\
-		"0"(VMW_BALLOON_HV_MAGIC),			\
-		"1"(VMW_BALLOON_CMD_##cmd),			\
-		"2"(VMW_BALLOON_HV_PORT),			\
-		"3"(data) :					\
-		"memory");					\
-	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	\
-		result = __dummy1;				\
-	result &= -1UL;						\
-	__status & -1UL;					\
+#define VMWARE_BALLOON_CMD(cmd, data, result)			   \
+({								   \
+	unsigned long __status, __dummy1, __dummy2;		   \
+	unsigned long __si = 0, __di = 0;			   \
+	VMW_PORT(VMW_BALLOON_CMD_##cmd, data, VMW_BALLOON_HV_PORT, \
+		 VMW_BALLOON_HV_MAGIC,				   \
+		 __status, result, __dummy1, __dummy2, __si, __di);\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	   \
+		result = __dummy1;				   \
+	result &= -1UL;						   \
+	__status & -1UL;					   \
 })
 
 #ifdef CONFIG_DEBUG_FS
Signature · 1 line
1.9.1
#57 lore raw

PATCH 3/6 Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh

Updated the VMMOUSE macro to use the new VMW_PORT macro. Doing this instead of replacing all existing instances of VMWMOUSE to minimize code change.

---

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

v4:
Swapped parameters 1 and 2 when calling VMW_PORT because the macro has been updated

v5:
Updated VMW_PORT() usage since the macro has been updated

---
 drivers/input/mouse/vmmouse.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/input/mouse/vmmouse.c +7 -15
index e272f06..d06daf6 100644
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #include "psmouse.h"
 #include "vmmouse.h"
@@ -84,21 +85,12 @@ struct vmmouse_data {
  * implementing the vmmouse protocol. Should never execute on
  * bare metal hardware.
  */
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)	\
-({							\
-	unsigned long __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :		\
-		"=a"(out1),				\
-		"=b"(out2),				\
-		"=c"(out3),				\
-		"=d"(out4),				\
-		"=S"(__dummy1),				\
-		"=D"(__dummy2) :			\
-		"a"(VMMOUSE_PROTO_MAGIC),		\
-		"b"(in1),				\
-		"c"(VMMOUSE_PROTO_CMD_##cmd),		\
-		"d"(VMMOUSE_PROTO_PORT) :		\
-		"memory");		                \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)		\
+({								\
+	unsigned long __dummy1, __dummy2;			\
+	VMW_PORT(VMMOUSE_PROTO_CMD_##cmd, in1, 0, 0,		\
+		 VMMOUSE_PROTO_PORT, VMMOUSE_PROTO_MAGIC,	\
+		 out1, out2, out3, out4, __dummy1, __dummy2);   \
 })
 
 /**
Signature · 1 line
1.9.1
#54 lore raw

cover Create common VMWare host port communication macros v3

In reply to a message not in the archive

The first patch in this series creates three macros for communicating with the host from a Linux guest.

Most of the subsequent patches convert the existing assembly code to using these new macros.

---

v2
Updated the patchset with comments from reviews

v3
vmw_balloon.c's usage of the macro has changed since this series was originally created in December 2015. The updated macros also addressed some of the variable initialization requirement comments from earlier reviews.

#60 lore raw

PATCH 5/6 x86: Remove address from the vmware.c header

We should no longer have mailing address of Free Software Foundation in the copyright header. Since this patch series touches this file, taking this opportunity to fix the header.

---
 arch/x86/kernel/cpu/vmware.c | 4 ----
 1 file changed, 4 deletions(-)
arch/x86/kernel/cpu/vmware.c +0 -4
index 8e900d3..93823f3 100644
@@ -15,10 +15,6 @@
  * NON INFRINGEMENT.  See the GNU General Public License for more
  * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
  */
 
 #include <linux/dmi.h>
Signature · 1 line
1.9.1
#56 lore raw

PATCH 2/6 x86: Update vmware.c to use the common VMW_PORT macros

In reply to Sinclair Yeh

Updated the VMWARE_PORT macro to use the new VMW_PORT macro. Doing this instead of replacing all existing instances of VMWARE_PORT to minimize code change.

---

v2:
Instead of replacing all existing instances of VMWARE_PORT with VMW_PORT, update VMWARE_PORT to use the new VMW_PORT.

v3:
Using updated VMWARE_PORT() macro, which needs hypervisor magic in the parameter

v4:
Swapped the first and second parameters because VMW_PORT has changed.

v5:
si and di are now separate input/output arguments in VMW_PORT()

---
 arch/x86/kernel/cpu/vmware.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/vmware.c +8 -6
index 628a059..8e900d3 100644
@@ -26,6 +26,7 @@
 #include <asm/div64.h>
 #include <asm/x86_init.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #define CPUID_VMWARE_INFO_LEAF	0x40000000
 #define VMWARE_HYPERVISOR_MAGIC	0x564D5868
@@ -38,12 +39,13 @@
 #define VMWARE_PORT_CMD_VCPU_RESERVED	31
 
 #define VMWARE_PORT(cmd, eax, ebx, ecx, edx)				\
-	__asm__("inl (%%dx)" :						\
-			"=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) :	\
-			"0"(VMWARE_HYPERVISOR_MAGIC),			\
-			"1"(VMWARE_PORT_CMD_##cmd),			\
-			"2"(VMWARE_HYPERVISOR_PORT), "3"(UINT_MAX) :	\
-			"memory");
+({									\
+	unsigned long __si, __di; /* Not used */			\
+	VMW_PORT(VMWARE_PORT_CMD_##cmd, UINT_MAX, 0, 0,			\
+		 VMWARE_HYPERVISOR_PORT, VMWARE_HYPERVISOR_MAGIC,	\
+		 eax, ebx, ecx, edx, __si, __di);			\
+})
+
 
 static inline int __vmware_platform(void)
 {
Signature · 1 line
1.9.1
#59 lore raw

PATCH 4/6 Input: Remove vmmouse port reservation

In reply to Sinclair Yeh

This port is used by quite a few guest-to-host communication capabilities, e.g. getting configuration, logging, etc. Currently multiple kernel modules, and one or more priviledged guest user mode app, e.g. open-vm-tools, use this port without reservation.

It was determined that no reservation is required when accessing the port in this manner.

---
 drivers/input/mouse/vmmouse.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/input/mouse/vmmouse.c +1 -18
index d06daf6..85fb3d47 100644
@@ -347,16 +347,10 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
 		return -ENXIO;
 	}
 
-	if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {
-		psmouse_dbg(psmouse, "VMMouse port in use.\n");
-		return -EBUSY;
-	}
-
 	/* Check if the device is present */
 	response = ~VMMOUSE_PROTO_MAGIC;
 	VMMOUSE_CMD(GETVERSION, 0, version, response, dummy1, dummy2);
 	if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU) {
-		release_region(VMMOUSE_PROTO_PORT, 4);
 		return -ENXIO;
 	}
 
@@ -366,8 +360,6 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
 		psmouse->model = version;
 	}
 
-	release_region(VMMOUSE_PROTO_PORT, 4);
-
 	return 0;
 }
 
@@ -386,7 +378,6 @@ static void vmmouse_disconnect(struct psmouse *psmouse)
 	psmouse_reset(psmouse);
 	input_unregister_device(priv->abs_dev);
 	kfree(priv);
-	release_region(VMMOUSE_PROTO_PORT, 4);
 }
 
 /**
@@ -430,15 +421,10 @@ int vmmouse_init(struct psmouse *psmouse)
 	struct input_dev *rel_dev = psmouse->dev, *abs_dev;
 	int error;
 
-	if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {
-		psmouse_dbg(psmouse, "VMMouse port in use.\n");
-		return -EBUSY;
-	}
-
 	psmouse_reset(psmouse);
 	error = vmmouse_enable(psmouse);
 	if (error)
-		goto release_region;
+		return error;
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	abs_dev = input_allocate_device();
@@ -493,8 +479,5 @@ init_fail:
 	kfree(priv);
 	psmouse->private = NULL;
 
-release_region:
-	release_region(VMMOUSE_PROTO_PORT, 4);
-
 	return error;
 }
Signature · 1 line
1.9.1
#55 lore raw

PATCH 1/6 x86: Add VMWare Host Communication Macros

In reply to Sinclair Yeh

These macros will be used by multiple VMWare modules for handling host communication.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Alok Kataria <[email protected]>
Cc Xavier Deguillard <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

---

v2:
* Keeping only the minimal common platform defines
* added vmware_platform() check function

v3:
* Added new field to handle different hypervisor magic values

v4:
* Make it so that "cmd" is always the first parameter for both High-Bandwidh and non-High-Bandwidth version of the macro
* Addressed comments from H. Peter Anvin on the assembly code

v5:
* Separate SI/DI as independent input/output arguments, given the latest update to vmw_balloon.c

---
 arch/x86/include/asm/vmware.h | 138 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 138 insertions(+)
 create mode 100644 arch/x86/include/asm/vmware.h
arch/x86/include/asm/vmware.h new file +138 -0
new file mode 100644
index 0000000..7d02a2b
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2015, VMware, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ * Based on code from vmware.c and vmmouse.c.
+ * Author:
+ *   Sinclair Yeh <[email protected]>
+ */
+#ifndef _ASM_X86_VMWARE_H
+#define _ASM_X86_VMWARE_H
+
+
+/**
+ * Hypervisor-specific bi-directional communication channel.  Should never
+ * execute on bare metal hardware.  The caller must make sure to check for
+ * supported hypervisor before using these macros.
+ *
+ * The last two parameters are both input and output and must be initialized.
+ *
+ * @cmd: [IN] Message Cmd
+ * @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]
+ * @magic: [IN] hypervisor magic value
+ * @eax: [OUT] value of EAX register
+ * @ebx: [OUT] e.g. status from an HB message status command
+ * @ecx: [OUT] e.g. status from a non-HB message status command
+ * @edx: [OUT] e.g. channel id
+ * @si:  [OUT]
+ * @di:  [OUT]
+ */
+#define VMW_PORT(cmd, in_ebx, in_si, in_di,	\
+		 port_num, magic,		\
+		 eax, ebx, ecx, edx, si, di)	\
+({						\
+	asm volatile ("inl %%dx, %%eax;" :	\
+		"=a"(eax),			\
+		"=b"(ebx),			\
+		"=c"(ecx),			\
+		"=d"(edx),			\
+		"=S"(si),			\
+		"=D"(di) :			\
+		"a"(magic),			\
+		"b"(in_ebx),			\
+		"c"(cmd),			\
+		"d"(port_num),			\
+		"S"(in_si),			\
+		"D"(in_di) :			\
+		"memory");			\
+})
+
+
+/**
+ * Hypervisor-specific bi-directional communication channel.  Should never
+ * execute on bare metal hardware.  The caller must make sure to check for
+ * supported hypervisor before using these macros.
+ *
+ * The last 3 parameters are both input and output and must be initialized.
+ *
+ * @cmd: [IN] Message Cmd
+ * @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]
+ * @magic: [IN] hypervisor magic value
+ * @eax: [OUT] value of EAX register
+ * @ebx: [OUT] e.g. status from an HB message status command
+ * @ecx: [OUT] e.g. status from a non-HB message status command
+ * @edx: [OUT] e.g. channel id
+ * @si:  [OUT]
+ * @di:  [OUT]
+ * @bp:  [INOUT] set to 0 if not used
+ */
+#define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di,	\
+			port_num, magic,		\
+			eax, ebx, ecx, edx, si, di, bp)	\
+({							\
+	asm volatile ("push %%rbp;"			\
+		"xchgq %6, %%rbp;"			\
+		"rep outsb;"				\
+		"xchgq %%rbp, %6;"			\
+		"pop %%rbp;" :				\
+		"=a"(eax),				\
+		"=b"(ebx),				\
+		"=c"(ecx),				\
+		"=d"(edx),				\
+		"=S"(si),				\
+		"=D"(di),				\
+		"+r"(bp) :				\
+		"a"(magic),				\
+		"b"(cmd),				\
+		"c"(in_ecx),				\
+		"d"(port_num),				\
+		"S"(in_si),				\
+		"D"(in_di) :				\
+		"memory", "cc");			\
+})
+
+
+#define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di,	\
+		       port_num, magic,			\
+		       eax, ebx, ecx, edx, si, di, bp)	\
+({							\
+	asm volatile ("push %%rbp;"			\
+		"xchgq %6, %%rbp;"			\
+		"rep insb;"				\
+		"xchgq %%rbp, %6;"			\
+		"pop %%rbp" :				\
+		"=a"(eax),				\
+		"=b"(ebx),				\
+		"=c"(ecx),				\
+		"=d"(edx),				\
+		"=S"(si),				\
+		"=D"(di),				\
+		"+r"(bp) :				\
+		"a"(magic),				\
+		"b"(cmd),				\
+		"c"(in_ecx),				\
+		"d"(port_num),				\
+		"S"(in_si),				\
+		"D"(in_di) :				\
+		"memory", "cc");			\
+})
+
+
+#endif
+
Signature · 1 line
1.9.1
#61 lore raw

PATCH 6/6 VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to Sinclair Yeh

Updated VMWARE_BALLOON_CMD to use the common VMW_PORT macro. Doing this rather than replacing all instances of VMWARE_BALLOON_CMD to minimize code change.

---
v1
Swapped parameters 1 and 2 to VMW_PORT because the macro has been updated

v2
Updated VMW_PORT() usage because the macro and vmw_balloon.c's usage have changed.

---
 drivers/misc/vmw_balloon.c | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)
drivers/misc/vmw_balloon.c +12 -19
index 1e688bf..6476b74 100644
@@ -46,6 +46,7 @@
 #include <linux/vmw_vmci_defs.h>
 #include <linux/vmw_vmci_api.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
@@ -197,25 +198,17 @@ static void vmballoon_batch_set_pa(struct vmballoon_batch_page *batch, int idx,
 }
 
 
-#define VMWARE_BALLOON_CMD(cmd, arg1, arg2, result)		\
-({								\
-	unsigned long __status, __dummy1, __dummy2, __dummy3;	\
-	__asm__ __volatile__ ("inl %%dx" :			\
-		"=a"(__status),					\
-		"=c"(__dummy1),					\
-		"=d"(__dummy2),					\
-		"=b"(result),					\
-		"=S" (__dummy3) :				\
-		"0"(VMW_BALLOON_HV_MAGIC),			\
-		"1"(VMW_BALLOON_CMD_##cmd),			\
-		"2"(VMW_BALLOON_HV_PORT),			\
-		"3"(arg1),					\
-		"4" (arg2) :					\
-		"memory");					\
-	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	\
-		result = __dummy1;				\
-	result &= -1UL;						\
-	__status & -1UL;					\
+#define VMWARE_BALLOON_CMD(cmd, arg1, arg2, result)			\
+({									\
+	unsigned long __status, __dummy1, __dummy2;			\
+	unsigned long __si, __di;					\
+	VMW_PORT(VMW_BALLOON_CMD_##cmd, arg1, arg2, 0,			\
+		 VMW_BALLOON_HV_PORT, VMW_BALLOON_HV_MAGIC,		\
+		 __status, result, __dummy1, __dummy2, __si, __di);	\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)		\
+		result = __dummy1;					\
+	result &= -1UL;							\
+	__status & -1UL;						\
 })
 
 #ifdef CONFIG_DEBUG_FS
Signature · 1 line
1.9.1
#58 lore raw

PATCH 3/6 Input: Update vmmouse.c to use the common VMW_PORT macros

In reply to Sinclair Yeh

Updated the VMMOUSE macro to use the new VMW_PORT macro. Doing this instead of replacing all existing instances of VMWMOUSE to minimize code change.

---

v2:
Instead of replacing existing VMMOUSE defines, only modify enough to use the new VMW_PORT define.

v3:
Use updated VMWARE_PORT() which requires hypervisor magic as an added parameter

v4:
Swapped parameters 1 and 2 when calling VMW_PORT because the macro has been updated

v5:
Updated VMW_PORT() usage since the macro has been updated

---
 drivers/input/mouse/vmmouse.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/input/mouse/vmmouse.c +7 -15
index e272f06..d06daf6 100644
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/hypervisor.h>
+#include <asm/vmware.h>
 
 #include "psmouse.h"
 #include "vmmouse.h"
@@ -84,21 +85,12 @@ struct vmmouse_data {
  * implementing the vmmouse protocol. Should never execute on
  * bare metal hardware.
  */
-#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)	\
-({							\
-	unsigned long __dummy1, __dummy2;		\
-	__asm__ __volatile__ ("inl %%dx" :		\
-		"=a"(out1),				\
-		"=b"(out2),				\
-		"=c"(out3),				\
-		"=d"(out4),				\
-		"=S"(__dummy1),				\
-		"=D"(__dummy2) :			\
-		"a"(VMMOUSE_PROTO_MAGIC),		\
-		"b"(in1),				\
-		"c"(VMMOUSE_PROTO_CMD_##cmd),		\
-		"d"(VMMOUSE_PROTO_PORT) :		\
-		"memory");		                \
+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4)		\
+({								\
+	unsigned long __dummy1, __dummy2;			\
+	VMW_PORT(VMMOUSE_PROTO_CMD_##cmd, in1, 0, 0,		\
+		 VMMOUSE_PROTO_PORT, VMMOUSE_PROTO_MAGIC,	\
+		 out1, out2, out3, out4, __dummy1, __dummy2);   \
 })
 
 /**
Signature · 1 line
1.9.1
maintainer Acked-by on v1 6/6
#62 lore raw

Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to Sinclair Yeh
Quoted 4 lines · Sinclair Yeh

Updated VMWARE_BALLOON_CMD to use the common VMW_PORT macro. Doing this rather than replacing all instances of VMWARE_BALLOON_CMD to minimize code change.

Quoted 9 lines
Quoted 21 lines
drivers/misc/vmw_balloon.c +2 -19
-#define VMWARE_BALLOON_CMD(cmd, arg1, arg2, result)		\
-({								\
-	unsigned long __status, __dummy1, __dummy2, __dummy3;	\
-	__asm__ __volatile__ ("inl %%dx" :			\
-		"=a"(__status),					\
-		"=c"(__dummy1),					\
-		"=d"(__dummy2),					\
-		"=b"(result),					\
-		"=S" (__dummy3) :				\
-		"0"(VMW_BALLOON_HV_MAGIC),			\
-		"1"(VMW_BALLOON_CMD_##cmd),			\
-		"2"(VMW_BALLOON_HV_PORT),			\
-		"3"(arg1),					\
-		"4" (arg2) :					\
-		"memory");					\
-	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	\
-		result = __dummy1;				\
-	result &= -1UL;						\
-	__status & -1UL;					\
+#define VMWARE_BALLOON_CMD(cmd, arg1, arg2, result)			\
+({									\

drivers/misc/vmw_balloon.c static void vmballoon_batch_set_pa(struct vmballoon_batch_page *batch, int idx, · line 212

Quoted 10 lines
drivers/misc/vmw_balloon.c +9 -0
+	unsigned long __status, __dummy1, __dummy2;			\
+	unsigned long __si, __di;					\
+	VMW_PORT(VMW_BALLOON_CMD_##cmd, arg1, arg2, 0,			\
+		 VMW_BALLOON_HV_PORT, VMW_BALLOON_HV_MAGIC,		\
+		 __status, result, __dummy1, __dummy2, __si, __di);	\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)		\
+		result = __dummy1;					\
+	result &= -1UL;							\
+	__status & -1UL;						\
 })

Honestly, it doesn't look anymore "readable" to me, but it's your code to maintain, not mine... :)

#63 lore raw

Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

Hi,

Does any one know when this series will be applied?

Sinclair

Quoted 53 lines · Greg KH
Quoted 4 lines · Sinclair Yeh

Updated VMWARE_BALLOON_CMD to use the common VMW_PORT macro. Doing this rather than replacing all instances of VMWARE_BALLOON_CMD to minimize code change.

Quoted 9 lines
Quoted 21 lines
drivers/misc/vmw_balloon.c +2 -19
-#define VMWARE_BALLOON_CMD(cmd, arg1, arg2, result)		\
-({								\
-	unsigned long __status, __dummy1, __dummy2, __dummy3;	\
-	__asm__ __volatile__ ("inl %%dx" :			\
-		"=a"(__status),					\
-		"=c"(__dummy1),					\
-		"=d"(__dummy2),					\
-		"=b"(result),					\
-		"=S" (__dummy3) :				\
-		"0"(VMW_BALLOON_HV_MAGIC),			\
-		"1"(VMW_BALLOON_CMD_##cmd),			\
-		"2"(VMW_BALLOON_HV_PORT),			\
-		"3"(arg1),					\
-		"4" (arg2) :					\
-		"memory");					\
-	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	\
-		result = __dummy1;				\
-	result &= -1UL;						\
-	__status & -1UL;					\
+#define VMWARE_BALLOON_CMD(cmd, arg1, arg2, result)			\
+({									\

drivers/misc/vmw_balloon.c static void vmballoon_batch_set_pa(struct vmballoon_batch_page *batch, int idx, · line 212

Quoted 10 lines
drivers/misc/vmw_balloon.c +9 -0
+	unsigned long __status, __dummy1, __dummy2;			\
+	unsigned long __si, __di;					\
+	VMW_PORT(VMW_BALLOON_CMD_##cmd, arg1, arg2, 0,			\
+		 VMW_BALLOON_HV_PORT, VMW_BALLOON_HV_MAGIC,		\
+		 __status, result, __dummy1, __dummy2, __si, __di);	\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)		\
+		result = __dummy1;					\
+	result &= -1UL;							\
+	__status & -1UL;						\
 })

Honestly, it doesn't look anymore "readable" to me, but it's your code to maintain, not mine... :)

#66 lore raw

Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to Greg KH

Hi,

Does any one know when this series will be applied?

Sinclair

Quoted 53 lines · Greg KH
Quoted 4 lines · Sinclair Yeh

Updated VMWARE_BALLOON_CMD to use the common VMW_PORT macro. Doing this rather than replacing all instances of VMWARE_BALLOON_CMD to minimize code change.

Quoted 9 lines
Quoted 21 lines
drivers/misc/vmw_balloon.c +2 -19
-#define VMWARE_BALLOON_CMD(cmd, arg1, arg2, result)		\
-({								\
-	unsigned long __status, __dummy1, __dummy2, __dummy3;	\
-	__asm__ __volatile__ ("inl %%dx" :			\
-		"=a"(__status),					\
-		"=c"(__dummy1),					\
-		"=d"(__dummy2),					\
-		"=b"(result),					\
-		"=S" (__dummy3) :				\
-		"0"(VMW_BALLOON_HV_MAGIC),			\
-		"1"(VMW_BALLOON_CMD_##cmd),			\
-		"2"(VMW_BALLOON_HV_PORT),			\
-		"3"(arg1),					\
-		"4" (arg2) :					\
-		"memory");					\
-	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)	\
-		result = __dummy1;				\
-	result &= -1UL;						\
-	__status & -1UL;					\
+#define VMWARE_BALLOON_CMD(cmd, arg1, arg2, result)			\
+({									\

drivers/misc/vmw_balloon.c static void vmballoon_batch_set_pa(struct vmballoon_batch_page *batch, int idx, · line 212

Quoted 10 lines
drivers/misc/vmw_balloon.c +9 -0
+	unsigned long __status, __dummy1, __dummy2;			\
+	unsigned long __si, __di;					\
+	VMW_PORT(VMW_BALLOON_CMD_##cmd, arg1, arg2, 0,			\
+		 VMW_BALLOON_HV_PORT, VMW_BALLOON_HV_MAGIC,		\
+		 __status, result, __dummy1, __dummy2, __si, __di);	\
+	if (VMW_BALLOON_CMD_##cmd == VMW_BALLOON_CMD_START)		\
+		result = __dummy1;					\
+	result &= -1UL;							\
+	__status & -1UL;						\
 })

Honestly, it doesn't look anymore "readable" to me, but it's your code to maintain, not mine... :)

maintainer
#64 lore raw

Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

In reply to Sinclair Yeh
Quoted 3 lines · Sinclair Yeh

Hi,

Does any one know when this series will be applied?

No idea, it's not going through my tree, as I don't have these in my queue anymore...

greg k-h

#65 lore raw

Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro

Quoted 7 lines · Greg KH
Quoted 3 lines · Sinclair Yeh

Hi,

Does any one know when this series will be applied?

No idea, it's not going through my tree, as I don't have these in my queue anymore...

Ok, I'm not sure what else to do. I've already updated the series once because it didn't get picked up last December. Can anyone on the x86 list pick this up?

Sinclair