aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2024-03-12 21:33:15 +0000
committerPeter Maydell <peter.maydell@linaro.org>2024-03-12 21:33:16 +0000
commita1932d7cd6507d4d9db2044a54731fff3e749bac (patch)
treee72adcccf83fe80770fdd51e1ff6b0a6d7d671e1
parent7e52d0b7c1daa96be317cb2b0f410d024fe46844 (diff)
parent4fe19bbbea2cb9f1ec28cfd40cdc7f61e95a790e (diff)
downloadqemu-a1932d7cd6507d4d9db2044a54731fff3e749bac.zip
qemu-a1932d7cd6507d4d9db2044a54731fff3e749bac.tar.gz
qemu-a1932d7cd6507d4d9db2044a54731fff3e749bac.tar.bz2
Merge tag 'pull-tcg-20240312' of https://gitlab.com/rth7680/qemu into staging
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 # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmXwoYwdHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV99KwgAlUxbn0dPTXKmCkIE # X+FAUllPYCZJwpTCa1h3P8taczLLeAocI4/iJxUudBE77I0HY7jv4FRnWrrdHr/V # rQXjNkpQUByWr0Y4MB6Gl1+AKYo2SNqVHNP5AI4DdgDeSASXhP1aSlT5h4V4gdeX # 1OwSnTQfONInJaoOQ7QQRf3JShKSYZSO7/sjMlJrubgGJBP8ivPxyPKiGbX3zUBS # 6fI/ICLewC/g1fLPKaMHmqdrPK30ubPSGtnKdcz0q5NsT3hy6QWgtrQs5WAf3Liz # 9WKGbq/y+qaFyLHat2tBpDnzT1Jso1SlIMkxL8kau3g6Pvk91E/pZjF5K3JOG8By # PR4uQA== # =FckT # -----END PGP SIGNATURE----- # gpg: Signature made Tue 12 Mar 2024 18:40:12 GMT # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full] # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A 05C0 64DF 38E8 AF7E 215F * tag 'pull-tcg-20240312' of https://gitlab.com/rth7680/qemu: tcg/aarch64: Fix tcg_out_brcond for test comparisons tcg/aarch64: Fix tcg_out_cmp for test comparisons linux-user/elfload: Fully initialize struct target_elf_prpsinfo linux-user/elfload: Don't close an unopened file descriptor linux-user: Implement PR_GET_TID_ADDRESS linux-user: Implement PR_{GET,SET}_SPECULATION_CTRL linux-user: Implement PR_{GET,SET}_CHILD_SUBREAPER linux-user: Add FIFREEZE and FITHAW ioctls Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--linux-user/elfload.c20
-rw-r--r--linux-user/ioctls.h6
-rw-r--r--linux-user/syscall.c22
-rw-r--r--linux-user/syscall_defs.h3
-rw-r--r--tcg/aarch64/tcg-target.c.inc4
5 files changed, 39 insertions, 16 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 4dbca05..60cf55b 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,
@@ -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 */
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 071f7ca..1aec9d5 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.c b/linux-user/syscall.c
index 597bdf0..e12d969 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6450,16 +6450,28 @@ 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:
+ 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));
case PR_GET_CHILD_SUBREAPER:
- case PR_SET_CHILD_SUBREAPER:
- case PR_GET_SPECULATION_CTRL:
- case PR_SET_SPECULATION_CTRL:
+ {
+ 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_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:
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 77ba343..744fda5 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".
diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc
index dec8ecc..56fc9cb 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) {
@@ -1465,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;