Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1312532 > unrolled thread
| Started by | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| First post | 2016-01-19 22:50 +0100 |
| Last post | 2016-01-19 22:50 +0100 |
| Articles | 6 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 0/6] Create common VMWare host port communication macros v3 "Sinclair Yeh" <syeh@vmware.com> - 2016-01-19 22:50 +0100
[PATCH 4/6] Input: Remove vmmouse port reservation "Sinclair Yeh" <syeh@vmware.com> - 2016-01-19 22:50 +0100
[PATCH 1/6] x86: Add VMWare Host Communication Macros "Sinclair Yeh" <syeh@vmware.com> - 2016-01-19 22:50 +0100
[PATCH 5/6] x86: Remove address from the vmware.c header "Sinclair Yeh" <syeh@vmware.com> - 2016-01-19 22:50 +0100
[PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros "Sinclair Yeh" <syeh@vmware.com> - 2016-01-19 22:50 +0100
[PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro "Sinclair Yeh" <syeh@vmware.com> - 2016-01-19 22:50 +0100
| From | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| Date | 2016-01-19 22:50 +0100 |
| Subject | [PATCH 0/6] Create common VMWare host port communication macros v3 |
| Message-ID | <qSMk2-59V-5@gated-at.bofh.it> |
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. Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> (entire series) Reviewed-by: Alok N Kataria <akataria@vmware.com> (all except 4/6) Acked-by: Xavier Deguillard <xdeguillard@vmware.com> (6/6) Signed-off-by: Sinclair Yeh <syeh@vmware.com> --- 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.
[toc] | [next] | [standalone]
| From | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| Date | 2016-01-19 22:50 +0100 |
| Subject | [PATCH 4/6] Input: Remove vmmouse port reservation |
| Message-ID | <qSMk2-59V-7@gated-at.bofh.it> |
| In reply to | #1312532 |
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.
Signed-off-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Cc: pv-drivers@vmware.com
Cc: linux-graphics-maintainer@vmware.com
Cc: virtualization@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/input/mouse/vmmouse.c | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c
index d06daf6..85fb3d47 100644
--- a/drivers/input/mouse/vmmouse.c
+++ b/drivers/input/mouse/vmmouse.c
@@ -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;
}
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| Date | 2016-01-19 22:50 +0100 |
| Subject | [PATCH 1/6] x86: Add VMWare Host Communication Macros |
| Message-ID | <qSMk2-59V-9@gated-at.bofh.it> |
| In reply to | #1312532 |
These macros will be used by multiple VMWare modules for handling
host communication.
Signed-off-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Alok N Kataria <akataria@vmware.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Alok Kataria <akataria@vmware.com>
Cc: linux-kernel@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Cc: Xavier Deguillard <xdeguillard@vmware.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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
diff --git a/arch/x86/include/asm/vmware.h b/arch/x86/include/asm/vmware.h
new file mode 100644
index 0000000..7d02a2b
--- /dev/null
+++ b/arch/x86/include/asm/vmware.h
@@ -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 <syeh@vmware.com>
+ */
+#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
+
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| Date | 2016-01-19 22:50 +0100 |
| Subject | [PATCH 5/6] x86: Remove address from the vmware.c header |
| Message-ID | <qSMk2-59V-23@gated-at.bofh.it> |
| In reply to | #1312532 |
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. Signed-off-by: Sinclair Yeh <syeh@vmware.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Alok N Kataria <akataria@vmware.com> Cc: pv-drivers@vmware.com Cc: Ingo Molnar <mingo@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- arch/x86/kernel/cpu/vmware.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c index 8e900d3..93823f3 100644 --- a/arch/x86/kernel/cpu/vmware.c +++ b/arch/x86/kernel/cpu/vmware.c @@ -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> -- 1.9.1
[toc] | [prev] | [next] | [standalone]
| From | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| Date | 2016-01-19 22:50 +0100 |
| Subject | [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros |
| Message-ID | <qSMk2-59V-15@gated-at.bofh.it> |
| In reply to | #1312532 |
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.
Signed-off-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Alok N Kataria <akataria@vmware.com>
Cc: pv-drivers@vmware.com
Cc: linux-graphics-maintainer@vmware.com
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Cc: linux-input@vger.kernel.org
---
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(-)
diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c
index e272f06..d06daf6 100644
--- a/drivers/input/mouse/vmmouse.c
+++ b/drivers/input/mouse/vmmouse.c
@@ -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); \
})
/**
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| Date | 2016-01-19 22:50 +0100 |
| Subject | [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro |
| Message-ID | <qSMk2-59V-19@gated-at.bofh.it> |
| In reply to | #1312532 |
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.
Signed-off-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Alok N Kataria <akataria@vmware.com>
Acked-by: Xavier Deguillard <xdeguillard@vmware.com>
Cc: pv-drivers@vmware.com
Cc: Xavier Deguillard <xdeguillard@vmware.com>
Cc: linux-kernel@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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(-)
diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 1e688bf..6476b74 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -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
--
1.9.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web