summaryrefslogtreecommitdiff
path: root/sys/src/9/xen/xen.s
diff options
context:
space:
mode:
authormischief <mischief@offblast.org>2014-06-24 18:02:25 -0700
committermischief <mischief@offblast.org>2014-06-24 18:02:25 -0700
commit5ba95fdb07ddc2c32111a1b2f57f17aa27fcbbf5 (patch)
treec1ec54cb9ecff85b0b820a26d26a10a32a118d0c /sys/src/9/xen/xen.s
parentfa03455b5057675b18d1c87aef2d1071b2088de0 (diff)
import xen 32 bit paravirtual kernel from /n/sources/xen.
Diffstat (limited to 'sys/src/9/xen/xen.s')
-rw-r--r--sys/src/9/xen/xen.s72
1 files changed, 72 insertions, 0 deletions
diff --git a/sys/src/9/xen/xen.s b/sys/src/9/xen/xen.s
new file mode 100644
index 000000000..e409f70d9
--- /dev/null
+++ b/sys/src/9/xen/xen.s
@@ -0,0 +1,72 @@
+#include "xendefs.h"
+#include "mem.h"
+
+#define ENTRY(X) TEXT X(SB), $0
+
+/*
+ * XXX there's a race in here because we can get an upcall
+ * betwen the spllo() (in xenupcall) and the rti. This will make
+ * handlers stack, which could lead to a blown stack. Probably
+ * not worth fixing (but possibly worth detecting and panicing).
+ *
+ * For fun get some popcorn and turn off the lights and read the
+ * linux solution (search for scrit/ecrit).
+ */
+ENTRY(hypervisor_callback)
+ SUBL $8, SP /* space for ecode and trap type */
+ PUSHL DS /* save DS */
+ PUSHL $(KDSEL)
+ POPL DS /* fix up DS */
+ PUSHL ES /* save ES */
+ PUSHL $(KDSEL)
+ POPL ES /* fix up ES */
+
+ PUSHL FS /* save the rest of the Ureg struct */
+ PUSHL GS
+ PUSHAL
+
+ PUSHL SP /* Ureg* argument to trap */
+ CALL xenupcall+0(SB)
+ POPL AX
+
+ POPAL
+ POPL GS
+ POPL FS
+ POPL ES
+ POPL DS
+ ADDL $8, SP /* pop error code and trap type */
+ IRETL
+
+/* Hypervisor uses this for application faults while it executes.*/
+ENTRY(failsafe_callback)
+ IRETL
+ PUSHL AX
+ CALL install_safe_pf_handler(SB)
+ MOVL 32(SP), BX
+ MOVW BX, DS
+ MOVL 36(SP), BX
+ MOVW BX, ES
+ MOVL 40(SP), BX
+ MOVW BX, FS
+ MOVL 44(SP), BX
+ MOVW BX, GS
+ CALL install_normal_pf_handler(SB)
+ POPL AX
+ ADDL $16, SP
+ IRETL
+
+/* xen traps with varying argument counts */
+TEXT xencall6(SB), $0
+ MOVL VDI+20(FP), DI
+TEXT xencall5(SB), $0
+ MOVL VSI+16(FP), SI
+TEXT xencall4(SB), $0
+ MOVL VDX+12(FP), DX
+TEXT xencall3(SB), $0
+ MOVL VCX+8(FP), CX
+TEXT xencall2(SB), $0
+ MOVL VBX+4(FP), BX
+TEXT xencall1(SB), $0
+ MOVL op+0(FP), AX
+ INT $0x82
+ RET