Re: [PATCH v2 00/13] drm: Eliminate plane->fb/crtc usage for atomic drivers
Thanks Ville. This series: Reviewed-by: Sinclair Yeh On Fri, May 25, 2018 at 09:50:32PM +0300, Ville Syrjala wrote: > From: Ville Syrjälä > > Here are again the last (?) bits of eliminating the plane->fb/crtc > usage for atomic drivers. I've pushed everything else (thanks to > everyone who reviewed them). > > Deepak said he'd tested the vmwgfx stuff, so I think it should be > safe to land. Just missing a bit of review... > > Cc: Alex Deucher > Cc: amd-...@lists.freedesktop.org > Cc: "Christian König" > Cc: Daniel Vetter > Cc: David Airlie > Cc: "David (ChunMing) Zhou" > Cc: Deepak Rawat > Cc: Eric Anholt > Cc: freedr...@lists.freedesktop.org > Cc: Gerd Hoffmann > Cc: Harry Wentland > Cc: Inki Dae > Cc: Joonyoung Shim > Cc: Kyungmin Park > Cc: linux-arm-...@vger.kernel.org > Cc: Rob Clark > Cc: Seung-Woo Kim > Cc: Sinclair Yeh > Cc: Thomas Hellstrom > Cc: virtualization@lists.linux-foundation.org > Cc: VMware Graphics > > Ville Syrjälä (13): > drm/vmwgfx: Stop using plane->fb in vmw_kms_atomic_check_modeset() > drm/vmwgfx: Stop using plane->fb in vmw_kms_helper_dirty() > drm/vmwgfx: Stop using plane->fb in vmw_kms_update_implicit_fb() > drm/vmwgfx: Stop updating plane->fb > drm/vmwgfx: Stop using plane->fb in atomic_enable() > drm/vmwgfx: Stop messing about with plane->fb/old_fb/crtc > drm/amdgpu/dc: Stop updating plane->fb > drm/i915: Stop updating plane->fb/crtc > drm/exynos: Stop updating plane->crtc > drm/msm: Stop updating plane->fb/crtc > drm/virtio: Stop updating plane->crtc > drm/vc4: Stop updating plane->fb/crtc > drm: Stop updating plane->crtc/fb/old_fb on atomic drivers > > drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 - > drivers/gpu/drm/drm_atomic.c | 55 > +++ > drivers/gpu/drm/drm_atomic_helper.c | 15 +-- > drivers/gpu/drm/drm_crtc.c| 8 +++- > drivers/gpu/drm/drm_fb_helper.c | 7 --- > drivers/gpu/drm/drm_framebuffer.c | 5 --- > drivers/gpu/drm/drm_plane.c | 14 +++--- > drivers/gpu/drm/drm_plane_helper.c| 4 +- > drivers/gpu/drm/exynos/exynos_drm_plane.c | 2 - > drivers/gpu/drm/i915/intel_atomic_plane.c | 12 - > drivers/gpu/drm/i915/intel_display.c | 7 ++- > drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 1 - > drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c| 2 - > drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 1 - > drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c| 2 - > drivers/gpu/drm/vc4/vc4_crtc.c| 3 -- > drivers/gpu/drm/virtio/virtgpu_display.c | 2 - > drivers/gpu/drm/vmwgfx/vmwgfx_fb.c| 24 -- > drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 24 +++--- > drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 2 - > drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 5 +-- > include/drm/drm_atomic.h | 3 -- > 22 files changed, 46 insertions(+), 154 deletions(-) > > -- > 2.16.1 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro
On Thu, Mar 31, 2016 at 09:30:37AM -0700, Greg KH wrote: > On Thu, Mar 31, 2016 at 07:39:53AM -0700, Sinclair Yeh wrote: > > 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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
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 On Mon, Feb 08, 2016 at 11:41:57AM -0800, Greg KH wrote: > On Tue, Jan 19, 2016 at 01:46:05PM -0800, Sinclair Yeh wrote: > > 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 <s...@vmware.com> > > Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> > > Reviewed-by: Alok N Kataria <akata...@vmware.com> > > Acked-by: Xavier Deguillard <xdeguill...@vmware.com> > > Cc: pv-driv...@vmware.com > > Cc: Xavier Deguillard <xdeguill...@vmware.com> > > Cc: linux-ker...@vger.kernel.org > > Cc: virtualization@lists.linux-foundation.org > > Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> > > > Acked-by: Greg Kroah-Hartman <gre...@linuxfoundation.org> > > > -#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;\ > > }) > > Honestly, it doesn't look anymore "readable" to me, but it's your code > to maintain, not mine... :) > ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH 4/6] Input: Remove vmmouse port reservation
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 <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Cc: pv-driv...@vmware.com Cc: linux-graphics-maintai...@vmware.com Cc: virtualization@lists.linux-foundation.org Cc: linux-ker...@vger.kernel.org Cc: Greg Kroah-Hartman <gre...@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 == 0xU) { - 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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH 2/6] x86: Update vmware.c to use the common VMW_PORT macros
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. Signed-off-by: Sinclair Yeh <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Reviewed-by: Alok N Kataria <akata...@vmware.com> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Ingo Molnar <mi...@redhat.com> Cc: "H. Peter Anvin" <h...@zytor.com> Cc: pv-driv...@vmware.com Cc: virtualization@lists.linux-foundation.org Cc: linux-ker...@vger.kernel.org Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> --- 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(-) diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c index 628a059..8e900d3 100644 --- a/arch/x86/kernel/cpu/vmware.c +++ b/arch/x86/kernel/cpu/vmware.c @@ -26,6 +26,7 @@ #include #include #include +#include #define CPUID_VMWARE_INFO_LEAF 0x4000 #define VMWARE_HYPERVISOR_MAGIC0x564D5868 @@ -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) { -- 1.9.1 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro
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 <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Reviewed-by: Alok N Kataria <akata...@vmware.com> Acked-by: Xavier Deguillard <xdeguill...@vmware.com> Cc: pv-driv...@vmware.com Cc: Xavier Deguillard <xdeguill...@vmware.com> Cc: linux-ker...@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Cc: Greg Kroah-Hartman <gre...@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 #include #include +#include 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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros
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 <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Reviewed-by: Alok N Kataria <akata...@vmware.com> Cc: pv-driv...@vmware.com Cc: linux-graphics-maintai...@vmware.com Cc: Dmitry Torokhov <dmitry.torok...@gmail.com> Cc: Arnd Bergmann <a...@arndb.de> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> Cc: linux-ker...@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Cc: linux-in...@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 #include #include +#include #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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH 1/6] x86: Add VMWare Host Communication Macros
These macros will be used by multiple VMWare modules for handling host communication. Signed-off-by: Sinclair Yeh <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Reviewed-by: Alok N Kataria <akata...@vmware.com> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Ingo Molnar <mi...@redhat.com> Cc: "H. Peter Anvin" <h...@zytor.com> Cc: Alok Kataria <akata...@vmware.com> Cc: linux-ker...@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Cc: Xavier Deguillard <xdeguill...@vmware.com> Cc: Greg Kroah-Hartman <gre...@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 000..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 <s...@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,
[PATCH 1/6] x86: Add VMWare Host Communication Macros
These macros will be used by multiple VMWare modules for handling host communication. Signed-off-by: Sinclair Yeh <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Reviewed-by: Alok N Kataria <akata...@vmware.com> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Ingo Molnar <mi...@redhat.com> Cc: "H. Peter Anvin" <h...@zytor.com> Cc: Alok Kataria <akata...@vmware.com> Cc: linux-ker...@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Cc: Xavier Deguillard <xdeguill...@vmware.com> Cc: Greg Kroah-Hartman <gre...@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 --- arch/x86/include/asm/vmware.h | 126 ++ 1 file changed, 126 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 000..ad359e0 --- /dev/null +++ b/arch/x86/include/asm/vmware.h @@ -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 <s...@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 + * @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,
[PATCH 2/6] x86: Update vmware.c to use the common VMW_PORT macros
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. Signed-off-by: Sinclair Yeh <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Reviewed-by: Alok N Kataria <akata...@vmware.com> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Ingo Molnar <mi...@redhat.com> Cc: "H. Peter Anvin" <h...@zytor.com> Cc: pv-driv...@vmware.com Cc: virtualization@lists.linux-foundation.org Cc: linux-ker...@vger.kernel.org Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> --- 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(-) diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c index 628a059..67c429d 100644 --- a/arch/x86/kernel/cpu/vmware.c +++ b/arch/x86/kernel/cpu/vmware.c @@ -26,6 +26,7 @@ #include #include #include +#include #define CPUID_VMWARE_INFO_LEAF 0x4000 #define VMWARE_HYPERVISOR_MAGIC0x564D5868 @@ -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) { -- 1.9.1 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro
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 <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Reviewed-by: Alok N Kataria <akata...@vmware.com> Cc: pv-driv...@vmware.com Cc: Xavier Deguillard <xdeguill...@vmware.com> Cc: linux-ker...@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> --- 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(-) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index ffb5634..f8f60ca 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -43,6 +43,7 @@ #include #include #include +#include MODULE_AUTHOR("VMware, Inc."); MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver"); @@ -142,23 +143,17 @@ enum vmwballoon_capabilities { #define VMW_BALLOON_SUCCESS_WITH_CAPABILITIES (0x0300) -#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 -- 1.9.1 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH 4/6] Input: Remove vmmouse port reservation
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 <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Cc: pv-driv...@vmware.com Cc: linux-graphics-maintai...@vmware.com Cc: virtualization@lists.linux-foundation.org Cc: linux-ker...@vger.kernel.org Cc: Greg Kroah-Hartman <gre...@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 ddb152c..e881c87 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 == 0xU) { - 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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 1/6] x86: Add VMWare Host Communication Macros
Thanks Peter. On Tue, Dec 01, 2015 at 02:49:11PM -0800, H. Peter Anvin wrote: > On 12/01/15 14:18, Sinclair Yeh wrote: > > These macros will be used by multiple VMWare modules for handling > > host communication. > > > + __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. > > Also, we don't need the underscored forms of asm and volatile for kernel > code. > > > + __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. > > 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");\ > +}) This is great. Changed. Updated patch set incoming. Sinclair ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros
On Wed, Dec 02, 2015 at 07:31:24AM -0800, Greg Kroah-Hartman wrote: > On Tue, Dec 01, 2015 at 06:21:06PM -0800, Sinclair Yeh wrote: > > On Tue, Dec 01, 2015 at 04:04:08PM -0800, Greg Kroah-Hartman wrote: > > > On Tue, Dec 01, 2015 at 02:54:20PM -0800, Sinclair Yeh wrote: > > > > Hi, > > > > > > > > On Tue, Dec 01, 2015 at 02:45:27PM -0800, Dmitry Torokhov wrote: > > > > > On Tue, Dec 1, 2015 at 2:32 PM, Sinclair Yeh <s...@vmware.com> wrote: > > > > > > Hi, > > > > > > > > > > > > > > > > > > > > > > > >> > */ > > > > > >> > -#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; \ > > > > > >> > > > > > >> Why do we need to initialize dummies? > > > > > > > > > > > > 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. > > > > > > 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... > > > > > 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. > > > > > 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. > > 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. > > thanks, > > greg k-h ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros
On Wed, Dec 02, 2015 at 10:45:28AM -0800, Greg Kroah-Hartman wrote: > On Wed, Dec 02, 2015 at 09:26:34AM -0800, Dmitry Torokhov wrote: > > On Wed, Dec 02, 2015 at 07:31:24AM -0800, Greg Kroah-Hartman wrote: > > > On Tue, Dec 01, 2015 at 06:21:06PM -0800, Sinclair Yeh wrote: > > > > On Tue, Dec 01, 2015 at 04:04:08PM -0800, Greg Kroah-Hartman wrote: > > > > > On Tue, Dec 01, 2015 at 02:54:20PM -0800, Sinclair Yeh wrote: > > > > > > Hi, > > > > > > > > > > > > On Tue, Dec 01, 2015 at 02:45:27PM -0800, Dmitry Torokhov wrote: > > > > > > > On Tue, Dec 1, 2015 at 2:32 PM, Sinclair Yeh <s...@vmware.com> > > > > > > > wrote: > > > > > > > > Hi, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >> > */ > > > > > > > >> > -#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; > > > > > > > >> > \ > > > > > > > >> > > > > > > > >> Why do we need to initialize dummies? > > > > > > > > > > > > > > > > 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. > > > > > > > > > > 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... > &g
[PATCH 1/6] x86: Add VMWare Host Communication Macros
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 Signed-off-by: Sinclair Yeh <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Reviewed-by: Alok N Kataria <akata...@vmware.com> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Ingo Molnar <mi...@redhat.com> Cc: "H. Peter Anvin" <h...@zytor.com> Cc: Alok Kataria <akata...@vmware.com> Cc: linux-ker...@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Cc: Xavier Deguillard <xdeguill...@vmware.com> --- arch/x86/include/asm/vmware.h | 110 ++ 1 file changed, 110 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 000..32bf99b --- /dev/null +++ b/arch/x86/include/asm/vmware.h @@ -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 <s...@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. + * + * 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),
[PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro
Signed-off-by: Sinclair Yeh <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Reviewed-by: Alok N Kataria <akata...@vmware.com> Cc: pv-driv...@vmware.com Cc: Xavier Deguillard <xdeguill...@vmware.com> Cc: linux-ker...@vger.kernel.org Cc: virtualization@lists.linux-foundation.org --- drivers/misc/vmw_balloon.c | 29 - 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index ffb5634..90a0d07 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -43,6 +43,7 @@ #include #include #include +#include MODULE_AUTHOR("VMware, Inc."); MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver"); @@ -142,23 +143,17 @@ enum vmwballoon_capabilities { #define VMW_BALLOON_SUCCESS_WITH_CAPABILITIES (0x0300) -#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 -- 1.9.1 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros
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 Signed-off-by: Sinclair Yeh <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Reviewed-by: Alok N Kataria <akata...@vmware.com> Cc: pv-driv...@vmware.com Cc: linux-graphics-maintai...@vmware.com Cc: Dmitry Torokhov <dmitry.torok...@gmail.com> Cc: Arnd Bergmann <a...@arndb.de> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> Cc: linux-ker...@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Cc: linux-in...@vger.kernel.org --- 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..d34e3e4 100644 --- a/drivers/input/mouse/vmmouse.c +++ b/drivers/input/mouse/vmmouse.c @@ -19,6 +19,7 @@ #include #include #include +#include #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); \ }) /** -- 1.9.1 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros
Hi, On Tue, Dec 01, 2015 at 02:24:14PM -0800, Dmitry Torokhov wrote: > On Tue, Dec 01, 2015 at 02:18:49PM -0800, Sinclair Yeh wrote: > > 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 > > > > Signed-off-by: Sinclair Yeh <s...@vmware.com> > > Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> > > Reviewed-by: Alok N Kataria <akata...@vmware.com> > > Cc: pv-driv...@vmware.com > > Cc: linux-graphics-maintai...@vmware.com > > Cc: Dmitry Torokhov <dmitry.torok...@gmail.com> > > Cc: Arnd Bergmann <a...@arndb.de> > > Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> > > Cc: linux-ker...@vger.kernel.org > > Cc: virtualization@lists.linux-foundation.org > > Cc: linux-in...@vger.kernel.org > > --- > > 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..d34e3e4 100644 > > --- a/drivers/input/mouse/vmmouse.c > > +++ b/drivers/input/mouse/vmmouse.c > > @@ -19,6 +19,7 @@ > > #include > > #include > > #include > > +#include > > > > #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; \ > > 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. > > > + VMW_PORT(in1, VMMOUSE_PROTO_CMD_##cmd, VMMOUSE_PROTO_PORT, \ > > +VMMOUSE_PROTO_MAGIC, \ > > +out1, out2, out3, out4, __dummy1, __dummy2); \ > > }) > > > > Thanks. > > -- > Dmitry ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH 4/6] Input: Remove vmmouse port reservation
Port reservation is not required. Furthermore, this port is shared by other VMware services for host-side communication. Signed-off-by: Sinclair Yeh <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Cc: pv-driv...@vmware.com Cc: linux-graphics-maintai...@vmware.com Cc: virtualization@lists.linux-foundation.org Cc: linux-ker...@vger.kernel.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 d34e3e4..9109d54 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 == 0xU) { - 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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[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 Signed-off-by: Sinclair Yeh <s...@vmware.com> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com> Reviewed-by: Alok N Kataria <akata...@vmware.com> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Ingo Molnar <mi...@redhat.com> Cc: "H. Peter Anvin" <h...@zytor.com> Cc: pv-driv...@vmware.com Cc: virtualization@lists.linux-foundation.org Cc: linux-ker...@vger.kernel.org --- arch/x86/kernel/cpu/vmware.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c index 628a059..1837f66 100644 --- a/arch/x86/kernel/cpu/vmware.c +++ b/arch/x86/kernel/cpu/vmware.c @@ -26,6 +26,7 @@ #include #include #include +#include #define CPUID_VMWARE_INFO_LEAF 0x4000 #define VMWARE_HYPERVISOR_MAGIC0x564D5868 @@ -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) { -- 1.9.1 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros
Hi, On Tue, Dec 01, 2015 at 02:45:27PM -0800, Dmitry Torokhov wrote: > On Tue, Dec 1, 2015 at 2:32 PM, Sinclair Yeh <s...@vmware.com> wrote: > > Hi, > > > >> > */ > >> > -#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; \ > >> > >> Why do we need to initialize dummies? > > > > 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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro
Thanks! Done. On Tue, Dec 01, 2015 at 02:38:01PM -0800, Xavier Deguillard wrote: > Hey Sinclair, > > On Tue, Dec 01, 2015 at 02:18:52PM -0800, Sinclair Yeh wrote: > > +#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: > > Acked-by: Xavier Deguillard <xdeguill...@vmware.com> > > Xavier ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 4/6] Input: Remove vmmouse port reservation
Hi, On Tue, Dec 01, 2015 at 02:30:05PM -0800, Dmitry Torokhov wrote: > Hi Sinclair, > > On Tue, Dec 1, 2015 at 2:18 PM, Sinclair Yeh <s...@vmware.com> wrote: > > 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 > > > 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? > > Thanks. > > -- > Dmitry ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 3/6] Input: Update vmmouse.c to use the common VMW_PORT macros
On Tue, Dec 01, 2015 at 04:04:08PM -0800, Greg Kroah-Hartman wrote: > On Tue, Dec 01, 2015 at 02:54:20PM -0800, Sinclair Yeh wrote: > > Hi, > > > > On Tue, Dec 01, 2015 at 02:45:27PM -0800, Dmitry Torokhov wrote: > > > On Tue, Dec 1, 2015 at 2:32 PM, Sinclair Yeh <s...@vmware.com> wrote: > > > > Hi, > > > > > > > > > > > > > >> > */ > > > >> > -#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; \ > > > >> > > > >> Why do we need to initialize dummies? > > > > > > > > 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. > > 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 > > > 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. > thanks, > > greg k-h ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization