qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/3] Linux user for 7.1 patches
@ 2022-07-26  9:44 Laurent Vivier
  2022-07-26  9:44 ` [PULL 1/3] linux-user/hppa: Fix segfaults on page zero Laurent Vivier
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Laurent Vivier @ 2022-07-26  9:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier

The following changes since commit 5288bee45fbd33203b61f8c76e41b15bb5913e6e:

  Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2022-07-21 11:13:01 +0100)

are available in the Git repository at:

  https://gitlab.com/laurent_vivier/qemu.git tags/linux-user-for-7.1-pull-request

for you to fetch changes up to 6f200f51869ff0de7ea0343dd7104362e994b382:

  linux-user: Use target abi_int type for pipefd[1] in pipe() (2022-07-25 10:42:11 +0200)

----------------------------------------------------------------
linux-user pull request 20220726

----------------------------------------------------------------

Helge Deller (3):
  linux-user/hppa: Fix segfaults on page zero
  linux-user: Unconditionally use pipe2() syscall
  linux-user: Use target abi_int type for pipefd[1] in pipe()

 linux-user/hppa/cpu_loop.c |  3 +++
 linux-user/syscall.c       | 13 ++-----------
 meson.build                |  9 ---------
 3 files changed, 5 insertions(+), 20 deletions(-)

-- 
2.37.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PULL 1/3] linux-user/hppa: Fix segfaults on page zero
  2022-07-26  9:44 [PULL 0/3] Linux user for 7.1 patches Laurent Vivier
@ 2022-07-26  9:44 ` Laurent Vivier
  2022-07-26  9:44 ` [PULL 2/3] linux-user: Unconditionally use pipe2() syscall Laurent Vivier
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2022-07-26  9:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Helge Deller, Peter Maydell

From: Helge Deller <deller@gmx.de>

This program:

    int main(void) { asm("bv %r0(%r0)"); return 0; }

produces on real hppa hardware the expected segfault:

    SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x3} ---
    killed by SIGSEGV +++
    Segmentation fault

But when run on linux-user you get instead internal qemu errors:

ERROR: linux-user/hppa/cpu_loop.c:172:cpu_loop: code should not be reached
Bail out! ERROR: linux-user/hppa/cpu_loop.c:172:cpu_loop: code should not be reached
ERROR: accel/tcg/cpu-exec.c:933:cpu_exec: assertion failed: (cpu == current_cpu)
Bail out! ERROR: accel/tcg/cpu-exec.c:933:cpu_exec: assertion failed: (cpu == current_cpu)

Fix it by adding the missing case for the EXCP_IMP trap in
cpu_loop() and raise a segfault.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <YtWNC56seiV6VenA@p100>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/hppa/cpu_loop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c
index a576d1a249fd..64263c3dc406 100644
--- a/linux-user/hppa/cpu_loop.c
+++ b/linux-user/hppa/cpu_loop.c
@@ -143,6 +143,9 @@ void cpu_loop(CPUHPPAState *env)
             env->iaoq_f = env->gr[31];
             env->iaoq_b = env->gr[31] + 4;
             break;
+        case EXCP_IMP:
+            force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, env->iaoq_f);
+            break;
         case EXCP_ILL:
             force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->iaoq_f);
             break;
-- 
2.37.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PULL 2/3] linux-user: Unconditionally use pipe2() syscall
  2022-07-26  9:44 [PULL 0/3] Linux user for 7.1 patches Laurent Vivier
  2022-07-26  9:44 ` [PULL 1/3] linux-user/hppa: Fix segfaults on page zero Laurent Vivier
@ 2022-07-26  9:44 ` Laurent Vivier
  2022-07-26  9:44 ` [PULL 3/3] linux-user: Use target abi_int type for pipefd[1] in pipe() Laurent Vivier
  2022-07-26 14:29 ` [PULL 0/3] Linux user for 7.1 patches Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2022-07-26  9:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Helge Deller, Peter Maydell

From: Helge Deller <deller@gmx.de>

The pipe2() syscall is available on all Linux platforms since kernel
2.6.27, so use it unconditionally to emulate pipe() and pipe2().

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <YtbZ2ojisTnzxN9Y@p100>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/syscall.c | 11 +----------
 meson.build          |  9 ---------
 2 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 991b85e6b4dd..4f89184d0585 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1586,21 +1586,12 @@ static abi_long do_ppoll(abi_long arg1, abi_long arg2, abi_long arg3,
 }
 #endif
 
-static abi_long do_pipe2(int host_pipe[], int flags)
-{
-#ifdef CONFIG_PIPE2
-    return pipe2(host_pipe, flags);
-#else
-    return -ENOSYS;
-#endif
-}
-
 static abi_long do_pipe(CPUArchState *cpu_env, abi_ulong pipedes,
                         int flags, int is_pipe2)
 {
     int host_pipe[2];
     abi_long ret;
-    ret = flags ? do_pipe2(host_pipe, flags) : pipe(host_pipe);
+    ret = pipe2(host_pipe, flags);
 
     if (is_error(ret))
         return get_errno(ret);
diff --git a/meson.build b/meson.build
index 8a8c415fc1f8..75aaca8462e8 100644
--- a/meson.build
+++ b/meson.build
@@ -2026,15 +2026,6 @@ config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + '''
   #else
   int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
   #endif'''))
-config_host_data.set('CONFIG_PIPE2', cc.links(gnu_source_prefix + '''
-  #include <unistd.h>
-  #include <fcntl.h>
-
-  int main(void)
-  {
-      int pipefd[2];
-      return pipe2(pipefd, O_CLOEXEC);
-  }'''))
 config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + '''
   #include <sys/mman.h>
   #include <stddef.h>
-- 
2.37.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PULL 3/3] linux-user: Use target abi_int type for pipefd[1] in pipe()
  2022-07-26  9:44 [PULL 0/3] Linux user for 7.1 patches Laurent Vivier
  2022-07-26  9:44 ` [PULL 1/3] linux-user/hppa: Fix segfaults on page zero Laurent Vivier
  2022-07-26  9:44 ` [PULL 2/3] linux-user: Unconditionally use pipe2() syscall Laurent Vivier
@ 2022-07-26  9:44 ` Laurent Vivier
  2022-07-26 14:29 ` [PULL 0/3] Linux user for 7.1 patches Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2022-07-26  9:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Helge Deller, Richard Henderson

From: Helge Deller <deller@gmx.de>

When writing back the fd[1] pipe file handle to emulated userspace
memory, use sizeof(abi_int) as offset insted of the hosts's int type.
There is no functional change in this patch.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Message-Id: <YtQ3Id6z8slpVr7r@p100>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 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 4f89184d0585..b27a6552aa34 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1615,7 +1615,7 @@ static abi_long do_pipe(CPUArchState *cpu_env, abi_ulong pipedes,
     }
 
     if (put_user_s32(host_pipe[0], pipedes)
-        || put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0])))
+        || put_user_s32(host_pipe[1], pipedes + sizeof(abi_int)))
         return -TARGET_EFAULT;
     return get_errno(ret);
 }
-- 
2.37.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PULL 0/3] Linux user for 7.1 patches
  2022-07-26  9:44 [PULL 0/3] Linux user for 7.1 patches Laurent Vivier
                   ` (2 preceding siblings ...)
  2022-07-26  9:44 ` [PULL 3/3] linux-user: Use target abi_int type for pipefd[1] in pipe() Laurent Vivier
@ 2022-07-26 14:29 ` Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2022-07-26 14:29 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-devel

On Tue, 26 Jul 2022 at 10:49, Laurent Vivier <laurent@vivier.eu> wrote:
>
> The following changes since commit 5288bee45fbd33203b61f8c76e41b15bb5913e6e:
>
>   Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2022-07-21 11:13:01 +0100)
>
> are available in the Git repository at:
>
>   https://gitlab.com/laurent_vivier/qemu.git tags/linux-user-for-7.1-pull-request
>
> for you to fetch changes up to 6f200f51869ff0de7ea0343dd7104362e994b382:
>
>   linux-user: Use target abi_int type for pipefd[1] in pipe() (2022-07-25 10:42:11 +0200)
>
> ----------------------------------------------------------------
> linux-user pull request 20220726
>
> ----------------------------------------------------------------


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/7.1
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-26 14:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-26  9:44 [PULL 0/3] Linux user for 7.1 patches Laurent Vivier
2022-07-26  9:44 ` [PULL 1/3] linux-user/hppa: Fix segfaults on page zero Laurent Vivier
2022-07-26  9:44 ` [PULL 2/3] linux-user: Unconditionally use pipe2() syscall Laurent Vivier
2022-07-26  9:44 ` [PULL 3/3] linux-user: Use target abi_int type for pipefd[1] in pipe() Laurent Vivier
2022-07-26 14:29 ` [PULL 0/3] Linux user for 7.1 patches Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).