Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Jul 2012 14:56:12 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 213850 for review
Message-ID:  <201207031456.q63EuCkX039358@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@213850?ac=10

Change 213850 by jhb@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();
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207031456.q63EuCkX039358>