Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/stsquad/tags/pull-misc-fixes-07…
Browse files Browse the repository at this point in the history
…0420-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>
  • Loading branch information
pm215 committed Apr 7, 2020
2 parents 3f1082e + cce743a commit e715f7b
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 72 deletions.
34 changes: 34 additions & 0 deletions .github/lockdown.yml
@@ -0,0 +1,34 @@
# Configuration for Repo Lockdown - https://github.com/dessant/repo-lockdown

# Close issues and pull requests
close: true

# Lock issues and pull requests
lock: true

issues:
comment: |
Thank you for your interest in the QEMU project.
This repository is a read-only mirror of the project's master
repostories hosted on https://git.qemu.org/git/qemu.git.
The project does not process issues filed on GitHub.
The project issues are tracked on Launchpad:
https://bugs.launchpad.net/qemu
QEMU welcomes bug report contributions. You can file new ones on:
https://bugs.launchpad.net/qemu/+filebug
pulls:
comment: |
Thank you for your interest in the QEMU project.
This repository is a read-only mirror of the project's master
repostories hosted on https://git.qemu.org/git/qemu.git.
The project does not process merge requests filed on GitHub.
QEMU welcomes contributions of code (either fixing bugs or adding new
functionality). However, we get a lot of patches, and so we have some
guidelines about contributing on the project website:
https://www.qemu.org/contribute/
1 change: 1 addition & 0 deletions MAINTAINERS
Expand Up @@ -2834,6 +2834,7 @@ M: Alex Bennée <alex.bennee@linaro.org>
M: Fam Zheng <fam@euphon.net>
R: Philippe Mathieu-Daudé <philmd@redhat.com>
S: Maintained
F: .github/lockdown.yml
F: .travis.yml
F: scripts/travis/
F: .shippable.yml
Expand Down
4 changes: 2 additions & 2 deletions configure
Expand Up @@ -2119,7 +2119,7 @@ if compile_prog "-Werror -fno-pie" "-no-pie"; then
fi

if test "$static" = "yes"; then
if test "$pie" != "no" && compile_prog "-fPIE -DPIE" "-static-pie"; then
if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
pie="yes"
Expand All @@ -2132,7 +2132,7 @@ if test "$static" = "yes"; then
elif test "$pie" = "no"; then
QEMU_CFLAGS="$CFLAGS_NOPIE $QEMU_CFLAGS"
QEMU_LDFLAGS="$LDFLAGS_NOPIE $QEMU_LDFLAGS"
elif compile_prog "-fPIE -DPIE" "-pie"; then
elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
QEMU_LDFLAGS="-pie $QEMU_LDFLAGS"
pie="yes"
Expand Down
3 changes: 3 additions & 0 deletions fpu/softfloat.c
Expand Up @@ -5856,6 +5856,9 @@ static floatx80 addFloatx80Sigs(floatx80 a, floatx80 b, flag zSign,
zSig1 = 0;
zSig0 = aSig + bSig;
if ( aExp == 0 ) {
if (zSig0 == 0) {
return packFloatx80(zSign, 0, 0);
}
normalizeFloatx80Subnormal( zSig0, &zExp, &zSig0 );
goto roundAndPack;
}
Expand Down
4 changes: 2 additions & 2 deletions gdbstub.c
Expand Up @@ -2060,8 +2060,8 @@ static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx)
/* Print the CPU model and name in multiprocess mode */
ObjectClass *oc = object_get_class(OBJECT(cpu));
const char *cpu_model = object_class_get_name(oc);
g_autofree char *cpu_name;
cpu_name = object_get_canonical_path_component(OBJECT(cpu));
g_autofree char *cpu_name =
object_get_canonical_path_component(OBJECT(cpu));
g_string_printf(rs, "%s %s [%s]", cpu_model, cpu_name,
cpu->halted ? "halted " : "running");
} else {
Expand Down
5 changes: 4 additions & 1 deletion hw/core/loader.c
Expand Up @@ -1447,6 +1447,7 @@ typedef struct {
uint32_t current_rom_index;
uint32_t rom_start_address;
AddressSpace *as;
bool complete;
} HexParser;

/* return size or -1 if error */
Expand Down Expand Up @@ -1484,6 +1485,7 @@ static int handle_record_type(HexParser *parser)
parser->current_rom_index,
parser->rom_start_address, parser->as);
}
parser->complete = true;
return parser->total_size;
case EXT_SEG_ADDR_RECORD:
case EXT_LINEAR_ADDR_RECORD:
Expand Down Expand Up @@ -1548,11 +1550,12 @@ static int parse_hex_blob(const char *filename, hwaddr *addr, uint8_t *hex_blob,
.bin_buf = g_malloc(hex_blob_size),
.start_addr = addr,
.as = as,
.complete = false
};

rom_transaction_begin();

for (; hex_blob < end; ++hex_blob) {
for (; hex_blob < end && !parser.complete; ++hex_blob) {
switch (*hex_blob) {
case '\r':
case '\n':
Expand Down
48 changes: 25 additions & 23 deletions include/hw/elf_ops.h
Expand Up @@ -104,19 +104,21 @@ static int glue(symcmp, SZ)(const void *s0, const void *s1)
: ((sym0->st_value > sym1->st_value) ? 1 : 0);
}

static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
int clear_lsb, symbol_fn_t sym_cb)
static void glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
int clear_lsb, symbol_fn_t sym_cb)
{
struct elf_shdr *symtab, *strtab, *shdr_table = NULL;
struct elf_sym *syms = NULL;
struct elf_shdr *symtab, *strtab;
g_autofree struct elf_shdr *shdr_table = NULL;
g_autofree struct elf_sym *syms = NULL;
g_autofree char *str = NULL;
struct syminfo *s;
int nsyms, i;
char *str = NULL;

shdr_table = load_at(fd, ehdr->e_shoff,
sizeof(struct elf_shdr) * ehdr->e_shnum);
if (!shdr_table)
return -1;
if (!shdr_table) {
return ;
}

if (must_swab) {
for (i = 0; i < ehdr->e_shnum; i++) {
Expand All @@ -125,23 +127,25 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
}

symtab = glue(find_section, SZ)(shdr_table, ehdr->e_shnum, SHT_SYMTAB);
if (!symtab)
goto fail;
if (!symtab) {
return;
}
syms = load_at(fd, symtab->sh_offset, symtab->sh_size);
if (!syms)
goto fail;
if (!syms) {
return;
}

nsyms = symtab->sh_size / sizeof(struct elf_sym);

/* String table */
if (symtab->sh_link >= ehdr->e_shnum) {
goto fail;
return;
}
strtab = &shdr_table[symtab->sh_link];

str = load_at(fd, strtab->sh_offset, strtab->sh_size);
if (!str) {
goto fail;
return;
}

i = 0;
Expand Down Expand Up @@ -170,8 +174,13 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
}
i++;
}
syms = g_realloc(syms, nsyms * sizeof(*syms));

/* check we have symbols left */
if (nsyms == 0) {
return;
}

syms = g_realloc(syms, nsyms * sizeof(*syms));
qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
for (i = 0; i < nsyms - 1; i++) {
if (syms[i].st_size == 0) {
Expand All @@ -182,18 +191,11 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
/* Commit */
s = g_malloc0(sizeof(*s));
s->lookup_symbol = glue(lookup_symbol, SZ);
glue(s->disas_symtab.elf, SZ) = syms;
glue(s->disas_symtab.elf, SZ) = g_steal_pointer(&syms);
s->disas_num_syms = nsyms;
s->disas_strtab = str;
s->disas_strtab = g_steal_pointer(&str);
s->next = syminfos;
syminfos = s;
g_free(shdr_table);
return 0;
fail:
g_free(syms);
g_free(str);
g_free(shdr_table);
return -1;
}

static int glue(elf_reloc, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
Expand Down
44 changes: 44 additions & 0 deletions include/qemu/selfmap.h
@@ -0,0 +1,44 @@
/*
* Utility functions to read our own memory map
*
* Copyright (c) 2020 Linaro Ltd
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#ifndef _SELFMAP_H_
#define _SELFMAP_H_

typedef struct {
unsigned long start;
unsigned long end;

/* flags */
bool is_read;
bool is_write;
bool is_exec;
bool is_priv;

unsigned long offset;
gchar *dev;
uint64_t inode;
gchar *path;
} MapInfo;


/**
* read_self_maps:
*
* Read /proc/self/maps and return a list of MapInfo structures.
*/
GSList *read_self_maps(void);

/**
* free_self_maps:
* @info: a GSlist
*
* Free a list of MapInfo structures.
*/
void free_self_maps(GSList *info);

#endif /* _SELFMAP_H_ */
8 changes: 7 additions & 1 deletion linux-user/elfload.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e715f7b

Please sign in to comment.