mirror of https://github.com/xemu-project/xemu.git
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 -----BEGIN PGP SIGNATURE----- iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmaoPYUdHHJpY2hhcmQu aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV/QoQgAhqVcFGTLW9ozw8cR 7DMloHfDbcZTmjQIUvq2WPWCGpUj6mXZXQCM7QAjfGVSa45zOsmRyTRM/If0aZxq r0/rQmNVchJ2bjnzz83tu1A+a2+yXLwzzfUdBZ6Jg91vSOrJ0io8CyHSIdtLrFlK mV/LQ5viFdhlqk5GO0o/vdAgBgz6rVk4Uwuc/wl88JR5AHk7tRB21XC2ZzhfupBR 7QnIru6K1Ltm1sJYxW7qX7DC720iqLeS/LFH67Q2f9eVgejUevoOPmCyOvVmt1kr VPwmxKUs46M3qs6zQ2DuPVIgXZof3Xs1C7jcPR6wvXzVcsof3X1Ma70zdVHWXkCN XKrTHQ== =WadL -----END PGP SIGNATURE----- Merge tag 'pull-misc-20240730' of https://gitlab.com/rth7680/qemu into staging 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 # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmaoPYUdHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV/QoQgAhqVcFGTLW9ozw8cR # 7DMloHfDbcZTmjQIUvq2WPWCGpUj6mXZXQCM7QAjfGVSa45zOsmRyTRM/If0aZxq # r0/rQmNVchJ2bjnzz83tu1A+a2+yXLwzzfUdBZ6Jg91vSOrJ0io8CyHSIdtLrFlK # mV/LQ5viFdhlqk5GO0o/vdAgBgz6rVk4Uwuc/wl88JR5AHk7tRB21XC2ZzhfupBR # 7QnIru6K1Ltm1sJYxW7qX7DC720iqLeS/LFH67Q2f9eVgejUevoOPmCyOvVmt1kr # VPwmxKUs46M3qs6zQ2DuPVIgXZof3Xs1C7jcPR6wvXzVcsof3X1Ma70zdVHWXkCN # XKrTHQ== # =WadL # -----END PGP SIGNATURE----- # gpg: Signature made Tue 30 Jul 2024 11:10:29 AM AEST # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate] * tag 'pull-misc-20240730' of https://gitlab.com/rth7680/qemu: linux-user: open_self_stat: Implement num_threads util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD linux-user/main: Check errno when getting AT_EXECFD util/getauxval: Ensure setting errno if not found target/rx: Use target_ulong for address in LI Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
commit
8617cb073c
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -95,16 +95,20 @@ unsigned long qemu_getauxval(unsigned long type)
|
|||
}
|
||||
}
|
||||
|
||||
errno = ENOENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(CONFIG_ELF_AUX_INFO)
|
||||
#include <sys/auxv.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue