aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-04-07 22:12:04 +0100
committerPeter Maydell <peter.maydell@linaro.org>2020-04-07 22:12:05 +0100
commite715f7b77ee12588b37ef25701373977d1fb02b9 (patch)
tree318802eb8a04950e1063e3b4c7af8cabf6b09367 /linux-user
parent3f1082e5b856a9c96baefdfa66504c17665234f9 (diff)
parentcce743abbf398a324879039cd582349b36da0ea6 (diff)
downloadqemu-e715f7b77ee12588b37ef25701373977d1fb02b9.zip
qemu-e715f7b77ee12588b37ef25701373977d1fb02b9.tar.gz
qemu-e715f7b77ee12588b37ef25701373977d1fb02b9.tar.bz2
Merge remote-tracking branch 'remotes/stsquad/tags/pull-misc-fixes-070420-1' into staging
Various fixes: - add .github repo lockdown config - better handle missing symbols in elf-ops - protect fcntl64 with #ifdef - remove unused macros from test - fix handling of /proc/self/maps - avoid BAD_SHIFT in x80 softfloat - properly terminate on .hex EOF - fix configure probe on windows cross build - fix %r12 guest_base initialization # gpg: Signature made Tue 07 Apr 2020 16:31:14 BST # gpg: using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44 # gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [full] # Primary key fingerprint: 6685 AE99 E751 67BC AFC8 DF35 FBD0 DB09 5A9E 2A44 * remotes/stsquad/tags/pull-misc-fixes-070420-1: tcg/i386: Fix %r12 guest_base initialization configure: Add -Werror to PIE probe hw/core: properly terminate loading .hex on EOF record linux-user: clean-up padding on /proc/self/maps linux-user: factor out reading of /proc/self/maps softfloat: Fix BAD_SHIFT from normalizeFloatx80Subnormal gdbstub: fix compiler complaining target/xtensa: add FIXME for translation memory leak linux-user: more debug for init_guest_space tests/tcg: remove extraneous pasting macros linux-user: protect fcntl64 with an #ifdef elf-ops: bail out if we have no function symbols .github: Enable repo-lockdown bot to refuse GitHub pull requests Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/elfload.c8
-rw-r--r--linux-user/syscall.c80
2 files changed, 49 insertions, 39 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 8198be0..619c054 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2172,6 +2172,8 @@ unsigned long init_guest_space(unsigned long host_start,
/* Check to see if the address is valid. */
if (host_start && real_start != current_start) {
+ qemu_log_mask(CPU_LOG_PAGE, "invalid %lx && %lx != %lx\n",
+ host_start, real_start, current_start);
goto try_again;
}
@@ -2240,7 +2242,11 @@ unsigned long init_guest_space(unsigned long host_start,
* probably a bad strategy if not, which means we got here
* because of trouble with ARM commpage setup.
*/
- munmap((void *)real_start, real_size);
+ if (munmap((void *)real_start, real_size) != 0) {
+ error_report("%s: failed to unmap %lx:%lx (%s)", __func__,
+ real_start, real_size, strerror(errno));
+ abort();
+ }
current_start += align;
if (host_start == current_start) {
/* Theoretically possible if host doesn't have any suitably
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 5af55fc..6495ddc 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -117,6 +117,7 @@
#include "qemu.h"
#include "qemu/guest-random.h"
+#include "qemu/selfmap.h"
#include "user/syscall-trace.h"
#include "qapi/error.h"
#include "fd-trans.h"
@@ -7232,58 +7233,61 @@ static int open_self_maps(void *cpu_env, int fd)
{
CPUState *cpu = env_cpu((CPUArchState *)cpu_env);
TaskState *ts = cpu->opaque;
- FILE *fp;
- char *line = NULL;
- size_t len = 0;
- ssize_t read;
+ GSList *map_info = read_self_maps();
+ GSList *s;
+ int count;
- fp = fopen("/proc/self/maps", "r");
- if (fp == NULL) {
- return -1;
- }
+ for (s = map_info; s; s = g_slist_next(s)) {
+ MapInfo *e = (MapInfo *) s->data;
- while ((read = getline(&line, &len, fp)) != -1) {
- int fields, dev_maj, dev_min, inode;
- uint64_t min, max, offset;
- char flag_r, flag_w, flag_x, flag_p;
- char path[512] = "";
- fields = sscanf(line, "%"PRIx64"-%"PRIx64" %c%c%c%c %"PRIx64" %x:%x %d"
- " %512s", &min, &max, &flag_r, &flag_w, &flag_x,
- &flag_p, &offset, &dev_maj, &dev_min, &inode, path);
-
- if ((fields < 10) || (fields > 11)) {
- continue;
- }
- if (h2g_valid(min)) {
+ if (h2g_valid(e->start)) {
+ unsigned long min = e->start;
+ unsigned long max = e->end;
int flags = page_get_flags(h2g(min));
- max = h2g_valid(max - 1) ? max : (uintptr_t)g2h(GUEST_ADDR_MAX) + 1;
+ const char *path;
+
+ max = h2g_valid(max - 1) ?
+ max : (uintptr_t) g2h(GUEST_ADDR_MAX) + 1;
+
if (page_check_range(h2g(min), max - min, flags) == -1) {
continue;
}
+
if (h2g(min) == ts->info->stack_limit) {
- pstrcpy(path, sizeof(path), " [stack]");
+ path = "[stack]";
+ } else {
+ path = e->path;
+ }
+
+ count = dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr
+ " %c%c%c%c %08" PRIx64 " %s %"PRId64,
+ h2g(min), h2g(max - 1) + 1,
+ e->is_read ? 'r' : '-',
+ e->is_write ? 'w' : '-',
+ e->is_exec ? 'x' : '-',
+ e->is_priv ? 'p' : '-',
+ (uint64_t) e->offset, e->dev, e->inode);
+ if (path) {
+ dprintf(fd, "%*s%s\n", 73 - count, "", path);
+ } else {
+ dprintf(fd, "\n");
}
- dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr
- " %c%c%c%c %08" PRIx64 " %02x:%02x %d %s%s\n",
- h2g(min), h2g(max - 1) + 1, flag_r, flag_w,
- flag_x, flag_p, offset, dev_maj, dev_min, inode,
- path[0] ? " " : "", path);
}
}
+ free_self_maps(map_info);
+
#ifdef TARGET_VSYSCALL_PAGE
/*
* We only support execution from the vsyscall page.
* This is as if CONFIG_LEGACY_VSYSCALL_XONLY=y from v5.3.
*/
- dprintf(fd, TARGET_FMT_lx "-" TARGET_FMT_lx
- " --xp 00000000 00:00 0 [vsyscall]\n",
- TARGET_VSYSCALL_PAGE, TARGET_VSYSCALL_PAGE + TARGET_PAGE_SIZE);
+ count = dprintf(fd, TARGET_FMT_lx "-" TARGET_FMT_lx
+ " --xp 00000000 00:00 0",
+ TARGET_VSYSCALL_PAGE, TARGET_VSYSCALL_PAGE + TARGET_PAGE_SIZE);
+ dprintf(fd, "%*s%s\n", 73 - count, "", "[vsyscall]");
#endif
- free(line);
- fclose(fp);
-
return 0;
}
@@ -11331,11 +11335,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
This is a hint, so ignoring and returning success is ok. */
return 0;
#endif
-#if TARGET_ABI_BITS == 32
+#ifdef TARGET_NR_fcntl64
case TARGET_NR_fcntl64:
{
- int cmd;
- struct flock64 fl;
+ int cmd;
+ struct flock64 fl;
from_flock64_fn *copyfrom = copy_from_user_flock64;
to_flock64_fn *copyto = copy_to_user_flock64;
@@ -11346,7 +11350,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
}
#endif
- cmd = target_to_host_fcntl_cmd(arg2);
+ cmd = target_to_host_fcntl_cmd(arg2);
if (cmd == -TARGET_EINVAL) {
return cmd;
}