Skip to content

Commit e715f7b

Browse files
committed
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) <[email protected]>" [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 <[email protected]>
2 parents 3f1082e + cce743a commit e715f7b

File tree

15 files changed

+250
-72
lines changed

15 files changed

+250
-72
lines changed

.github/lockdown.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Configuration for Repo Lockdown - https://github.com/dessant/repo-lockdown
2+
3+
# Close issues and pull requests
4+
close: true
5+
6+
# Lock issues and pull requests
7+
lock: true
8+
9+
issues:
10+
comment: |
11+
Thank you for your interest in the QEMU project.
12+
13+
This repository is a read-only mirror of the project's master
14+
repostories hosted on https://git.qemu.org/git/qemu.git.
15+
The project does not process issues filed on GitHub.
16+
17+
The project issues are tracked on Launchpad:
18+
https://bugs.launchpad.net/qemu
19+
20+
QEMU welcomes bug report contributions. You can file new ones on:
21+
https://bugs.launchpad.net/qemu/+filebug
22+
23+
pulls:
24+
comment: |
25+
Thank you for your interest in the QEMU project.
26+
27+
This repository is a read-only mirror of the project's master
28+
repostories hosted on https://git.qemu.org/git/qemu.git.
29+
The project does not process merge requests filed on GitHub.
30+
31+
QEMU welcomes contributions of code (either fixing bugs or adding new
32+
functionality). However, we get a lot of patches, and so we have some
33+
guidelines about contributing on the project website:
34+
https://www.qemu.org/contribute/

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,6 +2834,7 @@ M: Alex Bennée <[email protected]>
28342834
M: Fam Zheng <[email protected]>
28352835
R: Philippe Mathieu-Daudé <[email protected]>
28362836
S: Maintained
2837+
F: .github/lockdown.yml
28372838
F: .travis.yml
28382839
F: scripts/travis/
28392840
F: .shippable.yml

configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,7 @@ if compile_prog "-Werror -fno-pie" "-no-pie"; then
21192119
fi
21202120

21212121
if test "$static" = "yes"; then
2122-
if test "$pie" != "no" && compile_prog "-fPIE -DPIE" "-static-pie"; then
2122+
if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
21232123
QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
21242124
QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
21252125
pie="yes"
@@ -2132,7 +2132,7 @@ if test "$static" = "yes"; then
21322132
elif test "$pie" = "no"; then
21332133
QEMU_CFLAGS="$CFLAGS_NOPIE $QEMU_CFLAGS"
21342134
QEMU_LDFLAGS="$LDFLAGS_NOPIE $QEMU_LDFLAGS"
2135-
elif compile_prog "-fPIE -DPIE" "-pie"; then
2135+
elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
21362136
QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
21372137
QEMU_LDFLAGS="-pie $QEMU_LDFLAGS"
21382138
pie="yes"

fpu/softfloat.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5856,6 +5856,9 @@ static floatx80 addFloatx80Sigs(floatx80 a, floatx80 b, flag zSign,
58565856
zSig1 = 0;
58575857
zSig0 = aSig + bSig;
58585858
if ( aExp == 0 ) {
5859+
if (zSig0 == 0) {
5860+
return packFloatx80(zSign, 0, 0);
5861+
}
58595862
normalizeFloatx80Subnormal( zSig0, &zExp, &zSig0 );
58605863
goto roundAndPack;
58615864
}

gdbstub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,8 +2060,8 @@ static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx)
20602060
/* Print the CPU model and name in multiprocess mode */
20612061
ObjectClass *oc = object_get_class(OBJECT(cpu));
20622062
const char *cpu_model = object_class_get_name(oc);
2063-
g_autofree char *cpu_name;
2064-
cpu_name = object_get_canonical_path_component(OBJECT(cpu));
2063+
g_autofree char *cpu_name =
2064+
object_get_canonical_path_component(OBJECT(cpu));
20652065
g_string_printf(rs, "%s %s [%s]", cpu_model, cpu_name,
20662066
cpu->halted ? "halted " : "running");
20672067
} else {

hw/core/loader.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,7 @@ typedef struct {
14471447
uint32_t current_rom_index;
14481448
uint32_t rom_start_address;
14491449
AddressSpace *as;
1450+
bool complete;
14501451
} HexParser;
14511452

14521453
/* return size or -1 if error */
@@ -1484,6 +1485,7 @@ static int handle_record_type(HexParser *parser)
14841485
parser->current_rom_index,
14851486
parser->rom_start_address, parser->as);
14861487
}
1488+
parser->complete = true;
14871489
return parser->total_size;
14881490
case EXT_SEG_ADDR_RECORD:
14891491
case EXT_LINEAR_ADDR_RECORD:
@@ -1548,11 +1550,12 @@ static int parse_hex_blob(const char *filename, hwaddr *addr, uint8_t *hex_blob,
15481550
.bin_buf = g_malloc(hex_blob_size),
15491551
.start_addr = addr,
15501552
.as = as,
1553+
.complete = false
15511554
};
15521555

15531556
rom_transaction_begin();
15541557

1555-
for (; hex_blob < end; ++hex_blob) {
1558+
for (; hex_blob < end && !parser.complete; ++hex_blob) {
15561559
switch (*hex_blob) {
15571560
case '\r':
15581561
case '\n':

include/hw/elf_ops.h

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,21 @@ static int glue(symcmp, SZ)(const void *s0, const void *s1)
104104
: ((sym0->st_value > sym1->st_value) ? 1 : 0);
105105
}
106106

107-
static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
108-
int clear_lsb, symbol_fn_t sym_cb)
107+
static void glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
108+
int clear_lsb, symbol_fn_t sym_cb)
109109
{
110-
struct elf_shdr *symtab, *strtab, *shdr_table = NULL;
111-
struct elf_sym *syms = NULL;
110+
struct elf_shdr *symtab, *strtab;
111+
g_autofree struct elf_shdr *shdr_table = NULL;
112+
g_autofree struct elf_sym *syms = NULL;
113+
g_autofree char *str = NULL;
112114
struct syminfo *s;
113115
int nsyms, i;
114-
char *str = NULL;
115116

116117
shdr_table = load_at(fd, ehdr->e_shoff,
117118
sizeof(struct elf_shdr) * ehdr->e_shnum);
118-
if (!shdr_table)
119-
return -1;
119+
if (!shdr_table) {
120+
return ;
121+
}
120122

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

127129
symtab = glue(find_section, SZ)(shdr_table, ehdr->e_shnum, SHT_SYMTAB);
128-
if (!symtab)
129-
goto fail;
130+
if (!symtab) {
131+
return;
132+
}
130133
syms = load_at(fd, symtab->sh_offset, symtab->sh_size);
131-
if (!syms)
132-
goto fail;
134+
if (!syms) {
135+
return;
136+
}
133137

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

136140
/* String table */
137141
if (symtab->sh_link >= ehdr->e_shnum) {
138-
goto fail;
142+
return;
139143
}
140144
strtab = &shdr_table[symtab->sh_link];
141145

142146
str = load_at(fd, strtab->sh_offset, strtab->sh_size);
143147
if (!str) {
144-
goto fail;
148+
return;
145149
}
146150

147151
i = 0;
@@ -170,8 +174,13 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
170174
}
171175
i++;
172176
}
173-
syms = g_realloc(syms, nsyms * sizeof(*syms));
174177

178+
/* check we have symbols left */
179+
if (nsyms == 0) {
180+
return;
181+
}
182+
183+
syms = g_realloc(syms, nsyms * sizeof(*syms));
175184
qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
176185
for (i = 0; i < nsyms - 1; i++) {
177186
if (syms[i].st_size == 0) {
@@ -182,18 +191,11 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
182191
/* Commit */
183192
s = g_malloc0(sizeof(*s));
184193
s->lookup_symbol = glue(lookup_symbol, SZ);
185-
glue(s->disas_symtab.elf, SZ) = syms;
194+
glue(s->disas_symtab.elf, SZ) = g_steal_pointer(&syms);
186195
s->disas_num_syms = nsyms;
187-
s->disas_strtab = str;
196+
s->disas_strtab = g_steal_pointer(&str);
188197
s->next = syminfos;
189198
syminfos = s;
190-
g_free(shdr_table);
191-
return 0;
192-
fail:
193-
g_free(syms);
194-
g_free(str);
195-
g_free(shdr_table);
196-
return -1;
197199
}
198200

199201
static int glue(elf_reloc, SZ)(struct elfhdr *ehdr, int fd, int must_swab,

include/qemu/selfmap.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Utility functions to read our own memory map
3+
*
4+
* Copyright (c) 2020 Linaro Ltd
5+
*
6+
* SPDX-License-Identifier: GPL-2.0-or-later
7+
*/
8+
9+
#ifndef _SELFMAP_H_
10+
#define _SELFMAP_H_
11+
12+
typedef struct {
13+
unsigned long start;
14+
unsigned long end;
15+
16+
/* flags */
17+
bool is_read;
18+
bool is_write;
19+
bool is_exec;
20+
bool is_priv;
21+
22+
unsigned long offset;
23+
gchar *dev;
24+
uint64_t inode;
25+
gchar *path;
26+
} MapInfo;
27+
28+
29+
/**
30+
* read_self_maps:
31+
*
32+
* Read /proc/self/maps and return a list of MapInfo structures.
33+
*/
34+
GSList *read_self_maps(void);
35+
36+
/**
37+
* free_self_maps:
38+
* @info: a GSlist
39+
*
40+
* Free a list of MapInfo structures.
41+
*/
42+
void free_self_maps(GSList *info);
43+
44+
#endif /* _SELFMAP_H_ */

linux-user/elfload.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,8 @@ unsigned long init_guest_space(unsigned long host_start,
21722172

21732173
/* Check to see if the address is valid. */
21742174
if (host_start && real_start != current_start) {
2175+
qemu_log_mask(CPU_LOG_PAGE, "invalid %lx && %lx != %lx\n",
2176+
host_start, real_start, current_start);
21752177
goto try_again;
21762178
}
21772179

@@ -2240,7 +2242,11 @@ unsigned long init_guest_space(unsigned long host_start,
22402242
* probably a bad strategy if not, which means we got here
22412243
* because of trouble with ARM commpage setup.
22422244
*/
2243-
munmap((void *)real_start, real_size);
2245+
if (munmap((void *)real_start, real_size) != 0) {
2246+
error_report("%s: failed to unmap %lx:%lx (%s)", __func__,
2247+
real_start, real_size, strerror(errno));
2248+
abort();
2249+
}
22442250
current_start += align;
22452251
if (host_start == current_start) {
22462252
/* Theoretically possible if host doesn't have any suitably

0 commit comments

Comments
 (0)