Skip to contentSkip to conversation

misc patch queue

GIT PULL In review Richard Henderson 2 participants 9 messages Jul 30, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

The following changes since commit 93b799fafd9170da3a79a533ea6f73a18de82e22:

Merge tag 'pull-ppc-for-9.1-2-20240726-1' of https://gitlab.com/npiggin/qemu into staging (2024-07-26 15:10:45 +1000)

are available in the Git repository at:

https://gitlab.com/rth7680/qemu.git tags/pull-misc-20240730

for you to fetch changes up to d9b019e0a05cbbaa184815dd201b25006950c6d7:

linux-user: open_self_stat: Implement num_threads (2024-07-30 07:59:23 +1000)

----------------------------------------------------------------
util/getauxval: Ensure setting errno if not found util/getauxval: Use elf_aux_info on OpenBSD
linux-user: open_self_stat: Implement num_threads target/rx: Use target_ulong for address in LI

----------------------------------------------------------------
Brad Smith (1):
util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD

Fabio D'Urso (1):
linux-user: open_self_stat: Implement num_threads

Richard Henderson (1):
target/rx: Use target_ulong for address in LI

Vivian Wang (2):
util/getauxval: Ensure setting errno if not found linux-user/main: Check errno when getting AT_EXECFD

 linux-user/main.c      |  3 ++-
 linux-user/syscall.c   | 10 ++++++++++
 target/rx/translate.c  |  3 ++-
 util/cpuinfo-aarch64.c |  9 ++++++---
 util/cpuinfo-ppc.c     |  5 +++--
 util/getauxval.c       |  9 +++++++--
 meson.build            |  8 ++++++++
 7 files changed, 38 insertions(+), 9 deletions(-)
#1 lore raw

[PULL 2/5] util/getauxval: Ensure setting errno if not found

From: Vivian Wang <[email protected]>

Sometimes zero is a valid value for getauxval (e.g. AT_EXECFD). Make sure that we can distinguish between a valid zero value and a not found entry by setting errno.

Assumes that getauxval from sys/auxv.h sets errno correctly.

Message-ID: <[email protected]>

---
 util/getauxval.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
util/getauxval.c +6 -1
index b124107d61..ad4f6686a8 100644
@@ -95,6 +95,7 @@ unsigned long qemu_getauxval(unsigned long type)
         }
     }
 
+    errno = ENOENT;
     return 0;
 }
 
@@ -104,7 +105,10 @@ unsigned long qemu_getauxval(unsigned long type)
 unsigned long qemu_getauxval(unsigned long type)
 {
     unsigned long aux = 0;
-    elf_aux_info(type, &aux, sizeof(aux));
+    int ret = elf_aux_info(type, &aux, sizeof(aux));
+    if (ret != 0) {
+        errno = ret;
+    }
     return aux;
 }
 
@@ -112,6 +116,7 @@ unsigned long qemu_getauxval(unsigned long type)
 
 unsigned long qemu_getauxval(unsigned long type)
 {
+    errno = ENOSYS;
     return 0;
 }
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH 1/1 tests/vm/openbsd: Install tomli

In reply to Richard Henderson

Tomli is now required by configure.

---
 tests/vm/openbsd | 1 +
 1 file changed, 1 insertion(+)
tests/vm/openbsd +1 -0
index 5e646f7c51..49cab08782 100755
@@ -32,6 +32,7 @@ class OpenBSDVM(basevm.BaseVM):
         "pkgconf",
         "bzip2", "xz",
         "ninja",
+        "py3-tomli",
 
         # gnu tools
         "bash",
Signature · 1 line
2.43.0
#4 lore raw

[PULL 1/5] target/rx: Use target_ulong for address in LI

In reply to Richard Henderson

Using int32_t meant that the address was sign-extended to uint64_t when passing to translator_ld*, triggering an assert.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2453

---
 target/rx/translate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target/rx/translate.c +2 -1
index 9b81cf20b3..9aade2b6e5 100644
@@ -85,7 +85,8 @@ static uint32_t decode_load_bytes(DisasContext *ctx, uint32_t insn,
 
 static uint32_t li(DisasContext *ctx, int sz)
 {
-    int32_t tmp, addr;
+    target_ulong addr;
+    uint32_t tmp;
     CPURXState *env = ctx->env;
     addr = ctx->base.pc_next;
 
Signature · 1 line
2.43.0
#5 lore raw

[PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD

In reply to Richard Henderson

From: Vivian Wang <[email protected]>

It's possible for AT_EXECFD to end up with a valid value of 0. Check errno when using qemu_getauxval instead of return value to handle this case.

Not handling this case leads to a confusing condition where the executable ends up as fd 0, i.e. stdin.

Fixes 0b959cf5e4cc ("linux-user: Use qemu_getauxval for AT_EXECFD")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2448
Message-ID: <[email protected]>

---
 linux-user/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/main.c +2 -1
index 7d3cf45fa9..8143a0d4b0 100644
@@ -755,8 +755,9 @@ int main(int argc, char **argv, char **envp)
     /*
      * Manage binfmt-misc open-binary flag
      */
+    errno = 0;
     execfd = qemu_getauxval(AT_EXECFD);
-    if (execfd == 0) {
+    if (errno != 0) {
         execfd = open(exec_path, O_RDONLY);
         if (execfd < 0) {
             printf("Error while loading %s: %s\n", exec_path, strerror(errno));
Signature · 1 line
2.43.0
#6 lore raw

[PULL 4/5] util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD

In reply to Richard Henderson

From: Brad Smith <[email protected]>

Message-ID: <[email protected]>

---
 util/cpuinfo-aarch64.c | 9 ++++++---
 util/cpuinfo-ppc.c     | 5 +++--
 util/getauxval.c       | 2 +-
 meson.build            | 8 ++++++++
 4 files changed, 18 insertions(+), 6 deletions(-)
util/cpuinfo-aarch64.c +6 -3
index 8ca775a14b..57468890c3 100644
@@ -17,10 +17,13 @@
 #  define HWCAP2_BTI 0  /* added in glibc 2.32 */
 # endif
 #endif
+#ifdef CONFIG_ELF_AUX_INFO
+#include <sys/auxv.h>
+#endif
 #ifdef CONFIG_DARWIN
 # include <sys/sysctl.h>
 #endif
-#ifdef __OpenBSD__
+#if defined(__OpenBSD__) && !defined(CONFIG_ELF_AUX_INFO)
 # include <machine/armreg.h>
 # include <machine/cpu.h>
 # include <sys/types.h>
@@ -61,7 +64,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void)
 
     info = CPUINFO_ALWAYS;
 
-#ifdef CONFIG_LINUX
+#if defined(CONFIG_LINUX) || defined(CONFIG_ELF_AUX_INFO)
     unsigned long hwcap = qemu_getauxval(AT_HWCAP);
     info |= (hwcap & HWCAP_ATOMICS ? CPUINFO_LSE : 0);
     info |= (hwcap & HWCAP_USCAT ? CPUINFO_LSE2 : 0);
@@ -78,7 +81,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void)
     info |= sysctl_for_bool("hw.optional.arm.FEAT_PMULL") * CPUINFO_PMULL;
     info |= sysctl_for_bool("hw.optional.arm.FEAT_BTI") * CPUINFO_BTI;
 #endif
-#ifdef __OpenBSD__
+#if defined(__OpenBSD__) && !defined(CONFIG_ELF_AUX_INFO)
     int mib[2];
     uint64_t isar0;
     uint64_t pfr1;
util/cpuinfo-ppc.c +3 -2
index 1304f9aa80..4d3d3aae0b 100644
@@ -14,7 +14,8 @@
 #  include "elf.h"
 # endif
 #endif
-#ifdef __FreeBSD__
+#if defined(CONFIG_ELF_AUX_INFO)
+# include <sys/auxv.h>
 # include <machine/cpu.h>
 # ifndef PPC_FEATURE2_ARCH_3_1
 #  define PPC_FEATURE2_ARCH_3_1   0
@@ -35,7 +36,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void)
 
     info = CPUINFO_ALWAYS;
 
-#if defined(CONFIG_LINUX) || defined(__FreeBSD__)
+#if defined(CONFIG_LINUX) || defined(CONFIG_ELF_AUX_INFO)
     unsigned long hwcap = qemu_getauxval(AT_HWCAP);
     unsigned long hwcap2 = qemu_getauxval(AT_HWCAP2);
 
util/getauxval.c +1 -1
index ad4f6686a8..0735cd8271 100644
@@ -99,7 +99,7 @@ unsigned long qemu_getauxval(unsigned long type)
     return 0;
 }
 
-#elif defined(__FreeBSD__)
+#elif defined(CONFIG_ELF_AUX_INFO)
 #include <sys/auxv.h>
 
 unsigned long qemu_getauxval(unsigned long type)
meson.build +8 -0
index 5613b62a4f..97f63aa86c 100644
@@ -2835,6 +2835,14 @@ config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + '''
     return getauxval(AT_HWCAP) == 0;
   }'''))
 
+config_host_data.set('CONFIG_ELF_AUX_INFO', cc.links(gnu_source_prefix + '''
+  #include <sys/auxv.h>
+  int main(void) {
+    unsigned long hwcap = 0;
+    elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
+    return hwcap;
+  }'''))
+
 config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles('''
   #include <linux/usbdevice_fs.h>
 
Signature · 1 line
2.43.0
#7 lore raw

[PULL 5/5] linux-user: open_self_stat: Implement num_threads

In reply to Richard Henderson

From: Fabio D'Urso <[email protected]>

The num_threads field reports the total number of threads in the process. In QEMU, this is equal to the number of CPU instances.

Message-ID: <[email protected]>

---
 linux-user/syscall.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
linux-user/syscall.c +10 -0
index b8c278b91d..9d5415674d 100644
@@ -8168,6 +8168,16 @@ static int open_self_stat(CPUArchState *cpu_env, int fd)
         } else if (i == 3) {
             /* ppid */
             g_string_printf(buf, FMT_pid " ", getppid());
+        } else if (i == 19) {
+            /* num_threads */
+            int cpus = 0;
+            WITH_RCU_READ_LOCK_GUARD() {
+                CPUState *cpu_iter;
+                CPU_FOREACH(cpu_iter) {
+                    cpus++;
+                }
+            }
+            g_string_printf(buf, "%d ", cpus);
         } else if (i == 21) {
             /* starttime */
             g_string_printf(buf, "%" PRIu64 " ", ts->start_boottime);
Signature · 1 line
2.43.0
author Applied
#8 lore raw
In reply to Richard Henderson
Quoted 32 lines · Richard Henderson

The following changes since commit 93b799fafd9170da3a79a533ea6f73a18de82e22:

   Merge tag 'pull-ppc-for-9.1-2-20240726-1' of https://gitlab.com/npiggin/qemu into staging (2024-07-26 15:10:45 +1000)

are available in the Git repository at:

   https://gitlab.com/rth7680/qemu.git tags/pull-misc-20240730

for you to fetch changes up to d9b019e0a05cbbaa184815dd201b25006950c6d7:

   linux-user: open_self_stat: Implement num_threads (2024-07-30 07:59:23 +1000)

----------------------------------------------------------------
util/getauxval: Ensure setting errno if not found util/getauxval: Use elf_aux_info on OpenBSD
linux-user: open_self_stat: Implement num_threads target/rx: Use target_ulong for address in LI

----------------------------------------------------------------
Brad Smith (1):
util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD

Fabio D'Urso (1):
linux-user: open_self_stat: Implement num_threads

Richard Henderson (1):
target/rx: Use target_ulong for address in LI

Vivian Wang (2):
util/getauxval: Ensure setting errno if not found linux-user/main: Check errno when getting AT_EXECFD

Quoted 8 lines
  linux-user/main.c      |  3 ++-
  linux-user/syscall.c   | 10 ++++++++++
  target/rx/translate.c  |  3 ++-
  util/cpuinfo-aarch64.c |  9 ++++++---
  util/cpuinfo-ppc.c     |  5 +++--
  util/getauxval.c       |  9 +++++++--
  meson.build            |  8 ++++++++
  7 files changed, 38 insertions(+), 9 deletions(-)

Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/9.1 as appropriate.

r~