Page MenuHomeFreeBSD

D62278.1796212385.diff
No OneTemporary

Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None

D62278.1796212385.diff

diff --git a/sys/modules/linux64/Makefile b/sys/modules/linux64/Makefile
--- a/sys/modules/linux64/Makefile
+++ b/sys/modules/linux64/Makefile
@@ -35,8 +35,10 @@
bus_if.h \
device_if.h \
vnode_if.h \
- linux_support.S \
linux_vdso_inc.S
+.if ${MACHINE_CPUARCH} != "powerpc"
+SRCS+= linux_support.S
+.endif
.if ${MACHINE_CPUARCH} == "amd64"
SRCS+= linux_dummy_x86.c
.endif
diff --git a/sys/powerpc/linux/linux_machdep.c b/sys/powerpc/linux/linux_machdep.c
--- a/sys/powerpc/linux/linux_machdep.c
+++ b/sys/powerpc/linux/linux_machdep.c
@@ -47,7 +47,9 @@
#include <powerpc/linux/linux.h>
#include <powerpc/linux/linux_proto.h>
#include <compat/linux/linux_dtrace.h>
+#include <compat/linux/linux_emul.h>
#include <compat/linux/linux_fork.h>
+#include <compat/linux/linux_futex.h>
#include <compat/linux/linux_ioctl.h>
#include <compat/linux/linux_ipc.h>
#include <compat/linux/linux_misc.h>
@@ -78,6 +80,88 @@
uap->flags, uap->fd, uap->pgoff));
}
+/*
+ * Read-modify-write helpers for FUTEX_WAKE_OP. They return the old value
+ * of the userland word through oldval.
+ */
+enum futex_rmw {
+ FUTEX_RMW_XCHG,
+ FUTEX_RMW_ADD,
+ FUTEX_RMW_OR,
+ FUTEX_RMW_AND,
+ FUTEX_RMW_XOR,
+};
+
+static int
+futex_rmw(enum futex_rmw op, int oparg, uint32_t *uaddr, int *oldval)
+{
+ uint32_t new, old;
+ int rv;
+
+ if (fueword32(uaddr, (int32_t *)&old) != 0)
+ return (EFAULT);
+ do {
+ switch (op) {
+ case FUTEX_RMW_XCHG:
+ new = oparg;
+ break;
+ case FUTEX_RMW_ADD:
+ new = old + oparg;
+ break;
+ case FUTEX_RMW_OR:
+ new = old | oparg;
+ break;
+ case FUTEX_RMW_AND:
+ new = old & oparg;
+ break;
+ case FUTEX_RMW_XOR:
+ new = old ^ oparg;
+ break;
+ }
+ /* A failed compare leaves the current value in old. */
+ rv = casueword32(uaddr, old, &old, new);
+ if (rv == -1)
+ return (EFAULT);
+ } while (rv != 0);
+ *oldval = old;
+ return (0);
+}
+
+int
+futex_xchgl(int oparg, uint32_t *uaddr, int *oldval)
+{
+
+ return (futex_rmw(FUTEX_RMW_XCHG, oparg, uaddr, oldval));
+}
+
+int
+futex_addl(int oparg, uint32_t *uaddr, int *oldval)
+{
+
+ return (futex_rmw(FUTEX_RMW_ADD, oparg, uaddr, oldval));
+}
+
+int
+futex_orl(int oparg, uint32_t *uaddr, int *oldval)
+{
+
+ return (futex_rmw(FUTEX_RMW_OR, oparg, uaddr, oldval));
+}
+
+int
+futex_andl(int oparg, uint32_t *uaddr, int *oldval)
+{
+
+ return (futex_rmw(FUTEX_RMW_AND, oparg, uaddr, oldval));
+}
+
+int
+futex_xorl(int oparg, uint32_t *uaddr, int *oldval)
+{
+
+ return (futex_rmw(FUTEX_RMW_XOR, oparg, uaddr, oldval));
+}
+
/*
* PowerPC has dedicated send(2) and recv(2) system calls, where the other
* 64-bit architectures have their C library use sendto(2) and recvfrom(2).
diff --git a/sys/powerpc/linux/linux_support.S b/sys/powerpc/linux/linux_support.S
deleted file mode 100644
--- a/sys/powerpc/linux/linux_support.S
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (C) 2018 Turing Robotic Industries Inc.
- * Copyright (C) 2022 Dmitry Chagin <dchagin@FreeBSD.org>
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- */
-
-#include <machine/asm.h>
-
-#include <machine/param.h>
-#include <machine/vmparam.h>
-
-#include <sys/errno.h>
-
-#include "assym.inc"
-
-ENTRY(futex_xchgl)
- li %r3, ENOTSUP
- blr
- nop
-END(futex_xchgl)
-
-/* (int *)uaddr2 += oparg */
-ENTRY(futex_addl)
- li %r3, ENOTSUP
- blr
- nop
-END(futex_addl)
-
-/* (int *)uaddr2 |= oparg */
-ENTRY(futex_orl)
- li %r3, ENOTSUP
- blr
- nop
-END(futex_orl)
-
-/* (int *)uaddr2 &= oparg */
-ENTRY(futex_andl)
- li %r3, ENOTSUP
- blr
- nop
-END(futex_andl)
-
-/* (int *)uaddr2 ^= oparg */
-ENTRY(futex_xorl)
- li %r3, ENOTSUP
- blr
- nop
-END(futex_xorl)

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 2, 11:53 AM (19 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42141176
Default Alt Text
D62278.1796212385.diff (4 KB)

Event Timeline