]> xenbits.xensource.com Git - people/aperard/xtf.git/commitdiff
Introduce evntchn handling support for PV guests
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 12 Jun 2019 09:59:48 +0000 (10:59 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 18 Jun 2019 15:38:30 +0000 (16:38 +0100)
Fill in the event callback, and use a weak do_evtchn() hook which can be
implemented by guests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/entry_32.S
arch/x86/entry_64.S
arch/x86/include/arch/test.h
arch/x86/pv/traps.c
arch/x86/traps.c

index 9968b57bea3adaf9554a243faa656c69c8656227..8725fd9f4b1e002f92eb22e128872413ddd0556c 100644 (file)
@@ -154,6 +154,33 @@ ENTRY(exec_user_stub)
 ENDFUNC(exec_user_stub)
 .popsection
 
+ENTRY(entry_EVTCHN)
+        push $0
+        push $0x200
+
+        push %es
+        push %ds
+
+        SAVE_ALL
+
+        mov $__KERN_DS, %eax    /* Restore data segments. */
+        mov %eax, %ds
+        mov %eax, %es
+
+        push %esp               /* struct cpu_regs * */
+        call do_evtchn
+        add $4, %esp
+
+        RESTORE_ALL
+
+        pop %ds
+        pop %es
+
+        add $8, %esp            /* Pop error_code/entry_vector. */
+
+        env_IRET
+ENDFUNC(entry_EVTCHN)
+
 #if defined(CONFIG_PV)
 ENTRY(entry_SYSCALL)
         push $0
index 5136dd64474d26dfac7da8343d8745c233606da1..004afd3c0729b19d2c9ca72d76bd07009fd25365 100644 (file)
@@ -148,6 +148,23 @@ ENTRY(exec_user_stub)
 ENDFUNC(exec_user_stub)
 .popsection
 
+ENTRY(entry_EVTCHN)
+        env_ADJUST_FRAME
+
+        push $0
+        movl $0x200, 4(%rsp)
+
+        SAVE_ALL
+
+        mov %rsp, %rdi          /* struct cpu_regs * */
+        call do_evtchn
+
+        RESTORE_ALL
+        add $8, %rsp            /* Pop error_code/entry_vector. */
+
+        env_IRETQ
+ENDFUNC(entry_EVTCHN)
+
 #if defined(CONFIG_PV)
 ENTRY(entry_SYSCALL)
         env_ADJUST_FRAME
index a34cdbb87df486b38be7a06539a9488410f404d3..85ce373b3e01b7645cec9ffbef38b2c11dc524a7 100644 (file)
  */
 void do_syscall(struct cpu_regs *regs);
 
+/**
+ * May be implemented by a guest to handle Event Channel upcalls.
+ */
+void do_evtchn(struct cpu_regs *regs);
+
 #endif /* XTF_X86_TEST_H */
 
 /*
index 92dca02714e0005ffb310bb32e8998599696897a..6bb4e448323ec8a4eebe4c17b012170a55a34476 100644 (file)
@@ -36,6 +36,7 @@ void entry_VE(void);
 void entry_ret_to_kernel(void);
 
 void entry_SYSCALL(void);
+void entry_EVTCHN(void);
 
 struct xen_trap_info pv_default_trap_info[] =
 {
@@ -120,6 +121,15 @@ static void init_callbacks(void)
 
     xen_callback_register_t cb;
 
+    cb = (xen_callback_register_t) {
+        .type = CALLBACKTYPE_event,
+        .address = INIT_XEN_CALLBACK(__KERN_CS, _u(entry_EVTCHN)),
+    };
+
+    rc = hypercall_register_callback(&cb);
+    if ( rc )
+        panic("Failed to register evtchn callback: %d\n", rc);
+
 #ifdef __x86_64__
     cb = (xen_callback_register_t) {
         .type = CALLBACKTYPE_syscall,
index 2fe006661da36b561cafd22d77ff58961cc44333..dccbc5af377224b67f1a53ea1f07d5041fabbec0 100644 (file)
@@ -73,6 +73,11 @@ void __weak do_syscall(struct cpu_regs *regs)
     panic("Unhandled syscall\n");
 }
 
+void __weak do_evtchn(struct cpu_regs *regs)
+{
+    panic("Unhandled evtchn upcall\n");
+}
+
 /*
  * Local variables:
  * mode: C