]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
pv: Add sysenter handling for guests
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 29 Jun 2020 13:17:46 +0000 (14:17 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 29 Jun 2020 13:18:02 +0000 (14:18 +0100)
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 d577603e0865b58c10eddc1325ce3046f4a8d74a..b76d7ef3ac7e64d5d49635c470d52bb40b1e592b 100644 (file)
@@ -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
 
 /*
index 004afd3c0729b19d2c9ca72d76bd07009fd25365..8d01eba52923967746537c4fe354396cbc127c86 100644 (file)
@@ -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 */
 
 /*
index 85ce373b3e01b7645cec9ffbef38b2c11dc524a7..ac047a0635b64f38984a84fe9897b25bf02f6fd4 100644 (file)
  */
 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.
  */
index 0ce5ea83dc6d9ebce7f67960e4aafc7781340926..ae506d1c6c68f75e3315622f78b32751f21bccbf 100644 (file)
@@ -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 )
index dccbc5af377224b67f1a53ea1f07d5041fabbec0..4beb11e3f80f82931b2205c5ec762605ec8ef7ce 100644 (file)
@@ -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");