From: Andrew Cooper Date: Mon, 29 Jun 2020 13:17:46 +0000 (+0100) Subject: pv: Add sysenter handling for guests X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2dd14fbcf9d03fdc300491939aeac75d3eb9e05f;p=xtf.git pv: Add sysenter handling for guests Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/entry_32.S b/arch/x86/entry_32.S index d577603..b76d7ef 100644 --- a/arch/x86/entry_32.S +++ b/arch/x86/entry_32.S @@ -208,6 +208,33 @@ ENTRY(entry_SYSCALL) jmp HYPERCALL_iret ENDFUNC(entry_SYSCALL) + +ENTRY(entry_SYSENTER) + 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_sysenter + add $4, %esp + + RESTORE_ALL + + pop %ds + pop %es + + add $8, %esp /* Pop error_code/entry_vector. */ + + jmp HYPERCALL_iret +ENDFUNC(entry_SYSENTER) #endif /* diff --git a/arch/x86/entry_64.S b/arch/x86/entry_64.S index 004afd3..8d01eba 100644 --- a/arch/x86/entry_64.S +++ b/arch/x86/entry_64.S @@ -183,6 +183,24 @@ ENTRY(entry_SYSCALL) jmp HYPERCALL_iret ENDFUNC(entry_SYSCALL) + +ENTRY(entry_SYSENTER) + env_ADJUST_FRAME + + push $0 + movl $0x200, 4(%rsp) + + SAVE_ALL + + mov %rsp, %rdi /* struct cpu_regs * */ + call do_sysenter + + RESTORE_ALL + + movq $0, (%rsp) /* Clobber error_code/entry_vector */ + jmp HYPERCALL_iret + +ENDFUNC(entry_SYSENTER) #endif /* CONFIG_PV */ /* diff --git a/arch/x86/include/arch/test.h b/arch/x86/include/arch/test.h index 85ce373..ac047a0 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 SYSENTER invocations. + */ +void do_sysenter(struct cpu_regs *regs); + /** * May be implemented by a guest to handle Event Channel upcalls. */ diff --git a/arch/x86/pv/traps.c b/arch/x86/pv/traps.c index 0ce5ea8..ae506d1 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_SYSENTER(void); void entry_EVTCHN(void); struct xen_trap_info pv_default_trap_info[] = @@ -136,6 +137,11 @@ static void init_callbacks(void) .flags = CALLBACKF_mask_events, .address = INIT_XEN_CALLBACK(__KERN_CS, _u(entry_SYSCALL)), }, + { + .type = CALLBACKTYPE_sysenter, + .flags = CALLBACKF_mask_events, + .address = INIT_XEN_CALLBACK(__KERN_CS, _u(entry_SYSENTER)), + }, }; for ( unsigned int i = 0; i < ARRAY_SIZE(cb); ++i ) diff --git a/arch/x86/traps.c b/arch/x86/traps.c index dccbc5a..4beb11e 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_sysenter(struct cpu_regs *regs) +{ + panic("Unhandled sysenter\n"); +} + void __weak do_evtchn(struct cpu_regs *regs) { panic("Unhandled evtchn upcall\n");