aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-x86_64/stub.S
blob: 03c2797357842f2ad8cc4d61651c1e110d88ddb5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "uml-config.h"

	.globl syscall_stub
.section .__syscall_stub, "x"
syscall_stub:
	syscall
	/* We don't have 64-bit constants, so this constructs the address
	 * we need.
	 */
	movq	$(UML_CONFIG_STUB_DATA >> 32), %rbx
	salq	$32, %rbx
	movq	$(UML_CONFIG_STUB_DATA & 0xffffffff), %rcx
	or	%rcx, %rbx
	movq	%rax, (%rbx)
	int3

	.globl batch_syscall_stub
batch_syscall_stub:
	mov	$(UML_CONFIG_STUB_DATA >> 32), %rbx
	sal	$32, %rbx
	mov	$(UML_CONFIG_STUB_DATA & 0xffffffff), %rax
	or	%rax, %rbx
	/* load pointer to first operation */
	mov	%rbx, %rsp
	add	$0x10, %rsp
again:
	/* load length of additional data */
	mov	0x0(%rsp), %rax

	/* if(length == 0) : end of list */
	/* write possible 0 to header */
	mov	%rax, 8(%rbx)
	cmp	$0, %rax
	jz	done

	/* save current pointer */
	mov	%rsp, 8(%rbx)

	/* skip additional data */
	add	%rax, %rsp

	/* load syscall-# */
	pop	%rax

	/* load syscall params */
	pop	%rdi
	pop	%rsi
	pop	%rdx
	pop	%r10
 	pop	%r8
	pop	%r9

	/* execute syscall */
	syscall

	/* check return value */
	pop	%rcx
	cmp	%rcx, %rax
	je	again

done:
	/* save return value */
	mov	%rax, (%rbx)

	/* stop */
	int3