svn commit: r236603 - projects/amd64_xen_pv/sys/amd64/xen
Cherry G. Mathew
cherry at FreeBSD.org
Tue Jun 5 09:49:32 UTC 2012
Author: cherry
Date: Tue Jun 5 09:49:31 2012
New Revision: 236603
URL: http://svn.freebsd.org/changeset/base/236603
Log:
Enable the event channel callback code. Events are now routed via the xen/evtchn/evtchn.c:evtchn_do_upcall() callback.
Also initialise the "failsafe" callback.
Approved by: gibbs (implicit)
Modified:
projects/amd64_xen_pv/sys/amd64/xen/exception.S
projects/amd64_xen_pv/sys/amd64/xen/machdep.c
Modified: projects/amd64_xen_pv/sys/amd64/xen/exception.S
==============================================================================
--- projects/amd64_xen_pv/sys/amd64/xen/exception.S Tue Jun 5 09:45:42 2012 (r236602)
+++ projects/amd64_xen_pv/sys/amd64/xen/exception.S Tue Jun 5 09:49:31 2012 (r236603)
@@ -40,6 +40,8 @@
#include "assym.s"
+#define T_EVENT T_RESERVED /* XXX: */
+
/*
* We're guaranteed that sizeof(struct vcpu_info) == 64 bytes.
* log2(64) == 6;
@@ -143,6 +145,11 @@
movq %rsp, %rdi ; \
call trap
+#define EVENT_UPCALL \
+ cld ; \
+ movq %rsp, %rdi ; \
+ call evtchn_do_upcall
+
#define DO_AST_MAYBE \
testb $SEL_RPL_MASK, TF_CS(%rsp) /* are we returning to user mode? */ ; \
jz 2f /* can't handle ASTs now if not */ ; \
@@ -473,3 +480,20 @@ ENTRY(fork_trampoline)
INTR_EXIT ;
/* XXX: more work required - %rsp offset calc etc. */
+IDTVEC(hypervisor_callback) /* Xen only */
+ TRAP_FRAME_ENTER_NOERR ;
+ TRAP_PROLOGUE(T_EVENT) ;
+ SAVE_SEGMENT_REGS ;
+ SAVE_GENERAL_REGS ;
+ DO_STI_MAYBE ;
+ EVENT_UPCALL ;
+ DO_AST_MAYBE ;
+ RESTORE_GENERAL_REGS ;
+ RESTORE_SEGMENT_REGS ;
+ TRAP_FRAME_EXIT_NOERR ;
+ INTR_EXIT ;
+
+ENTRY(failsafe_callback)
+ movq msgfailsafe, %rdi ;
+ call panic ; /* panic("..."); */
+msgfailsafe: .asciz "Failsafe upcall triggered\n"
Modified: projects/amd64_xen_pv/sys/amd64/xen/machdep.c
==============================================================================
--- projects/amd64_xen_pv/sys/amd64/xen/machdep.c Tue Jun 5 09:45:42 2012 (r236602)
+++ projects/amd64_xen_pv/sys/amd64/xen/machdep.c Tue Jun 5 09:49:31 2012 (r236603)
@@ -104,7 +104,7 @@ xen_pfn_t *xen_phys_machine;
#define PHYSMAP_SIZE (2 * VM_PHYSSEG_MAX)
vm_offset_t pa_index = 0;
vm_paddr_t phys_avail[PHYSMAP_SIZE + 2];
-vm_paddr_t dump_avail[0]; /* XXX: todo */
+vm_paddr_t dump_avail[2] = {0, 0}; /* XXX: todo */
struct pcpu __pcpu[MAXCPU];
@@ -114,6 +114,10 @@ __aligned(PAGE_SIZE); /* vcpu0 global de
struct mtx icu_lock;
struct mtx dt_lock; /* lock for GDT and LDT */ /* XXX : please review its use */
+/* Event callback prototypes */
+void Xhypervisor_callback(void);
+void failsafe_callback(void);
+
vm_paddr_t initxen(struct start_info *);
extern void identify_cpu(void);
@@ -255,6 +259,25 @@ init_exception_table(void)
}
+static void init_event_callbacks(void)
+{
+ struct callback_register event = {
+ .type = CALLBACKTYPE_event,
+ .address = (unsigned long)Xhypervisor_callback
+ };
+
+ struct callback_register failsafe = {
+ .type = CALLBACKTYPE_failsafe,
+ .address = (unsigned long)failsafe_callback
+ };
+
+ PANIC_IF(HYPERVISOR_callback_op(CALLBACKOP_register, &event));
+
+ PANIC_IF(HYPERVISOR_callback_op(CALLBACKOP_register, &failsafe));
+
+ /* XXX: syscall */
+}
+
#define XEN_CPUID_LEAF_HYPERCALL XEN_CPUID_LEAF(3 - 1)
void xen_set_hypercall_page(vm_paddr_t);
@@ -406,6 +429,9 @@ initxen(struct start_info *si)
/* exception handling */
init_exception_table();
+ /* Event handling */
+ init_event_callbacks();
+
identify_cpu(); /* Final stage of CPU initialization */
//msgbufinit(msgbufp, msgbufsize);
More information about the svn-src-projects
mailing list