Sat Jul 29 07:00:00 2023 UTC ()
compat/linux: aarch64 does not have epoll_create(2) nor epoll_wait(2)

Note that for Linux, new architectures like arm64 use MI system call
table in include/uapi/asm-generic/unistd.h, instead of MD syscall.tbl.

XXX
Too many ifdef's like this. We should be smarter...


(rin)
diff -r1.258 -r1.259 src/sys/compat/linux/common/linux_misc.c

cvs diff -r1.258 -r1.259 src/sys/compat/linux/common/linux_misc.c (expand / switch to unified diff)

--- src/sys/compat/linux/common/linux_misc.c 2023/07/28 18:19:01 1.258
+++ src/sys/compat/linux/common/linux_misc.c 2023/07/29 07:00:00 1.259
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: linux_misc.c,v 1.258 2023/07/28 18:19:01 christos Exp $ */ 1/* $NetBSD: linux_misc.c,v 1.259 2023/07/29 07:00:00 rin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe 8 * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe
9 * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center. 9 * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -47,27 +47,27 @@ @@ -47,27 +47,27 @@
47 * linux_sys_readdir : linux_misc_notalpha.c 47 * linux_sys_readdir : linux_misc_notalpha.c
48 * linux_sys_setresgid : linux_misc_notalpha.c 48 * linux_sys_setresgid : linux_misc_notalpha.c
49 * linux_sys_time : linux_misc_notalpha.c 49 * linux_sys_time : linux_misc_notalpha.c
50 * linux_sys_utime : linux_misc_notalpha.c 50 * linux_sys_utime : linux_misc_notalpha.c
51 * linux_sys_waitpid : linux_misc_notalpha.c 51 * linux_sys_waitpid : linux_misc_notalpha.c
52 * linux_sys_old_mmap : linux_oldmmap.c 52 * linux_sys_old_mmap : linux_oldmmap.c
53 * linux_sys_oldolduname : linux_oldolduname.c 53 * linux_sys_oldolduname : linux_oldolduname.c
54 * linux_sys_oldselect : linux_oldselect.c 54 * linux_sys_oldselect : linux_oldselect.c
55 * linux_sys_olduname : linux_olduname.c 55 * linux_sys_olduname : linux_olduname.c
56 * linux_sys_pipe : linux_pipe.c 56 * linux_sys_pipe : linux_pipe.c
57 */ 57 */
58 58
59#include <sys/cdefs.h> 59#include <sys/cdefs.h>
60__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.258 2023/07/28 18:19:01 christos Exp $"); 60__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.259 2023/07/29 07:00:00 rin Exp $");
61 61
62#include <sys/param.h> 62#include <sys/param.h>
63#include <sys/systm.h> 63#include <sys/systm.h>
64#include <sys/namei.h> 64#include <sys/namei.h>
65#include <sys/proc.h> 65#include <sys/proc.h>
66#include <sys/dirent.h> 66#include <sys/dirent.h>
67#include <sys/epoll.h> 67#include <sys/epoll.h>
68#include <sys/eventfd.h> 68#include <sys/eventfd.h>
69#include <sys/file.h> 69#include <sys/file.h>
70#include <sys/stat.h> 70#include <sys/stat.h>
71#include <sys/filedesc.h> 71#include <sys/filedesc.h>
72#include <sys/ioctl.h> 72#include <sys/ioctl.h>
73#include <sys/kernel.h> 73#include <sys/kernel.h>
@@ -1673,48 +1673,50 @@ linux_sys_eventfd(struct lwp *l, const s @@ -1673,48 +1673,50 @@ linux_sys_eventfd(struct lwp *l, const s
1673int 1673int
1674linux_sys_eventfd2(struct lwp *l, const struct linux_sys_eventfd2_args *uap, 1674linux_sys_eventfd2(struct lwp *l, const struct linux_sys_eventfd2_args *uap,
1675 register_t *retval) 1675 register_t *retval)
1676{ 1676{
1677 /* { 1677 /* {
1678 syscallarg(unsigned int) initval; 1678 syscallarg(unsigned int) initval;
1679 syscallarg(int) flags; 1679 syscallarg(int) flags;
1680 } */ 1680 } */
1681 1681
1682 return linux_do_eventfd2(l, SCARG(uap, initval), SCARG(uap, flags), 1682 return linux_do_eventfd2(l, SCARG(uap, initval), SCARG(uap, flags),
1683 retval); 1683 retval);
1684} 1684}
1685 1685
 1686#ifndef __aarch64__
1686/* 1687/*
1687 * epoll_create(2). Check size and call sys_epoll_create1. 1688 * epoll_create(2). Check size and call sys_epoll_create1.
1688 */ 1689 */
1689int 1690int
1690linux_sys_epoll_create(struct lwp *l, 1691linux_sys_epoll_create(struct lwp *l,
1691 const struct linux_sys_epoll_create_args *uap, register_t *retval) 1692 const struct linux_sys_epoll_create_args *uap, register_t *retval)
1692{ 1693{
1693 /* { 1694 /* {
1694 syscallarg(int) size; 1695 syscallarg(int) size;
1695 } */ 1696 } */
1696 struct sys_epoll_create1_args ca; 1697 struct sys_epoll_create1_args ca;
1697 1698
1698 /* 1699 /*
1699 * SCARG(uap, size) is unused. Linux just tests it and then 1700 * SCARG(uap, size) is unused. Linux just tests it and then
1700 * forgets it as well. 1701 * forgets it as well.
1701 */ 1702 */
1702 if (SCARG(uap, size) <= 0) 1703 if (SCARG(uap, size) <= 0)
1703 return EINVAL; 1704 return EINVAL;
1704 1705
1705 SCARG(&ca, flags) = 0; 1706 SCARG(&ca, flags) = 0;
1706 return sys_epoll_create1(l, &ca, retval); 1707 return sys_epoll_create1(l, &ca, retval);
1707} 1708}
 1709#endif /* !__aarch64__ */
1708 1710
1709/* 1711/*
1710 * epoll_create1(2). Translate the flags and call sys_epoll_create1. 1712 * epoll_create1(2). Translate the flags and call sys_epoll_create1.
1711 */ 1713 */
1712int 1714int
1713linux_sys_epoll_create1(struct lwp *l, 1715linux_sys_epoll_create1(struct lwp *l,
1714 const struct linux_sys_epoll_create1_args *uap, register_t *retval) 1716 const struct linux_sys_epoll_create1_args *uap, register_t *retval)
1715{ 1717{
1716 /* { 1718 /* {
1717 syscallarg(int) flags; 1719 syscallarg(int) flags;
1718 } */ 1720 } */
1719 struct sys_epoll_create1_args ca; 1721 struct sys_epoll_create1_args ca;
1720 1722
@@ -1758,49 +1760,51 @@ linux_sys_epoll_ctl(struct lwp *l, const @@ -1758,49 +1760,51 @@ linux_sys_epoll_ctl(struct lwp *l, const
1758 * the contents are the same. 1760 * the contents are the same.
1759 */ 1761 */
1760 ee.events = lee.events; 1762 ee.events = lee.events;
1761 ee.data = lee.data; 1763 ee.data = lee.data;
1762 1764
1763 eep = &ee; 1765 eep = &ee;
1764 } else 1766 } else
1765 eep = NULL; 1767 eep = NULL;
1766 1768
1767 return epoll_ctl_common(l, retval, SCARG(uap, epfd), SCARG(uap, op), 1769 return epoll_ctl_common(l, retval, SCARG(uap, epfd), SCARG(uap, op),
1768 SCARG(uap, fd), eep); 1770 SCARG(uap, fd), eep);
1769} 1771}
1770 1772
 1773#ifndef __aarch64__
1771/* 1774/*
1772 * epoll_wait(2). Call sys_epoll_pwait(). 1775 * epoll_wait(2). Call sys_epoll_pwait().
1773 */ 1776 */
1774int 1777int
1775linux_sys_epoll_wait(struct lwp *l, 1778linux_sys_epoll_wait(struct lwp *l,
1776 const struct linux_sys_epoll_wait_args *uap, register_t *retval) 1779 const struct linux_sys_epoll_wait_args *uap, register_t *retval)
1777{ 1780{
1778 /* { 1781 /* {
1779 syscallarg(int) epfd; 1782 syscallarg(int) epfd;
1780 syscallarg(struct linux_epoll_event *) events; 1783 syscallarg(struct linux_epoll_event *) events;
1781 syscallarg(int) maxevents; 1784 syscallarg(int) maxevents;
1782 syscallarg(int) timeout; 1785 syscallarg(int) timeout;
1783 } */ 1786 } */
1784 struct linux_sys_epoll_pwait_args ea; 1787 struct linux_sys_epoll_pwait_args ea;
1785 1788
1786 SCARG(&ea, epfd) = SCARG(uap, epfd); 1789 SCARG(&ea, epfd) = SCARG(uap, epfd);
1787 SCARG(&ea, events) = SCARG(uap, events); 1790 SCARG(&ea, events) = SCARG(uap, events);
1788 SCARG(&ea, maxevents) = SCARG(uap, maxevents); 1791 SCARG(&ea, maxevents) = SCARG(uap, maxevents);
1789 SCARG(&ea, timeout) = SCARG(uap, timeout); 1792 SCARG(&ea, timeout) = SCARG(uap, timeout);
1790 SCARG(&ea, sigmask) = NULL; 1793 SCARG(&ea, sigmask) = NULL;
1791 1794
1792 return linux_sys_epoll_pwait(l, &ea, retval); 1795 return linux_sys_epoll_pwait(l, &ea, retval);
1793} 1796}
 1797#endif /* !__aarch64__ */
1794 1798
1795/* 1799/*
1796 * Main body of epoll_pwait2(2). Translate timeout and sigmask and 1800 * Main body of epoll_pwait2(2). Translate timeout and sigmask and
1797 * call epoll_wait_common. 1801 * call epoll_wait_common.
1798 */ 1802 */
1799static int 1803static int
1800linux_epoll_pwait2_common(struct lwp *l, register_t *retval, int epfd, 1804linux_epoll_pwait2_common(struct lwp *l, register_t *retval, int epfd,
1801 struct linux_epoll_event *events, int maxevents, 1805 struct linux_epoll_event *events, int maxevents,
1802 struct linux_timespec *timeout, const linux_sigset_t *sigmask) 1806 struct linux_timespec *timeout, const linux_sigset_t *sigmask)
1803{ 1807{
1804 struct timespec ts, *tsp; 1808 struct timespec ts, *tsp;
1805 linux_sigset_t lss; 1809 linux_sigset_t lss;
1806 sigset_t ss, *ssp; 1810 sigset_t ss, *ssp;