Module Name:    src
Committed By:   bouyer
Date:           Mon Apr 11 14:15:30 UTC 2016

Modified Files:
        src/sys/arch/amd64/include: profile.h

Log Message:
x86_lfence() calls mcount(), so inline lfence instructions in mcount
helper functions


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/amd64/include/profile.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/include/profile.h
diff -u src/sys/arch/amd64/include/profile.h:1.17 src/sys/arch/amd64/include/profile.h:1.18
--- src/sys/arch/amd64/include/profile.h:1.17	Sun Jan 10 09:04:32 2016
+++ src/sys/arch/amd64/include/profile.h	Mon Apr 11 14:15:30 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: profile.h,v 1.17 2016/01/10 09:04:32 ryo Exp $	*/
+/*	$NetBSD: profile.h,v 1.18 2016/04/11 14:15:30 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -83,8 +83,9 @@ __asm(" .globl __mcount		\n"			\
 static inline void
 mcount_disable_intr(void)
 {
-	/* works because __cli is a macro */
-	__cli();
+	/* should be __cli() but this calls x86_lfence() which calls mcount */
+	curcpu()->ci_vcpu->evtchn_upcall_mask = 1;
+	__asm volatile("lfence" ::: "memory"); /* x86_lfence() */
 }
 
 static inline u_long
@@ -97,7 +98,8 @@ static inline void
 mcount_write_psl(u_long psl)
 {
 	curcpu()->ci_vcpu->evtchn_upcall_mask = psl;
-	x86_lfence();
+	/* can't call x86_lfence because it calls mcount() */
+	__asm volatile("lfence" ::: "memory"); /* x86_lfence() */
 	/* XXX can't call hypervisor_force_callback() because we're in mcount*/ 
 }
 

Reply via email to