Skip to contentSkip to conversation

x86/VMX: Implement vmptrst

PATCH In review Anshul Makkar 4 participants 6 messages Jan 5, 2017 – Jan 11, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/VMX: Implement vmptrst

Current codebase doesn't implement and use vmptrst. Implementing it as it may be required in future.

---
 xen/include/asm-x86/hvm/vmx/vmx.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
xen/include/asm-x86/hvm/vmx/vmx.h +22 -0
index e5c6499..2db6c1d 100644
@@ -328,6 +328,28 @@ static always_inline void __vmptrld(u64 addr)
                    : "memory");
 }
 
+static always_inline u64 __vmptrst(void)
+{
+    u64 paddr;
+
+    asm volatile (
+#ifdef HAVE_GAS_VMX
+                   "vmptrst %0\n"
+#else
+                   VMPTRST_OPCODE MODRM_EAX_07
+#endif
+
+#ifdef HAVE_GAS_VMX
+                   : "=m" (paddr)
+                   :
+#else
+                   :
+                   : "a" (&paddr),
+#endif
+                   : "memory");
+    return paddr;
+}
+
 static always_inline void __vmpclear(u64 addr)
 {
     asm volatile (
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 05.01.17 at 19:42, <[email protected]> wrote:
xen/include/asm-x86/hvm/vmx/vmx.h +9 -0
+static always_inline u64 __vmptrst(void)
+{
+    u64 paddr;
+
+    asm volatile (
+#ifdef HAVE_GAS_VMX
+                   "vmptrst %0\n"
+#else
+                   VMPTRST_OPCODE MODRM_EAX_07

xen/include/asm-x86/hvm/vmx/vmx.h static always_inline void __vmptrld(u64 addr) · line 349

Quoted 10 lines
xen/include/asm-x86/hvm/vmx/vmx.h +10 -0
+#endif
+
+#ifdef HAVE_GAS_VMX
+                   : "=m" (paddr)
+                   :
+#else
+                   :
+                   : "a" (&paddr),
+#endif
+                   : "memory");

I don't see the point of the memory clobber here in the HAVE_GAS_VMX case (and in the other case it could be easily avoided by making the output common). In fact some time ago I did raise the question already as to whether some of the other inline functions shouldn't also be relaxed.

Also there's a missing blank before the closing parenthesis.

Beyond that I'll leave it to the VMX maintainers to decide whether having an unused function in the code base is a good idea.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 05.01.17 at 19:42, <[email protected]> wrote:
xen/include/asm-x86/hvm/vmx/vmx.h +14 -0
+static always_inline u64 __vmptrst(void)
+{
+    u64 paddr;
+
+    asm volatile (
+#ifdef HAVE_GAS_VMX
+                   "vmptrst %0\n"
+#else
+                   VMPTRST_OPCODE MODRM_EAX_07
+#endif
+
+#ifdef HAVE_GAS_VMX
+                   : "=m" (paddr)
+                   :
Quoted 8 lines

xen/include/asm-x86/hvm/vmx/vmx.h static always_inline void __vmptrld(u64 addr) · line 349

Quoted 5 lines
xen/include/asm-x86/hvm/vmx/vmx.h +5 -0
+#else
+                   :
+                   : "a" (&paddr),
+#endif
+                   : "memory");

I don't see the point of the memory clobber here in the HAVE_GAS_VMX case (and in the other case it could be easily avoided by making the output common).

Currently it is the only thing covering the fact that paddr actually gets written to.

Quoted 3 lines

In fact some time ago I
did raise the question already as to whether some of the other inline functions shouldn't also be relaxed.

Didn't we agree that removing the memory clobbers was a good thing to do? I recall that you asked, but I don't recall what the outcome was.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 26 lines
Quoted 1 line
Quoted 1 line · On 06.01.17 at 15:39, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 05.01.17 at 19:42, <[email protected]> wrote:
xen/include/asm-x86/hvm/vmx/vmx.h +14 -0
+static always_inline u64 __vmptrst(void)
+{
+    u64 paddr;
+
+    asm volatile (
+#ifdef HAVE_GAS_VMX
+                   "vmptrst %0\n"
+#else
+                   VMPTRST_OPCODE MODRM_EAX_07
+#endif
+
+#ifdef HAVE_GAS_VMX
+                   : "=m" (paddr)
+                   :
Quoted 8 lines

xen/include/asm-x86/hvm/vmx/vmx.h static always_inline void __vmptrld(u64 addr) · line 349

Quoted 5 lines
xen/include/asm-x86/hvm/vmx/vmx.h +5 -0
+#else
+                   :
+                   : "a" (&paddr),
+#endif
+                   : "memory");

I don't see the point of the memory clobber here in the HAVE_GAS_VMX case (and in the other case it could be easily avoided by making the output common).

Quoted 2 lines

Currently it is the only thing covering the fact that paddr actually gets written to.

Well, see especially my remark in parentheses.

Quoted 6 lines
Quoted 3 lines

In fact some time ago I
did raise the question already as to whether some of the other inline functions shouldn't also be relaxed.

Didn't we agree that removing the memory clobbers was a good thing to do? I recall that you asked, but I don't recall what the outcome was.

Afair the outcome was at best ambiguous, or else I would either have done it already, or I would at least have an item on my todo list. Actually, looking through patch history I did do it for vmread/ vmwrite, so I assume there was a reason to leave the others alone (possibly just to be overcautious).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw
Quoted 8 lines · Kevin
Quoted 7 lines

From: Anshul Makkar [mailto:[email protected]]
Sent: Friday, January 06, 2017 2:42 AM

Current codebase doesn't implement and use vmptrst. Implementing it as it may be required in future.

Then let's do it when it's really required. :-)

I needed it to debug an issue, found it missing and that's why I added. I have a sanity test, that continuously uses it. There may be other users out there who can use it for similar or some other purpose. Having it in standard code base will do no harm.

Quoted 3 lines

Thanks
Kevin

Anshul

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel