a selection of random fixes
v3 cover a selection of random fixes
Hi,
Here is version 3 of my random fixes series.
I've dropped the more involved re-factoring of init_guest_space as it's going to take more thought and is best left to 5.1. I've left in the earlier clean-ups which fix the spacing and of the /proc/self/maps but I can drop them if they seem too radical for rc2.
The elf-ops fix is a little cleaner, dropping the return ignored value and using autoptr to avoid the goto magic.
I've includes the .hex and ARM gdbstub fixes which were posted separately because I didn't have another series to put them in. Richard's configure fix is there just so I can run my CI runs but may well get picked up via another tree?
Anyway I intend to cut the PR on Monday with whatever hasn't been already pulled in by other trees.
The only un-reviewed patch is:
- linux-user: factor out reading of /proc/self/maps
Alex Bennée (9):
elf-ops: bail out if we have no function symbols
linux-user: protect fcntl64 with an #ifdef tests/tcg: remove extraneous pasting macros
linux-user: more debug for init_guest_space target/xtensa: add FIXME for translation memory leak
linux-user: factor out reading of /proc/self/maps
linux-user: clean-up padding on /proc/self/maps target/arm: don't expose "ieee_half" via gdbstub hw/core: properly terminate loading .hex on EOF record
Denis Plotnikov (1):
gdbstub: fix compiler complaining
Richard Henderson (2):
softfloat: Fix BAD_SHIFT from normalizeFloatx80Subnormal
configure: Add -Werror to PIE probe
configure | 4 +- include/hw/elf_ops.h | 48 ++++++++++---------- include/qemu/selfmap.h | 44 +++++++++++++++++++ fpu/softfloat.c | 3 ++ gdbstub.c | 4 +- hw/core/loader.c | 5 ++- linux-user/elfload.c | 8 +++- linux-user/syscall.c | 80 ++++++++++++++++++---------------- target/arm/gdbstub.c | 7 ++- target/xtensa/translate.c | 5 +++ util/selfmap.c | 77 ++++++++++++++++++++++++++++++++ tests/tcg/x86_64/system/boot.S | 5 +-- util/Makefile.objs | 1 + 13 files changed, 219 insertions(+), 72 deletions(-) create mode 100644 include/qemu/selfmap.h create mode 100644 util/selfmap.c
Signature · 1 line
2.20.1
PATCH v3 1/12 elf-ops: bail out if we have no function symbols
It's perfectly possible to have no function symbols in your elf file and if we do the undefined behaviour sanitizer rightly complains about us passing NULL to qsort. Check nsyms before we go ahead.
While we are at it lets drop the unchecked return value and cleanup the fail leg by use of g_autoptr.
Another fix was proposed 101 weeks ago in:
Message-Id: [email protected]
--- include/hw/elf_ops.h | 48 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 23 deletions(-)
include/hw/elf_ops.h +25 -23
@@ -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++) {
@@ -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 ;
@@ -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 ) {
@@ -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,
Signature · 1 line
2.20.1
PATCH v3 2/12 linux-user: protect fcntl64 with an #ifdef
In reply to Alex BennéeChecking TARGET_ABI_BITS is sketchy - we should check for the presence of the define to be sure. Also clean up the white space while we are there.
--- linux-user/syscall.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
linux-user/syscall.c +4 -4
@@ -11331,11 +11331,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_fcntl64case 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 +11346,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; }
Signature · 1 line
2.20.1
PATCH v3 3/12 tests/tcg: remove extraneous pasting macros
In reply to Alex BennéeWe are not using them and they just get in the way.
--- tests/tcg/x86_64/system/boot.S | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
tests/tcg/x86_64/system/boot.S +1 -4
@@ -41,10 +41,7 @@ #define XEN_ELFNOTE_PHYS32_ENTRY 18 #define __ASM_FORM(x) x -#define __ASM_FORM_RAW(x) x -#define __ASM_FORM_COMMA(x) x, -#define __ASM_SEL(a,b) __ASM_FORM(b) -#define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(b) +#define __ASM_SEL(a,b) __ASM_FORM(b) #define _ASM_PTR __ASM_SEL(.long, .quad) ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR 0x100000)
Signature · 1 line
2.20.1
PATCH v3 4/12 linux-user: more debug for init_guest_space
In reply to Alex BennéeSearching for memory space can cause problems so lets extend the CPU_LOG_PAGE output so you can watch init_guest_space fail to allocate memory. A more involved fix is actually required to make this function play nicely with the large guard pages the sanitiser likes to use.
--- linux-user/elfload.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
linux-user/elfload.c +7 -1
@@ -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
Signature · 1 line
2.20.1
Re: [PATCH v3 04/12] linux-user: more debug for init_guest_space
Quoted 4 lines · Alex Bennée
Searching for memory space can cause problems so lets extend the
CPU_LOG_PAGEoutput so you can watchinit_guest_spacefail to allocate memory. A more involved fix is actually required to make this function play nicely with the large guard pages the sanitiser likes to
TIL "in an effort to differentiate British English from American, many British publishers have begun giving -ise endings even to words that have always been spelled -ize."
https://grammarist.com/spelling/sanitise-sanitize/
Quoted 4 lines
use.
Signed-off-by Alex Bennée <[email protected]>Reviewed-by Laurent Vivier <[email protected]>
Quoted 31 lines
--- linux-user/elfload.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)linux-user/elfload.c +7
-1@@ -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
PATCH v3 5/12 target/xtensa: add FIXME for translation memory leak
In reply to Alex BennéeDynamically allocating a new structure within the DisasContext can potentially leak as we can longjmp out of the translation loop (see test_phys_mem). The proper fix would be to use static allocation within the DisasContext but as the Xtensa translator imports it's code from elsewhere I leave that as an exercise for the maintainer.
--- target/xtensa/translate.c | 5 +++++ 1 file changed, 5 insertions(+)
target/xtensa/translate.c +5 -0
@@ -1174,6 +1174,11 @@ static void xtensa_tr_init_disas_context(DisasContextBase *dcbase, dc->callinc = ((tb_flags &XTENSA_TBFLAG_CALLINC_MASK ) >>XTENSA_TBFLAG_CALLINC_SHIFT ); +/* +* FIXME: This will leak when a failed instruction load or similar +* event causes us to longjump out of the translation loop and +* hence not clean-up in xtensa_tr_tb_stop +*/ if (dc->config->isa) { dc->insnbuf =xtensa_insnbuf_alloc (dc->config->isa); dc->slotbuf =xtensa_insnbuf_alloc (dc->config->isa);
Signature · 1 line
2.20.1
PATCH v3 6/12 gdbstub: fix compiler complaining
In reply to Alex BennéeFrom: Denis Plotnikov <[email protected]>
./gdbstub.c: In function ‘handle_query_thread_extra’:
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:10:
error: ‘cpu_name’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
g_free (*pp);
^
./gdbstub.c:2063:26: note: ‘cpu_name’ was declared here
g_autofree char *cpu_name;
^
cc1: all warnings being treated as errorsMessage-Id: <[email protected]>
--- gdbstub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
gdbstub.c +2 -2
@@ -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 {
Signature · 1 line
2.20.1
RE: [PATCH v3 06/12] gdbstub: fix compiler complaining
Quoted 23 lines
-----Original Message-----
From: Alex Bennée [mailto:[email protected]]
Sent: Saturday, April 4, 2020 3:12 AM
To: [email protected]
Cc: Denis Plotnikov <[email protected]>; Euler Robot <[email protected]>; Chenqun (kuhn) <[email protected]>; Richard Henderson <[email protected]>; Alex Bennée <[email protected]>; Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH v3 06/12] gdbstub: fix compiler complainingFrom: Denis Plotnikov <[email protected]>
./gdbstub.c: In function ‘handle_query_thread_extra’: /usr/include/glib-2.0/glib/glib-autocleanups.h:28:10: error: ‘cpu_name’ may be used uninitialized in this function [-Werror=maybe-uninitialized] g_free (*pp); ^ ./gdbstub.c:2063:26: note: ‘cpu_name’ was declared here g_autofree char *cpu_name; ^ cc1: all warnings being treated as errors
Quoted 8 lines
Signed-off-by Denis Plotnikov <[email protected]>Message-Id: <[email protected]>
Reported-by Euler Robot <[email protected]>Reported-by Chen Qun <[email protected]>Reviewed-by Richard Henderson <[email protected]>Signed-off-by Alex Bennée <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>---
Add Miroslav Rezanina's "Reviewed-by" tag.
https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg07651.html
Thanks.
Quoted 21 lines
gdbstub.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)gdbstub.c +2
-2@@ -2060,8 +2060,8 @@ static voidhandle_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 {--
2.20.1
PATCH v3 7/12 softfloat: Fix BAD_SHIFT from normalizeFloatx80Subnormal
In reply to Alex BennéeFrom: Richard Henderson <[email protected]>
All other calls to normalize*Subnormal detect zero input before the call -- this is the only outlier. This case can happen with +0.0 + +0.0 = +0.0 or -0.0 + -0.0 = -0.0, so return a zero of the correct sign.
Message-Id: <[email protected]>
--- fpu/softfloat.c | 3 +++ 1 file changed, 3 insertions(+)
fpu/softfloat.c +3 -0
@@ -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; }
Signature · 1 line
2.20.1
PATCH v3 8/12 linux-user: factor out reading of /proc/self/maps
In reply to Alex BennéeUnfortunately reading /proc/self/maps is still considered the gold standard for a process finding out about it's own memory layout. As we will want this data in other contexts soon factor out the code to read and parse the data. Rather than just blindly copying the existing sscanf based code we use a more modern glib version of the parsing code to make a more general purpose map structure.
---
v2
- s/uint64_t/unsigned long/ for MapInfo structure
- limit to 6 fields and strip leading spaces
--- include/qemu/selfmap.h | 44 ++++++++++++++++++++++++ linux-user/syscall.c | 58 +++++++++++++++---------------- util/selfmap.c | 77 ++++++++++++++++++++++++++++++++++++++++++ util/Makefile.objs | 1 + 4 files changed, 150 insertions(+), 30 deletions(-) create mode 100644 include/qemu/selfmap.h create mode 100644 util/selfmap.c
include/qemu/selfmap.h new file +44 -0
@@ -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; +int 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_ */
linux-user/syscall.c +28 -30
88 lines not on this page · raw message
util/selfmap.c new file +77 -0
77 lines not on this page · raw message
util/Makefile.objs +1 -0
@@ -63,3 +63,4 @@ util-obj-y += guest-random.o util-obj-$(CONFIG_GIO) += dbus.o dbus.o-cflags = $(GIO_CFLAGS) dbus.o-libs = $(GIO_LIBS) +util-obj-$(CONFIG_USER_ONLY) += selfmap.o
Signature · 1 line
2.20.1
Re: [PATCH v3 08/12] linux-user: factor out reading of /proc/self/maps
util/selfmap.c line 35
Quoted 4 lines · Alex Bennée
util/selfmap.c new file +4
-0+ e->is_read = fields[1 ][0 ] =='r' ? true : false; + e->is_write = fields[1 ][1 ] =='w' ? true : false; + e->is_exec = fields[1 ][2 ] =='x' ? true : false; + e->is_priv = fields[1 ][3 ] =='p' ? true : false;
Drop the redundant ? true : false. That is of course the result of the boolean operation.
Quoted 1 line
+ errors +=
qemu_strtoi(fields[4], NULL, 10, &e->inode);
The root of the typedef chain for ino_t is
/usr/include/asm-generic/posix_types.h:typedef __kernel_ulong_t __kernel_ino_t;
so I think you should just go ahead and use unsigned long here too. Or maybe even uint64_t, because 32-bit has ino64_t, and could in fact have a Large Number here.
r~
Re: [PATCH v3 08/12] linux-user: factor out reading of /proc/self/maps
Quoted 8 lines · Richard Henderson
util/selfmap.c line 35
Quoted 4 lines · Alex Bennée
util/selfmap.c new file +4
-0+ e->is_read = fields[1 ][0 ] =='r' ? true : false; + e->is_write = fields[1 ][1 ] =='w' ? true : false; + e->is_exec = fields[1 ][2 ] =='x' ? true : false; + e->is_priv = fields[1 ][3 ] =='p' ? true : false;Drop the redundant ? true : false. That is of course the result of the boolean operation.
doh! Fortunately the compiler was smart enough to see through my idiocy...
Quoted 10 lines
Quoted 2 lines
+ errors +=
qemu_strtoi(fields[4], NULL, 10, &e->inode);The root of the typedef chain for
ino_tis/usr/include/asm-generic/posix_types.h:typedef
__kernel_ulong_t__kernel_ino_t;so I think you should just go ahead and use unsigned long here too. Or maybe even
uint64_t, because 32-bit hasino64_t, and could in fact have a Large Number here.
Will fix.
Quoted 3 lines
r~
Signature · 1 line
Alex Bennée
PATCH v3 9/12 linux-user: clean-up padding on /proc/self/maps
In reply to Alex BennéeDon't use magic spaces, calculate the justification for the file field like the kernel does with seq_pad.
---
v2
- change for unsigned long update
--- linux-user/syscall.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
linux-user/syscall.c +19 -13
@@ -7235,6 +7235,7 @@ static int open_self_maps(void *cpu_env, int fd)TaskState *ts = cpu->opaque;GSList *map_info =read_self_maps ();GSList *s; +int count;for (s = map_info; s; s =g_slist_next (s)) {MapInfo *e = (MapInfo *) s->data;
@@ -7253,20 +7254,24 @@ static int open_self_maps(void *cpu_env, int fd) }if (h2g (min) == ts->info->stack_limit) { - path =" [stack]" ; + path ="[stack]" ; }else { path = e->path; } -dprintf (fd, TARGET_ABI_FMT_ptr"-" TARGET_ABI_FMT_ptr -" %c%c%c%c %08" PRIx64" %s %d %s%s\n" , -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, - path ?" " :"" , path ? path :"" ); + count =dprintf (fd, TARGET_ABI_FMT_ptr"-" TARGET_ABI_FMT_ptr +" %c%c%c%c %08" PRIx64" %s %d" , +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" ); + } } }
@@ -7277,9 +7282,10 @@ static int open_self_maps(void *cpu_env, int fd)* 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 return 0 ;
Signature · 1 line
2.20.1
PATCH v3 10/12 target/arm: don't expose "ieee_half" via gdbstub
In reply to Alex BennéeWhile support for parsing ieee_half in the XML description was added to gdb in 2019 (a6d0f249) there is no easy way for the gdbstub to know if the gdb end will understand it. Disable it for now and allow older gdbs to successfully connect to the default -cpu max SVE enabled QEMUs.
--- target/arm/gdbstub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
target/arm/gdbstub.c +6 -1
@@ -192,7 +192,12 @@ static const struct TypeSize vec_lanes[] = {/* 16 bit */ { "uint16", 16, 'h', 'u' }, { "int16", 16, 'h', 's' }, - { "ieee_half", 16, 'h', 'f' }, +/* +* TODO: currently there is no reliable way of telling +* if the remote gdb actually understands ieee_half so +* we don't expose it in the target description for now. +* { "ieee_half", 16, 'h', 'f' }, +*/ /* bytes */ { "uint8", 8, 'b', 'u' }, { "int8", 8, 'b', 's' },
Signature · 1 line
2.20.1
PATCH v3 11/12 hw/core: properly terminate loading .hex on EOF record
In reply to Alex BennéeThe https://makecode.microbit.org/#editor generates slightly weird .hex files which work fine on a real microbit but causes QEMU to choke. The reason is extraneous data after the EOF record which causes the loader to attempt to write a bigger file than it should to the "rom". According to the HEX file spec an EOF really should be the last thing we process so lets do that.
--- hw/core/loader.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/core/loader.c +4 -1
@@ -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 */
@@ -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 :
@@ -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' :
Signature · 1 line
2.20.1
PATCH v3 12/12 configure: Add -Werror to PIE probe
In reply to Alex BennéeFrom: Richard Henderson <[email protected]>
Without -Werror, the probe may succeed, but then compilation fails later when -Werror is added for other reasons. Shows up on windows, where the compiler complains about -fPIC.
Message-Id: <[email protected]>
--- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
configure +2 -2
@@ -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"
@@ -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"
Signature · 1 line
2.20.1
Re: [PATCH v3 12/12] configure: Add -Werror to PIE probe
Quoted 9 lines · Alex Bennée
From: Richard Henderson <[email protected]>
Without -Werror, the probe may succeed, but then compilation fails later when -Werror is added for other reasons. Shows up on windows, where the compiler complains about -fPIC.
Signed-off-by Richard Henderson <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Quoted 27 lines
--- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)configure +2
-2@@ -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"@@ -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"