diff mbox series

[for-4.0,v2,35/37] tcg/i386: Add setup_guest_base_seg for FreeBSD

Message ID 20181123144558.5048-36-richard.henderson@linaro.org
State New
Headers show
Series tcg: Assorted cleanups | expand

Commit Message

Richard Henderson Nov. 23, 2018, 2:45 p.m. UTC
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 tcg/i386/tcg-target.inc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

-- 
2.17.2
diff mbox series

Patch

diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c
index 79de8d0cd2..55c5a8516c 100644
--- a/tcg/i386/tcg-target.inc.c
+++ b/tcg/i386/tcg-target.inc.c
@@ -1818,6 +1818,16 @@  static inline void setup_guest_base_seg(void)
         guest_base_flags = P_GS;
     }
 }
+#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+# include <machine/sysarch.h>
+
+static int guest_base_flags;
+static inline void setup_guest_base_seg(void)
+{
+    if (sysarch(AMD64_SET_GSBASE, &guest_base) == 0) {
+        guest_base_flags = P_GS;
+    }
+}
 #else
 # define guest_base_flags 0
 static inline void setup_guest_base_seg(void) { }