git: e54ae8258d64 - main - amd64: Fix output operand specs for the stmxcsr and vmread intrinsics

Mark Johnston markj at FreeBSD.org
Mon Aug 9 17:49:31 UTC 2021


The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=e54ae8258d6433ad2f2411dbeaa1fde6b817d5ef

commit e54ae8258d6433ad2f2411dbeaa1fde6b817d5ef
Author:     Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-08-09 17:28:08 +0000
Commit:     Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-08-09 17:28:08 +0000

    amd64: Fix output operand specs for the stmxcsr and vmread intrinsics
    
    This does not appear to affect code generation, at least with the
    default toolchain.
    
    Noticed because incorrect output specifications lead to false positives
    from KMSAN, as the instrumentation uses them to update shadow state for
    output operands.
    
    Reviewed by:    kib
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D31466
---
 sys/amd64/amd64/fpu.c             | 2 +-
 sys/amd64/vmm/intel/vmx_cpufunc.h | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c
index 20e3dd34405d..d7936b3b1922 100644
--- a/sys/amd64/amd64/fpu.c
+++ b/sys/amd64/amd64/fpu.c
@@ -79,7 +79,7 @@ __FBSDID("$FreeBSD$");
 #define	fxrstor(addr)		__asm __volatile("fxrstor %0" : : "m" (*(addr)))
 #define	fxsave(addr)		__asm __volatile("fxsave %0" : "=m" (*(addr)))
 #define	ldmxcsr(csr)		__asm __volatile("ldmxcsr %0" : : "m" (csr))
-#define	stmxcsr(addr)		__asm __volatile("stmxcsr %0" : : "m" (*(addr)))
+#define	stmxcsr(addr)		__asm __volatile("stmxcsr %0" : "=m" (*(addr)))
 
 static __inline void
 xrstor32(char *addr, uint64_t mask)
diff --git a/sys/amd64/vmm/intel/vmx_cpufunc.h b/sys/amd64/vmm/intel/vmx_cpufunc.h
index 09d6d25a18e0..05ac56290cb9 100644
--- a/sys/amd64/vmm/intel/vmx_cpufunc.h
+++ b/sys/amd64/vmm/intel/vmx_cpufunc.h
@@ -137,10 +137,9 @@ vmread(uint64_t r, uint64_t *addr)
 
 	__asm __volatile("vmread %[r], %[addr];"
 			 VMX_SET_ERROR_CODE
-			 : [error] "=r" (error)
-			 : [r] "r" (r), [addr] "m" (*addr)
+			 : [error] "=r" (error), [addr] "=m" (*addr)
+			 : [r] "r" (r)
 			 : "memory");
-
 	return (error);
 }
 


More information about the dev-commits-src-all mailing list