]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/x86/xen/xen-asm_64.S
Merge tag 'driver-core-4.11-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-artful-kernel.git] / arch / x86 / xen / xen-asm_64.S
CommitLineData
cdacc127 1/*
130ace11
TH
2 * Asm versions of Xen pv-ops, suitable for either direct use or
3 * inlining. The inline versions are the same as the direct-use
4 * versions, with the pre- and post-amble chopped off.
5 *
6 * This code is encoded for size rather than absolute efficiency, with
7 * a view to being able to inline as much as possible.
8 *
9 * We only bother with direct forms (ie, vcpu in pda) of the
10 * operations here; the indirect forms are better handled in C, since
11 * they're generally too large to inline anyway.
cdacc127
JF
12 */
13
6fcac6d3 14#include <asm/errno.h>
9af45651 15#include <asm/percpu.h>
5393744b
JF
16#include <asm/processor-flags.h>
17#include <asm/segment.h>
63332a84 18#include <asm/asm-offsets.h>
3a23208e 19#include <asm/thread_info.h>
cdacc127
JF
20
21#include <xen/interface/xen.h>
22
5393744b 23#include "xen-asm.h"
cdacc127 24
997409d3 25ENTRY(xen_adjust_exception_frame)
130ace11
TH
26 mov 8+0(%rsp), %rcx
27 mov 8+8(%rsp), %r11
997409d3 28 ret $16
9fd21606 29ENDPROC(xen_adjust_exception_frame)
997409d3 30
6fcac6d3
JF
31hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32
32/*
130ace11
TH
33 * Xen64 iret frame:
34 *
35 * ss
36 * rsp
37 * rflags
38 * cs
39 * rip <-- standard iret frame
40 *
41 * flags
42 *
43 * rcx }
44 * r11 }<-- pushed by hypercall page
45 * rsp->rax }
6fcac6d3 46 */
cdacc127
JF
47ENTRY(xen_iret)
48 pushq $0
6fcac6d3
JF
491: jmp hypercall_iret
50ENDPATCH(xen_iret)
51RELOC(xen_iret, 1b+1)
cdacc127 52
6fcac6d3 53ENTRY(xen_sysret64)
130ace11
TH
54 /*
55 * We're already on the usermode stack at this point, but
56 * still with the kernel gs, so we can easily switch back
57 */
c38e5038 58 movq %rsp, PER_CPU_VAR(rsp_scratch)
3a23208e 59 movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
6fcac6d3
JF
60
61 pushq $__USER_DS
c38e5038 62 pushq PER_CPU_VAR(rsp_scratch)
6fcac6d3
JF
63 pushq %r11
64 pushq $__USER_CS
65 pushq %rcx
66
67 pushq $VGCF_in_syscall
681: jmp hypercall_iret
69ENDPATCH(xen_sysret64)
70RELOC(xen_sysret64, 1b+1)
71
6fcac6d3 72/*
130ace11
TH
73 * Xen handles syscall callbacks much like ordinary exceptions, which
74 * means we have:
75 * - kernel gs
76 * - kernel rsp
77 * - an iret-like stack frame on the stack (including rcx and r11):
78 * ss
79 * rsp
80 * rflags
81 * cs
82 * rip
83 * r11
84 * rsp->rcx
85 *
86 * In all the entrypoints, we undo all that to make it look like a
87 * CPU-generated syscall/sysenter and jump to the normal entrypoint.
6fcac6d3
JF
88 */
89
90.macro undo_xen_syscall
130ace11
TH
91 mov 0*8(%rsp), %rcx
92 mov 1*8(%rsp), %r11
93 mov 5*8(%rsp), %rsp
6fcac6d3
JF
94.endm
95
96/* Normal 64-bit system call target */
97ENTRY(xen_syscall_target)
98 undo_xen_syscall
b2502b41 99 jmp entry_SYSCALL_64_after_swapgs
6fcac6d3
JF
100ENDPROC(xen_syscall_target)
101
102#ifdef CONFIG_IA32_EMULATION
103
104/* 32-bit compat syscall target */
105ENTRY(xen_syscall32_target)
106 undo_xen_syscall
2cd23553 107 jmp entry_SYSCALL_compat
6fcac6d3
JF
108ENDPROC(xen_syscall32_target)
109
110/* 32-bit compat sysenter target */
111ENTRY(xen_sysenter_target)
112 undo_xen_syscall
4c8cd0c5 113 jmp entry_SYSENTER_compat
6fcac6d3
JF
114ENDPROC(xen_sysenter_target)
115
116#else /* !CONFIG_IA32_EMULATION */
117
118ENTRY(xen_syscall32_target)
119ENTRY(xen_sysenter_target)
130ace11 120 lea 16(%rsp), %rsp /* strip %rcx, %r11 */
6fcac6d3 121 mov $-ENOSYS, %rax
6aaf5d63 122 pushq $0
6fcac6d3
JF
123 jmp hypercall_iret
124ENDPROC(xen_syscall32_target)
125ENDPROC(xen_sysenter_target)
126
127#endif /* CONFIG_IA32_EMULATION */