Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/livep...
[deliverable/linux.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
JF
28 ret $16
29
6fcac6d3
JF
30hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32
31/*
130ace11
TH
32 * Xen64 iret frame:
33 *
34 * ss
35 * rsp
36 * rflags
37 * cs
38 * rip <-- standard iret frame
39 *
40 * flags
41 *
42 * rcx }
43 * r11 }<-- pushed by hypercall page
44 * rsp->rax }
6fcac6d3 45 */
cdacc127
JF
46ENTRY(xen_iret)
47 pushq $0
6fcac6d3
JF
481: jmp hypercall_iret
49ENDPATCH(xen_iret)
50RELOC(xen_iret, 1b+1)
cdacc127 51
6fcac6d3 52ENTRY(xen_sysret64)
130ace11
TH
53 /*
54 * We're already on the usermode stack at this point, but
55 * still with the kernel gs, so we can easily switch back
56 */
c38e5038 57 movq %rsp, PER_CPU_VAR(rsp_scratch)
3a23208e 58 movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
6fcac6d3
JF
59
60 pushq $__USER_DS
c38e5038 61 pushq PER_CPU_VAR(rsp_scratch)
6fcac6d3
JF
62 pushq %r11
63 pushq $__USER_CS
64 pushq %rcx
65
66 pushq $VGCF_in_syscall
671: jmp hypercall_iret
68ENDPATCH(xen_sysret64)
69RELOC(xen_sysret64, 1b+1)
70
6fcac6d3 71/*
130ace11
TH
72 * Xen handles syscall callbacks much like ordinary exceptions, which
73 * means we have:
74 * - kernel gs
75 * - kernel rsp
76 * - an iret-like stack frame on the stack (including rcx and r11):
77 * ss
78 * rsp
79 * rflags
80 * cs
81 * rip
82 * r11
83 * rsp->rcx
84 *
85 * In all the entrypoints, we undo all that to make it look like a
86 * CPU-generated syscall/sysenter and jump to the normal entrypoint.
6fcac6d3
JF
87 */
88
89.macro undo_xen_syscall
130ace11
TH
90 mov 0*8(%rsp), %rcx
91 mov 1*8(%rsp), %r11
92 mov 5*8(%rsp), %rsp
6fcac6d3
JF
93.endm
94
95/* Normal 64-bit system call target */
96ENTRY(xen_syscall_target)
97 undo_xen_syscall
b2502b41 98 jmp entry_SYSCALL_64_after_swapgs
6fcac6d3
JF
99ENDPROC(xen_syscall_target)
100
101#ifdef CONFIG_IA32_EMULATION
102
103/* 32-bit compat syscall target */
104ENTRY(xen_syscall32_target)
105 undo_xen_syscall
2cd23553 106 jmp entry_SYSCALL_compat
6fcac6d3
JF
107ENDPROC(xen_syscall32_target)
108
109/* 32-bit compat sysenter target */
110ENTRY(xen_sysenter_target)
111 undo_xen_syscall
4c8cd0c5 112 jmp entry_SYSENTER_compat
6fcac6d3
JF
113ENDPROC(xen_sysenter_target)
114
115#else /* !CONFIG_IA32_EMULATION */
116
117ENTRY(xen_syscall32_target)
118ENTRY(xen_sysenter_target)
130ace11 119 lea 16(%rsp), %rsp /* strip %rcx, %r11 */
6fcac6d3 120 mov $-ENOSYS, %rax
6aaf5d63 121 pushq $0
6fcac6d3
JF
122 jmp hypercall_iret
123ENDPROC(xen_syscall32_target)
124ENDPROC(xen_sysenter_target)
125
126#endif /* CONFIG_IA32_EMULATION */
This page took 0.410364 seconds and 5 git commands to generate.