From: Andrew Cooper Date: Wed, 12 Jun 2019 09:59:48 +0000 (+0100) Subject: Introduce evntchn handling support for PV guests X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=334e1935b99ca663c8808df5f545d996b19ee345;p=xtf.git Introduce evntchn handling support for PV guests Fill in the event callback, and use a weak do_evtchn() hook which can be implemented by guests. Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/entry_32.S b/arch/x86/entry_32.S index 9968b57..8725fd9 100644 --- a/arch/x86/entry_32.S +++ b/arch/x86/entry_32.S @@ -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 diff --git a/arch/x86/entry_64.S b/arch/x86/entry_64.S index 5136dd6..004afd3 100644 --- a/arch/x86/entry_64.S +++ b/arch/x86/entry_64.S @@ -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 diff --git a/arch/x86/include/arch/test.h b/arch/x86/include/arch/test.h index a34cdbb..85ce373 100644 --- a/arch/x86/include/arch/test.h +++ b/arch/x86/include/arch/test.h @@ -13,6 +13,11 @@ */ 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 */ /* diff --git a/arch/x86/pv/traps.c b/arch/x86/pv/traps.c index 92dca02..6bb4e44 100644 --- a/arch/x86/pv/traps.c +++ b/arch/x86/pv/traps.c @@ -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, diff --git a/arch/x86/traps.c b/arch/x86/traps.c index 2fe0066..dccbc5a 100644 --- a/arch/x86/traps.c +++ b/arch/x86/traps.c @@ -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