linux-user patches
PATCH 1/5 linux-user: Add target struct defs needed for POSIX timer syscalls.
In reply to [email protected]From: Erik de Castro Lopo <[email protected]>
--- linux-user/syscall_defs.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
linux-user/syscall_defs.h +25 -0
@@ -168,6 +168,11 @@ struct target_itimerval {struct target_timeval it_value; }; +struct target_itimerspec { +struct target_timespec it_interval; +struct target_timespec it_value; +}; +typedef abi_long target_clock_t ;#define TARGET_HZ 100
@@ -2527,3 +2532,23 @@ struct target_ucred { };#endif + + +struct target_timer_t { +abi_ulong ptr; +}; + +struct target_sigevent { +target_sigval_t sigev_value; +int32_t sigev_signo; +int32_t sigev_notify; +union { +int32_t _pad[ARRAY_SIZE (((struct sigevent *)0 )->_sigev_un._pad)]; +int32_t _tid; + +struct { +void (*_function)(sigval_t ); +void *_attribute; + } _sigev_thread; + } _sigev_un; +};
Signature · 1 line
1.8.1.2
PATCH 3/5 flatload: fix non-GOT relocations
In reply to [email protected]From: "Corey J. Boyle" <[email protected]>
Use target address rather than host address when performing non-GOT relocations
--- linux-user/flatload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/flatload.c +1 -1
@@ -633,7 +633,7 @@ static int load_flat_file(struct linux_binprm * bprm,/* Get the pointer's value. */ if (get_user_ual (addr, rp))return -EFAULT ; - addr =flat_get_addr_from_rp (rp, relval, flags, &persistent); + addr =flat_get_addr_from_rp (addr, relval, flags, &persistent);if (addr !=0 ) {/* * Do the relocation. PIC relocs in the data section are
Signature · 1 line
1.8.1.2
PATCH 4/5 linux-user: create target_structs header to place ipc_perm and shmid_ds
In reply to [email protected]From: Petar Jovanovic <[email protected]>
Creating target_structs header in linux-user/$arch/ and making target_ipc_perm and target_shmid_ds its first inhabitants.
The struct defintions may/should be further fine-tuned by arch maintainers.
--- linux-user/aarch64/target_structs.h | 58 ++++++++++++++++++++++++++ linux-user/alpha/target_structs.h | 48 +++++++++++++++++++++ linux-user/arm/target_structs.h | 52 +++++++++++++++++++++++ linux-user/cris/target_structs.h | 58 ++++++++++++++++++++++++++ linux-user/i386/target_structs.h | 58 ++++++++++++++++++++++++++ linux-user/m68k/target_structs.h | 58 ++++++++++++++++++++++++++ linux-user/microblaze/target_structs.h | 58 ++++++++++++++++++++++++++ linux-user/mips/target_structs.h | 48 +++++++++++++++++++++ linux-user/mips64/target_cpu.h | 18 ++++++++ linux-user/mips64/target_structs.h | 2 + linux-user/openrisc/target_structs.h | 58 ++++++++++++++++++++++++++ linux-user/ppc/target_structs.h | 60 +++++++++++++++++++++++++++ linux-user/qemu.h | 1 + linux-user/s390x/target_structs.h | 63 ++++++++++++++++++++++++++++ linux-user/sh4/target_structs.h | 58 ++++++++++++++++++++++++++ linux-user/sparc/target_structs.h | 63 ++++++++++++++++++++++++++++ linux-user/sparc64/target_structs.h | 58 ++++++++++++++++++++++++++ linux-user/syscall.c | 76 +++++++++++++--------------------- linux-user/unicore32/target_structs.h | 58 ++++++++++++++++++++++++++ linux-user/x86_64/target_structs.h | 58 ++++++++++++++++++++++++++ 20 files changed, 963 insertions(+), 48 deletions(-) create mode 100644 linux-user/aarch64/target_structs.h create mode 100644 linux-user/alpha/target_structs.h create mode 100644 linux-user/arm/target_structs.h create mode 100644 linux-user/cris/target_structs.h create mode 100644 linux-user/i386/target_structs.h create mode 100644 linux-user/m68k/target_structs.h create mode 100644 linux-user/microblaze/target_structs.h create mode 100644 linux-user/mips/target_structs.h create mode 100644 linux-user/mips64/target_structs.h create mode 100644 linux-user/openrisc/target_structs.h create mode 100644 linux-user/ppc/target_structs.h create mode 100644 linux-user/s390x/target_structs.h create mode 100644 linux-user/sh4/target_structs.h create mode 100644 linux-user/sparc/target_structs.h create mode 100644 linux-user/sparc64/target_structs.h create mode 100644 linux-user/unicore32/target_structs.h create mode 100644 linux-user/x86_64/target_structs.h
linux-user/aarch64/target_structs.h new file +58 -0
@@ -0,0 +1,58 @@ +/* +* ARM AArch64 specific structures for linux-user +* +* Copyright (c) 2013 Fabrice Bellard +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef TARGET_STRUCTS_H +#define TARGET_STRUCTS_H + +struct target_ipc_perm { +abi_int __key;/* Key. */ +abi_uint uid;/* Owner's user ID. */ +abi_uint gid;/* Owner's group ID. */ +abi_uint cuid;/* Creator's user ID. */ +abi_uint cgid;/* Creator's group ID. */ +abi_ushort mode;/* Read/write permission. */ +abi_ushort __pad1; +abi_ushort __seq;/* Sequence number. */ +abi_ushort __pad2; +abi_ulong __unused1; +abi_ulong __unused2; +}; + +struct target_shmid_ds { +struct target_ipc_perm shm_perm;/* operation permission struct */ +abi_long shm_segsz;/* size of segment in bytes */ +abi_ulong shm_atime;/* time of last shmat() */ +#if TARGET_ABI_BITS ==32 +abi_ulong __unused1; +#endif +abi_ulong shm_dtime;/* time of last shmdt() */ +#if TARGET_ABI_BITS ==32 +abi_ulong __unused2; +#endif +abi_ulong shm_ctime;/* time of last change by shmctl() */ +#if TARGET_ABI_BITS ==32 +abi_ulong __unused3; +#endif +abi_int shm_cpid;/* pid of creator */ +abi_int shm_lpid;/* pid of last shmop */ +abi_ulong shm_nattch;/* number of current attaches */ +abi_ulong __unused4; +abi_ulong __unused5; +}; + +#endif
linux-user/alpha/target_structs.h new file +48 -0
48 lines not on this page · raw message
linux-user/arm/target_structs.h new file +52 -0
52 lines not on this page · raw message
linux-user/cris/target_structs.h new file +58 -0
58 lines not on this page · raw message
linux-user/i386/target_structs.h new file +58 -0
58 lines not on this page · raw message
linux-user/m68k/target_structs.h new file +58 -0
58 lines not on this page · raw message
linux-user/microblaze/target_structs.h new file +58 -0
58 lines not on this page · raw message
linux-user/mips/target_structs.h new file +48 -0
48 lines not on this page · raw message
linux-user/mips64/target_cpu.h +18 -0
@@ -1 +1,19 @@ +/* +* MIPS64 specific structures for linux-user +* +* Copyright (c) 2013 Fabrice Bellard +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ #include "../mips/target_cpu.h"
linux-user/mips64/target_structs.h new file +2 -0
@@ -0,0 +1,2 @@ +#include "../mips/target_structs.h" +
linux-user/openrisc/target_structs.h new file +58 -0
58 lines not on this page · raw message
linux-user/ppc/target_structs.h new file +60 -0
60 lines not on this page · raw message
linux-user/qemu.h +1 -0
@@ -452,5 +452,6 @@ static inline void *lock_user_string(abi_ulong guest_addr)*/ #include "target_cpu.h" #include "target_signal.h" +#include "target_structs.h" #endif /* QEMU_H */
linux-user/s390x/target_structs.h new file +63 -0
63 lines not on this page · raw message
linux-user/sh4/target_structs.h new file +58 -0
58 lines not on this page · raw message
linux-user/sparc/target_structs.h new file +63 -0
63 lines not on this page · raw message
linux-user/sparc64/target_structs.h new file +58 -0
58 lines not on this page · raw message
linux-user/syscall.c +28 -48
102 lines not on this page · raw message
linux-user/unicore32/target_structs.h new file +58 -0
58 lines not on this page · raw message
linux-user/x86_64/target_structs.h new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
1.8.1.2
PATCH 2/5 linux-user: Implement handling of 5 POSIX timer syscalls.
In reply to [email protected]From: Erik de Castro Lopo <[email protected]>
Implement timer_create, timer_settime, timer_gettime, timer_getoverrun and timer_delete.
--- linux-user/syscall.c | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+)
linux-user/syscall.c +176 -0
@@ -428,6 +428,25 @@ _syscall4(int, sys_prlimit64, pid_t, pid, int, resource, struct host_rlimit64 *, old_limit)#endif + +#if defined(TARGET_NR_timer_create) +/* Maxiumum of 32 active POSIX timers allowed at any one time. */ +static timer_t g_posix_timers[32 ] = {0 , } ; + +static inline int next_free_host_timer (void ) +{ +int k ; +/* FIXME: Does finding the next free slot require a lock? */ +for (k =0 ; k <ARRAY_SIZE (g_posix_timers); k++) { +if (g_posix_timers[k] ==0 ) { + g_posix_timers[k] = (timer_t )1 ; +return k; + } + } +return -1 ; +} +#endif +/* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ #ifdef TARGET_ARM static inline int regpairs_aligned (void *cpu_env) {
@@ -4838,6 +4857,45 @@ static inline abi_long host_to_target_timespec(abi_ulong target_addr,return 0 ; } +static inline abi_long target_to_host_itimerspec (struct itimerspec *host_itspec, +abi_ulong target_addr) +{ +struct target_itimerspec *target_itspec; + +if (!lock_user_struct (VERIFY_READ , target_itspec, target_addr,1 )) { +return -TARGET_EFAULT ; + } + + host_itspec->it_interval.tv_sec = +tswapal (target_itspec->it_interval.tv_sec); + host_itspec->it_interval.tv_nsec = +tswapal (target_itspec->it_interval.tv_nsec); + host_itspec->it_value.tv_sec =tswapal (target_itspec->it_value.tv_sec); + host_itspec->it_value.tv_nsec =tswapal (target_itspec->it_value.tv_nsec); + +unlock_user_struct (target_itspec, target_addr,1 ); +return 0 ; +} + +static inline abi_long host_to_target_itimerspec (abi_ulong target_addr, +struct itimerspec *host_its) +{ +struct target_itimerspec *target_itspec; + +if (!lock_user_struct (VERIFY_WRITE , target_itspec, target_addr,0 )) { +return -TARGET_EFAULT ; + } + + target_itspec->it_interval.tv_sec =tswapal (host_its->it_interval.tv_sec); + target_itspec->it_interval.tv_nsec =tswapal (host_its->it_interval.tv_nsec); + + target_itspec->it_value.tv_sec =tswapal (host_its->it_value.tv_sec); + target_itspec->it_value.tv_nsec =tswapal (host_its->it_value.tv_nsec); + +unlock_user_struct (target_itspec, target_addr,0 ); +return 0 ; +} +#if defined(TARGET_NR_stat64) || defined(TARGET_NR_newfstatat) static inline abi_long host_to_target_stat64(void *cpu_env, abi_ulong target_addr,
@@ -9195,6 +9253,124 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ; }#endif + +#ifdef TARGET_NR_timer_create +case TARGET_NR_timer_create: + { +/* args: clockid_t clockid, struct sigevent *sevp, timer_t *timerid */ + +struct sigevent host_sevp = { {0 }, }, *phost_sevp =NULL ; +struct target_sigevent *ptarget_sevp; +struct target_timer_t *ptarget_timer; + +int clkid = arg1; +int timer_index =next_free_host_timer (); + +if (timer_index <0 ) { + ret = -TARGET_EAGAIN ; + }else { +timer_t *phtimer = g_posix_timers + timer_index; + +if (arg2) { +if (!lock_user_struct (VERIFY_READ , ptarget_sevp, arg2,1 )) { + goto efault; + } + + host_sevp.sigev_signo =tswap32 (ptarget_sevp->sigev_signo); + host_sevp.sigev_notify =tswap32 (ptarget_sevp->sigev_notify); + + phost_sevp = &host_sevp; + } + + ret =get_errno (timer_create (clkid, phost_sevp, phtimer)); +if (ret) { + phtimer =NULL ; + }else { +if (!lock_user_struct (VERIFY_WRITE , ptarget_timer, arg3,1 )) { + goto efault; + } + ptarget_timer->ptr =tswap32 (0xcafe0000 | timer_index); +unlock_user_struct (ptarget_timer, arg3,1 ); + } + } +break ; + } +#endif + +#ifdef TARGET_NR_timer_settime +case TARGET_NR_timer_settime: + { +/* args: timer_t timerid, int flags, const struct itimerspec *new_value, +* struct itimerspec * old_value */ + arg1 &=0xffff ; +if (arg3 ==0 || arg1 <0 || arg1 >=ARRAY_SIZE (g_posix_timers)) { + ret = -TARGET_EINVAL ; + }else { +timer_t htimer = g_posix_timers[arg1]; +struct itimerspec hspec_new = {{0 },}, hspec_old = {{0 },}; + +target_to_host_itimerspec (&hspec_new, arg3); + ret =get_errno ( +timer_settime (htimer, arg2, &hspec_new, &hspec_old)); +host_to_target_itimerspec (arg2, &hspec_old); + } +break ; + } +#endif + +#ifdef TARGET_NR_timer_gettime +case TARGET_NR_timer_gettime: + { +/* args: timer_t timerid, struct itimerspec *curr_value */ + arg1 &=0xffff ; +if (!arg2) { +return -TARGET_EFAULT ; + }else if (arg1 <0 || arg1 >=ARRAY_SIZE (g_posix_timers)) { + ret = -TARGET_EINVAL ; + }else { +timer_t htimer = g_posix_timers[arg1]; +struct itimerspec hspec; + ret =get_errno (timer_gettime (htimer, &hspec)); + +if (host_to_target_itimerspec (arg2, &hspec)) { + ret = -TARGET_EFAULT ; + } + } +break ; + } +#endif + +#ifdef TARGET_NR_timer_getoverrun +case TARGET_NR_timer_getoverrun: + { +/* args: timer_t timerid */ + arg1 &=0xffff ; +if (arg1 <0 || arg1 >=ARRAY_SIZE (g_posix_timers)) { + ret = -TARGET_EINVAL ; + }else { +timer_t htimer = g_posix_timers[arg1]; + ret =get_errno (timer_getoverrun (htimer)); + } +break ; + } +#endif + +#ifdef TARGET_NR_timer_delete +case TARGET_NR_timer_delete: + { +/* args: timer_t timerid */ + arg1 &=0xffff ; +if (arg1 <0 || arg1 >=ARRAY_SIZE (g_posix_timers)) { + ret = -TARGET_EINVAL ; + }else { +timer_t htimer = g_posix_timers[arg1]; + ret =get_errno (timer_delete (htimer)); + g_posix_timers[arg1] =0 ; + } +break ; + } +#endif +default : unimplemented:gemu_log ("qemu: Unsupported syscall: %d\n" , num);
Signature · 1 line
1.8.1.2
From: Riku Voipio <[email protected]>
The following changes since commit 7dc65c02fe3fb8f3146ce0b9ff5fec5945329f0e:
Open 2.0 development tree (2013-11-27 14:02:45 -0800)
are available in the git repository at:
git://git.linaro.org/people/rikuvoipio/qemu.git linux-user-for-upstream
for you to fetch changes up to a29267846a52b4ca294ba3a962b74b67df7ce6d2:
linux-user: pass correct parameter to do_shmctl() (2013-11-29 11:42:14 +0200)
----------------------------------------------------------------
Corey J. Boyle (1):
flatload: fix non-GOT relocations
Erik de Castro Lopo (2):
linux-user: Add target struct defs needed for POSIX timer syscalls.
linux-user: Implement handling of 5 POSIX timer syscalls.
Petar Jovanovic (2):
linux-user: create target_structs header to place ipc_perm and shmid_ds
linux-user: pass correct parameter to do_shmctl()
linux-user/aarch64/target_structs.h | 58 ++++++++++++++++++++ linux-user/alpha/target_structs.h | 48 ++++++++++++++++ linux-user/arm/target_structs.h | 52 ++++++++++++++++++ linux-user/cris/target_structs.h | 58 ++++++++++++++++++++ linux-user/flatload.c | 2 +- linux-user/i386/target_structs.h | 58 ++++++++++++++++++++ linux-user/m68k/target_structs.h | 58 ++++++++++++++++++++ linux-user/microblaze/target_structs.h | 58 ++++++++++++++++++++ linux-user/mips/target_structs.h | 48 ++++++++++++++++ linux-user/mips64/target_cpu.h | 18 ++++++ linux-user/mips64/target_structs.h | 2 + linux-user/openrisc/target_structs.h | 58 ++++++++++++++++++++ linux-user/ppc/target_structs.h | 60 ++++++++++++++++++++ linux-user/qemu.h | 1 + linux-user/s390x/target_structs.h | 63 +++++++++++++++++++++ linux-user/sh4/target_structs.h | 58 ++++++++++++++++++++ linux-user/sparc/target_structs.h | 63 +++++++++++++++++++++ linux-user/sparc64/target_structs.h | 58 ++++++++++++++++++++ linux-user/syscall.c | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------- linux-user/syscall_defs.h | 25 +++++++++ linux-user/unicore32/target_structs.h | 58 ++++++++++++++++++++ linux-user/x86_64/target_structs.h | 58 ++++++++++++++++++++ 22 files changed, 1166 insertions(+), 50 deletions(-) create mode 100644 linux-user/aarch64/target_structs.h create mode 100644 linux-user/alpha/target_structs.h create mode 100644 linux-user/arm/target_structs.h create mode 100644 linux-user/cris/target_structs.h create mode 100644 linux-user/i386/target_structs.h create mode 100644 linux-user/m68k/target_structs.h create mode 100644 linux-user/microblaze/target_structs.h create mode 100644 linux-user/mips/target_structs.h create mode 100644 linux-user/mips64/target_structs.h create mode 100644 linux-user/openrisc/target_structs.h create mode 100644 linux-user/ppc/target_structs.h create mode 100644 linux-user/s390x/target_structs.h create mode 100644 linux-user/sh4/target_structs.h create mode 100644 linux-user/sparc/target_structs.h create mode 100644 linux-user/sparc64/target_structs.h create mode 100644 linux-user/unicore32/target_structs.h create mode 100644 linux-user/x86_64/target_structs.h
PATCH 5/5 linux-user: pass correct parameter to do_shmctl()
From: Petar Jovanovic <[email protected]>
Fix shmctl issue by passing correct parameter buf to do_shmctl().
--- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
@@ -3215,7 +3215,7 @@ static abi_long do_ipc(unsigned int call, int first,/* IPC_* and SHM_* command values are the same on all linux platforms */ case IPCOP_shmctl: - ret =do_shmctl (first, second, third); + ret =do_shmctl (first, second, ptr);break ;default :gemu_log ("Unsupported ipc call: %d (version %d)\n" , call, version);
Signature · 1 line
1.8.1.2