[PATCH] linux-user: Correctly start brk after executable

2020-07-28 Thread Timothy E Baldwin
info->brk was erroneously set to the end of highest addressed writable segment which could result it in overlapping the executable. As per load_elf_binary in fs/binfmt_elf.c in Linux, it should be set to end of highest addressed segment. Signed-off-by: Timothy E Baldwin --- linux-u

[Qemu-devel] [PATCH] linux-user: Fix incorrect offset of tuc_stack in ARM do_sigframe_return_v2

2016-09-09 Thread Timothy E Baldwin
struct target_ucontext_v2 is not at the begining of the signal frame, therefore do_sigaltstack was being passed bogus arguments. As the offset depends on the type of signal frame fixed by passing in the beginning of the context from do_sigreturn_v2 and do_rt_sigreturn_v2. Suggested-by: Peter Mayd

[Qemu-devel] [PATCH v2] linux-user: Use correct offset of tuc_stack in ARM do_sigframe_return_v2

2016-09-03 Thread Timothy E Baldwin
struct target_ucontext_v2 is not at the begining of the signal frame, therefore do_sigaltstack was being passed bogus arguments. Signed-off-by: Timothy Edward Baldwin --- linux-user/signal.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) Changes since v1: Fix style. diff --git a/li

[Qemu-devel] [PATCH] linux-user: Use correct offset of tuc_stack in ARM do_sigframe_return_v2

2016-09-03 Thread Timothy E Baldwin
struct target_ucontext_v2 is not at the begining of the signal frame, therefore do_sigaltstack was being passed bogus arguments. Signed-off-by: Timothy Edward Baldwin --- linux-user/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/signal.c b/linux-user/sign

[Qemu-devel] [PATCH 02/34] linux-user: Reindent signal handling

2015-09-05 Thread Timothy E Baldwin
Some of the signal handling was a mess with a mixture of tabs and 8 space indents. Signed-off-by: Timothy Edward Baldwin --- linux-user/signal.c | 1691 ++- 1 file changed, 867 insertions(+), 824 deletions(-) diff --git a/linux-user/signal.c b/lin

[Qemu-devel] [PATCH 34/34] linux-user: Remove TARGET_USE_ERESTARTSYS

2015-09-05 Thread Timothy E Baldwin
Now with system call restarting support by all targets remove uneeded conditionals. Signed-off-by: Timothy Edward Baldwin --- linux-user/aarch64/syscall.h| 2 -- linux-user/alpha/syscall.h | 2 -- linux-user/arm/syscall.h| 2 -- linux-user/cris/syscall.h | 2 -- linux-user

[Qemu-devel] [PATCH 31/34] linux-user: Support for restarting system calls for M68K targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- linux-user/m68k/syscall.h | 2 ++ linux-user/main.c | 24 +++- linux-user/signal.c | 20 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/linux-user/m68k/syscall.h b/linux-user/m68k/s

[Qemu-devel] [PATCH 23/34] linux-user: Queue synchronous signals separately

2015-09-05 Thread Timothy E Baldwin
If a synchronous signal and an asynchronous signal arrive near simultaneously, and the signal number of the asynchronous signal is lower than that of the synchronous signal the the handler for the asynchronous would be called first, and then the handler for the synchronous signal would be called wi

[Qemu-devel] [PATCH 24/34] linux-user: Restart execve() if signal pending

2015-09-05 Thread Timothy E Baldwin
Without this SIGTERM could fail to terminate the process, as the signal lost in QEMU's queue. Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1ce381e..4839154 10

[Qemu-devel] [PATCH 12/34] linux-user: Support for restarting system calls for APLHA targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- Signal handling NOT TESTED linux-user/alpha/syscall.h | 2 ++ linux-user/main.c | 7 +-- linux-user/signal.c| 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/linux-user/alpha/syscall.h b/linux-user/alpha/sysca

[Qemu-devel] [PATCH 22/34] linux-user: Remove real-time signal queuing

2015-09-05 Thread Timothy E Baldwin
As host signals are now blocked whenever guest signals are blocked, the queue of realtime signals in now in Linux. The Qemu queue is now redundant and removed. Signed-off-by: Timothy Edward Baldwin Conflicts: linux-user/qemu.h --- linux-user/main.c | 7 -- linux-user/qemu.h | 1

[Qemu-devel] [PATCH 13/34] linux-user: Fix signal before blocking system calls race and SA_RESTART

2015-09-05 Thread Timothy E Baldwin
If a signal is delivered immediately before a blocking system calls the handler will only be called after the system call returns, which may be a long time later or never. This is fixed by using a function (safe_syscall_base) that checks if a guest signal is pending prior to making a system call,

[Qemu-devel] [PATCH 29/34] linux-user: Support for restarting system calls for UniCore32 targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- WARNING - NOT TESTED linux-user/main.c | 7 ++- linux-user/unicore32/syscall.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/linux-user/main.c b/linux-user/main.c index d86751a..9ca1c99 100644 --- a/linux-user/ma

[Qemu-devel] [PATCH 11/34] linux-user: Support for restarting system calls for SH4 targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- Works without signals, but my signal test case crashes with or without my changes. linux-user/main.c| 6 +- linux-user/sh4/syscall.h | 2 ++ linux-user/signal.c | 16 ++-- 3 files changed, 13 insertions(+), 11 deletions(-)

[Qemu-devel] [PATCH 27/34] linux-user: pause() should not pause if signal pending

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index da6d140..f89b730 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6106,7 +6106,10 @@ abi_long do

[Qemu-devel] [PATCH 25/34] linux-user: Restart exit() if signal pending

2015-09-05 Thread Timothy E Baldwin
Without this a signal could vanish on thread exit. Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4839154..efe61e3 100644 --- a/linux-user/syscall.c +++ b

[Qemu-devel] [PATCH 05/34] linux-user: Support for restarting system calls for ARM targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- linux-user/aarch64/syscall.h | 2 ++ linux-user/arm/syscall.h | 2 ++ linux-user/main.c| 47 +++- linux-user/signal.c | 10 +- 4 files changed, 38 insertions(+), 23 deletions(-) d

[Qemu-devel] [PATCH 18/34] linux-user: Fix race between multiple signals

2015-09-05 Thread Timothy E Baldwin
If multiple host signals are recieved in quick succession they would be queued in TaskState then delivered to the guest in spite of signals being blocked. Fixed by keeping host signals blocked until process_pending_signals() runs, this needs the guest signal state to be maintained by Qemu. Blockin

[Qemu-devel] [PATCH 10/34] linux-user: Support for restarting system calls for Microblaze targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- Works without signals, but my signal test case crashes with or without my changes. linux-user/main.c | 14 +- linux-user/microblaze/syscall.h | 2 ++ linux-user/signal.c | 2 +- 3 files changed, 12 insertions(+),

[Qemu-devel] [PATCH 26/34] linux-user: Restart kill() if signal pending

2015-09-05 Thread Timothy E Baldwin
Without this a signal could vanish if thread sends SIGKILL to itself. Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index efe61e3..da6d140 100644 --- a/linux-user

[Qemu-devel] [PATCH 21/34] linux-user: Remove redundant gdb_queuesig()

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- gdbstub.c | 13 - include/exec/gdbstub.h | 1 - 2 files changed, 14 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index ffe7e6e..fd319af 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1472,19 +1472,6 @@ void gdb_exit(CPUArchState

[Qemu-devel] [PATCH 33/34] linux-user: Support for restarting system calls for CRIS targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- WARNING - NOT TESTED linux-user/cris/syscall.h | 2 ++ linux-user/main.c | 6 +- linux-user/signal.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/linux-user/cris/syscall.h b/linux-user/cris/syscall.h index 295

[Qemu-devel] [PATCH 14/34] linux-user: Use safe_syscall for read and write system calls

2015-09-05 Thread Timothy E Baldwin
Restart read() and write() if signals occur before, or during with SA_RESTART Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b9ad7b6..c213588 100644 --- a

[Qemu-devel] [PATCH 20/34] linux-user: Remove redundant default action check in queue_signal()

2015-09-05 Thread Timothy E Baldwin
Both queue_signal() and process_pending_signals() did check for default actions of signals, this is redundant and also causes fatal and stopping signals to incorrectly cause guest system calls to be interrupted. The code in queue_signal() is removed. Signed-off-by: Timothy Edward Baldwin --- li

[Qemu-devel] [PATCH 32/34] linux-user: Support for restarting system calls for S390 targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- WARNING - NOT TESTED linux-user/main.c | 12 +--- linux-user/s390x/syscall.h | 2 ++ linux-user/signal.c| 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 0863

[Qemu-devel] [PATCH 15/34] linux-user: Remove redundant get_errno() calls

2015-09-05 Thread Timothy E Baldwin
The return value of openat was being translated by get_errno() twice. Fixed by removing calls of get_errno() in do_syscall() and keeping those in do_openat(). Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff -

[Qemu-devel] [PATCH 07/34] linux-user: Support for restarting system calls for PPC targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- linux-user/main.c| 4 linux-user/ppc/syscall.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index 124e9cc..5e9e3a8 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1948,6 +1948,10 @@ v

[Qemu-devel] [PATCH 19/34] linux-user: Restart fork() if signals pending

2015-09-05 Thread Timothy E Baldwin
If there is a signal pending during fork() the signal handler will erroneously be called in both the parent and child, so handle any pending signals first. Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 5 + 1 file changed, 5 insertions(+) diff --git a/linux-user/syscall.c

[Qemu-devel] [PATCH 28/34] linux-user: Restart sigaction() if signal pending

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- linux-user/signal.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 15bd082..fc37f3b 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -629,7 +629,7 @@ out:

[Qemu-devel] [PATCH 08/34] linux-user: Support for restarting system calls for SPARC targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- linux-user/main.c| 3 +++ linux-user/signal.c | 2 +- linux-user/sparc/syscall.h | 2 ++ linux-user/sparc64/syscall.h | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/linux-user/main.c b/linux-user/main.c index

[Qemu-devel] [PATCH 17/34] linux-user: Use safe_syscall for wait system calls

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e68eddb..281fa2d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -698,6 +698,10 @@ safe_s

[Qemu-devel] [PATCH 03/34] linux-user: Support for restarting system calls

2015-09-05 Thread Timothy E Baldwin
This allows SA_RESTART to be supported along with various case where pending signals need to be handled before a system call. New macro TARGET_ERESTARTSYS which is the error code used by Linux to indicate that system call should be restarted. TARGET_QEMU_ESIGRETURN moved into errno_defs.h and ren

[Qemu-devel] [PATCH 30/34] linux-user: Support for restarting system calls for OpenRISC targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- WARNING - NOT TESTED linux-user/main.c | 22 ++ linux-user/openrisc/syscall.h | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 9ca1c99..b052e17 100644 --

[Qemu-devel] [PATCH 04/34] linux-user: Support for restarting system calls for x86 targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- linux-user/i386/syscall.h | 2 ++ linux-user/main.c | 47 - linux-user/signal.c | 15 +++ linux-user/syscall.c| 2 -- linux-user/x86_64/syscall.h | 2 ++ 5 files change

[Qemu-devel] [PATCH 09/34] linux-user: Test for restarting system calls

2015-09-05 Thread Timothy E Baldwin
If DEBUG_ERESTARTSYS is set restart all system calls once. Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 04c91fb..80b8fa8 100644 --- a/linux-user/syscall.c +++ b/lin

[Qemu-devel] [PATCH 16/34] linux-user: Use safe_syscall for open and openat system calls

2015-09-05 Thread Timothy E Baldwin
Restart open() and openat() if signals occur before, or during with SA_RESTART. Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 18 -- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index df9b2ca..e68edd

[Qemu-devel] [PATCH 06/34] linux-user: Support for restarting system calls for MIPS targets

2015-09-05 Thread Timothy E Baldwin
Signed-off-by: Timothy Edward Baldwin --- linux-user/main.c | 4 linux-user/mips/syscall.h | 2 ++ linux-user/mips64/syscall.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index 9653155..124e9cc 100644 --- a/linux-user/main.c +++ b/

[Qemu-devel] [PATCH 01/34] linux-user: Fix array bounds in errno conversion

2015-09-05 Thread Timothy E Baldwin
Check array bounds in host_to_target_errno() and target_to_host_errno(). Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 264debc..4e40dc6 100644 --- a/linux-us

[Qemu-devel] [PATCH 00/34] linux-user: Fix signal race conditions and SA_RESTART

2015-09-05 Thread Timothy E Baldwin
ld be appreciated - this is the only change I intend to make to unshared code to all targets. Outstanding issues: - The remaining blocking target system calls. - Fatal default actions may be delayed in a broken blocking target system call. Timothy E Baldwin (34): linux-user: Fix array bounds in

[Qemu-devel] [PATCH v2] linux-user: Return target error number in do_fork()

2015-08-30 Thread Timothy E Baldwin
Whilst calls to do_fork() are wrapped in get_errno() this does not translate return values. Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f62c698..264debc 1

[Qemu-devel] [PATCH] linux-user: Implement atomic_barrier system call

2015-08-30 Thread Timothy E Baldwin
Implemented atomic_barrier system call using GCC/clang builtin __sync_synchronize(). Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bca3424..72d107a 100644 --- a/

[Qemu-devel] [PATCH] linux-user: Implement ARM __kernel_memory_barrier

2015-08-30 Thread Timothy E Baldwin
Implemented ARM __kernel_memory_barrier using GCC/clang builtin __sync_synchronize(). Signed-off-by: Timothy Edward Baldwin --- linux-user/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/main.c b/linux-user/main.c index 2c9658e..f4b81b1 100644 --- a/linux-us

[Qemu-devel] [PATCH] linux-user: Return target error number in do_fork()

2015-08-30 Thread Timothy E Baldwin
Whilst calls to do_fork() are wrapped in get_errno() this does not translate return values. Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f62c698..bca3424 100644

[Qemu-devel] [PATCH v2] linux-user: Correct TARGET_NR_timerfd to TARGET_NR_timerfd_create.

2015-04-08 Thread Timothy E Baldwin
Misspelled system call name in macro was causing timerfd_create not to be supported for the ARM target. Signed-off-by: Timothy Edward Baldwin --- linux-user/arm/syscall_nr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/arm/syscall_nr.h b/linux-user/arm/syscall_n

[Qemu-devel] [PATCH] linux-user: Correct TARGET_NR_timerfd to TARGET_NR_timerfd_create.

2015-04-08 Thread Timothy E Baldwin
Misspelled system call name in macro was causing timerfd_create not to be supported for the ARM target. --- linux-user/arm/syscall_nr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/arm/syscall_nr.h b/linux-user/arm/syscall_nr.h index 7d7be7c..53552be 100644 --- a