Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1281256 > unrolled thread
| Started by | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| First post | 2015-12-01 23:20 +0100 |
| Last post | 2015-12-04 23:40 +0100 |
| Articles | 8 — 3 participants |
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 1/6] x86: Add VMWare Host Communication Macros "Sinclair Yeh" <syeh@vmware.com> - 2015-12-01 23:20 +0100
[PATCH 2/6] x86: Update vmware.c to use the common VMW_PORT macros "Sinclair Yeh" <syeh@vmware.com> - 2015-12-01 23:20 +0100
[PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro "Sinclair Yeh" <syeh@vmware.com> - 2015-12-01 23:20 +0100
Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro Xavier Deguillard <xdeguillard@vmware.com> - 2015-12-01 23:40 +0100
Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro "Sinclair Yeh" <syeh@vmware.com> - 2015-12-02 00:20 +0100
Re: [PATCH 1/6] x86: Add VMWare Host Communication Macros Xavier Deguillard <xdeguillard@vmware.com> - 2015-12-01 23:40 +0100
Re: [PATCH 1/6] x86: Add VMWare Host Communication Macros "H. Peter Anvin" <hpa@zytor.com> - 2015-12-01 23:50 +0100
Re: [PATCH 1/6] x86: Add VMWare Host Communication Macros "Sinclair Yeh" <syeh@vmware.com> - 2015-12-04 23:40 +0100
| From | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| Date | 2015-12-01 23:20 +0100 |
| Subject | [PATCH 1/6] x86: Add VMWare Host Communication Macros |
| Message-ID | <qB1rb-76P-5@gated-at.bofh.it> |
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 <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>
---
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 0000000..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 <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.
+ *
+ * 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
+
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| Date | 2015-12-01 23:20 +0100 |
| Subject | [PATCH 2/6] x86: Update vmware.c to use the common VMW_PORT macros |
| Message-ID | <qB1rc-76P-21@gated-at.bofh.it> |
| In reply to | #1281256 |
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 <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: pv-drivers@vmware.com
Cc: virtualization@lists.linux-foundation.org
Cc: linux-kernel@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 <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)
{
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| Date | 2015-12-01 23:20 +0100 |
| Subject | [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro |
| Message-ID | <qB1rd-76P-23@gated-at.bofh.it> |
| In reply to | #1281256 |
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: Xavier Deguillard <xdeguillard@vmware.com>
Cc: linux-kernel@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 <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
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Xavier Deguillard <xdeguillard@vmware.com> |
|---|---|
| Date | 2015-12-01 23:40 +0100 |
| Subject | Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro |
| Message-ID | <qB1Kx-7cT-9@gated-at.bofh.it> |
| In reply to | #1281259 |
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 <xdeguillard@vmware.com>
Xavier
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| Date | 2015-12-02 00:20 +0100 |
| Subject | Re: [PATCH 6/6] VMware balloon: Update vmw_balloon.c to use the VMW_PORT macro |
| Message-ID | <qB2ng-7GU-37@gated-at.bofh.it> |
| In reply to | #1281268 |
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 <xdeguillard@vmware.com>
>
> Xavier
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Xavier Deguillard <xdeguillard@vmware.com> |
|---|---|
| Date | 2015-12-01 23:40 +0100 |
| Message-ID | <qB1Kx-7cT-3@gated-at.bofh.it> |
| In reply to | #1281256 |
Hey Sinclair,
On Tue, Dec 01, 2015 at 02:18:47PM -0800, Sinclair Yeh wrote:
> +/**
> + * 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"?
> + * @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" : \
Are those '\' aligned in the code?
> +
> +#define VMW_PORT_HB_OUT(in1, in2, port_num, magic, \
> + eax, ebx, ecx, edx, si, di, bp) \
> +({ \
> + __asm__ __volatile__ ("movq %13, %%rbp;" \
Same here.
> +
> +#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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2015-12-01 23:50 +0100 |
| Message-ID | <qB1Ue-7g2-7@gated-at.bofh.it> |
| In reply to | #1281256 |
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
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.
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"); \
+})
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Sinclair Yeh" <syeh@vmware.com> |
|---|---|
| Date | 2015-12-04 23:40 +0100 |
| Message-ID | <qC7bc-hI-11@gated-at.bofh.it> |
| In reply to | #1281274 |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web