Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Mar 2015 20:13:50 +0000 (UTC)
From:      Neel Natu <neel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r279540 - head/sys/amd64/vmm/amd
Message-ID:  <201503022013.t22KDoGK068513@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: neel
Date: Mon Mar  2 20:13:49 2015
New Revision: 279540
URL: https://svnweb.freebsd.org/changeset/base/279540

Log:
  Fix warnings/errors when building vmm.ko with gcc:
  
  - fix warning about comparison of 'uint8_t v_tpr >= 0' always being true.
  
  - fix error triggered by an empty clobber list in the inline assembly for
    "clgi" and "stgi"
  
  - fix error when compiling "vmload %rax", "vmrun %rax" and "vmsave %rax". The
    gcc assembler does not like the explicit operand "%rax" while the clang
    assembler requires specifying the operand "%rax". Fix this by encoding the
    instructions using the ".byte" directive.
  
  Reported by:	julian
  MFC after:	1 week

Modified:
  head/sys/amd64/vmm/amd/svm.c
  head/sys/amd64/vmm/amd/svm_support.S

Modified: head/sys/amd64/vmm/amd/svm.c
==============================================================================
--- head/sys/amd64/vmm/amd/svm.c	Mon Mar  2 20:05:16 2015	(r279539)
+++ head/sys/amd64/vmm/amd/svm.c	Mon Mar  2 20:13:49 2015	(r279540)
@@ -1641,7 +1641,7 @@ done:
 	 * VMRUN.
 	 */
 	v_tpr = vlapic_get_cr8(vlapic);
-	KASSERT(v_tpr >= 0 && v_tpr <= 15, ("invalid v_tpr %#x", v_tpr));
+	KASSERT(v_tpr <= 15, ("invalid v_tpr %#x", v_tpr));
 	if (ctrl->v_tpr != v_tpr) {
 		VCPU_CTR2(sc->vm, vcpu, "VMCB V_TPR changed from %#x to %#x",
 		    ctrl->v_tpr, v_tpr);
@@ -1808,14 +1808,14 @@ static __inline void
 disable_gintr(void)
 {
 
-        __asm __volatile("clgi" : : :);
+	__asm __volatile("clgi");
 }
 
 static __inline void
 enable_gintr(void)
 {
 
-        __asm __volatile("stgi" : : :);
+        __asm __volatile("stgi");
 }
 
 /*

Modified: head/sys/amd64/vmm/amd/svm_support.S
==============================================================================
--- head/sys/amd64/vmm/amd/svm_support.S	Mon Mar  2 20:05:16 2015	(r279539)
+++ head/sys/amd64/vmm/amd/svm_support.S	Mon Mar  2 20:13:49 2015	(r279540)
@@ -22,6 +22,8 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
  */
 #include <machine/asmacros.h>
 
@@ -35,6 +37,10 @@
 #define	VENTER  push %rbp ; mov %rsp,%rbp
 #define	VLEAVE  pop %rbp
 
+#define	VMLOAD	.byte 0x0f, 0x01, 0xda
+#define	VMRUN	.byte 0x0f, 0x01, 0xd8
+#define	VMSAVE	.byte 0x0f, 0x01, 0xdb
+
 /*
  * svm_launch(uint64_t vmcb, struct svm_regctx *gctx)
  * %rdi: physical address of VMCB
@@ -79,9 +85,9 @@ ENTRY(svm_launch)
 	movq SCTX_RDI(%rsi), %rdi
 	movq SCTX_RSI(%rsi), %rsi	/* %rsi must be restored last */
 
-	vmload %rax
-	vmrun %rax
-	vmsave %rax
+	VMLOAD
+	VMRUN
+	VMSAVE
 
 	pop %rax		/* pop guest context pointer from the stack */
 



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