1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-16 15:11:52 +00:00

linuxulator: do not include legacy syscalls on arm64

Existing linuxulator platforms (i386, amd64) support legacy syscalls,
such as non-*at ones like open, but arm64 and other new platforms do
not.

Wrap these in #ifdef LINUX_LEGACY_SYSCALLS, #defined in the MD linux.h
files.  We may need finer grained control in the future but this is
sufficient for now.

Reviewed by:	andrew
Sponsored by:	Turing Robotic Industries
Differential Revision:	https://reviews.freebsd.org/D15237
This commit is contained in:
Ed Maste 2018-06-15 14:41:51 +00:00
parent 4b842782da
commit 931e2a1a6e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335201
9 changed files with 70 additions and 1 deletions

View File

@ -35,6 +35,8 @@
#include <compat/linux/linux.h>
#include <amd64/linux/linux_syscall.h>
#define LINUX_LEGACY_SYSCALLS
/*
* debugging support
*/

View File

@ -38,6 +38,8 @@
#include <compat/linux/linux.h>
#include <amd64/linux32/linux32_syscall.h>
#define LINUX_LEGACY_SYSCALLS
/*
* debugging support
*/

View File

@ -263,6 +263,7 @@ epoll_create_common(struct thread *td, int flags)
return (0);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_epoll_create(struct thread *td, struct linux_epoll_create_args *args)
{
@ -276,6 +277,7 @@ linux_epoll_create(struct thread *td, struct linux_epoll_create_args *args)
return (epoll_create_common(td, 0));
}
#endif
int
linux_epoll_create1(struct thread *td, struct linux_epoll_create1_args *args)
@ -616,6 +618,7 @@ linux_epoll_wait_common(struct thread *td, int epfd, struct epoll_event *events,
return (error);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_epoll_wait(struct thread *td, struct linux_epoll_wait_args *args)
{
@ -623,6 +626,7 @@ linux_epoll_wait(struct thread *td, struct linux_epoll_wait_args *args)
return (linux_epoll_wait_common(td, args->epfd, args->events,
args->maxevents, args->timeout, NULL));
}
#endif
int
linux_epoll_pwait(struct thread *td, struct linux_epoll_pwait_args *args)
@ -707,12 +711,14 @@ eventfd_create(struct thread *td, uint32_t initval, int flags)
return (error);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_eventfd(struct thread *td, struct linux_eventfd_args *args)
{
return (eventfd_create(td, args->initval, 0));
}
#endif
int
linux_eventfd2(struct thread *td, struct linux_eventfd2_args *args)

View File

@ -68,6 +68,7 @@ static int linux_common_open(struct thread *, int, char *, int, int);
static int linux_getdents_error(struct thread *, int, int);
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_creat(struct thread *td, struct linux_creat_args *args)
{
@ -84,7 +85,7 @@ linux_creat(struct thread *td, struct linux_creat_args *args)
LFREEPATH(path);
return (error);
}
#endif
static int
linux_common_open(struct thread *td, int dirfd, char *path, int l_flags, int mode)
@ -165,7 +166,11 @@ linux_common_open(struct thread *td, int dirfd, char *path, int l_flags, int mod
done:
#ifdef DEBUG
#ifdef LINUX_LEGACY_SYSCALLS
if (ldebug(open))
#else
if (ldebug(openat))
#endif
printf(LMSG("open returns error %d"), error);
#endif
LFREEPATH(path);
@ -191,6 +196,7 @@ linux_openat(struct thread *td, struct linux_openat_args *args)
return (linux_common_open(td, dfd, path, args->flags, args->mode));
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_open(struct thread *td, struct linux_open_args *args)
{
@ -207,6 +213,7 @@ linux_open(struct thread *td, struct linux_open_args *args)
#endif
return (linux_common_open(td, AT_FDCWD, path, args->flags, args->mode));
}
#endif
int
linux_lseek(struct thread *td, struct linux_lseek_args *args)
@ -305,6 +312,7 @@ struct l_dirent64 {
roundup(offsetof(struct l_dirent64, d_name) + (namlen) + 1, \
sizeof(uint64_t))
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_getdents(struct thread *td, struct linux_getdents_args *args)
{
@ -384,6 +392,7 @@ linux_getdents(struct thread *td, struct linux_getdents_args *args)
free(buf, M_TEMP);
return (error);
}
#endif
int
linux_getdents64(struct thread *td, struct linux_getdents64_args *args)
@ -517,6 +526,7 @@ linux_readdir(struct thread *td, struct linux_readdir_args *args)
* These exist mainly for hooks for doing /compat/linux translation.
*/
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_access(struct thread *td, struct linux_access_args *args)
{
@ -539,6 +549,7 @@ linux_access(struct thread *td, struct linux_access_args *args)
return (error);
}
#endif
int
linux_faccessat(struct thread *td, struct linux_faccessat_args *args)
@ -564,6 +575,7 @@ linux_faccessat(struct thread *td, struct linux_faccessat_args *args)
return (error);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_unlink(struct thread *td, struct linux_unlink_args *args)
{
@ -590,6 +602,7 @@ linux_unlink(struct thread *td, struct linux_unlink_args *args)
LFREEPATH(path);
return (error);
}
#endif
int
linux_unlinkat(struct thread *td, struct linux_unlinkat_args *args)
@ -639,6 +652,7 @@ linux_chdir(struct thread *td, struct linux_chdir_args *args)
return (error);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_chmod(struct thread *td, struct linux_chmod_args *args)
{
@ -656,6 +670,7 @@ linux_chmod(struct thread *td, struct linux_chmod_args *args)
LFREEPATH(path);
return (error);
}
#endif
int
linux_fchmodat(struct thread *td, struct linux_fchmodat_args *args)
@ -676,6 +691,7 @@ linux_fchmodat(struct thread *td, struct linux_fchmodat_args *args)
return (error);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_mkdir(struct thread *td, struct linux_mkdir_args *args)
{
@ -692,6 +708,7 @@ linux_mkdir(struct thread *td, struct linux_mkdir_args *args)
LFREEPATH(path);
return (error);
}
#endif
int
linux_mkdirat(struct thread *td, struct linux_mkdirat_args *args)
@ -711,6 +728,7 @@ linux_mkdirat(struct thread *td, struct linux_mkdirat_args *args)
return (error);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_rmdir(struct thread *td, struct linux_rmdir_args *args)
{
@ -751,6 +769,7 @@ linux_rename(struct thread *td, struct linux_rename_args *args)
LFREEPATH(to);
return (error);
}
#endif
int
linux_renameat(struct thread *td, struct linux_renameat_args *args)
@ -778,6 +797,7 @@ linux_renameat(struct thread *td, struct linux_renameat_args *args)
return (error);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_symlink(struct thread *td, struct linux_symlink_args *args)
{
@ -801,6 +821,7 @@ linux_symlink(struct thread *td, struct linux_symlink_args *args)
LFREEPATH(to);
return (error);
}
#endif
int
linux_symlinkat(struct thread *td, struct linux_symlinkat_args *args)
@ -828,6 +849,7 @@ linux_symlinkat(struct thread *td, struct linux_symlinkat_args *args)
return (error);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_readlink(struct thread *td, struct linux_readlink_args *args)
{
@ -846,6 +868,7 @@ linux_readlink(struct thread *td, struct linux_readlink_args *args)
LFREEPATH(name);
return (error);
}
#endif
int
linux_readlinkat(struct thread *td, struct linux_readlinkat_args *args)
@ -913,6 +936,7 @@ linux_ftruncate(struct thread *td, struct linux_ftruncate_args *args)
return (kern_ftruncate(td, args->fd, args->length));
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_link(struct thread *td, struct linux_link_args *args)
{
@ -937,6 +961,7 @@ linux_link(struct thread *td, struct linux_link_args *args)
LFREEPATH(to);
return (error);
}
#endif
int
linux_linkat(struct thread *td, struct linux_linkat_args *args)
@ -1138,6 +1163,7 @@ linux_oldumount(struct thread *td, struct linux_oldumount_args *args)
}
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_umount(struct thread *td, struct linux_umount_args *args)
{
@ -1147,6 +1173,7 @@ linux_umount(struct thread *td, struct linux_umount_args *args)
bsd.flags = args->flags; /* XXX correct? */
return (sys_unmount(td, &bsd));
}
#endif
/*
* fcntl family of syscalls
@ -1458,6 +1485,7 @@ linux_fcntl64(struct thread *td, struct linux_fcntl64_args *args)
}
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_chown(struct thread *td, struct linux_chown_args *args)
{
@ -1475,6 +1503,7 @@ linux_chown(struct thread *td, struct linux_chown_args *args)
LFREEPATH(path);
return (error);
}
#endif
int
linux_fchownat(struct thread *td, struct linux_fchownat_args *args)
@ -1501,6 +1530,7 @@ linux_fchownat(struct thread *td, struct linux_fchownat_args *args)
return (error);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_lchown(struct thread *td, struct linux_lchown_args *args)
{
@ -1518,6 +1548,7 @@ linux_lchown(struct thread *td, struct linux_lchown_args *args)
LFREEPATH(path);
return (error);
}
#endif
static int
convert_fadvice(int advice)
@ -1566,6 +1597,7 @@ linux_fadvise64_64(struct thread *td, struct linux_fadvise64_64_args *args)
}
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_pipe(struct thread *td, struct linux_pipe_args *args)
{
@ -1589,6 +1621,7 @@ linux_pipe(struct thread *td, struct linux_pipe_args *args)
return (error);
}
#endif
int
linux_pipe2(struct thread *td, struct linux_pipe2_args *args)

View File

@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <compat/linux/linux_misc.h>
#include <compat/linux/linux_util.h>
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_fork(struct thread *td, struct linux_fork_args *args)
{
@ -135,6 +136,7 @@ linux_vfork(struct thread *td, struct linux_vfork_args *args)
return (0);
}
#endif
static int
linux_clone_proc(struct thread *td, struct linux_clone_args *args)

View File

@ -191,6 +191,7 @@ linux_sysinfo(struct thread *td, struct linux_sysinfo_args *args)
return (copyout(&sysinfo, args->info, sizeof(sysinfo)));
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_alarm(struct thread *td, struct linux_alarm_args *args)
{
@ -225,6 +226,7 @@ linux_alarm(struct thread *td, struct linux_alarm_args *args)
td->td_retval[0] = old_it.it_value.tv_sec;
return (0);
}
#endif
int
linux_brk(struct thread *td, struct linux_brk_args *args)
@ -494,6 +496,7 @@ linux_uselib(struct thread *td, struct linux_uselib_args *args)
#endif /* __i386__ */
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_select(struct thread *td, struct linux_select_args *args)
{
@ -585,6 +588,7 @@ linux_select(struct thread *td, struct linux_select_args *args)
#endif
return (error);
}
#endif
int
linux_mremap(struct thread *td, struct linux_mremap_args *args)
@ -646,6 +650,7 @@ linux_msync(struct thread *td, struct linux_msync_args *args)
args->fl & ~LINUX_MS_SYNC));
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_time(struct thread *td, struct linux_time_args *args)
{
@ -665,6 +670,7 @@ linux_time(struct thread *td, struct linux_time_args *args)
td->td_retval[0] = tm;
return (0);
}
#endif
struct l_times_argv {
l_clock_t tms_utime;
@ -761,6 +767,7 @@ struct l_utimbuf {
l_time_t l_modtime;
};
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_utime(struct thread *td, struct linux_utime_args *args)
{
@ -794,7 +801,9 @@ linux_utime(struct thread *td, struct linux_utime_args *args)
LFREEPATH(fname);
return (error);
}
#endif
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_utimes(struct thread *td, struct linux_utimes_args *args)
{
@ -827,6 +836,7 @@ linux_utimes(struct thread *td, struct linux_utimes_args *args)
LFREEPATH(fname);
return (error);
}
#endif
static int
linux_utimensat_nsec_valid(l_long nsec)
@ -921,6 +931,7 @@ linux_utimensat(struct thread *td, struct linux_utimensat_args *args)
return (error);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_futimesat(struct thread *td, struct linux_futimesat_args *args)
{
@ -953,6 +964,7 @@ linux_futimesat(struct thread *td, struct linux_futimesat_args *args)
LFREEPATH(fname);
return (error);
}
#endif
int
linux_common_wait(struct thread *td, int pid, int *status,
@ -1094,6 +1106,7 @@ linux_waitid(struct thread *td, struct linux_waitid_args *args)
return (error);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_mknod(struct thread *td, struct linux_mknod_args *args)
{
@ -1142,6 +1155,7 @@ linux_mknod(struct thread *td, struct linux_mknod_args *args)
LFREEPATH(path);
return (error);
}
#endif
int
linux_mknodat(struct thread *td, struct linux_mknodat_args *args)

View File

@ -81,6 +81,7 @@ linux_kern_statat(struct thread *td, int flag, int fd, char *path,
translate_vnhook_major_minor));
}
#ifdef LINUX_LEGACY_SYSCALLS
static int
linux_kern_stat(struct thread *td, char *path, enum uio_seg pathseg,
struct stat *sbp)
@ -97,6 +98,7 @@ linux_kern_lstat(struct thread *td, char *path, enum uio_seg pathseg,
return (linux_kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, path,
pathseg, sbp));
}
#endif
static void
translate_fd_major_minor(struct thread *td, int fd, struct stat *buf)
@ -173,6 +175,7 @@ newstat_copyout(struct stat *buf, void *ubuf)
return (copyout(&tbuf, ubuf, sizeof(tbuf)));
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_newstat(struct thread *td, struct linux_newstat_args *args)
{
@ -214,6 +217,7 @@ linux_newlstat(struct thread *td, struct linux_newlstat_args *args)
return (error);
return (newstat_copyout(&sb, args->buf));
}
#endif
int
linux_newfstat(struct thread *td, struct linux_newfstat_args *args)
@ -524,6 +528,7 @@ struct l_ustat
char f_fpack[6];
};
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_ustat(struct thread *td, struct linux_ustat_args *args)
{
@ -534,6 +539,7 @@ linux_ustat(struct thread *td, struct linux_ustat_args *args)
return (EOPNOTSUPP);
}
#endif
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))

View File

@ -115,6 +115,7 @@ handle_string(struct l___sysctl_args *la, char *value)
return (0);
}
#ifdef LINUX_LEGACY_SYSCALLS
int
linux_sysctl(struct thread *td, struct linux_sysctl_args *args)
{
@ -191,3 +192,4 @@ linux_sysctl(struct thread *td, struct linux_sysctl_args *args)
LIN_SDT_PROBE1(sysctl, linux_sysctl, return, ENOTDIR);
return (ENOTDIR);
}
#endif

View File

@ -35,6 +35,8 @@
#include <compat/linux/linux.h>
#include <i386/linux/linux_syscall.h>
#define LINUX_LEGACY_SYSCALLS
/*
* debugging support
*/