linux-user: Implement prlimit64
cover linux-user: Implement prlimit64
The main purpose of this patch series is to implement the prlimit64 syscall, which is what patch 2 does. Since prlimit64 is a new syscall number, I had to add it to the syscall number definitions. Patch 1 is therefore a comprehensive update of the syscall number tables for all archs to match the mainline 2.6.39.2 defined syscalls.
The exception is that I haven't touched the unicore32 syscall_nr.h, because as far as I can tell it doesn't match the kernel's syscall numbers for that architecture at all...
Peter Maydell (2):
linux-user: Add syscall numbers from kernel 2.6.39.2
linux-user: Implement prlimit64 syscall
linux-user/alpha/syscall_nr.h | 23 ++++++++++++++++++- linux-user/arm/syscall_nr.h | 13 +++++++++++ linux-user/cris/syscall_nr.h | 2 + linux-user/i386/syscall_nr.h | 12 ++++++++++ linux-user/m68k/syscall_nr.h | 16 +++++++++++++ linux-user/main.c | 27 ++++++++++++++++++++++ linux-user/microblaze/syscall_nr.h | 14 ++++++++++- linux-user/mips/syscall_nr.h | 13 +++++++++++ linux-user/mips64/syscall_nr.h | 13 +++++++++++ linux-user/mipsn32/syscall_nr.h | 14 +++++++++++ linux-user/ppc/syscall_nr.h | 30 +++++++++++++++++++++++++ linux-user/s390x/syscall_nr.h | 13 +++++++++- linux-user/sh4/syscall_nr.h | 32 ++++++++++++++++++++++++++ linux-user/sparc/syscall_nr.h | 12 ++++++++++ linux-user/sparc64/syscall_nr.h | 12 ++++++++++ linux-user/syscall.c | 43 ++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 5 ++++ linux-user/x86_64/syscall_nr.h | 12 ++++++++++ 18 files changed, 301 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.4.1
PATCH 1/2 linux-user: Add syscall numbers from kernel 2.6.39.2
Add syscall numbers for new syscall numbers; this brings us into line with Linux 2.6.39.2.
--- linux-user/alpha/syscall_nr.h | 23 ++++++++++++++++++++++- linux-user/arm/syscall_nr.h | 13 +++++++++++++ linux-user/cris/syscall_nr.h | 2 ++ linux-user/i386/syscall_nr.h | 12 ++++++++++++ linux-user/m68k/syscall_nr.h | 16 ++++++++++++++++ linux-user/main.c | 27 +++++++++++++++++++++++++++ linux-user/microblaze/syscall_nr.h | 14 ++++++++++++-- linux-user/mips/syscall_nr.h | 13 +++++++++++++ linux-user/mips64/syscall_nr.h | 13 +++++++++++++ linux-user/mipsn32/syscall_nr.h | 14 ++++++++++++++ linux-user/ppc/syscall_nr.h | 30 ++++++++++++++++++++++++++++++ linux-user/s390x/syscall_nr.h | 13 +++++++++++-- linux-user/sh4/syscall_nr.h | 32 ++++++++++++++++++++++++++++++++ linux-user/sparc/syscall_nr.h | 12 ++++++++++++ linux-user/sparc64/syscall_nr.h | 12 ++++++++++++ linux-user/x86_64/syscall_nr.h | 12 ++++++++++++ 16 files changed, 253 insertions(+), 5 deletions(-)
linux-user/alpha/syscall_nr.h +22 -1
@@ -411,4 +411,25 @@#define TARGET_NR_signalfd 476#define TARGET_NR_timerfd 477#define TARGET_NR_eventfd 478 - +#define TARGET_NR_recvmmsg 479 +#define TARGET_NR_fallocate 480 +#define TARGET_NR_timerfd_create 481 +#define TARGET_NR_timerfd_settime 482 +#define TARGET_NR_timerfd_gettime 483 +#define TARGET_NR_signalfd4 484 +#define TARGET_NR_eventfd2 485 +#define TARGET_NR_epoll_create1 486 +#define TARGET_NR_dup3 487 +#define TARGET_NR_pipe2 488 +#define TARGET_NR_inotify_init1 489 +#define TARGET_NR_preadv 490 +#define TARGET_NR_pwritev 491 +#define TARGET_NR_rt_tgsigqueueinfo 492 +#define TARGET_NR_perf_event_open 493 +#define TARGET_NR_fanotify_init 494 +#define TARGET_NR_fanotify_mark 495 +#define TARGET_NR_prlimit64 496 +#define TARGET_NR_name_to_handle_at 497 +#define TARGET_NR_open_by_handle_at 498 +#define TARGET_NR_clock_adjtime 499 +#define TARGET_NR_syncfs 500
linux-user/arm/syscall_nr.h +13 -0
@@ -365,3 +365,16 @@#define TARGET_NR_dup3 (358)#define TARGET_NR_pipe2 (359)#define TARGET_NR_inotify_init1 (360) +#define TARGET_NR_preadv (361) +#define TARGET_NR_pwritev (362) +#define TARGET_NR_rt_tgsigqueueinfo (363) +#define TARGET_NR_perf_event_open (364) +#define TARGET_NR_recvmmsg (365) +#define TARGET_NR_accept4 (366) +#define TARGET_NR_fanotify_init (367) +#define TARGET_NR_fanotify_mark (368) +#define TARGET_NR_prlimit64 (369) +#define TARGET_NR_name_to_handle_at (370) +#define TARGET_NR_open_by_handle_at (371) +#define TARGET_NR_clock_adjtime (372) +#define TARGET_NR_syncfs (373)
linux-user/cris/syscall_nr.h +2 -0
@@ -333,3 +333,5 @@#define TARGET_NR_dup3 330#define TARGET_NR_pipe2 331#define TARGET_NR_inotify_init1 332 +#define TARGET_NR_preadv 333 +#define TARGET_NR_pwritev 334
linux-user/i386/syscall_nr.h +12 -0
@@ -335,3 +335,15 @@#define TARGET_NR_dup3 330#define TARGET_NR_pipe2 331#define TARGET_NR_inotify_init1 332 +#define TARGET_NR_preadv 333 +#define TARGET_NR_pwritev 334 +#define TARGET_NR_rt_tgsigqueueinfo 335 +#define TARGET_NR_perf_event_open 336 +#define TARGET_NR_recvmmsg 337 +#define TARGET_NR_fanotify_init 338 +#define TARGET_NR_fanotify_mark 339 +#define TARGET_NR_prlimit64 340 +#define TARGET_NR_name_to_handle_at 341 +#define TARGET_NR_open_by_handle_at 342 +#define TARGET_NR_clock_adjtime 343 +#define TARGET_NR_syncfs 344
linux-user/m68k/syscall_nr.h +16 -0
@@ -328,3 +328,19 @@#define TARGET_NR_dup3 326#define TARGET_NR_pipe2 327#define TARGET_NR_inotify_init1 328 +#define TARGET_NR_inotify_init1 328 +#define TARGET_NR_preadv 329 +#define TARGET_NR_pwritev 330 +#define TARGET_NR_rt_tgsigqueueinfo 331 +#define TARGET_NR_perf_event_open 332 +#define TARGET_NR_get_thread_area 333 +#define TARGET_NR_set_thread_area 334 +#define TARGET_NR_atomic_cmpxchg_32 335 +#define TARGET_NR_atomic_barrier 336 +#define TARGET_NR_fanotify_init 337 +#define TARGET_NR_fanotify_mark 338 +#define TARGET_NR_prlimit64 339 +#define TARGET_NR_name_to_handle_at 340 +#define TARGET_NR_open_by_handle_at 341 +#define TARGET_NR_clock_adjtime 342 +#define TARGET_NR_syncfs 343
linux-user/main.c +27 -0
@@ -1980,6 +1980,33 @@ static const uint8_t mips_syscall_args[] = { MIPS_SYS(sys_epoll_pwait, 6) MIPS_SYS(sys_ioprio_set, 3) MIPS_SYS(sys_ioprio_get, 2) + MIPS_SYS(sys_utimensat, 4) + MIPS_SYS(sys_signalfd, 3) + MIPS_SYS(sys_ni_syscall, 0) /* was timerfd */ + MIPS_SYS(sys_eventfd, 1) + MIPS_SYS(sys_fallocate, 6) /* 4320 */ + MIPS_SYS(sys_timerfd_create, 2) + MIPS_SYS(sys_timerfd_gettime, 2) + MIPS_SYS(sys_timerfd_settime, 4) + MIPS_SYS(sys_signalfd4, 4) + MIPS_SYS(sys_eventfd2, 2) /* 4325 */ + MIPS_SYS(sys_epoll_create1, 1) + MIPS_SYS(sys_dup3, 3) + MIPS_SYS(sys_pipe2, 2) + MIPS_SYS(sys_inotify_init1, 1) + MIPS_SYS(sys_preadv, 6) /* 4330 */ + MIPS_SYS(sys_pwritev, 6) + MIPS_SYS(sys_rt_tgsigqueueinfo, 4) + MIPS_SYS(sys_perf_event_open, 5) + MIPS_SYS(sys_accept4, 4) + MIPS_SYS(sys_recvmmsg, 5) /* 4335 */ + MIPS_SYS(sys_fanotify_init, 2) + MIPS_SYS(sys_fanotify_mark, 6) + MIPS_SYS(sys_prlimit64, 4) + MIPS_SYS(sys_name_to_handle_at, 5) + MIPS_SYS(sys_open_by_handle_at, 3) /* 4340 */ + MIPS_SYS(sys_clock_adjtime, 2) + MIPS_SYS(sys_syncfs, 1) };#undef MIPS_SYS
linux-user/microblaze/syscall_nr.h +12 -2
@@ -364,6 +364,16 @@#define TARGET_NR_sendmsg 360/* new */ #define TARGET_NR_recvmsg 361/* new */ #define TARGET_NR_accept04 362/* new */ - -#define TARGET_NR_syscalls 363 +#define TARGET_NR_preadv 363/* new */ +#define TARGET_NR_pwritev 364/* new */ +#define TARGET_NR_rt_tgsigqueueinfo 365/* new */ +#define TARGET_NR_perf_event_open 366/* new */ +#define TARGET_NR_recvmmsg 367/* new */ +#define TARGET_NR_fanotify_init 368 +#define TARGET_NR_fanotify_mark 369 +#define TARGET_NR_prlimit64 370 +#define TARGET_NR_name_to_handle_at 371 +#define TARGET_NR_open_by_handle_at 372 +#define TARGET_NR_clock_adjtime 373 +#define TARGET_NR_syncfs 374
linux-user/mips/syscall_nr.h +13 -0
@@ -332,3 +332,16 @@#define TARGET_NR_dup3 (TARGET_NR_Linux + 327)#define TARGET_NR_pipe2 (TARGET_NR_Linux + 328)#define TARGET_NR_inotify_init1 (TARGET_NR_Linux + 329) +#define TARGET_NR_preadv (TARGET_NR_Linux + 330) +#define TARGET_NR_pwritev (TARGET_NR_Linux + 331) +#define TARGET_NR_rt_tgsigqueueinfo (TARGET_NR_Linux + 332) +#define TARGET_NR_perf_event_open (TARGET_NR_Linux + 333) +#define TARGET_NR_accept4 (TARGET_NR_Linux + 334) +#define TARGET_NR_recvmmsg (TARGET_NR_Linux + 335) +#define TARGET_NR_fanotify_init (TARGET_NR_Linux + 336) +#define TARGET_NR_fanotify_mark (TARGET_NR_Linux + 337) +#define TARGET_NR_prlimit64 (TARGET_NR_Linux + 338) +#define TARGET_NR_name_to_handle_at (TARGET_NR_Linux + 339) +#define TARGET_NR_open_by_handle_at (TARGET_NR_Linux + 340) +#define TARGET_NR_clock_adjtime (TARGET_NR_Linux + 341) +#define TARGET_NR_syncfs (TARGET_NR_Linux + 342)
linux-user/mips64/syscall_nr.h +13 -0
@@ -291,3 +291,16 @@#define TARGET_NR_dup3 (TARGET_NR_Linux + 286)#define TARGET_NR_pipe2 (TARGET_NR_Linux + 287)#define TARGET_NR_inotify_init1 (TARGET_NR_Linux + 288) +#define TARGET_NR_preadv (TARGET_NR_Linux + 289) +#define TARGET_NR_pwritev (TARGET_NR_Linux + 290) +#define TARGET_NR_rt_tgsigqueueinfo (TARGET_NR_Linux + 291) +#define TARGET_NR_perf_event_open (TARGET_NR_Linux + 292) +#define TARGET_NR_accept4 (TARGET_NR_Linux + 293) +#define TARGET_NR_recvmmsg (TARGET_NR_Linux + 294) +#define TARGET_NR_fanotify_init (TARGET_NR_Linux + 295) +#define TARGET_NR_fanotify_mark (TARGET_NR_Linux + 296) +#define TARGET_NR_prlimit64 (TARGET_NR_Linux + 297) +#define TARGET_NR_name_to_handle_at (TARGET_NR_Linux + 298) +#define TARGET_NR_open_by_handle_at (TARGET_NR_Linux + 299) +#define TARGET_NR_clock_adjtime (TARGET_NR_Linux + 300) +#define TARGET_NR_syncfs (TARGET_NR_Linux + 301)
linux-user/mipsn32/syscall_nr.h +14 -0
@@ -295,3 +295,17 @@#define TARGET_NR_dup3 (TARGET_NR_Linux + 290)#define TARGET_NR_pipe2 (TARGET_NR_Linux + 291)#define TARGET_NR_inotify_init1 (TARGET_NR_Linux + 292) +#define TARGET_NR_preadv (TARGET_NR_Linux + 293) +#define TARGET_NR_pwritev (TARGET_NR_Linux + 294) +#define TARGET_NR_rt_tgsigqueueinfo (TARGET_NR_Linux + 295) +#define TARGET_NR_perf_event_open (TARGET_NR_Linux + 296) +#define TARGET_NR_accept4 (TARGET_NR_Linux + 297) +#define TARGET_NR_recvmmsg (TARGET_NR_Linux + 298) +#define TARGET_NR_getdents64 (TARGET_NR_Linux + 299) +#define TARGET_NR_fanotify_init (TARGET_NR_Linux + 300) +#define TARGET_NR_fanotify_mark (TARGET_NR_Linux + 301) +#define TARGET_NR_prlimit64 (TARGET_NR_Linux + 302) +#define TARGET_NR_name_to_handle_at (TARGET_NR_Linux + 303) +#define TARGET_NR_open_by_handle_at (TARGET_NR_Linux + 304) +#define TARGET_NR_clock_adjtime (TARGET_NR_Linux + 305) +#define TARGET_NR_syncfs (TARGET_NR_Linux + 306)
linux-user/ppc/syscall_nr.h +30 -0
@@ -332,3 +332,33 @@#define TARGET_NR_dup3 316#define TARGET_NR_pipe2 317#define TARGET_NR_inotify_init1 318 +#define TARGET_NR_perf_event_open 319 +#define TARGET_NR_preadv 320 +#define TARGET_NR_pwritev 321 +#define TARGET_NR_rt_tgsigqueueinfo 322 +#define TARGET_NR_fanotify_init 323 +#define TARGET_NR_fanotify_mark 324 +#define TARGET_NR_prlimit64 325 +#define TARGET_NR_socket 326 +#define TARGET_NR_bind 327 +#define TARGET_NR_connect 328 +#define TARGET_NR_listen 329 +#define TARGET_NR_accept 330 +#define TARGET_NR_getsockname 331 +#define TARGET_NR_getpeername 332 +#define TARGET_NR_socketpair 333 +#define TARGET_NR_send 334 +#define TARGET_NR_sendto 335 +#define TARGET_NR_recv 336 +#define TARGET_NR_recvfrom 337 +#define TARGET_NR_shutdown 338 +#define TARGET_NR_setsockopt 339 +#define TARGET_NR_getsockopt 340 +#define TARGET_NR_sendmsg 341 +#define TARGET_NR_recvmsg 342 +#define TARGET_NR_recvmmsg 343 +#define TARGET_NR_accept4 344 +#define TARGET_NR_name_to_handle_at 345 +#define TARGET_NR_open_by_handle_at 346 +#define TARGET_NR_clock_adjtime 347 +#define TARGET_NR_syncfs 348
linux-user/s390x/syscall_nr.h +11 -2
@@ -254,8 +254,17 @@#define TARGET_NR_pipe2 325#define TARGET_NR_dup3 326#define TARGET_NR_epoll_create1 327 -#undef NR_syscalls -#define NR_syscalls 328 +#define TARGET_NR_preadv 328 +#define TARGET_NR_pwritev 329 +#define TARGET_NR_rt_tgsigqueueinfo 330 +#define TARGET_NR_perf_event_open 331 +#define TARGET_NR_fanotify_init 332 +#define TARGET_NR_fanotify_mark 333 +#define TARGET_NR_prlimit64 334 +#define TARGET_NR_name_to_handle_at 335 +#define TARGET_NR_open_by_handle_at 336 +#define TARGET_NR_clock_adjtime 337 +#define TARGET_NR_syncfs 338/* * There are some system calls that are not present on 64 bit, some
linux-user/sh4/syscall_nr.h +32 -0
@@ -334,3 +334,35 @@#define TARGET_NR_dup3 330#define TARGET_NR_pipe2 331#define TARGET_NR_inotify_init1 332 +#define TARGET_NR_preadv 333 +#define TARGET_NR_pwritev 334 +#define TARGET_NR_rt_tgsigqueueinfo 335 +#define TARGET_NR_perf_event_open 336 +#define TARGET_NR_fanotify_init 337 +#define TARGET_NR_fanotify_mark 338 +#define TARGET_NR_prlimit64 339 + +/* Non-multiplexed socket family */ +#define TARGET_NR_socket 340 +#define TARGET_NR_bind 341 +#define TARGET_NR_connect 342 +#define TARGET_NR_listen 343 +#define TARGET_NR_accept 344 +#define TARGET_NR_getsockname 345 +#define TARGET_NR_getpeername 346 +#define TARGET_NR_socketpair 347 +#define TARGET_NR_send 348 +#define TARGET_NR_sendto 349 +#define TARGET_NR_recv 350 +#define TARGET_NR_recvfrom 351 +#define TARGET_NR_shutdown 352 +#define TARGET_NR_setsockopt 353 +#define TARGET_NR_getsockopt 354 +#define TARGET_NR_sendmsg 355 +#define TARGET_NR_recvmsg 356 +#define TARGET_NR_recvmmsg 357 +#define TARGET_NR_accept4 358 +#define TARGET_NR_name_to_handle_at 359 +#define TARGET_NR_open_by_handle_at 360 +#define TARGET_NR_clock_adjtime 361 +#define TARGET_NR_syncfs 362
linux-user/sparc/syscall_nr.h +12 -0
@@ -285,3 +285,15 @@#define TARGET_NR_pipe2 321#define TARGET_NR_inotify_init1 322#define TARGET_NR_accept4 323 +#define TARGET_NR_preadv 324 +#define TARGET_NR_pwritev 325 +#define TARGET_NR_rt_tgsigqueueinfo 326 +#define TARGET_NR_perf_event_open 327 +#define TARGET_NR_recvmmsg 328 +#define TARGET_NR_fanotify_init 329 +#define TARGET_NR_fanotify_mark 330 +#define TARGET_NR_prlimit64 331 +#define TARGET_NR_name_to_handle_at 332 +#define TARGET_NR_open_by_handle_at 333 +#define TARGET_NR_clock_adjtime 334 +#define TARGET_NR_syncfs 335
linux-user/sparc64/syscall_nr.h +12 -0
@@ -322,3 +322,15 @@#define TARGET_NR_pipe2 321#define TARGET_NR_inotify_init1 322#define TARGET_NR_accept4 323 +#define TARGET_NR_preadv 324 +#define TARGET_NR_pwritev 325 +#define TARGET_NR_rt_tgsigqueueinfo 326 +#define TARGET_NR_perf_event_open 327 +#define TARGET_NR_recvmmsg 328 +#define TARGET_NR_fanotify_init 329 +#define TARGET_NR_fanotify_mark 330 +#define TARGET_NR_prlimit64 331 +#define TARGET_NR_name_to_handle_at 332 +#define TARGET_NR_open_by_handle_at 333 +#define TARGET_NR_clock_adjtime 334 +#define TARGET_NR_syncfs 335
linux-user/x86_64/syscall_nr.h +12 -0
@@ -293,3 +293,15 @@#define TARGET_NR_dup3 292#define TARGET_NR_pipe2 293#define TARGET_NR_inotify_init1 294 +#define TARGET_NR_preadv 295 +#define TARGET_NR_pwritev 296 +#define TARGET_NR_rt_tgsigqueueinfo 297 +#define TARGET_NR_perf_event_open 298 +#define TARGET_NR_recvmmsg 299 +#define TARGET_NR_fanotify_init 300 +#define TARGET_NR_fanotify_mark 301 +#define TARGET_NR_prlimit64 302 +#define TARGET_NR_name_to_handle_at 303 +#define TARGET_NR_open_by_handle_at 304 +#define TARGET_NR_clock_adjtime 305 +#define TARGET_NR_syncfs 306
Signature · 1 line
1.7.4.1
PATCH 2/2 linux-user: Implement prlimit64 syscall
In reply to Peter MaydellImplement the prlimit64 syscall.
--- linux-user/syscall.c | 43 +++++++++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 5 +++++ 2 files changed, 48 insertions(+), 0 deletions(-)
linux-user/syscall.c +43 -0
@@ -550,6 +550,21 @@ _syscall5(int, sys_ppoll, struct pollfd *, fds, nfds_t, nfds, size_t, sigsetsize)#endif +#if defined(TARGET_NR_prlimit64) +#ifndef __NR_prlimit64 +# define __NR_prlimit64 -1 +#endif +#define __NR_sys_prlimit64 __NR_prlimit64 +/* The glibc rlimit structure may not be that used by the underlying syscall */ +struct host_rlimit64 { +uint64_t rlim_cur; +uint64_t rlim_max; +}; +_syscall4 (int, sys_prlimit64, pid_t, pid, int, resource, + const struct host_rlimit64 *, new_limit, + struct host_rlimit64 *, old_limit) +#endif +extern int personality (int );extern int flock (int ,int );extern int setfsuid (int );
@@ -7840,6 +7855,34 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, }#endif #endif +#ifdef TARGET_NR_prlimit64 +case TARGET_NR_prlimit64: + { +/* args: pid, resource number, ptr to new rlimit, ptr to old rlimit */ +struct target_rlimit64 *target_rnew, *target_rold; +struct host_rlimit64 rnew, rold, *rnewp =0 ; +if (arg3) { +if (!lock_user_struct (VERIFY_READ , target_rnew, arg3,1 )) { + goto efault; + } + rnew.rlim_cur =tswap64 (target_rnew->rlim_cur); + rnew.rlim_max =tswap64 (target_rnew->rlim_max); +unlock_user_struct (target_rnew, arg3,0 ); + rnewp = &rnew; + } + + ret =get_errno (sys_prlimit64 (arg1, arg2, rnewp, arg4 ? &rold :0 )); +if (!is_error (ret) && arg4) { +if (!lock_user_struct (VERIFY_WRITE , target_rold, arg4,1 )) { + goto efault; + } + target_rold->rlim_cur =tswap64 (rold.rlim_cur); + target_rold->rlim_max =tswap64 (rold.rlim_max); +unlock_user_struct (target_rold, arg4,1 ); + } +break ; + } +#endif default : unimplemented:gemu_log ("qemu: Unsupported syscall: %d\n" , num);
linux-user/syscall_defs.h +5 -0
@@ -2280,3 +2280,8 @@ struct target_epoll_event { target_epoll_data_t data; };#endif + +struct target_rlimit64 { +uint64_t rlim_cur; +uint64_t rlim_max; +};
Signature · 1 line
1.7.4.1