* [PULL 0/5] misc patch queue
@ 2024-07-30 1:11 Richard Henderson
2024-07-30 1:11 ` [PULL 1/5] target/rx: Use target_ulong for address in LI Richard Henderson
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Richard Henderson @ 2024-07-30 1:11 UTC (permalink / raw)
To: qemu-devel
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(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PULL 1/5] target/rx: Use target_ulong for address in LI
2024-07-30 1:11 [PULL 0/5] misc patch queue Richard Henderson
@ 2024-07-30 1:11 ` Richard Henderson
2024-07-30 1:11 ` [PATCH for-9.1] tests/vm/openbsd: Install tomli Richard Henderson
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Richard Henderson @ 2024-07-30 1:11 UTC (permalink / raw)
To: qemu-devel; +Cc: Thomas Huth
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
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
---
target/rx/translate.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/target/rx/translate.c b/target/rx/translate.c
index 9b81cf20b3..9aade2b6e5 100644
--- a/target/rx/translate.c
+++ b/target/rx/translate.c
@@ -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;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH for-9.1] tests/vm/openbsd: Install tomli
2024-07-30 1:11 [PULL 0/5] misc patch queue Richard Henderson
2024-07-30 1:11 ` [PULL 1/5] target/rx: Use target_ulong for address in LI Richard Henderson
@ 2024-07-30 1:11 ` Richard Henderson
2024-07-30 6:53 ` Philippe Mathieu-Daudé
2024-07-30 1:11 ` [PULL 2/5] util/getauxval: Ensure setting errno if not found Richard Henderson
` (4 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: Richard Henderson @ 2024-07-30 1:11 UTC (permalink / raw)
To: qemu-devel
Tomli is now required by configure.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tests/vm/openbsd | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/vm/openbsd b/tests/vm/openbsd
index 5e646f7c51..49cab08782 100755
--- a/tests/vm/openbsd
+++ b/tests/vm/openbsd
@@ -32,6 +32,7 @@ class OpenBSDVM(basevm.BaseVM):
"pkgconf",
"bzip2", "xz",
"ninja",
+ "py3-tomli",
# gnu tools
"bash",
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PULL 2/5] util/getauxval: Ensure setting errno if not found
2024-07-30 1:11 [PULL 0/5] misc patch queue Richard Henderson
2024-07-30 1:11 ` [PULL 1/5] target/rx: Use target_ulong for address in LI Richard Henderson
2024-07-30 1:11 ` [PATCH for-9.1] tests/vm/openbsd: Install tomli Richard Henderson
@ 2024-07-30 1:11 ` Richard Henderson
2024-07-30 1:12 ` [PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD Richard Henderson
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Richard Henderson @ 2024-07-30 1:11 UTC (permalink / raw)
To: qemu-devel; +Cc: Vivian Wang
From: Vivian Wang <uwu@dram.page>
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.
Signed-off-by: Vivian Wang <uwu@dram.page>
Message-ID: <20240723100545.405476-2-uwu@dram.page>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
util/getauxval.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/util/getauxval.c b/util/getauxval.c
index b124107d61..ad4f6686a8 100644
--- a/util/getauxval.c
+++ b/util/getauxval.c
@@ -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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD
2024-07-30 1:11 [PULL 0/5] misc patch queue Richard Henderson
` (2 preceding siblings ...)
2024-07-30 1:11 ` [PULL 2/5] util/getauxval: Ensure setting errno if not found Richard Henderson
@ 2024-07-30 1:12 ` Richard Henderson
2024-07-30 1:12 ` [PULL 4/5] util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD Richard Henderson
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Richard Henderson @ 2024-07-30 1:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Vivian Wang
From: Vivian Wang <uwu@dram.page>
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.
Signed-off-by: Vivian Wang <uwu@dram.page>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Fixes: 0b959cf5e4cc ("linux-user: Use qemu_getauxval for AT_EXECFD")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2448
Message-ID: <20240723100545.405476-3-uwu@dram.page>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 7d3cf45fa9..8143a0d4b0 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -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));
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PULL 4/5] util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD
2024-07-30 1:11 [PULL 0/5] misc patch queue Richard Henderson
` (3 preceding siblings ...)
2024-07-30 1:12 ` [PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD Richard Henderson
@ 2024-07-30 1:12 ` Richard Henderson
2024-07-30 1:12 ` [PULL 5/5] linux-user: open_self_stat: Implement num_threads Richard Henderson
2024-07-30 5:31 ` [PULL 0/5] misc patch queue Richard Henderson
6 siblings, 0 replies; 9+ messages in thread
From: Richard Henderson @ 2024-07-30 1:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Brad Smith
From: Brad Smith <brad@comstyle.com>
Signed-off-by: Brad Smith <brad@comstyle.com>
Message-ID: <ZqXB_zz0fR1CpA7k@humpty.home.comstyle.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
util/cpuinfo-aarch64.c | 9 ++++++---
util/cpuinfo-ppc.c | 5 +++--
util/getauxval.c | 2 +-
meson.build | 8 ++++++++
4 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/util/cpuinfo-aarch64.c b/util/cpuinfo-aarch64.c
index 8ca775a14b..57468890c3 100644
--- a/util/cpuinfo-aarch64.c
+++ b/util/cpuinfo-aarch64.c
@@ -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;
diff --git a/util/cpuinfo-ppc.c b/util/cpuinfo-ppc.c
index 1304f9aa80..4d3d3aae0b 100644
--- a/util/cpuinfo-ppc.c
+++ b/util/cpuinfo-ppc.c
@@ -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);
diff --git a/util/getauxval.c b/util/getauxval.c
index ad4f6686a8..0735cd8271 100644
--- a/util/getauxval.c
+++ b/util/getauxval.c
@@ -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)
diff --git a/meson.build b/meson.build
index 5613b62a4f..97f63aa86c 100644
--- a/meson.build
+++ b/meson.build
@@ -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>
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PULL 5/5] linux-user: open_self_stat: Implement num_threads
2024-07-30 1:11 [PULL 0/5] misc patch queue Richard Henderson
` (4 preceding siblings ...)
2024-07-30 1:12 ` [PULL 4/5] util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD Richard Henderson
@ 2024-07-30 1:12 ` Richard Henderson
2024-07-30 5:31 ` [PULL 0/5] misc patch queue Richard Henderson
6 siblings, 0 replies; 9+ messages in thread
From: Richard Henderson @ 2024-07-30 1:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Fabio D'Urso, Alex Bennée
From: Fabio D'Urso <fdurso@google.com>
The num_threads field reports the total number of threads in the
process. In QEMU, this is equal to the number of CPU instances.
Signed-off-by: Fabio D'Urso <fdurso@google.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20240619194109.248066-1-fdurso@google.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/syscall.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b8c278b91d..9d5415674d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PULL 0/5] misc patch queue
2024-07-30 1:11 [PULL 0/5] misc patch queue Richard Henderson
` (5 preceding siblings ...)
2024-07-30 1:12 ` [PULL 5/5] linux-user: open_self_stat: Implement num_threads Richard Henderson
@ 2024-07-30 5:31 ` Richard Henderson
6 siblings, 0 replies; 9+ messages in thread
From: Richard Henderson @ 2024-07-30 5:31 UTC (permalink / raw)
To: qemu-devel
On 7/30/24 11:11, Richard Henderson wrote:
> 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(-)
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/9.1 as appropriate.
r~
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH for-9.1] tests/vm/openbsd: Install tomli
2024-07-30 1:11 ` [PATCH for-9.1] tests/vm/openbsd: Install tomli Richard Henderson
@ 2024-07-30 6:53 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-30 6:53 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
On 30/7/24 03:11, Richard Henderson wrote:
> Tomli is now required by configure.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> tests/vm/openbsd | 1 +
> 1 file changed, 1 insertion(+)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-07-30 6:54 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-30 1:11 [PULL 0/5] misc patch queue Richard Henderson
2024-07-30 1:11 ` [PULL 1/5] target/rx: Use target_ulong for address in LI Richard Henderson
2024-07-30 1:11 ` [PATCH for-9.1] tests/vm/openbsd: Install tomli Richard Henderson
2024-07-30 6:53 ` Philippe Mathieu-Daudé
2024-07-30 1:11 ` [PULL 2/5] util/getauxval: Ensure setting errno if not found Richard Henderson
2024-07-30 1:12 ` [PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD Richard Henderson
2024-07-30 1:12 ` [PULL 4/5] util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD Richard Henderson
2024-07-30 1:12 ` [PULL 5/5] linux-user: open_self_stat: Implement num_threads Richard Henderson
2024-07-30 5:31 ` [PULL 0/5] misc patch queue Richard Henderson
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).