svn commit: r185386 - in user/dfr/xenhvm/6/sys/amd64/include: . xen

Doug Rabson dfr at FreeBSD.org
Fri Nov 28 07:49:37 PST 2008


Author: dfr
Date: Fri Nov 28 15:49:36 2008
New Revision: 185386
URL: http://svn.freebsd.org/changeset/base/185386

Log:
  Add some Xen support for amd64 - initially HVM only.

Added:
  user/dfr/xenhvm/6/sys/amd64/include/xen/   (props changed)
     - copied from r185181, user/dfr/xenhvm/6/sys/i386/include/xen/
Modified:
  user/dfr/xenhvm/6/sys/amd64/include/pcpu.h
  user/dfr/xenhvm/6/sys/amd64/include/xen/hypercall.h
  user/dfr/xenhvm/6/sys/amd64/include/xen/hypervisor.h
  user/dfr/xenhvm/6/sys/amd64/include/xen/synch_bitops.h
  user/dfr/xenhvm/6/sys/amd64/include/xen/xen-os.h
  user/dfr/xenhvm/6/sys/amd64/include/xen/xenfunc.h
  user/dfr/xenhvm/6/sys/amd64/include/xen/xenvar.h

Modified: user/dfr/xenhvm/6/sys/amd64/include/pcpu.h
==============================================================================
--- user/dfr/xenhvm/6/sys/amd64/include/pcpu.h	Fri Nov 28 14:53:18 2008	(r185385)
+++ user/dfr/xenhvm/6/sys/amd64/include/pcpu.h	Fri Nov 28 15:49:36 2008	(r185386)
@@ -35,6 +35,24 @@
 
 #ifdef _KERNEL
 
+#if defined(XEN) || defined(XENHVM)
+#ifndef NR_VIRQS
+#define	NR_VIRQS	24
+#endif
+#ifndef NR_IPIS
+#define	NR_IPIS		2
+#endif
+#endif
+
+#ifdef XENHVM
+#define PCPU_XEN_FIELDS							\
+	;								\
+	unsigned int pc_last_processed_l1i;				\
+	unsigned int pc_last_processed_l2i
+#else
+#define PCPU_XEN_FIELDS
+#endif
+
 /*
  * The SMP parts are setup in pmap.c and locore.s for the BSP, and
  * mp_machdep.c sets up the data for the AP's to "see" when they awake.
@@ -49,7 +67,8 @@
 	register_t pc_rsp0;						\
 	register_t pc_scratch_rsp;	/* User %rsp in syscall */	\
 	u_int	pc_apic_id;						\
-	u_int   pc_acpi_id		/* ACPI CPU id */
+	u_int   pc_acpi_id		/* ACPI CPU id */		\
+	PCPU_XEN_FIELDS
 
 #if defined(lint)
  

Modified: user/dfr/xenhvm/6/sys/amd64/include/xen/hypercall.h
==============================================================================
--- user/dfr/xenhvm/6/sys/i386/include/xen/hypercall.h	Sat Nov 22 16:14:52 2008	(r185181)
+++ user/dfr/xenhvm/6/sys/amd64/include/xen/hypercall.h	Fri Nov 28 15:49:36 2008	(r185386)
@@ -5,8 +5,15 @@
  * 
  * Copyright (c) 2002-2004, K A Fraser
  * 
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
+ * 64-bit updates:
+ *   Benjamin Liu <benjamin.liu at intel.com>
+ *   Jun Nakajima <jun.nakajima at intel.com>
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this source file (the "Software"), to deal in the Software without
@@ -31,141 +38,151 @@
 #define __HYPERCALL_H__
 
 #include <sys/systm.h>
-#include <xen/interface/xen.h>
-#include <xen/interface/sched.h>
+
+#ifndef __HYPERVISOR_H__
+# error "please don't include this file directly"
+#endif
 
 #define __STR(x) #x
 #define STR(x) __STR(x)
 #define	ENOXENSYS	38
 #define CONFIG_XEN_COMPAT	0x030002
+#define __must_check
 
-
-#if defined(XEN)
-#define HYPERCALL_STR(name)                                     \
-        "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
+#ifdef XEN
+#define HYPERCALL_STR(name)					\
+	"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
 #else
-#define HYPERCALL_STR(name)                                     \
-        "mov hypercall_stubs,%%eax; "                           \
-        "add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "        \
-        "call *%%eax"
+#define HYPERCALL_STR(name)					\
+	"mov $("STR(__HYPERVISOR_##name)" * 32),%%eax; "\
+	"add hypercall_stubs(%%rip),%%rax; "			\
+	"call *%%rax"
 #endif
 
-#define _hypercall0(type, name)                 \
-({                                              \
-        long __res;                             \
-        __asm__ volatile (                          \
-                HYPERCALL_STR(name)             \
-                : "=a" (__res)                  \
-                :                               \
-                : "memory" );                   \
-        (type)__res;                            \
+#define _hypercall0(type, name)			\
+({						\
+	type __res;				\
+	__asm__ volatile (				\
+		HYPERCALL_STR(name)		\
+		: "=a" (__res)			\
+		:				\
+		: "memory" );			\
+	__res;					\
 })
 
-#define _hypercall1(type, name, a1)                             \
-({                                                              \
-        long __res, __ign1;                                     \
-        __asm__ volatile (                                          \
-                HYPERCALL_STR(name)                             \
-                : "=a" (__res), "=b" (__ign1)                   \
-                : "1" ((long)(a1))                              \
-                : "memory" );                                   \
-        (type)__res;                                            \
+#define _hypercall1(type, name, a1)				\
+({								\
+	type __res;						\
+	long __ign1;						\
+	__asm__ volatile (						\
+		HYPERCALL_STR(name)				\
+		: "=a" (__res), "=D" (__ign1)			\
+		: "1" ((long)(a1))				\
+		: "memory" );					\
+	__res;							\
 })
 
-#define _hypercall2(type, name, a1, a2)                         \
-({                                                              \
-        long __res, __ign1, __ign2;                             \
-        __asm__ volatile (                                          \
-                HYPERCALL_STR(name)                             \
-                : "=a" (__res), "=b" (__ign1), "=c" (__ign2)    \
-                : "1" ((long)(a1)), "2" ((long)(a2))            \
-                : "memory" );                                   \
-        (type)__res;                                            \
+#define _hypercall2(type, name, a1, a2)				\
+({								\
+	type __res;						\
+	long __ign1, __ign2;					\
+	__asm__ volatile (						\
+		HYPERCALL_STR(name)				\
+		: "=a" (__res), "=D" (__ign1), "=S" (__ign2)	\
+		: "1" ((long)(a1)), "2" ((long)(a2))		\
+		: "memory" );					\
+	__res;							\
 })
 
-#define _hypercall3(type, name, a1, a2, a3)                     \
-({                                                              \
-        long __res, __ign1, __ign2, __ign3;                     \
-        __asm__ volatile (                                          \
-                HYPERCALL_STR(name)                             \
-                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
-                "=d" (__ign3)                                   \
-                : "1" ((long)(a1)), "2" ((long)(a2)),           \
-                "3" ((long)(a3))                                \
-                : "memory" );                                   \
-        (type)__res;                                            \
+#define _hypercall3(type, name, a1, a2, a3)			\
+({								\
+	type __res;						\
+	long __ign1, __ign2, __ign3;				\
+	__asm__ volatile (						\
+		HYPERCALL_STR(name)				\
+		: "=a" (__res), "=D" (__ign1), "=S" (__ign2), 	\
+		"=d" (__ign3)					\
+		: "1" ((long)(a1)), "2" ((long)(a2)),		\
+		"3" ((long)(a3))				\
+		: "memory" );					\
+	__res;							\
 })
 
-#define _hypercall4(type, name, a1, a2, a3, a4)                 \
-({                                                              \
-        long __res, __ign1, __ign2, __ign3, __ign4;             \
-        __asm__ volatile (                                          \
-                HYPERCALL_STR(name)                             \
-                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
-                "=d" (__ign3), "=S" (__ign4)                    \
-                : "1" ((long)(a1)), "2" ((long)(a2)),           \
-                "3" ((long)(a3)), "4" ((long)(a4))              \
-                : "memory" );                                   \
-        (type)__res;                                            \
+#define _hypercall4(type, name, a1, a2, a3, a4)			\
+({								\
+	type __res;						\
+	long __ign1, __ign2, __ign3;				\
+	register long __arg4 __asm__("r10") = (long)(a4);		\
+	__asm__ volatile (						\
+		HYPERCALL_STR(name)				\
+		: "=a" (__res), "=D" (__ign1), "=S" (__ign2),	\
+		  "=d" (__ign3), "+r" (__arg4)			\
+		: "1" ((long)(a1)), "2" ((long)(a2)),		\
+		  "3" ((long)(a3))				\
+		: "memory" );					\
+	__res;							\
 })
 
-#define _hypercall5(type, name, a1, a2, a3, a4, a5)             \
-({                                                              \
-        long __res, __ign1, __ign2, __ign3, __ign4, __ign5;     \
-        __asm__ volatile (                                          \
-                HYPERCALL_STR(name)                             \
-                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
-                "=d" (__ign3), "=S" (__ign4), "=D" (__ign5)     \
-                : "1" ((long)(a1)), "2" ((long)(a2)),           \
-                "3" ((long)(a3)), "4" ((long)(a4)),             \
-                "5" ((long)(a5))                                \
-                : "memory" );                                   \
-        (type)__res;                                            \
-})								
+#define _hypercall5(type, name, a1, a2, a3, a4, a5)		\
+({								\
+	type __res;						\
+	long __ign1, __ign2, __ign3;				\
+	register long __arg4 __asm__("r10") = (long)(a4);		\
+	register long __arg5 __asm__("r8") = (long)(a5);		\
+	__asm__ volatile (						\
+		HYPERCALL_STR(name)				\
+		: "=a" (__res), "=D" (__ign1), "=S" (__ign2),	\
+		  "=d" (__ign3), "+r" (__arg4), "+r" (__arg5)	\
+		: "1" ((long)(a1)), "2" ((long)(a2)),		\
+		  "3" ((long)(a3))				\
+		: "memory" );					\
+	__res;							\
+})
 
-static inline int
+static inline int __must_check
 HYPERVISOR_set_trap_table(
-	trap_info_t *table)
+	const trap_info_t *table)
 {
 	return _hypercall1(int, set_trap_table, table);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_mmu_update(
-	mmu_update_t *req, int count, int *success_count, domid_t domid)
+	mmu_update_t *req, unsigned int count, unsigned int *success_count,
+	domid_t domid)
 {
 	return _hypercall4(int, mmu_update, req, count, success_count, domid);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_mmuext_op(
-	mmuext_op_t *op, int count, int *success_count, domid_t domid)
+	struct mmuext_op *op, unsigned int count, unsigned int *success_count,
+	domid_t domid)
 {
 	return _hypercall4(int, mmuext_op, op, count, success_count, domid);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_set_gdt(
-	unsigned long *frame_list, int entries)
+	unsigned long *frame_list, unsigned int entries)
 {
 	return _hypercall2(int, set_gdt, frame_list, entries);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_stack_switch(
 	unsigned long ss, unsigned long esp)
 {
 	return _hypercall2(int, stack_switch, ss, esp);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_set_callbacks(
-	unsigned long event_selector, unsigned long event_address,
-	unsigned long failsafe_selector, unsigned long failsafe_address)
+	unsigned long event_address, unsigned long failsafe_address, 
+	unsigned long syscall_address)
 {
-	return _hypercall4(int, set_callbacks,
-			   event_selector, event_address,
-			   failsafe_selector, failsafe_address);
+	return _hypercall3(int, set_callbacks,
+			   event_address, failsafe_address, syscall_address);
 }
 
 static inline int
@@ -175,93 +192,85 @@ HYPERVISOR_fpu_taskswitch(
 	return _hypercall1(int, fpu_taskswitch, set);
 }
 
-static inline int 
+static inline int __must_check
 HYPERVISOR_sched_op_compat(
 	int cmd, unsigned long arg)
 {
 	return _hypercall2(int, sched_op_compat, cmd, arg);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_sched_op(
 	int cmd, void *arg)
 {
 	return _hypercall2(int, sched_op, cmd, arg);
 }
 
-static inline long
+static inline long __must_check
 HYPERVISOR_set_timer_op(
 	uint64_t timeout)
 {
-	unsigned long timeout_hi = (unsigned long)(timeout>>32);
-	unsigned long timeout_lo = (unsigned long)timeout;
-	return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
+	return _hypercall1(long, set_timer_op, timeout);
 }
-#if 0
-static inline int
+
+static inline int __must_check
 HYPERVISOR_platform_op(
-        struct xen_platform_op *platform_op)
+	struct xen_platform_op *platform_op)
 {
-        platform_op->interface_version = XENPF_INTERFACE_VERSION;
-        return _hypercall1(int, platform_op, platform_op);
+	platform_op->interface_version = XENPF_INTERFACE_VERSION;
+	return _hypercall1(int, platform_op, platform_op);
 }
-#endif
-static inline int
+
+static inline int __must_check
 HYPERVISOR_set_debugreg(
-	int reg, unsigned long value)
+	unsigned int reg, unsigned long value)
 {
 	return _hypercall2(int, set_debugreg, reg, value);
 }
 
-static inline unsigned long
+static inline unsigned long __must_check
 HYPERVISOR_get_debugreg(
-	int reg)
+	unsigned int reg)
 {
 	return _hypercall1(unsigned long, get_debugreg, reg);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_update_descriptor(
-	uint64_t ma, uint64_t desc)
+	unsigned long ma, unsigned long word)
 {
-	return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
+	return _hypercall2(int, update_descriptor, ma, word);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_memory_op(
 	unsigned int cmd, void *arg)
 {
 	return _hypercall2(int, memory_op, cmd, arg);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_multicall(
-	void *call_list, int nr_calls)
+	multicall_entry_t *call_list, unsigned int nr_calls)
 {
 	return _hypercall2(int, multicall, call_list, nr_calls);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_update_va_mapping(
 	unsigned long va, uint64_t new_val, unsigned long flags)
 {
-	uint32_t hi, lo;
-
-	lo = (uint32_t)(new_val & 0xffffffff);
-	hi = (uint32_t)(new_val >> 32);
-	
-	return _hypercall4(int, update_va_mapping, va,
-			   lo, hi, flags);
+	return _hypercall3(int, update_va_mapping, va, new_val, flags);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_event_channel_op(
 	int cmd, void *arg)
 {
 	int rc = _hypercall2(int, event_channel_op, cmd, arg);
 
 #if CONFIG_XEN_COMPAT <= 0x030002
-	if (__predict_false(rc == -ENOXENSYS)) {
+	if (unlikely(rc == -ENOXENSYS)) {
 		struct evtchn_op op;
 		op.cmd = cmd;
 		memcpy(&op.u, arg, sizeof(op.u));
@@ -269,30 +278,32 @@ HYPERVISOR_event_channel_op(
 		memcpy(arg, &op.u, sizeof(op.u));
 	}
 #endif
-	return (rc);
+
+	return rc;
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_xen_version(
 	int cmd, void *arg)
 {
 	return _hypercall2(int, xen_version, cmd, arg);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_console_io(
-	int cmd, int count, char *str)
+	int cmd, unsigned int count, char *str)
 {
 	return _hypercall3(int, console_io, cmd, count, str);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_physdev_op(
 	int cmd, void *arg)
 {
 	int rc = _hypercall2(int, physdev_op, cmd, arg);
+
 #if CONFIG_XEN_COMPAT <= 0x030002
-	if (__predict_false(rc == -ENOXENSYS)) {
+	if (unlikely(rc == -ENOXENSYS)) {
 		struct physdev_op op;
 		op.cmd = cmd;
 		memcpy(&op.u, arg, sizeof(op.u));
@@ -300,78 +311,77 @@ HYPERVISOR_physdev_op(
 		memcpy(arg, &op.u, sizeof(op.u));
 	}
 #endif
-	return (rc);
+
+	return rc;
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_grant_table_op(
 	unsigned int cmd, void *uop, unsigned int count)
 {
 	return _hypercall3(int, grant_table_op, cmd, uop, count);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_update_va_mapping_otherdomain(
 	unsigned long va, uint64_t new_val, unsigned long flags, domid_t domid)
 {
-	uint32_t hi, lo;
-	
-	lo = (uint32_t)(new_val & 0xffffffff);
-	hi = (uint32_t)(new_val >> 32);
-	
-	return _hypercall5(int, update_va_mapping_otherdomain, va,
-			   lo, hi, flags, domid);
+	return _hypercall4(int, update_va_mapping_otherdomain, va,
+			   new_val, flags, domid);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_vm_assist(
 	unsigned int cmd, unsigned int type)
 {
 	return _hypercall2(int, vm_assist, cmd, type);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_vcpu_op(
-	int cmd, int vcpuid, void *extra_args)
+	int cmd, unsigned int vcpuid, void *extra_args)
 {
 	return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
 }
 
-static inline int
+static inline int __must_check
+HYPERVISOR_set_segment_base(
+	int reg, unsigned long value)
+{
+	return _hypercall2(int, set_segment_base, reg, value);
+}
+
+static inline int __must_check
 HYPERVISOR_suspend(
 	unsigned long srec)
 {
 	struct sched_shutdown sched_shutdown = {
 		.reason = SHUTDOWN_suspend
 	};
+
 	int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
-			   &sched_shutdown, srec);
+			     &sched_shutdown, srec);
+
 #if CONFIG_XEN_COMPAT <= 0x030002
 	if (rc == -ENOXENSYS)
 		rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
 				 SHUTDOWN_suspend, srec);
-#endif	
-	return (rc);
+#endif
+
+	return rc;
 }
 
 #if CONFIG_XEN_COMPAT <= 0x030002
 static inline int
 HYPERVISOR_nmi_op(
-        unsigned long op, void *arg)
+	unsigned long op, void *arg)
 {
-        return _hypercall2(int, nmi_op, op, arg);
+	return _hypercall2(int, nmi_op, op, arg);
 }
 #endif
 
-static inline int
-HYPERVISOR_callback_op(
-        int cmd, void *arg)
-{
-        return _hypercall2(int, callback_op, cmd, arg);
-}
-
 #ifndef CONFIG_XEN
-static inline unsigned long
+static inline unsigned long __must_check
 HYPERVISOR_hvm_op(
     int op, void *arg)
 {
@@ -379,27 +389,27 @@ HYPERVISOR_hvm_op(
 }
 #endif
 
-static inline int
+static inline int __must_check
+HYPERVISOR_callback_op(
+	int cmd, const void *arg)
+{
+	return _hypercall2(int, callback_op, cmd, arg);
+}
+
+static inline int __must_check
 HYPERVISOR_xenoprof_op(
-        int op, void *arg)
+	int op, void *arg)
 {
-        return _hypercall2(int, xenoprof_op, op, arg);
+	return _hypercall2(int, xenoprof_op, op, arg);
 }
 
-static inline int
+static inline int __must_check
 HYPERVISOR_kexec_op(
-        unsigned long op, void *args)
+	unsigned long op, void *args)
 {
-        return _hypercall2(int, kexec_op, op, args);
+	return _hypercall2(int, kexec_op, op, args);
 }
-#endif /* __HYPERCALL_H__ */
 
-/*
- * Local variables:
- *  c-file-style: "linux"
- *  indent-tabs-mode: t
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
- * End:
- */
+#undef __must_check
+
+#endif /* __HYPERCALL_H__ */

Modified: user/dfr/xenhvm/6/sys/amd64/include/xen/hypervisor.h
==============================================================================
--- user/dfr/xenhvm/6/sys/i386/include/xen/hypervisor.h	Sat Nov 22 16:14:52 2008	(r185181)
+++ user/dfr/xenhvm/6/sys/amd64/include/xen/hypervisor.h	Fri Nov 28 15:49:36 2008	(r185386)
@@ -9,8 +9,16 @@
 #ifndef __HYPERVISOR_H__
 #define __HYPERVISOR_H__
 
+#ifdef XENHVM
+
+#define is_running_on_xen()	(HYPERVISOR_shared_info != NULL)
+
+#else
+
 #define is_running_on_xen() 1
 
+#endif
+
 #ifdef PAE
 #ifndef CONFIG_X86_PAE
 #define CONFIG_X86_PAE
@@ -42,7 +50,9 @@
 #define is_initial_xendomain() 0
 #endif
 
+#ifndef XENHVM
 extern start_info_t *xen_start_info;
+#endif
 
 extern uint64_t get_system_time(int ticks);
 
@@ -130,7 +140,7 @@ MULTI_update_va_mapping(
     mcl->op = __HYPERVISOR_update_va_mapping;
     mcl->args[0] = va;
 #if defined(__amd64__)
-    mcl->args[1] = new_val.pte;
+    mcl->args[1] = new_val;
 #elif defined(PAE)
     mcl->args[1] = (uint32_t)(new_val & 0xffffffff) ;
     mcl->args[2] = (uint32_t)(new_val >> 32);

Modified: user/dfr/xenhvm/6/sys/amd64/include/xen/synch_bitops.h
==============================================================================
--- user/dfr/xenhvm/6/sys/i386/include/xen/synch_bitops.h	Sat Nov 22 16:14:52 2008	(r185181)
+++ user/dfr/xenhvm/6/sys/amd64/include/xen/synch_bitops.h	Fri Nov 28 15:49:36 2008	(r185386)
@@ -88,7 +88,6 @@ static inline unsigned long __synch_cmpx
 				       "0"(old)
 				     : "memory");
 		return prev;
-#ifdef CONFIG_X86_64
 	case 4:
 		__asm__ __volatile__("lock; cmpxchgl %k1,%2"
 				     : "=a"(prev)
@@ -103,15 +102,6 @@ static inline unsigned long __synch_cmpx
 				       "0"(old)
 				     : "memory");
 		return prev;
-#else
-	case 4:
-		__asm__ __volatile__("lock; cmpxchgl %1,%2"
-				     : "=a"(prev)
-				     : "q"(new), "m"(*__synch_xg(ptr)),
-				       "0"(old)
-				     : "memory");
-		return prev;
-#endif
 	}
 	return old;
 }

Modified: user/dfr/xenhvm/6/sys/amd64/include/xen/xen-os.h
==============================================================================
--- user/dfr/xenhvm/6/sys/i386/include/xen/xen-os.h	Sat Nov 22 16:14:52 2008	(r185181)
+++ user/dfr/xenhvm/6/sys/amd64/include/xen/xen-os.h	Fri Nov 28 15:49:36 2008	(r185386)
@@ -11,7 +11,7 @@
 #define CONFIG_X86_PAE
 #endif
 
-#if defined(XEN) && !defined(__XEN_INTERFACE_VERSION__)  
+#if !defined(__XEN_INTERFACE_VERSION__)  
 /*  
  * Can update to a more recent version when we implement  
  * the hypercall page  
@@ -51,7 +51,7 @@ smp_processor_id(void)  
 #endif
 
 #ifndef PANIC_IF
-#define PANIC_IF(exp) if (unlikely(exp)) {printk("panic - %s: %s:%d\n",#exp, __FILE__, __LINE__); panic("%s: %s:%d", #exp, __FILE__, __LINE__);} 
+#define PANIC_IF(exp) if (unlikely(exp)) {panic("%s: %s:%d", #exp, __FILE__, __LINE__);} 
 #endif
 
 extern shared_info_t *HYPERVISOR_shared_info;
@@ -91,16 +91,17 @@ void printk(const char *fmt, ...);
 /* some function prototypes */
 void trap_init(void);
 
+#define likely(x)  __builtin_expect((x),1)
+#define unlikely(x)  __builtin_expect((x),0)
+
+#ifndef XENHVM
+
 /*
  * STI/CLI equivalents. These basically set and clear the virtual
  * event_enable flag in teh shared_info structure. Note that when
  * the enable bit is set, there may be pending events to be handled.
  * We may therefore call into do_hypervisor_callback() directly.
  */
-#define likely(x)  __builtin_expect((x),1)
-#define unlikely(x)  __builtin_expect((x),0)
-
-
 
 #define __cli()                                                         \
 do {                                                                    \
@@ -163,12 +164,14 @@ do {                                    
 #define spin_lock_irqsave mtx_lock_irqsave
 #define spin_unlock_irqrestore mtx_unlock_irqrestore
 
+#else
+#endif
 
 #ifndef mb
-#define mb() __asm__ __volatile__("lock; addl $0, 0(%%esp)": : :"memory")
+#define mb() __asm__ __volatile__("mfence":::"memory")
 #endif
 #ifndef rmb
-#define rmb() mb()
+#define rmb() __asm__ __volatile__("lfence":::"memory");
 #endif
 #ifndef wmb
 #define wmb() barrier()

Modified: user/dfr/xenhvm/6/sys/amd64/include/xen/xenfunc.h
==============================================================================
--- user/dfr/xenhvm/6/sys/i386/include/xen/xenfunc.h	Sat Nov 22 16:14:52 2008	(r185181)
+++ user/dfr/xenhvm/6/sys/amd64/include/xen/xenfunc.h	Fri Nov 28 15:49:36 2008	(r185386)
@@ -32,8 +32,12 @@
 
 #include <machine/xen/xen-os.h>
 #include <machine/xen/hypervisor.h>
+#ifdef XENHVM
+#include <machine/xen/xenvar.h>
+#else
 #include <machine/xen/xenpmap.h>
 #include <machine/segments.h>
+#endif
 #include <sys/pcpu.h>
 #define BKPT __asm__("int3");
 #define XPQ_CALL_DEPTH 5
@@ -63,7 +67,9 @@ void _xen_machphys_update(vm_paddr_t, vm
 #define xen_machphys_update(a, b) _xen_machphys_update((a), (b), NULL, 0)
 #endif	
 
+#ifndef XENHVM
 void xen_update_descriptor(union descriptor *, union descriptor *);
+#endif
 
 extern struct mtx balloon_lock;
 #if 0

Modified: user/dfr/xenhvm/6/sys/amd64/include/xen/xenvar.h
==============================================================================
--- user/dfr/xenhvm/6/sys/i386/include/xen/xenvar.h	Sat Nov 22 16:14:52 2008	(r185181)
+++ user/dfr/xenhvm/6/sys/amd64/include/xen/xenvar.h	Fri Nov 28 15:49:36 2008	(r185386)
@@ -39,8 +39,6 @@ extern int xendebug_flags;
 #endif
 #include <machine/xen/features.h>
 
-extern	xen_pfn_t *xen_phys_machine;
-
 #if 0
 #define TRACE_ENTER XENPRINTF("(file=%s, line=%d) entered %s\n", __FILE__, __LINE__, __FUNCTION__)
 #define TRACE_EXIT XENPRINTF("(file=%s, line=%d) exiting %s\n", __FILE__, __LINE__, __FUNCTION__)
@@ -52,6 +50,33 @@ if (xendebug_flags & argflags) XENPRINTF
 #define TRACE_DEBUG(argflags, _f, _a...)
 #endif
 
+#ifdef XENHVM
+
+static inline vm_paddr_t
+phystomach(vm_paddr_t pa)
+{
+
+	return (pa);
+}
+
+static inline vm_paddr_t
+machtophys(vm_paddr_t ma)
+{
+
+	return (ma);
+}
+
+#define vtomach(va)	pmap_kextract((vm_offset_t) (va))
+#define PFNTOMFN(pa)	(pa)
+
+#define set_phys_to_machine(pfn, mfn)	((void)0)
+#define PT_UPDATES_FLUSH()		((void)0)
+
+#else
+
+extern	xen_pfn_t *xen_phys_machine;
+
+
 extern xen_pfn_t *xen_machine_phys;
 /* Xen starts physical pages after the 4MB ISA hole -
  * FreeBSD doesn't
@@ -84,6 +109,8 @@ extern xen_pfn_t *xen_machine_phys;
 #define phystomach(pa) (((vm_paddr_t)(PFNTOMFN((pa) >> PAGE_SHIFT))) << PAGE_SHIFT)
 #define machtophys(ma) (((vm_paddr_t)(MFNTOPFN((ma) >> PAGE_SHIFT))) << PAGE_SHIFT)
 
+#endif
+
 
 void xpq_init(void);
 


More information about the svn-src-user mailing list