Skip to content

Commit

Permalink
Merge tag 'linux-user-for-7.2-pull-request' of https://gitlab.com/lau…
Browse files Browse the repository at this point in the history
…rent_vivier/qemu into staging

linux-user pull request 20220928

use 'max' instead of 'qemu32' / 'qemu64'
add  pidfd_open(), pidfd_send_signal() and pidfd_getfd()
Improve madvise(MADV_DONTNEED)
futex syscal rework
strace improvement
HP/PA fixes and improvement
Misc fixes

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCAAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAmM0AnkSHGxhdXJlbnRA
# dml2aWVyLmV1AAoJEPMMOL0/L748fwwP+wSnEs64bcD7dXTs3LAICKILUtZsb7uR
# XN1wSwd6CXQ5M7USFsSvT0vhm+xpFyDcbq43bc8wV2Ua3mQCBhFziRXLVqdO8xWG
# wjZPVC8/PUFFDBdMEX6iY90OQMfmQlzMX1IXs5nkgyE+LX/GIVuLL+KB4wVhlYBH
# 8/shAuhLLW+eiEF/SHxHBjsXZEWzD/fVhMEglMwsHomgG08EXz7NNYMHrYqaQYwu
# ATct/rkVxbUl3WD1bQZPQ1iBh1ZSqGzm/e/NP393Q9KCQPQnYY9sCpMs9TrsMZXA
# 9oI/1Hn3QOr3VLgRdVTBITOjd6EzMrN83aGEXqyxq2FTOXL5ots4D1VpCuX3/VXX
# Pfdau3XhJLJIaPOwI1SXS3XRFogKuGx/SsKkzMpfZMNmLGLw0tPqCj8S005ItS68
# 8pAwN/r96lwELK0lprrYMGwV6+8MmTXc5/RRgYfJCNblXiWcb+Hv6yJXhcH53reG
# Eid35/0CBhgTNWRrCfLOi9DCjzp5hMrxu2WlZxsKcSPD249RiOOePh2GaP/470/m
# rmDtztPmE3fo5+onKLbSPWNoDk0m08AAJccVqlRzfyTyUskCLSAMM1QP6BMJzxZw
# B3m5llbE3vxb2H2Aj14bAzdEqELmDB7hLd3HTmERen9MlWMa4yWOCBYbxCFGg10g
# J3AAOrCG2sc5
# =76RI
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 28 Sep 2022 04:14:49 EDT
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full]
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* tag 'linux-user-for-7.2-pull-request' of https://gitlab.com/laurent_vivier/qemu: (38 commits)
  linux-user: Add parameters of getrandom() syscall for strace
  linux-user: Log tid for strace
  linux-user: Lock log around strace
  linux-user: Update print_futex_op
  linux-user: Implement PI futexes
  linux-user: Convert signal number for FUTEX_FD
  linux-user: Implement FUTEX_WAKE_BITSET
  linux-user: Sink call to do_safe_futex
  linux-user: Combine do_futex and do_futex_time64
  linux-user: Set ELF_BASE_PLATFORM for MIPS
  linux-user: Introduce stubs for ELF AT_BASE_PLATFORM
  linux-user/s390x: Save/restore fpc when handling a signal
  linux-user: Don't assume 0 is not a valid host timer_t value
  linux-user: fix bug about missing signum convert of sigqueue
  linux-user/hppa: Fix setup_sigcontext()
  linux-user/hppa: Allow PROT_GROWSUP and PROT_GROWSDOWN in mprotect()
  linux-user/hppa: Increase guest stack size to 80MB for hppa target
  linux-user/hppa: Drop stack guard page on hppa target
  linux-user/hppa: Add signal trampoline for hppa target
  linux-user: Add proper strace format strings for getdents()/getdents64()
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
stefanhaRH committed Sep 28, 2022
2 parents 8dfd6e8 + b049978 commit 8b38406
Show file tree
Hide file tree
Showing 43 changed files with 797 additions and 262 deletions.
2 changes: 1 addition & 1 deletion accel/tcg/translate-all.c
Expand Up @@ -2258,7 +2258,7 @@ int page_get_flags(target_ulong address)
#ifndef PAGE_TARGET_STICKY
#define PAGE_TARGET_STICKY 0
#endif
#define PAGE_STICKY (PAGE_ANON | PAGE_TARGET_STICKY)
#define PAGE_STICKY (PAGE_ANON | PAGE_PASSTHROUGH | PAGE_TARGET_STICKY)

/* Modify the flags of a page and invalidate the code if necessary.
The flag PAGE_WRITE_ORG is positioned automatically depending
Expand Down
6 changes: 6 additions & 0 deletions include/exec/cpu-all.h
Expand Up @@ -262,6 +262,12 @@ extern const TargetPageBits target_page;
#define PAGE_TARGET_1 0x0200
#define PAGE_TARGET_2 0x0400

/*
* For linux-user, indicates that the page is mapped with the same semantics
* in both guest and host.
*/
#define PAGE_PASSTHROUGH 0x0800

#if defined(CONFIG_USER_ONLY)
void page_dump(FILE *f);

Expand Down
1 change: 1 addition & 0 deletions linux-user/aarch64/target_mman.h
@@ -0,0 +1 @@
#include "../generic/target_mman.h"
8 changes: 8 additions & 0 deletions linux-user/alpha/target_mman.h
@@ -0,0 +1,8 @@
#ifndef ALPHA_TARGET_MMAN_H
#define ALPHA_TARGET_MMAN_H

#define TARGET_MADV_DONTNEED 6

#include "../generic/target_mman.h"

#endif
1 change: 1 addition & 0 deletions linux-user/arm/target_mman.h
@@ -0,0 +1 @@
#include "../generic/target_mman.h"
2 changes: 2 additions & 0 deletions linux-user/cpu_loop-common.h
Expand Up @@ -27,9 +27,11 @@
do { \
CPUState *cs = env_cpu(env); \
fprintf(stderr, fmt , ## __VA_ARGS__); \
fprintf(stderr, "Failing executable: %s\n", exec_path); \
cpu_dump_state(cs, stderr, 0); \
if (qemu_log_separate()) { \
qemu_log(fmt, ## __VA_ARGS__); \
qemu_log("Failing executable: %s\n", exec_path); \
log_cpu_state(cs, 0); \
} \
} while (0)
Expand Down
1 change: 1 addition & 0 deletions linux-user/cris/target_mman.h
@@ -0,0 +1 @@
#include "../generic/target_mman.h"
73 changes: 67 additions & 6 deletions linux-user/elfload.c
Expand Up @@ -1080,6 +1080,37 @@ static uint32_t get_elf_hwcap(void)
#define elf_check_abi(x) (!((x) & EF_MIPS_ABI2))
#endif

#define ELF_BASE_PLATFORM get_elf_base_platform()

#define MATCH_PLATFORM_INSN(_flags, _base_platform) \
do { if ((cpu->env.insn_flags & (_flags)) == _flags) \
{ return _base_platform; } } while (0)

static const char *get_elf_base_platform(void)
{
MIPSCPU *cpu = MIPS_CPU(thread_cpu);

/* 64 bit ISAs goes first */
MATCH_PLATFORM_INSN(CPU_MIPS64R6, "mips64r6");
MATCH_PLATFORM_INSN(CPU_MIPS64R5, "mips64r5");
MATCH_PLATFORM_INSN(CPU_MIPS64R2, "mips64r2");
MATCH_PLATFORM_INSN(CPU_MIPS64R1, "mips64");
MATCH_PLATFORM_INSN(CPU_MIPS5, "mips5");
MATCH_PLATFORM_INSN(CPU_MIPS4, "mips4");
MATCH_PLATFORM_INSN(CPU_MIPS3, "mips3");

/* 32 bit ISAs */
MATCH_PLATFORM_INSN(CPU_MIPS32R6, "mips32r6");
MATCH_PLATFORM_INSN(CPU_MIPS32R5, "mips32r5");
MATCH_PLATFORM_INSN(CPU_MIPS32R2, "mips32r2");
MATCH_PLATFORM_INSN(CPU_MIPS32R1, "mips32");
MATCH_PLATFORM_INSN(CPU_MIPS2, "mips2");

/* Fallback */
return "mips";
}
#undef MATCH_PLATFORM_INSN

static inline void init_thread(struct target_pt_regs *regs,
struct image_info *infop)
{
Expand Down Expand Up @@ -1776,6 +1807,10 @@ static inline void init_thread(struct target_pt_regs *regs,

#endif /* TARGET_HEXAGON */

#ifndef ELF_BASE_PLATFORM
#define ELF_BASE_PLATFORM (NULL)
#endif

#ifndef ELF_PLATFORM
#define ELF_PLATFORM (NULL)
#endif
Expand Down Expand Up @@ -2096,9 +2131,15 @@ static abi_ulong setup_arg_pages(struct linux_binprm *bprm,
if (size < STACK_LOWER_LIMIT) {
size = STACK_LOWER_LIMIT;
}
guard = TARGET_PAGE_SIZE;
if (guard < qemu_real_host_page_size()) {
guard = qemu_real_host_page_size();

if (STACK_GROWS_DOWN) {
guard = TARGET_PAGE_SIZE;
if (guard < qemu_real_host_page_size()) {
guard = qemu_real_host_page_size();
}
} else {
/* no guard page for hppa target where stack grows upwards. */
guard = 0;
}

prot = PROT_READ | PROT_WRITE;
Expand All @@ -2118,7 +2159,6 @@ static abi_ulong setup_arg_pages(struct linux_binprm *bprm,
info->stack_limit = error + guard;
return info->stack_limit + size - sizeof(void *);
} else {
target_mprotect(error + size, guard, PROT_NONE);
info->stack_limit = error + size;
return error;
}
Expand Down Expand Up @@ -2215,8 +2255,8 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
int i;
abi_ulong u_rand_bytes;
uint8_t k_rand_bytes[16];
abi_ulong u_platform;
const char *k_platform;
abi_ulong u_platform, u_base_platform;
const char *k_platform, *k_base_platform;
const int n = sizeof(elf_addr_t);

sp = p;
Expand All @@ -2238,6 +2278,22 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
}
}

u_base_platform = 0;
k_base_platform = ELF_BASE_PLATFORM;
if (k_base_platform) {
size_t len = strlen(k_base_platform) + 1;
if (STACK_GROWS_DOWN) {
sp -= (len + n - 1) & ~(n - 1);
u_base_platform = sp;
/* FIXME - check return value of memcpy_to_target() for failure */
memcpy_to_target(sp, k_base_platform, len);
} else {
memcpy_to_target(sp, k_base_platform, len);
u_base_platform = sp;
sp += len + 1;
}
}

u_platform = 0;
k_platform = ELF_PLATFORM;
if (k_platform) {
Expand Down Expand Up @@ -2279,6 +2335,8 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
}

size = (DLINFO_ITEMS + 1) * 2;
if (k_base_platform)
size += 2;
if (k_platform)
size += 2;
#ifdef DLINFO_ARCH_ITEMS
Expand Down Expand Up @@ -2356,6 +2414,9 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
NEW_AUX_ENT(AT_HWCAP2, (abi_ulong) ELF_HWCAP2);
#endif

if (u_base_platform) {
NEW_AUX_ENT(AT_BASE_PLATFORM, u_base_platform);
}
if (u_platform) {
NEW_AUX_ENT(AT_PLATFORM, u_platform);
}
Expand Down
92 changes: 92 additions & 0 deletions linux-user/generic/target_mman.h
@@ -0,0 +1,92 @@
#ifndef LINUX_USER_TARGET_MMAN_H
#define LINUX_USER_TARGET_MMAN_H

#ifndef TARGET_MADV_NORMAL
#define TARGET_MADV_NORMAL 0
#endif

#ifndef TARGET_MADV_RANDOM
#define TARGET_MADV_RANDOM 1
#endif

#ifndef TARGET_MADV_SEQUENTIAL
#define TARGET_MADV_SEQUENTIAL 2
#endif

#ifndef TARGET_MADV_WILLNEED
#define TARGET_MADV_WILLNEED 3
#endif

#ifndef TARGET_MADV_DONTNEED
#define TARGET_MADV_DONTNEED 4
#endif

#ifndef TARGET_MADV_FREE
#define TARGET_MADV_FREE 8
#endif

#ifndef TARGET_MADV_REMOVE
#define TARGET_MADV_REMOVE 9
#endif

#ifndef TARGET_MADV_DONTFORK
#define TARGET_MADV_DONTFORK 10
#endif

#ifndef TARGET_MADV_DOFORK
#define TARGET_MADV_DOFORK 11
#endif

#ifndef TARGET_MADV_MERGEABLE
#define TARGET_MADV_MERGEABLE 12
#endif

#ifndef TARGET_MADV_UNMERGEABLE
#define TARGET_MADV_UNMERGEABLE 13
#endif

#ifndef TARGET_MADV_HUGEPAGE
#define TARGET_MADV_HUGEPAGE 14
#endif

#ifndef TARGET_MADV_NOHUGEPAGE
#define TARGET_MADV_NOHUGEPAGE 15
#endif

#ifndef TARGET_MADV_DONTDUMP
#define TARGET_MADV_DONTDUMP 16
#endif

#ifndef TARGET_MADV_DODUMP
#define TARGET_MADV_DODUMP 17
#endif

#ifndef TARGET_MADV_WIPEONFORK
#define TARGET_MADV_WIPEONFORK 18
#endif

#ifndef TARGET_MADV_KEEPONFORK
#define TARGET_MADV_KEEPONFORK 19
#endif

#ifndef TARGET_MADV_COLD
#define TARGET_MADV_COLD 20
#endif

#ifndef TARGET_MADV_PAGEOUT
#define TARGET_MADV_PAGEOUT 21
#endif

#ifndef TARGET_MADV_POPULATE_READ
#define TARGET_MADV_POPULATE_READ 22
#endif

#ifndef TARGET_MADV_POPULATE_WRITE
#define TARGET_MADV_POPULATE_WRITE 23
#endif

#ifndef TARGET_MADV_DONTNEED_LOCKED
#define TARGET_MADV_DONTNEED_LOCKED 24
#endif

#endif
1 change: 1 addition & 0 deletions linux-user/hexagon/target_mman.h
@@ -0,0 +1 @@
#include "../generic/target_mman.h"
6 changes: 5 additions & 1 deletion linux-user/hppa/cpu_loop.c
Expand Up @@ -147,12 +147,15 @@ void cpu_loop(CPUHPPAState *env)
force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, env->iaoq_f);
break;
case EXCP_ILL:
EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr);
force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->iaoq_f);
break;
case EXCP_PRIV_OPR:
EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr);
force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->iaoq_f);
break;
case EXCP_PRIV_REG:
EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr);
force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVREG, env->iaoq_f);
break;
case EXCP_OVERFLOW:
Expand All @@ -171,7 +174,8 @@ void cpu_loop(CPUHPPAState *env)
/* just indicate that signals should be handled asap */
break;
default:
g_assert_not_reached();
EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
abort();
}
process_pending_signals(env);
}
Expand Down

0 comments on commit 8b38406

Please sign in to comment.