qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/8] tcg + linux-user patch queue
@ 2024-03-12 18:41 Richard Henderson
  2024-03-12 18:41 ` [PULL 1/8] linux-user: Add FIFREEZE and FITHAW ioctls Richard Henderson
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Richard Henderson @ 2024-03-12 18:41 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit 8f3f329f5e0117bd1a23a79ab751f8a7d3471e4b:

  Merge tag 'migration-20240311-pull-request' of https://gitlab.com/peterx/qemu into staging (2024-03-12 11:35:41 +0000)

are available in the Git repository at:

  https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20240312

for you to fetch changes up to 4fe19bbbea2cb9f1ec28cfd40cdc7f61e95a790e:

  tcg/aarch64: Fix tcg_out_brcond for test comparisons (2024-03-12 04:09:21 -1000)

----------------------------------------------------------------
linux-user: Add FIFREEZE and FITHAW ioctls
linux-user: Implement PR_*_{CHILD_SUBREAPER,SPECULATION_CTRL,TID_ADDRESS}
linux-user/elfload: Fixes for two Coverity CIDs
tcg/aarch64: Fixes for two TCG_COND_TST{EQ,NE} bugs

----------------------------------------------------------------
Michael Vogt (1):
      linux-user: Add FIFREEZE and FITHAW ioctls

Richard Henderson (7):
      linux-user: Implement PR_{GET,SET}_CHILD_SUBREAPER
      linux-user: Implement PR_{GET,SET}_SPECULATION_CTRL
      linux-user: Implement PR_GET_TID_ADDRESS
      linux-user/elfload: Don't close an unopened file descriptor
      linux-user/elfload: Fully initialize struct target_elf_prpsinfo
      tcg/aarch64: Fix tcg_out_cmp for test comparisons
      tcg/aarch64: Fix tcg_out_brcond for test comparisons

 linux-user/ioctls.h          |  6 ++++++
 linux-user/syscall_defs.h    |  3 +++
 linux-user/elfload.c         | 20 +++++++++++---------
 linux-user/syscall.c         | 22 +++++++++++++++++-----
 tcg/aarch64/tcg-target.c.inc |  4 ++--
 5 files changed, 39 insertions(+), 16 deletions(-)


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

* [PULL 1/8] linux-user: Add FIFREEZE and FITHAW ioctls
  2024-03-12 18:41 [PULL 0/8] tcg + linux-user patch queue Richard Henderson
@ 2024-03-12 18:41 ` Richard Henderson
  2024-03-12 18:41 ` [PULL 2/8] linux-user: Implement PR_{GET,SET}_CHILD_SUBREAPER Richard Henderson
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-03-12 18:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Vogt, Daniel P . Berrangé

From: Michael Vogt <michael.vogt@gmail.com>

Add missing FIFREEZE and FITHAW ioctls.

Signed-off-by: Michael Vogt <michael.vogt@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20240220105726.8852-1-michael.vogt@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/ioctls.h       | 6 ++++++
 linux-user/syscall_defs.h | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 071f7ca253..1aec9d5836 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -134,6 +134,12 @@
      IOCTL(FICLONE, IOC_W, TYPE_INT)
      IOCTL(FICLONERANGE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_file_clone_range)))
 #endif
+#ifdef FIFREEZE
+     IOCTL(FIFREEZE, IOC_W | IOC_R, TYPE_INT)
+#endif
+#ifdef FITHAW
+     IOCTL(FITHAW, IOC_W | IOC_R, TYPE_INT)
+#endif
 
      IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_LONG))
 #ifdef CONFIG_FIEMAP
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 77ba343c85..744fda599e 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -943,6 +943,9 @@ struct target_rtc_pll_info {
 #define TARGET_FICLONE    TARGET_IOW(0x94, 9, abi_int)
 #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range)
 
+#define TARGET_FIFREEZE    TARGET_IOWR('X', 119, abi_int)
+#define TARGET_FITHAW    TARGET_IOWR('X', 120, abi_int)
+
 /*
  * Note that the ioctl numbers for FS_IOC_<GET|SET><FLAGS|VERSION>
  * claim type "long" but the actual type used by the kernel is "int".
-- 
2.34.1



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

* [PULL 2/8] linux-user: Implement PR_{GET,SET}_CHILD_SUBREAPER
  2024-03-12 18:41 [PULL 0/8] tcg + linux-user patch queue Richard Henderson
  2024-03-12 18:41 ` [PULL 1/8] linux-user: Add FIFREEZE and FITHAW ioctls Richard Henderson
@ 2024-03-12 18:41 ` Richard Henderson
  2024-03-12 18:41 ` [PULL 3/8] linux-user: Implement PR_{GET,SET}_SPECULATION_CTRL Richard Henderson
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-03-12 18:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

The "set" prctl passes through integral values.
The "get" prctl returns the value into a pointer.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1929
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 597bdf0c2d..0801ae124d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6450,11 +6450,21 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,
     case PR_SET_NO_NEW_PRIVS:
     case PR_GET_IO_FLUSHER:
     case PR_SET_IO_FLUSHER:
+    case PR_SET_CHILD_SUBREAPER:
         /* Some prctl options have no pointer arguments and we can pass on. */
         return get_errno(prctl(option, arg2, arg3, arg4, arg5));
 
     case PR_GET_CHILD_SUBREAPER:
-    case PR_SET_CHILD_SUBREAPER:
+        {
+            int val;
+            ret = get_errno(prctl(PR_GET_CHILD_SUBREAPER, &val,
+                                  arg3, arg4, arg5));
+            if (!is_error(ret) && put_user_s32(val, arg2)) {
+                return -TARGET_EFAULT;
+            }
+            return ret;
+        }
+
     case PR_GET_SPECULATION_CTRL:
     case PR_SET_SPECULATION_CTRL:
     case PR_GET_TID_ADDRESS:
-- 
2.34.1



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

* [PULL 3/8] linux-user: Implement PR_{GET,SET}_SPECULATION_CTRL
  2024-03-12 18:41 [PULL 0/8] tcg + linux-user patch queue Richard Henderson
  2024-03-12 18:41 ` [PULL 1/8] linux-user: Add FIFREEZE and FITHAW ioctls Richard Henderson
  2024-03-12 18:41 ` [PULL 2/8] linux-user: Implement PR_{GET,SET}_CHILD_SUBREAPER Richard Henderson
@ 2024-03-12 18:41 ` Richard Henderson
  2024-03-12 18:41 ` [PULL 4/8] linux-user: Implement PR_GET_TID_ADDRESS Richard Henderson
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-03-12 18:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

Both of these only pass and return integral values.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 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 0801ae124d..4871c4b648 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6451,6 +6451,8 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,
     case PR_GET_IO_FLUSHER:
     case PR_SET_IO_FLUSHER:
     case PR_SET_CHILD_SUBREAPER:
+    case PR_GET_SPECULATION_CTRL:
+    case PR_SET_SPECULATION_CTRL:
         /* Some prctl options have no pointer arguments and we can pass on. */
         return get_errno(prctl(option, arg2, arg3, arg4, arg5));
 
@@ -6465,8 +6467,6 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,
             return ret;
         }
 
-    case PR_GET_SPECULATION_CTRL:
-    case PR_SET_SPECULATION_CTRL:
     case PR_GET_TID_ADDRESS:
         /* TODO */
         return -TARGET_EINVAL;
-- 
2.34.1



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

* [PULL 4/8] linux-user: Implement PR_GET_TID_ADDRESS
  2024-03-12 18:41 [PULL 0/8] tcg + linux-user patch queue Richard Henderson
                   ` (2 preceding siblings ...)
  2024-03-12 18:41 ` [PULL 3/8] linux-user: Implement PR_{GET,SET}_SPECULATION_CTRL Richard Henderson
@ 2024-03-12 18:41 ` Richard Henderson
  2024-03-12 18:41 ` [PULL 5/8] linux-user/elfload: Don't close an unopened file descriptor Richard Henderson
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-03-12 18:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4871c4b648..e12d969c2e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6468,8 +6468,10 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,
         }
 
     case PR_GET_TID_ADDRESS:
-        /* TODO */
-        return -TARGET_EINVAL;
+        {
+            TaskState *ts = env_cpu(env)->opaque;
+            return put_user_ual(ts->child_tidptr, arg2);
+        }
 
     case PR_GET_FPEXC:
     case PR_SET_FPEXC:
-- 
2.34.1



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

* [PULL 5/8] linux-user/elfload: Don't close an unopened file descriptor
  2024-03-12 18:41 [PULL 0/8] tcg + linux-user patch queue Richard Henderson
                   ` (3 preceding siblings ...)
  2024-03-12 18:41 ` [PULL 4/8] linux-user: Implement PR_GET_TID_ADDRESS Richard Henderson
@ 2024-03-12 18:41 ` Richard Henderson
  2024-03-12 18:41 ` [PULL 6/8] linux-user/elfload: Fully initialize struct target_elf_prpsinfo Richard Henderson
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-03-12 18:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé

Fixes Coverity CID: 1534964
Fixes: 106f8da664 ("linux-user/elfload: Open core file after vma_init")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/elfload.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 4dbca05646..26d4c1d6b3 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -4522,7 +4522,9 @@ static int elf_core_dump(int signr, const CPUArchState *env)
     ret = -errno;
     mmap_unlock();
     cpu_list_unlock();
-    close(fd);
+    if (fd >= 0) {
+        close(fd);
+    }
     return ret;
 }
 #endif /* USE_ELF_CORE_DUMP */
-- 
2.34.1



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

* [PULL 6/8] linux-user/elfload: Fully initialize struct target_elf_prpsinfo
  2024-03-12 18:41 [PULL 0/8] tcg + linux-user patch queue Richard Henderson
                   ` (4 preceding siblings ...)
  2024-03-12 18:41 ` [PULL 5/8] linux-user/elfload: Don't close an unopened file descriptor Richard Henderson
@ 2024-03-12 18:41 ` Richard Henderson
  2024-03-12 18:41 ` [PULL 7/8] tcg/aarch64: Fix tcg_out_cmp for test comparisons Richard Henderson
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-03-12 18:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé

Fixes Coverity CID: 1534962
Fixes: 243c4706625 ("linux-user/elfload: Write corefile elf header in one block")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/elfload.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 26d4c1d6b3..60cf55b36c 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -4204,7 +4204,14 @@ static void fill_prpsinfo_note(void *data, const TaskState *ts)
      * may well have higher alignment requirements, fill locally and
      * memcpy to the destination afterward.
      */
-    struct target_elf_prpsinfo psinfo;
+    struct target_elf_prpsinfo psinfo = {
+        .pr_pid = getpid(),
+        .pr_ppid = getppid(),
+        .pr_pgrp = getpgrp(),
+        .pr_sid = getsid(0),
+        .pr_uid = getuid(),
+        .pr_gid = getgid(),
+    };
     char *base_filename;
     size_t len;
 
@@ -4217,13 +4224,6 @@ static void fill_prpsinfo_note(void *data, const TaskState *ts)
         }
     }
 
-    psinfo.pr_pid = getpid();
-    psinfo.pr_ppid = getppid();
-    psinfo.pr_pgrp = getpgrp();
-    psinfo.pr_sid = getsid(0);
-    psinfo.pr_uid = getuid();
-    psinfo.pr_gid = getgid();
-
     base_filename = g_path_get_basename(ts->bprm->filename);
     /*
      * Using strncpy here is fine: at max-length,
-- 
2.34.1



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

* [PULL 7/8] tcg/aarch64: Fix tcg_out_cmp for test comparisons
  2024-03-12 18:41 [PULL 0/8] tcg + linux-user patch queue Richard Henderson
                   ` (5 preceding siblings ...)
  2024-03-12 18:41 ` [PULL 6/8] linux-user/elfload: Fully initialize struct target_elf_prpsinfo Richard Henderson
@ 2024-03-12 18:41 ` Richard Henderson
  2024-03-12 18:41 ` [PULL 8/8] tcg/aarch64: Fix tcg_out_brcond " Richard Henderson
  2024-03-13 12:36 ` [PULL 0/8] tcg + linux-user patch queue Peter Maydell
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-03-12 18:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Michael Tokarev

Pass the type to tcg_out_logicali; remove the assert, duplicated
at the start of tcg_out_logicali.

Fixes: 339adf2f38e ("tcg/aarch64: Support TCG_COND_TST{EQ,NE}")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/aarch64/tcg-target.c.inc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc
index dec8ecc1b6..38446c167e 100644
--- a/tcg/aarch64/tcg-target.c.inc
+++ b/tcg/aarch64/tcg-target.c.inc
@@ -1388,8 +1388,7 @@ static void tcg_out_cmp(TCGContext *s, TCGType ext, TCGCond cond, TCGReg a,
         if (!const_b) {
             tcg_out_insn(s, 3510, ANDS, ext, TCG_REG_XZR, a, b);
         } else {
-            tcg_debug_assert(is_limm(b));
-            tcg_out_logicali(s, I3404_ANDSI, 0, TCG_REG_XZR, a, b);
+            tcg_out_logicali(s, I3404_ANDSI, ext, TCG_REG_XZR, a, b);
         }
     } else {
         if (!const_b) {
-- 
2.34.1



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

* [PULL 8/8] tcg/aarch64: Fix tcg_out_brcond for test comparisons
  2024-03-12 18:41 [PULL 0/8] tcg + linux-user patch queue Richard Henderson
                   ` (6 preceding siblings ...)
  2024-03-12 18:41 ` [PULL 7/8] tcg/aarch64: Fix tcg_out_cmp for test comparisons Richard Henderson
@ 2024-03-12 18:41 ` Richard Henderson
  2024-03-13 12:36 ` [PULL 0/8] tcg + linux-user patch queue Peter Maydell
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-03-12 18:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé

When converting test vs UINT32_MAX to compare vs 0, we need to
adjust the condition to match.

Fixes: 34aff3c2e06 ("tcg/aarch64: Generate CBNZ for TSTNE of UINT32_MAX")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/aarch64/tcg-target.c.inc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc
index 38446c167e..56fc9cb9e0 100644
--- a/tcg/aarch64/tcg-target.c.inc
+++ b/tcg/aarch64/tcg-target.c.inc
@@ -1464,6 +1464,7 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a,
     case TCG_COND_TSTNE:
         /* tst xN,0xffffffff; b.ne L -> cbnz wN,L */
         if (b_const && b == UINT32_MAX) {
+            c = tcg_tst_eqne_cond(c);
             ext = TCG_TYPE_I32;
             need_cmp = false;
             break;
-- 
2.34.1



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

* Re: [PULL 0/8] tcg + linux-user patch queue
  2024-03-12 18:41 [PULL 0/8] tcg + linux-user patch queue Richard Henderson
                   ` (7 preceding siblings ...)
  2024-03-12 18:41 ` [PULL 8/8] tcg/aarch64: Fix tcg_out_brcond " Richard Henderson
@ 2024-03-13 12:36 ` Peter Maydell
  8 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2024-03-13 12:36 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel

On Tue, 12 Mar 2024 at 18:43, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> The following changes since commit 8f3f329f5e0117bd1a23a79ab751f8a7d3471e4b:
>
>   Merge tag 'migration-20240311-pull-request' of https://gitlab.com/peterx/qemu into staging (2024-03-12 11:35:41 +0000)
>
> are available in the Git repository at:
>
>   https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20240312
>
> for you to fetch changes up to 4fe19bbbea2cb9f1ec28cfd40cdc7f61e95a790e:
>
>   tcg/aarch64: Fix tcg_out_brcond for test comparisons (2024-03-12 04:09:21 -1000)
>
> ----------------------------------------------------------------
> linux-user: Add FIFREEZE and FITHAW ioctls
> linux-user: Implement PR_*_{CHILD_SUBREAPER,SPECULATION_CTRL,TID_ADDRESS}
> linux-user/elfload: Fixes for two Coverity CIDs
> tcg/aarch64: Fixes for two TCG_COND_TST{EQ,NE} bugs
>


Applied, thanks.

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

-- PMM


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

end of thread, other threads:[~2024-03-13 12:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-12 18:41 [PULL 0/8] tcg + linux-user patch queue Richard Henderson
2024-03-12 18:41 ` [PULL 1/8] linux-user: Add FIFREEZE and FITHAW ioctls Richard Henderson
2024-03-12 18:41 ` [PULL 2/8] linux-user: Implement PR_{GET,SET}_CHILD_SUBREAPER Richard Henderson
2024-03-12 18:41 ` [PULL 3/8] linux-user: Implement PR_{GET,SET}_SPECULATION_CTRL Richard Henderson
2024-03-12 18:41 ` [PULL 4/8] linux-user: Implement PR_GET_TID_ADDRESS Richard Henderson
2024-03-12 18:41 ` [PULL 5/8] linux-user/elfload: Don't close an unopened file descriptor Richard Henderson
2024-03-12 18:41 ` [PULL 6/8] linux-user/elfload: Fully initialize struct target_elf_prpsinfo Richard Henderson
2024-03-12 18:41 ` [PULL 7/8] tcg/aarch64: Fix tcg_out_cmp for test comparisons Richard Henderson
2024-03-12 18:41 ` [PULL 8/8] tcg/aarch64: Fix tcg_out_brcond " Richard Henderson
2024-03-13 12:36 ` [PULL 0/8] tcg + linux-user patch queue 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).