summaryrefslogtreecommitdiffstats
path: root/sys/amd64/linux/linux_support.s
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2015-05-24 16:07:11 +0000
committerdchagin <dchagin@FreeBSD.org>2015-05-24 16:07:11 +0000
commit2f453c26e7b08815526b8c9e97856276b36baf1d (patch)
tree35df2c514a1dae4de7326c9bdbac37a088358088 /sys/amd64/linux/linux_support.s
parent5b7bd42ffe60c56b4a4f470f7c692c1392e0c502 (diff)
downloadFreeBSD-src-2f453c26e7b08815526b8c9e97856276b36baf1d.zip
FreeBSD-src-2f453c26e7b08815526b8c9e97856276b36baf1d.tar.gz
Add preliminary support for x86-64 Linux binaries.
Differential Revision: https://reviews.freebsd.org/D1076
Diffstat (limited to 'sys/amd64/linux/linux_support.s')
-rw-r--r--sys/amd64/linux/linux_support.s124
1 files changed, 124 insertions, 0 deletions
diff --git a/sys/amd64/linux/linux_support.s b/sys/amd64/linux/linux_support.s
new file mode 100644
index 0000000..f809d11
--- /dev/null
+++ b/sys/amd64/linux/linux_support.s
@@ -0,0 +1,124 @@
+/*-
+ * Copyright (c) 2007 Konstantin Belousov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include "linux_assym.h" /* system definitions */
+#include <machine/asmacros.h> /* miscellaneous asm macros */
+
+#include "assym.s"
+
+futex_fault:
+ movq $0,PCB_ONFAULT(%r8)
+ movl $-EFAULT,%eax
+ ret
+
+ENTRY(futex_xchgl)
+ movq PCPU(CURPCB),%r8
+ movq $futex_fault,PCB_ONFAULT(%r8)
+ movq $VM_MAXUSER_ADDRESS-4,%rax
+ cmpq %rax,%rsi
+ ja futex_fault
+ xchgq %rdi,(%rsi)
+ movq %rdi,(%rdx)
+ xorq %rax,%rax
+ movq %rax,PCB_ONFAULT(%r8)
+ ret
+
+ENTRY(futex_addl)
+ movq PCPU(CURPCB),%r8
+ movq $futex_fault,PCB_ONFAULT(%r8)
+ movq $VM_MAXUSER_ADDRESS-4,%rax
+ cmpq %rax,%rsi
+ ja futex_fault
+#ifdef SMP
+ lock
+#endif
+ xaddq %rdi,(%rsi)
+ movq %rdi,(%rdx)
+ xorq %rax,%rax
+ movq %rax,PCB_ONFAULT(%r8)
+ ret
+
+ENTRY(futex_orl)
+ movq PCPU(CURPCB),%r8
+ movq $futex_fault,PCB_ONFAULT(%r8)
+ movq $VM_MAXUSER_ADDRESS-4,%rax
+ cmpq %rax,%rsi
+ ja futex_fault
+ movq (%rsi),%rax
+1: movq %rax,%rcx
+ orq %rdi,%rcx
+#ifdef SMP
+ lock
+#endif
+ cmpxchgq %rcx,(%rsi)
+ jnz 1b
+ movq %rax,(%rdx)
+ xorq %rax,%rax
+ movq %rax,PCB_ONFAULT(%r8)
+ ret
+
+ENTRY(futex_andl)
+ movq PCPU(CURPCB),%r8
+ movq $futex_fault,PCB_ONFAULT(%r8)
+ movq $VM_MAXUSER_ADDRESS-4,%rax
+ cmpq %rax,%rsi
+ ja futex_fault
+ movq (%rsi),%rax
+1: movq %rax,%rcx
+ andq %rdi,%rcx
+#ifdef SMP
+ lock
+#endif
+ cmpxchgq %rcx,(%rsi)
+ jnz 1b
+ movq %rax,(%rdx)
+ xorq %rax,%rax
+ movq %rax,PCB_ONFAULT(%r8)
+ ret
+
+ENTRY(futex_xorl)
+ movq PCPU(CURPCB),%r8
+ movq $futex_fault,PCB_ONFAULT(%r8)
+ movq $VM_MAXUSER_ADDRESS-4,%rax
+ cmpq %rax,%rsi
+ ja futex_fault
+ movq (%rsi),%rax
+1: movq %rax,%rcx
+ xorq %rdi,%rcx
+#ifdef SMP
+ lock
+#endif
+ cmpxchgq %rcx,(%rsi)
+ jnz 1b
+ movq %rax,(%rdx)
+ xorq %rax,%rax
+ movq %rax,PCB_ONFAULT(%r8)
+ ret
OpenPOWER on IntegriCloud