PERFORCE change 213850 for review
John Baldwin
jhb at FreeBSD.org
Tue Jul 3 14:56:14 UTC 2012
http://p4web.freebsd.org/@@213850?ac=10
Change 213850 by jhb at jhb_ralph on 2012/07/03 14:55:34
More test cases.
Affected files ...
.. //depot/projects/smpng/sys/modules/x86dis/x86dis.c#2 edit
Differences ...
==== //depot/projects/smpng/sys/modules/x86dis/x86dis.c#2 (text+ko) ====
@@ -25,6 +25,28 @@
}
static __inline void
+xsaveopt(char *addr, uint64_t mask)
+{
+ uint32_t low, hi;
+
+ low = mask;
+ hi = mask >> 32;
+ /* xsaveopt (%rdi) */
+ __asm __volatile(".byte 0x0f,0xae,0x37" : :
+ "a" (low), "d" (hi), "D" (addr) : "memory");
+}
+
+static __inline uint64_t
+xgetbv(uint32_t reg)
+{
+ uint32_t low, high;
+
+ __asm __volatile(".byte 0x0f,0x01,0xd0" : "=a" (low), "=d" (high) :
+ "c" (reg));
+ return (low | ((uint64_t)high << 32));
+}
+
+static __inline void
xsetbv(uint32_t reg, uint64_t val)
{
uint32_t low, hi;
@@ -35,13 +57,54 @@
"c" (reg), "a" (low), "d" (hi));
}
+static __inline uint64_t
+rdtscp(uint32_t *aux)
+{
+ uint32_t low, high;
+
+ __asm __volatile("rdtscp" : "=a" (low), "=d" (high), "=c" (*aux));
+ return (low | ((uint64_t)high << 32));
+}
+
+static __inline void
+vmcall(void)
+{
+
+ __asm __volatile(".byte 0x0f,0x01,0xc1");
+}
+
+static __inline void
+vmlaunch(void)
+{
+
+ __asm __volatile(".byte 0x0f,0x01,0xc2");
+}
+
+static __inline void
+vmresume(void)
+{
+
+ __asm __volatile(".byte 0x0f,0x01,0xc3");
+}
+
extern void
isn_list(char *addr, uint32_t reg, uint64_t mask, uint64_t val);
void
isn_list(char *addr, uint32_t reg, uint64_t mask, uint64_t val)
{
+ uint32_t aux;
+
+ /*
+ * XXX: More to add?
+ */
+ rdtscp(&aux);
+ xsaveopt(addr, mask);
xrstor(addr, mask);
xsave(addr, mask);
+ xgetbv(reg);
xsetbv(reg, val);
+ vmcall();
+ vmlaunch();
+ vmresume();
}
More information about the p4-projects
mailing list