Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Feb 2008 00:34:06 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 135689 for review
Message-ID:  <200802190034.m1J0Y65Q008069@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=135689

Change 135689 by kmacy@pandemonium:kmacy:xen31 on 2008/02/19 00:33:47

	add in more backward compatibility support

Affected files ...

.. //depot/projects/xen31/sys/i386/i386/machdep.c#16 edit
.. //depot/projects/xen31/sys/i386/include/xen/hypercall.h#9 edit
.. //depot/projects/xen31/sys/i386/include/xen/hypervisor.h#7 edit

Differences ...

==== //depot/projects/xen31/sys/i386/i386/machdep.c#16 (text+ko) ====

@@ -2166,10 +2166,17 @@
 void
 init386(int first)
 {
-	
 	int error, gsel_tss, metadata_missing, x;
 	unsigned long gdtmachpfn;
 	struct pcpu *pc;
+	struct callback_register event = {
+		.type = CALLBACKTYPE_event,
+		.address = {GSEL(GCODE_SEL, SEL_KPL), (unsigned long)Xhypervisor_callback },
+	};
+	struct callback_register failsafe = {
+		.type = CALLBACKTYPE_failsafe,
+		.address = {GSEL(GCODE_SEL, SEL_KPL), (unsigned long)failsafe_callback },
+	};
 
 	thread0.td_kstack = proc0kstack;
 	thread0.td_pcb = (struct pcb *)
@@ -2238,10 +2245,16 @@
 	if ((error = HYPERVISOR_set_trap_table(trap_table)) != 0) {
 		panic("set_trap_table failed - error %d\n", error);
 	}
-        HYPERVISOR_set_callbacks(GSEL(GCODE_SEL, SEL_KPL),
-	    (unsigned long)Xhypervisor_callback,
-	    GSEL(GCODE_SEL, SEL_KPL), (unsigned long)failsafe_callback);
-	
+
+	error = HYPERVISOR_callback_op(CALLBACKOP_register, &event);
+	if (error == 0)
+		error = HYPERVISOR_callback_op(CALLBACKOP_register, &failsafe);
+#if	CONFIG_XEN_COMPAT <= 0x030002
+	if (error == -ENOXENSYS)
+		HYPERVISOR_set_callbacks(GSEL(GCODE_SEL, SEL_KPL),
+		    (unsigned long)Xhypervisor_callback,
+		    GSEL(GCODE_SEL, SEL_KPL), (unsigned long)failsafe_callback);
+#endif
 	pcpu_init(pc, 0, sizeof(struct pcpu));
 	PCPU_SET(prvspace, pc);
 	PCPU_SET(curthread, &thread0);

==== //depot/projects/xen31/sys/i386/include/xen/hypercall.h#9 (text+ko) ====

@@ -37,6 +37,7 @@
 #define __STR(x) #x
 #define STR(x) __STR(x)
 #define	ENOXENSYS	38
+#define CONFIG_XEN_COMPAT	0x030002
 
 
 #if defined(XEN)
@@ -259,6 +260,7 @@
 {
 	int rc = _hypercall2(int, event_channel_op, cmd, arg);
 
+#if CONFIG_XEN_COMPAT <= 0x030002
 	if (__predict_false(rc == -ENOXENSYS)) {
 		struct evtchn_op op;
 		op.cmd = cmd;
@@ -266,7 +268,7 @@
 		rc = _hypercall1(int, event_channel_op_compat, &op);
 		memcpy(arg, &op.u, sizeof(op.u));
 	}
-
+#endif
 	return (rc);
 }
 
@@ -289,7 +291,7 @@
 	int cmd, void *arg)
 {
 	int rc = _hypercall2(int, physdev_op, cmd, arg);
-
+#if CONFIG_XEN_COMPAT <= 0x030002
 	if (__predict_false(rc == -ENOXENSYS)) {
 		struct physdev_op op;
 		op.cmd = cmd;
@@ -297,7 +299,7 @@
 		rc = _hypercall1(int, physdev_op_compat, &op);
 		memcpy(arg, &op.u, sizeof(op.u));
 	}
-
+#endif
 	return (rc);
 }
 
@@ -344,34 +346,40 @@
 	};
 	int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
 			   &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);
 }
+
+#if CONFIG_XEN_COMPAT <= 0x030002
 static inline int
 HYPERVISOR_nmi_op(
         unsigned long op, void *arg)
 {
         return _hypercall2(int, nmi_op, op, arg);
 }
+#endif
 
-#ifdef notyet
+static inline int
+HYPERVISOR_callback_op(
+        int cmd, void *arg)
+{
+        return _hypercall2(int, callback_op, cmd, arg);
+}
+
+#ifndef CONFIG_XEN
 static inline unsigned long
 HYPERVISOR_hvm_op(
     int op, void *arg)
 {
     return _hypercall2(unsigned long, hvm_op, op, arg);
 }
+#endif
 
 static inline int
-HYPERVISOR_callback_op(
-        int cmd, void *arg)
-{
-        return _hypercall2(int, callback_op, cmd, arg);
-}
-
-static inline int
 HYPERVISOR_xenoprof_op(
         int op, void *arg)
 {
@@ -384,7 +392,6 @@
 {
         return _hypercall2(int, kexec_op, op, args);
 }
-#endif
 #endif /* __HYPERCALL_H__ */
 
 /*

==== //depot/projects/xen31/sys/i386/include/xen/hypervisor.h#7 (text+ko) ====

@@ -12,8 +12,10 @@
 #define is_running_on_xen() 1
 
 #ifdef PAE
+#ifndef CONFIG_X86_PAE
 #define CONFIG_X86_PAE
 #endif
+#endif
 
 #include <sys/cdefs.h>
 #include <sys/systm.h>
@@ -22,6 +24,7 @@
 #include <xen/interface/event_channel.h>
 #include <xen/interface/physdev.h>
 #include <xen/interface/sched.h>
+#include <xen/interface/callback.h>
 #include <machine/xen/hypercall.h>
 
 #if defined(__amd64__)
@@ -55,7 +58,11 @@
 {
         int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
 
-        return rc;
+#if CONFIG_XEN_COMPAT <= 0x030002
+	if (rc == -ENOXENSYS)
+		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
+#endif
+        return (rc);
 }
 
 static inline int
@@ -64,18 +71,25 @@
 {
         int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
 
-        return rc;
+#if CONFIG_XEN_COMPAT <= 0x030002
+	if (rc == -ENOXENSYS)
+		rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
+#endif
+        return (rc);
 }
 
 
-static inline int
+static inline void 
 HYPERVISOR_shutdown(unsigned int reason)
 {
 	struct sched_shutdown sched_shutdown = {
 		.reason = reason
 	};
 
-	return HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+	HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+#if CONFIG_XEN_COMPAT <= 0x030002
+	HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
+#endif
 }
 
 static inline void
@@ -92,13 +106,19 @@
 HYPERVISOR_poll(
 	evtchn_port_t *ports, unsigned int nr_ports, int ticks)
 {
+	int rc;
 	struct sched_poll sched_poll = {
 		.nr_ports = nr_ports,
 		.timeout = get_system_time(ticks)
 	};
 	set_xen_guest_handle(sched_poll.ports, ports);
 
-	return HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
+	rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
+#if CONFIG_XEN_COMPAT <= 0x030002
+	if (rc == -ENOXENSYS)
+		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
+#endif	
+	return (rc);
 }
 
 static inline void



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