Skip to contentSkip to conversation

more random fixes

PATCH Superseded Alex Bennée 8 participants 34 messages Apr 9, 2020 – Apr 14, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover more random fixes

Hi,

Here are some more random fixes for the tree. In no particular order we have:

- A couple of bugs found in the gdbstub GByteArray conversion
- A trivial fix to /proc/self/stat output
- An attempt to fix broken PIE builds for Windows (please test!)
- Some fixes to get "make docker-all-tests" running again
- Some travis MacOSX tweaks

I've also included the guest base re-factoring patches as it makes it easier for me to soak test the tree with the sanitiser although those actual fixes won't go into 5.0 at this late stage.

The following patches need review:

- linux-user: fix /proc/self/stat handling
- configure: disable PIE for Windows builds
- configure: redirect sphinx-build check to config.log
- tests/docker: add docs FEATURE flag and use for test-misc
- linux-user: completely re-write init_guest_space

Alex Bennée (5):
linux-user: completely re-write init_guest_space tests/docker: add docs FEATURE flag and use for test-misc
configure: redirect sphinx-build check to config.log
configure: disable PIE for Windows builds
linux-user: fix /proc/self/stat handling

Peter Xu (1):
gdbstub: i386: Fix gdb_get_reg16() parameter to unbreak gdb

Philippe Mathieu-Daudé (2):
target/m68k/helper: Fix m68k_fpu_gdb_get_reg() use of GByteArray .travis.yml: Build OSX 10.14 with Xcode 10.0

Richard Henderson (3):
exec/cpu-all: Use bool for have_guest_base accel/tcg: Relax va restrictions on 64-bit guests linux-user/ppc: Fix padding in mcontext_t for ppc64

 configure                                  |   3 +-
 include/exec/cpu-all.h                     |  25 +-
 linux-user/qemu.h                          |  31 +-
 target/alpha/cpu-param.h                   |  15 +-
 accel/tcg/translate-all.c                  |  15 +-
 bsd-user/main.c                            |   4 +-
 linux-user/elfload.c                       | 503 ++++++++++-----------
 linux-user/flatload.c                      |   6 +
 linux-user/main.c                          |  27 +-
 linux-user/ppc/signal.c                    |  69 ++-
 linux-user/syscall.c                       |  43 +-
 target/i386/gdbstub.c                      |   2 +-
 target/m68k/helper.c                       |   4 +-
 .travis.yml                                |   4 +-
 tests/docker/dockerfiles/debian10.docker   |   2 +
 tests/docker/dockerfiles/debian9.docker    |   2 -
 tests/docker/dockerfiles/fedora.docker     |   2 +-
 tests/docker/dockerfiles/travis.docker     |   2 +-
 tests/docker/dockerfiles/ubuntu.docker     |   2 +-
 tests/docker/dockerfiles/ubuntu1804.docker |   2 +-
 tests/docker/test-misc                     |   2 +
 21 files changed, 375 insertions(+), 390 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/11 linux-user: completely re-write init_guest_space

First we ensure all guest space initialisation logic comes through probe_guest_base once we understand the nature of the binary we are loading. The convoluted init_guest_space routine is removed and replaced with a number of pgb_* helpers which are called depending on what requirements we have when loading the binary.

We first try to do what is requested by the host. Failing that we try and satisfy the guest requested base address. If all those options fail we fall back to finding a space in the memory map using our recently written read_self_maps() helper.

There are some additional complications we try and take into account when looking for holes in the address space. We try not to go directly after the system brk() space so there is space for a little growth. We also don't want to have to use negative offsets which would result in slightly less efficient code on x86 when it's unable to use the segment offset register.

Less mind-binding gotos and hopefully clearer logic throughout.

---
v3
- include rth updates that
- split probe_guest_base into multiple functions
- more heuristics on gap finding

---
 linux-user/qemu.h     |  31 ++-
 linux-user/elfload.c  | 503 +++++++++++++++++++++---------------------
 linux-user/flatload.c |   6 +
 linux-user/main.c     |  23 +-
 4 files changed, 277 insertions(+), 286 deletions(-)
linux-user/qemu.h +20 -11
index 792c74290f8..e1febb88cf5 100644
@@ -219,18 +219,27 @@ void init_qemu_uname_release(void);
 void fork_start(void);
 void fork_end(int child);
 
-/* Creates the initial guest address space in the host memory space using
- * the given host start address hint and size.  The guest_start parameter
- * specifies the start address of the guest space.  guest_base will be the
- * difference between the host start address computed by this function and
- * guest_start.  If fixed is specified, then the mapped address space must
- * start at host_start.  The real start address of the mapped memory space is
- * returned or -1 if there was an error.
+/**
+ * probe_guest_base:
+ * @image_name: the executable being loaded
+ * @loaddr: the lowest fixed address in the executable
+ * @hiaddr: the highest fixed address in the executable
+ *
+ * Creates the initial guest address space in the host memory space.
+ * 
+ * If @loaddr == 0, then no address in the executable is fixed,
+ * i.e. it is fully relocatable.  In that case @hiaddr is the size
+ * of the executable.
+ *
+ * This function will not return if a valid value for guest_base
+ * cannot be chosen.  On return, the executable loader can expect
+ *
+ *    target_mmap(loaddr, hiaddr - loaddr, ...)
+ *
+ * to succeed.
  */
-unsigned long init_guest_space(unsigned long host_start,
-                               unsigned long host_size,
-                               unsigned long guest_start,
-                               bool fixed);
+void probe_guest_base(const char *image_name,
+                      abi_ulong loaddr, abi_ulong hiaddr);
 
 #include "qemu/log.h"
 
linux-user/elfload.c +250 -253

569 lines not on this page · raw message

linux-user/flatload.c +6 -0
index 0122ab3afe6..952b4cb26d8 100644
@@ -441,6 +441,12 @@ static int load_flat_file(struct linux_binprm * bprm,
     indx_len = MAX_SHARED_LIBS * sizeof(abi_ulong);
     indx_len = (indx_len + 15) & ~(abi_ulong)15;
 
+    /*
+     * Alloate the address space.
+     */
+    probe_guest_base(bprm->filename, 0,
+                     text_len + data_len + extra + indx_len);
+
     /*
      * there are a couple of cases here,  the separate code/data
      * case,  and then the fully copied to RAM case which lumps
linux-user/main.c +1 -22
index 22578b16336..1d20a83d4e8 100644
@@ -24,6 +24,7 @@
 #include "qemu-version.h"
 #include <sys/syscall.h>
 #include <sys/resource.h>
+#include <sys/shm.h>
 
 #include "qapi/error.h"
 #include "qemu.h"
@@ -747,28 +748,6 @@ int main(int argc, char **argv, char **envp)
     target_environ = envlist_to_environ(envlist, NULL);
     envlist_free(envlist);
 
-    /*
-     * Now that page sizes are configured in tcg_exec_init() we can do
-     * proper page alignment for guest_base.
-     */
-    guest_base = HOST_PAGE_ALIGN(guest_base);
-
-    if (reserved_va || have_guest_base) {
-        guest_base = init_guest_space(guest_base, reserved_va, 0,
-                                      have_guest_base);
-        if (guest_base == (unsigned long)-1) {
-            fprintf(stderr, "Unable to reserve 0x%lx bytes of virtual address "
-                    "space for use as guest address space (check your virtual "
-                    "memory ulimit setting or reserve less using -R option)\n",
-                    reserved_va);
-            exit(EXIT_FAILURE);
-        }
-
-        if (reserved_va) {
-            mmap_next_start = reserved_va;
-        }
-    }
-
     /*
      * Read in mmap_min_addr kernel parameter.  This value is used
      * When loading the ELF image to determine whether guest_base
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/11 exec/cpu-all: Use bool for have_guest_base

In reply to Alex Bennée

From: Richard Henderson <[email protected]>

---
 include/exec/cpu-all.h | 2 +-
 bsd-user/main.c        | 4 ++--
 linux-user/main.c      | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
include/exec/cpu-all.h +1 -1
index 49384bb66a5..b4fb5832c4a 100644
@@ -159,7 +159,7 @@ static inline void tswap64s(uint64_t *s)
  * This allows the guest address space to be offset to a convenient location.
  */
 extern unsigned long guest_base;
-extern int have_guest_base;
+extern bool have_guest_base;
 extern unsigned long reserved_va;
 
 #if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS
bsd-user/main.c +2 -2
index 770c2b267ad..aef5531628a 100644
@@ -42,7 +42,7 @@
 int singlestep;
 unsigned long mmap_min_addr;
 unsigned long guest_base;
-int have_guest_base;
+bool have_guest_base;
 unsigned long reserved_va;
 
 static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX;
@@ -828,7 +828,7 @@ int main(int argc, char **argv)
             }
         } else if (!strcmp(r, "B")) {
            guest_base = strtol(argv[optind++], NULL, 0);
-           have_guest_base = 1;
+           have_guest_base = true;
         } else if (!strcmp(r, "drop-ld-preload")) {
             (void) envlist_unsetenv(envlist, "LD_PRELOAD");
         } else if (!strcmp(r, "bsd")) {
linux-user/main.c +2 -2
index 1d20a83d4e8..90ad365b439 100644
@@ -59,7 +59,7 @@ static const char *cpu_type;
 static const char *seed_optarg;
 unsigned long mmap_min_addr;
 unsigned long guest_base;
-int have_guest_base;
+bool have_guest_base;
 
 /*
  * Used to implement backwards-compatibility for the `-strace`, and
@@ -334,7 +334,7 @@ static void handle_arg_cpu(const char *arg)
 static void handle_arg_guest_base(const char *arg)
 {
     guest_base = strtol(arg, NULL, 0);
-    have_guest_base = 1;
+    have_guest_base = true;
 }
 
 static void handle_arg_reserved_va(const char *arg)
Signature · 1 line
2.20.1
Reviewed-by on v1 2/11
#3 lore raw

Re: [PATCH v1 02/11] exec/cpu-all: Use bool for have_guest_base

Quoted 60 lines · Alex Bennée

From: Richard Henderson <[email protected]>

---
  include/exec/cpu-all.h | 2 +-
  bsd-user/main.c        | 4 ++--
  linux-user/main.c      | 4 ++--
  3 files changed, 5 insertions(+), 5 deletions(-)
include/exec/cpu-all.h +1 -1
index 49384bb66a5..b4fb5832c4a 100644
@@ -159,7 +159,7 @@ static inline void tswap64s(uint64_t *s)
   * This allows the guest address space to be offset to a convenient location.
   */
  extern unsigned long guest_base;
-extern int have_guest_base;
+extern bool have_guest_base;
  extern unsigned long reserved_va;
 
  #if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS
bsd-user/main.c +2 -2
index 770c2b267ad..aef5531628a 100644
@@ -42,7 +42,7 @@
  int singlestep;
  unsigned long mmap_min_addr;
  unsigned long guest_base;
-int have_guest_base;
+bool have_guest_base;
  unsigned long reserved_va;
 
  static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX;
@@ -828,7 +828,7 @@ int main(int argc, char **argv)
              }
          } else if (!strcmp(r, "B")) {
             guest_base = strtol(argv[optind++], NULL, 0);
-           have_guest_base = 1;
+           have_guest_base = true;
          } else if (!strcmp(r, "drop-ld-preload")) {
              (void) envlist_unsetenv(envlist, "LD_PRELOAD");
          } else if (!strcmp(r, "bsd")) {
linux-user/main.c +1 -1
index 1d20a83d4e8..90ad365b439 100644
@@ -59,7 +59,7 @@ static const char *cpu_type;
  static const char *seed_optarg;
  unsigned long mmap_min_addr;
  unsigned long guest_base;
-int have_guest_base;
+bool have_guest_base;
 
  /*
   * Used to implement backwards-compatibility for the `-strace`, and

linux-user/main.c static void handle_arg_cpu(const char *arg) · line 340

Quoted 8 lines
linux-user/main.c +1 -1
@@ -334,7 +334,7 @@ static void handle_arg_cpu(const char *arg)
  static void handle_arg_guest_base(const char *arg)
  {
      guest_base = strtol(arg, NULL, 0);
-    have_guest_base = 1;
+    have_guest_base = true;
  }
 
  static void handle_arg_reserved_va(const char *arg)
#4 lore raw

PATCH 3/11 accel/tcg: Relax va restrictions on 64-bit guests

In reply to Alex Bennée

From: Richard Henderson <[email protected]>

We cannot at present limit a 64-bit guest to a virtual address space smaller than the host. It will mostly work to ignore this limitation, except if the guest uses high bits of the address space for tags. But it will certainly work better, as presently we can wind up failing to allocate the guest stack.

Widen our user-only page tree to the host or abi pointer width. Remove the workaround for this problem from target/alpha. Always validate guest addresses vs reserved_va, as there we control allocation ourselves.

---
 include/exec/cpu-all.h    | 23 +++++++++++++++++++----
 target/alpha/cpu-param.h  | 15 ++-------------
 accel/tcg/translate-all.c | 15 +++++++++------
 3 files changed, 30 insertions(+), 23 deletions(-)
include/exec/cpu-all.h +19 -4
index b4fb5832c4a..c0c2fa3cc56 100644
@@ -162,12 +162,27 @@ extern unsigned long guest_base;
 extern bool have_guest_base;
 extern unsigned long reserved_va;
 
-#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS
-#define GUEST_ADDR_MAX (~0ul)
+/*
+ * Limit the guest addresses as best we can.
+ *
+ * When not using -R reserved_va, we cannot really limit the guest
+ * to less address space than the host.  For 32-bit guests, this
+ * acts as a sanity check that we're not giving the guest an address
+ * that it cannot even represent.  For 64-bit guests... the address
+ * might not be what the real kernel would give, but it is at least
+ * representable in the guest.
+ *
+ * TODO: Improve address allocation to avoid this problem, and to
+ * avoid setting bits at the top of guest addresses that might need
+ * to be used for tags.
+ */
+#if MIN(TARGET_VIRT_ADDR_SPACE_BITS, TARGET_ABI_BITS) <= 32
+# define GUEST_ADDR_MAX_  UINT32_MAX
 #else
-#define GUEST_ADDR_MAX (reserved_va ? reserved_va - 1 : \
-                                    (1ul << TARGET_VIRT_ADDR_SPACE_BITS) - 1)
+# define GUEST_ADDR_MAX_  ~0ul
 #endif
+#define GUEST_ADDR_MAX    (reserved_va ? reserved_va - 1 : GUEST_ADDR_MAX_)
+
 #else
 
 #include "exec/hwaddr.h"
target/alpha/cpu-param.h +2 -13
index 692aee27ca9..1153992e42a 100644
@@ -10,22 +10,11 @@
 
 #define TARGET_LONG_BITS 64
 #define TARGET_PAGE_BITS 13
-#ifdef CONFIG_USER_ONLY
-/*
- * ??? The kernel likes to give addresses in high memory.  If the host has
- * more virtual address space than the guest, this can lead to impossible
- * allocations.  Honor the long-standing assumption that only kernel addrs
- * are negative, but otherwise allow allocations anywhere.  This could lead
- * to tricky emulation problems for programs doing tagged addressing, but
- * that's far fewer than encounter the impossible allocation problem.
- */
-#define TARGET_PHYS_ADDR_SPACE_BITS  63
-#define TARGET_VIRT_ADDR_SPACE_BITS  63
-#else
+
 /* ??? EV4 has 34 phys addr bits, EV5 has 40, EV6 has 44.  */
 #define TARGET_PHYS_ADDR_SPACE_BITS  44
 #define TARGET_VIRT_ADDR_SPACE_BITS  (30 + TARGET_PAGE_BITS)
-#endif
+
 #define NB_MMU_MODES 3
 
 #endif
accel/tcg/translate-all.c +9 -6
index 9924e66d1f7..e4f703a7e6d 100644
@@ -173,8 +173,13 @@ struct page_collection {
 #define TB_FOR_EACH_JMP(head_tb, tb, n)                                 \
     TB_FOR_EACH_TAGGED((head_tb)->jmp_list_head, tb, n, jmp_list_next)
 
-/* In system mode we want L1_MAP to be based on ram offsets,
-   while in user mode we want it to be based on virtual addresses.  */
+/*
+ * In system mode we want L1_MAP to be based on ram offsets,
+ * while in user mode we want it to be based on virtual addresses.
+ *
+ * TODO: For user mode, see the caveat re host vs guest virtual
+ * address spaces near GUEST_ADDR_MAX.
+ */
 #if !defined(CONFIG_USER_ONLY)
 #if HOST_LONG_BITS < TARGET_PHYS_ADDR_SPACE_BITS
 # define L1_MAP_ADDR_SPACE_BITS  HOST_LONG_BITS
@@ -182,7 +187,7 @@ struct page_collection {
 # define L1_MAP_ADDR_SPACE_BITS  TARGET_PHYS_ADDR_SPACE_BITS
 #endif
 #else
-# define L1_MAP_ADDR_SPACE_BITS  TARGET_VIRT_ADDR_SPACE_BITS
+# define L1_MAP_ADDR_SPACE_BITS  MIN(HOST_LONG_BITS, TARGET_ABI_BITS)
 #endif
 
 /* Size of the L2 (and L3, etc) page tables.  */
@@ -2497,9 +2502,7 @@ void page_set_flags(target_ulong start, target_ulong end, int flags)
     /* This function should never be called with addresses outside the
        guest address space.  If this assert fires, it probably indicates
        a missing call to h2g_valid.  */
-#if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS
-    assert(end <= ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS));
-#endif
+    assert(end - 1 <= GUEST_ADDR_MAX);
     assert(start < end);
     assert_memory_lock();
 
Signature · 1 line
2.20.1
#5 lore raw

PATCH 4/11 linux-user/ppc: Fix padding in mcontext_t for ppc64

In reply to Alex Bennée

From: Richard Henderson <[email protected]>

The padding that was added in 95cda4c44ee was added to a union, and so it had no effect. This fixes misalignment errors detected by clang sanitizers for ppc64 and ppc64le.

In addition, only ppc64 allocates space for VSX registers, so do not save them for ppc32. The kernel only has references to CONFIG_SPE in signal_32.c, so do not attempt to save them for ppc64.

---
 linux-user/ppc/signal.c | 69 +++++++++++++++++------------------------
 1 file changed, 29 insertions(+), 40 deletions(-)
linux-user/ppc/signal.c +29 -40
index ecd99736b7e..20a02c197cb 100644
@@ -35,12 +35,26 @@ struct target_mcontext {
     target_ulong mc_gregs[48];
     /* Includes fpscr.  */
     uint64_t mc_fregs[33];
+
 #if defined(TARGET_PPC64)
     /* Pointer to the vector regs */
     target_ulong v_regs;
+    /*
+     * On ppc64, this mcontext structure is naturally *unaligned*,
+     * or rather it is aligned on a 8 bytes boundary but not on
+     * a 16 byte boundary.  This pad fixes it up.  This is why we
+     * cannot use ppc_avr_t, which would force alignment.  This is
+     * also why the vector regs are referenced in the ABI by the
+     * v_regs pointer above so any amount of padding can be added here.
+     */
+    target_ulong pad;
+    /* VSCR and VRSAVE are saved separately.  Also reserve space for VSX. */
+    struct {
+        uint64_t altivec[34 + 16][2];
+    } mc_vregs;
 #else
     target_ulong mc_pad[2];
-#endif
+
     /* We need to handle Altivec and SPE at the same time, which no
        kernel needs to do.  Fortunately, the kernel defines this bit to
        be Altivec-register-large all the time, rather than trying to
@@ -48,32 +62,14 @@ struct target_mcontext {
     union {
         /* SPE vector registers.  One extra for SPEFSCR.  */
         uint32_t spe[33];
-        /* Altivec vector registers.  The packing of VSCR and VRSAVE
-           varies depending on whether we're PPC64 or not: PPC64 splits
-           them apart; PPC32 stuffs them together.
-           We also need to account for the VSX registers on PPC64
-        */
-#if defined(TARGET_PPC64)
-#define QEMU_NVRREG (34 + 16)
-        /* On ppc64, this mcontext structure is naturally *unaligned*,
-         * or rather it is aligned on a 8 bytes boundary but not on
-         * a 16 bytes one. This pad fixes it up. This is also why the
-         * vector regs are referenced by the v_regs pointer above so
-         * any amount of padding can be added here
-         */
-        target_ulong pad;
-#else
-        /* On ppc32, we are already aligned to 16 bytes */
-#define QEMU_NVRREG 33
-#endif
-        /* We cannot use ppc_avr_t here as we do *not* want the implied
-         * 16-bytes alignment that would result from it. This would have
-         * the effect of making the whole struct target_mcontext aligned
-         * which breaks the layout of struct target_ucontext on ppc64.
+        /*
+         * Altivec vector registers.  One extra for VRSAVE.
+         * On ppc32, we are already aligned to 16 bytes.  We could
+         * use ppc_avr_t, but choose to share the same type as ppc64.
          */
-        uint64_t altivec[QEMU_NVRREG][2];
-#undef QEMU_NVRREG
+        uint64_t altivec[33][2];
     } mc_vregs;
+#endif
 };
 
 /* See arch/powerpc/include/asm/sigcontext.h.  */
@@ -278,6 +274,7 @@ static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame)
         __put_user((uint32_t)env->spr[SPR_VRSAVE], vrsave);
     }
 
+#if defined(TARGET_PPC64)
     /* Save VSX second halves */
     if (env->insns_flags2 & PPC2_VSX) {
         uint64_t *vsregs = (uint64_t *)&frame->mc_vregs.altivec[34];
@@ -286,6 +283,7 @@ static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame)
             __put_user(*vsrl, &vsregs[i]);
         }
     }
+#endif
 
     /* Save floating point registers.  */
     if (env->insns_flags & PPC_FLOAT) {
@@ -296,22 +294,18 @@ static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame)
         __put_user((uint64_t) env->fpscr, &frame->mc_fregs[32]);
     }
 
+#if !defined(TARGET_PPC64)
     /* Save SPE registers.  The kernel only saves the high half.  */
     if (env->insns_flags & PPC_SPE) {
-#if defined(TARGET_PPC64)
-        for (i = 0; i < ARRAY_SIZE(env->gpr); i++) {
-            __put_user(env->gpr[i] >> 32, &frame->mc_vregs.spe[i]);
-        }
-#else
         for (i = 0; i < ARRAY_SIZE(env->gprh); i++) {
             __put_user(env->gprh[i], &frame->mc_vregs.spe[i]);
         }
-#endif
         /* Set MSR_SPE in the saved MSR value to indicate that
            frame->mc_vregs contains valid data.  */
         msr |= MSR_SPE;
         __put_user(env->spe_fscr, &frame->mc_vregs.spe[32]);
     }
+#endif
 
     /* Store MSR.  */
     __put_user(msr, &frame->mc_gregs[TARGET_PT_MSR]);
@@ -392,6 +386,7 @@ static void restore_user_regs(CPUPPCState *env,
         __get_user(env->spr[SPR_VRSAVE], vrsave);
     }
 
+#if defined(TARGET_PPC64)
     /* Restore VSX second halves */
     if (env->insns_flags2 & PPC2_VSX) {
         uint64_t *vsregs = (uint64_t *)&frame->mc_vregs.altivec[34];
@@ -400,6 +395,7 @@ static void restore_user_regs(CPUPPCState *env,
             __get_user(*vsrl, &vsregs[i]);
         }
     }
+#endif
 
     /* Restore floating point registers.  */
     if (env->insns_flags & PPC_FLOAT) {
@@ -412,22 +408,15 @@ static void restore_user_regs(CPUPPCState *env,
         env->fpscr = (uint32_t) fpscr;
     }
 
+#if !defined(TARGET_PPC64)
     /* Save SPE registers.  The kernel only saves the high half.  */
     if (env->insns_flags & PPC_SPE) {
-#if defined(TARGET_PPC64)
-        for (i = 0; i < ARRAY_SIZE(env->gpr); i++) {
-            uint32_t hi;
-
-            __get_user(hi, &frame->mc_vregs.spe[i]);
-            env->gpr[i] = ((uint64_t)hi << 32) | ((uint32_t) env->gpr[i]);
-        }
-#else
         for (i = 0; i < ARRAY_SIZE(env->gprh); i++) {
             __get_user(env->gprh[i], &frame->mc_vregs.spe[i]);
         }
-#endif
         __get_user(env->spe_fscr, &frame->mc_vregs.spe[32]);
     }
+#endif
 }
 
 #if !defined(TARGET_PPC64)
Signature · 1 line
2.20.1
#6 lore raw

PATCH 5/11 tests/docker: add docs FEATURE flag and use for test-misc

In reply to Alex Bennée

The test-misc docker test fails on a number of images which don't have the prerequisites to build the docs. Use the FEATURES flag so we can skip those tests.

As the sphinx test fails to detect whatever feature we need to get hxtool to work we drop them from debian9 so the windows build doesn't attempt to build the docs.

---
 tests/docker/dockerfiles/debian10.docker   | 2 ++
 tests/docker/dockerfiles/debian9.docker    | 2 --
 tests/docker/dockerfiles/fedora.docker     | 2 +-
 tests/docker/dockerfiles/travis.docker     | 2 +-
 tests/docker/dockerfiles/ubuntu.docker     | 2 +-
 tests/docker/dockerfiles/ubuntu1804.docker | 2 +-
 tests/docker/test-misc                     | 2 ++
 7 files changed, 8 insertions(+), 6 deletions(-)
tests/docker/dockerfiles/debian10.docker +2 -0
index 2fcdc406e83..0769700a416 100644
@@ -34,3 +34,5 @@ RUN apt update && \
         python3-sphinx \
         texinfo \
         $(apt-get -s build-dep qemu | egrep ^Inst | fgrep '[all]' | cut -d\  -f2)
+
+ENV FEATURES docs
tests/docker/dockerfiles/debian9.docker +0 -2
index 92edbbf0f48..08cc970feb1 100644
@@ -30,6 +30,4 @@ RUN apt update && \
         pkg-config \
         psmisc \
         python3 \
-        python3-sphinx \
-        texinfo \
         $(apt-get -s build-dep qemu | egrep ^Inst | fgrep '[all]' | cut -d\  -f2)
tests/docker/dockerfiles/fedora.docker +1 -1
index 4bd2c953af8..179575ecaaa 100644
@@ -103,4 +103,4 @@ ENV QEMU_CONFIGURE_OPTS --python=/usr/bin/python3
 RUN dnf install -y $PACKAGES
 RUN rpm -q $PACKAGES | sort > /packages.txt
 ENV PATH $PATH:/usr/libexec/python3-sphinx/
-ENV FEATURES mingw clang pyyaml asan
+ENV FEATURES mingw clang pyyaml asan docs
tests/docker/dockerfiles/travis.docker +1 -1
index e8eb48dccfd..591282561bc 100644
@@ -13,5 +13,5 @@ RUN apt-get -y install device-tree-compiler python3 python3-yaml dh-autoreconf g
 # Travis tools require PhantomJS / Neo4j / Maven accessible
 # in their PATH (QEMU build won't access them).
 ENV PATH /usr/local/phantomjs/bin:/usr/local/phantomjs:/usr/local/neo4j-3.2.7/bin:/usr/local/maven-3.5.2/bin:/usr/local/cmake-3.9.2/bin:/usr/local/clang-5.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-ENV FEATURES clang pyyaml
+ENV FEATURES clang pyyaml docs
 USER travis
tests/docker/dockerfiles/ubuntu.docker +1 -1
index b6c7b41dddd..eeb3b22bf20 100644
@@ -68,4 +68,4 @@ ENV PACKAGES flex bison \
 RUN apt-get update && \
     DEBIAN_FRONTEND=noninteractive apt-get -y install $PACKAGES
 RUN dpkg -l $PACKAGES | sort > /packages.txt
-ENV FEATURES clang pyyaml sdl2
+ENV FEATURES clang pyyaml sdl2 docs
tests/docker/dockerfiles/ubuntu1804.docker +1 -1
index 1efedeef995..f66b06f4cff 100644
@@ -54,7 +54,7 @@ ENV PACKAGES flex bison \
 RUN apt-get update && \
     DEBIAN_FRONTEND=noninteractive apt-get -y install $PACKAGES
 RUN dpkg -l $PACKAGES | sort > /packages.txt
-ENV FEATURES clang pyyaml sdl2
+ENV FEATURES clang pyyaml sdl2 docs
 
 # https://bugs.launchpad.net/qemu/+bug/1838763
 ENV QEMU_CONFIGURE_OPTS --disable-libssh
tests/docker/test-misc +2 -0
index d480afedca7..cc94a738dd0 100755
@@ -14,6 +14,8 @@
 
 . common.rc
 
+requires docs
+
 cd "$BUILD_DIR"
 
 # build everything else but QEMU
Signature · 1 line
2.20.1
Reviewed-by on v1 5/11
#7 lore raw

Re: [PATCH v1 05/11] tests/docker: add docs FEATURE flag and use for test-misc

Quoted 89 lines · Alex Bennée

The test-misc docker test fails on a number of images which don't have the prerequisites to build the docs. Use the FEATURES flag so we can skip those tests.

As the sphinx test fails to detect whatever feature we need to get hxtool to work we drop them from debian9 so the windows build doesn't attempt to build the docs.

---
  tests/docker/dockerfiles/debian10.docker   | 2 ++
  tests/docker/dockerfiles/debian9.docker    | 2 --
  tests/docker/dockerfiles/fedora.docker     | 2 +-
  tests/docker/dockerfiles/travis.docker     | 2 +-
  tests/docker/dockerfiles/ubuntu.docker     | 2 +-
  tests/docker/dockerfiles/ubuntu1804.docker | 2 +-
  tests/docker/test-misc                     | 2 ++
  7 files changed, 8 insertions(+), 6 deletions(-)
tests/docker/dockerfiles/debian10.docker +2 -0
index 2fcdc406e83..0769700a416 100644
@@ -34,3 +34,5 @@ RUN apt update && \
          python3-sphinx \
          texinfo \
          $(apt-get -s build-dep qemu | egrep ^Inst | fgrep '[all]' | cut -d\  -f2)
+
+ENV FEATURES docs
tests/docker/dockerfiles/debian9.docker +0 -2
index 92edbbf0f48..08cc970feb1 100644
@@ -30,6 +30,4 @@ RUN apt update && \
          pkg-config \
          psmisc \
          python3 \
-        python3-sphinx \
-        texinfo \
          $(apt-get -s build-dep qemu | egrep ^Inst | fgrep '[all]' | cut -d\  -f2)
tests/docker/dockerfiles/fedora.docker +1 -1
index 4bd2c953af8..179575ecaaa 100644
@@ -103,4 +103,4 @@ ENV QEMU_CONFIGURE_OPTS --python=/usr/bin/python3
  RUN dnf install -y $PACKAGES
  RUN rpm -q $PACKAGES | sort > /packages.txt
  ENV PATH $PATH:/usr/libexec/python3-sphinx/
-ENV FEATURES mingw clang pyyaml asan
+ENV FEATURES mingw clang pyyaml asan docs
tests/docker/dockerfiles/travis.docker +1 -1
index e8eb48dccfd..591282561bc 100644
@@ -13,5 +13,5 @@ RUN apt-get -y install device-tree-compiler python3 python3-yaml dh-autoreconf g
  # Travis tools require PhantomJS / Neo4j / Maven accessible
  # in their PATH (QEMU build won't access them).
  ENV PATH /usr/local/phantomjs/bin:/usr/local/phantomjs:/usr/local/neo4j-3.2.7/bin:/usr/local/maven-3.5.2/bin:/usr/local/cmake-3.9.2/bin:/usr/local/clang-5.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-ENV FEATURES clang pyyaml
+ENV FEATURES clang pyyaml docs
  USER travis
tests/docker/dockerfiles/ubuntu.docker +1 -1
index b6c7b41dddd..eeb3b22bf20 100644
@@ -68,4 +68,4 @@ ENV PACKAGES flex bison \
  RUN apt-get update && \
      DEBIAN_FRONTEND=noninteractive apt-get -y install $PACKAGES
  RUN dpkg -l $PACKAGES | sort > /packages.txt
-ENV FEATURES clang pyyaml sdl2
+ENV FEATURES clang pyyaml sdl2 docs
tests/docker/dockerfiles/ubuntu1804.docker +1 -1
index 1efedeef995..f66b06f4cff 100644
@@ -54,7 +54,7 @@ ENV PACKAGES flex bison \
  RUN apt-get update && \
      DEBIAN_FRONTEND=noninteractive apt-get -y install $PACKAGES
  RUN dpkg -l $PACKAGES | sort > /packages.txt
-ENV FEATURES clang pyyaml sdl2
+ENV FEATURES clang pyyaml sdl2 docs
 
  # https://bugs.launchpad.net/qemu/+bug/1838763
  ENV QEMU_CONFIGURE_OPTS --disable-libssh
tests/docker/test-misc +0 -0
index d480afedca7..cc94a738dd0 100755

tests/docker/test-misc line 17

Quoted 4 lines
tests/docker/test-misc +1 -0
@@ -14,6 +14,8 @@
 
  . common.rc
 
+requires docs

TIL 'requires' macro. Clean fix.

Quoted 5 lines
tests/docker/test-misc +1 -0
+
  cd "$BUILD_DIR"
 
  # build everything else but QEMU
Reviewed-by on v1 5/11
#8 lore raw

Re: [PATCH v1 05/11] tests/docker: add docs FEATURE flag and use for test-misc

In reply to Alex Bennée
Quoted 9 lines · Alex Bennée

The test-misc docker test fails on a number of images which don't have the prerequisites to build the docs. Use the FEATURES flag so we can skip those tests.

As the sphinx test fails to detect whatever feature we need to get hxtool to work we drop them from debian9 so the windows build doesn't attempt to build the docs.

Quoted 9 lines
---
 tests/docker/dockerfiles/debian10.docker   | 2 ++
 tests/docker/dockerfiles/debian9.docker    | 2 --
 tests/docker/dockerfiles/fedora.docker     | 2 +-
 tests/docker/dockerfiles/travis.docker     | 2 +-
 tests/docker/dockerfiles/ubuntu.docker     | 2 +-
 tests/docker/dockerfiles/ubuntu1804.docker | 2 +-
 tests/docker/test-misc                     | 2 ++
 7 files changed, 8 insertions(+), 6 deletions(-)

r~

#9 lore raw

PATCH 6/11 configure: redirect sphinx-build check to config.log

In reply to Alex Bennée

Otherwise it's hard to debug whats going on.

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
index 233c671aaa9..a207cce82bc 100755
@@ -4936,7 +4936,7 @@ has_sphinx_build() {
     # sphinx-build doesn't exist at all or if it is too old.
     mkdir -p "$TMPDIR1/sphinx"
     touch "$TMPDIR1/sphinx/index.rst"
-    "$sphinx_build" -c "$source_path/docs" -b html "$TMPDIR1/sphinx" "$TMPDIR1/sphinx/out" >/dev/null 2>&1
+    "$sphinx_build" -c "$source_path/docs" -b html "$TMPDIR1/sphinx" "$TMPDIR1/sphinx/out" >> config.log 2>&1
 }
 
 # Check if tools are available to build documentation.
Signature · 1 line
2.20.1
Reviewed-by on v1 6/11
#10 lore raw

Re: [PATCH v1 06/11] configure: redirect sphinx-build check to config.log

Quoted 13 lines · Alex Bennée

Otherwise it's hard to debug whats going on.

---
  configure | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
configure +0 -0
index 233c671aaa9..a207cce82bc 100755

configure has_sphinx_build() { · line 4942

Quoted 8 lines
configure +1 -1
@@ -4936,7 +4936,7 @@ has_sphinx_build() {
      # sphinx-build doesn't exist at all or if it is too old.
      mkdir -p "$TMPDIR1/sphinx"
      touch "$TMPDIR1/sphinx/index.rst"
-    "$sphinx_build" -c "$source_path/docs" -b html "$TMPDIR1/sphinx" "$TMPDIR1/sphinx/out" >/dev/null 2>&1
+    "$sphinx_build" -c "$source_path/docs" -b html "$TMPDIR1/sphinx" "$TMPDIR1/sphinx/out" >> config.log 2>&1
  }
 
  # Check if tools are available to build documentation.
#12 lore raw

PATCH 7/11 configure: disable PIE for Windows builds

In reply to Alex Bennée

It seems on some compilers the test can pass but still give you broken binaries.

[AJB untested - please could windows users test]

Fixes d2cd29e30736
Cc Bug 1871798 <[email protected]>
Cc James Le Cuirot <[email protected]>
---
 configure | 1 +
 1 file changed, 1 insertion(+)
configure +1 -0
index a207cce82bc..e9c5f630c14 100755
@@ -807,6 +807,7 @@ MINGW32*)
     audio_drv_list=""
   fi
   supported_os="yes"
+  pie="no"
 ;;
 GNU/kFreeBSD)
   bsd="yes"
Signature · 1 line
2.20.1
Tested-by on v1 7/11
#13 lore raw

Re: [PATCH v1 07/11] configure: disable PIE for Windows builds

Quoted 27 lines · Alex Bennée

It seems on some compilers the test can pass but still give you broken binaries.

[AJB untested - please could windows users test]

Fixes d2cd29e30736
Cc Bug 1871798 <[email protected]>
Cc James Le Cuirot <[email protected]>
---
 configure | 1 +
 1 file changed, 1 insertion(+)
configure +1 -1
index a207cce82bc..e9c5f630c14 100755
@@ -807,6 +807,7 @@ MINGW32*)
     audio_drv_list=""
   fi
   supported_os="yes"
+  pie="no"
 ;;
 GNU/kFreeBSD)
   bsd="yes"
--
Quoted 2 lines

2.20.1

Solves my issue! So,

Reviewed-by on v1 7/11
#14 lore raw

Re: [PATCH v1 07/11] configure: disable PIE for Windows builds

In reply to Alex Bennée
Quoted 20 lines · Alex Bennée

It seems on some compilers the test can pass but still give you broken binaries.

[AJB untested - please could windows users test]

Fixes d2cd29e30736
Cc Bug 1871798 <[email protected]>
Cc James Le Cuirot <[email protected]>
---
  configure | 1 +
  1 file changed, 1 insertion(+)
configure +0 -0
index a207cce82bc..e9c5f630c14 100755

configure MINGW32*) · line 813

Quoted 7 lines
configure +1 -0
@@ -807,6 +807,7 @@ MINGW32*)
      audio_drv_list=""
    fi
    supported_os="yes"
+  pie="no"
  ;;
  GNU/kFreeBSD)
    bsd="yes"
Reviewed-by on v1 7/11
#15 lore raw

Re: [PATCH v1 07/11] configure: disable PIE for Windows builds

In reply to Alex Bennée
Quoted 5 lines · Alex Bennée

It seems on some compilers the test can pass but still give you broken binaries.

[AJB untested - please could windows users test]

Quoted 8 lines
Fixes d2cd29e30736
Cc Bug 1871798 <[email protected]>
Cc James Le Cuirot <[email protected]>
---
 configure | 1 +
 1 file changed, 1 insertion(+)

r~

#16 lore raw

PATCH 8/11 target/m68k/helper: Fix m68k_fpu_gdb_get_reg() use of GByteArray

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

Since a010bdbe719 the gdbstub API takes a GByteArray*. Unfortunately we forgot to update the gdb_get_reg*() calls. Do it now.

Fixes a010bdbe719 ("extend GByteArray to read register helpers")

Message-Id: <[email protected]>

---
 target/m68k/helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/m68k/helper.c +2 -2
index 014657c6372..cad40838956 100644
@@ -109,8 +109,8 @@ static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int n)
 {
     if (n < 8) {
         int len = gdb_get_reg16(mem_buf, env->fregs[n].l.upper);
-        len += gdb_get_reg16(mem_buf + len, 0);
-        len += gdb_get_reg64(mem_buf + len, env->fregs[n].l.lower);
+        len += gdb_get_reg16(mem_buf, 0);
+        len += gdb_get_reg64(mem_buf, env->fregs[n].l.lower);
         return len;
     }
     switch (n) {
Signature · 1 line
2.20.1
Reviewed-by on v1 8/11
#17 lore raw

Re: [PATCH v1 08/11] target/m68k/helper: Fix m68k_fpu_gdb_get_reg() use of GByteArray

Quoted 11 lines · Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

Since a010bdbe719 the gdbstub API takes a GByteArray*. Unfortunately we forgot to update the gdb_get_reg*() calls. Do it now.

Fixes a010bdbe719 ("extend GByteArray to read register helpers")
Quoted 4 lines

Message-Id: <[email protected]>

---
 target/m68k/helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

r~

#18 lore raw

PATCH 9/11 gdbstub: i386: Fix gdb_get_reg16() parameter to unbreak gdb

In reply to Alex Bennée

From: Peter Xu <[email protected]>

We should only pass in gdb_get_reg16() with the GByteArray* object itself, no need to shift. Without this patch, gdb remote attach will crash QEMU.

Fixes a010bdbe719 ("extend GByteArray to read register helpers")

Message-Id: <[email protected]>

---
 target/i386/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/gdbstub.c +1 -1
index f3d23b614ee..b98a99500ae 100644
@@ -106,7 +106,7 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
     } else if (n >= IDX_FP_REGS && n < IDX_FP_REGS + 8) {
         floatx80 *fp = (floatx80 *) &env->fpregs[n - IDX_FP_REGS];
         int len = gdb_get_reg64(mem_buf, cpu_to_le64(fp->low));
-        len += gdb_get_reg16(mem_buf + len, cpu_to_le16(fp->high));
+        len += gdb_get_reg16(mem_buf, cpu_to_le16(fp->high));
         return len;
     } else if (n >= IDX_XMM_REGS && n < IDX_XMM_REGS + CPU_NB_REGS) {
         n -= IDX_XMM_REGS;
Signature · 1 line
2.20.1
Tested-by on v1 9/11
#19 lore raw

Re: [PATCH v1 09/11] gdbstub: i386: Fix gdb_get_reg16() parameter to unbreak gdb

Quoted 32 lines · Alex Bennée

From: Peter Xu <[email protected]>

We should only pass in gdb_get_reg16() with the GByteArray* object itself, no need to shift. Without this patch, gdb remote attach will crash QEMU.

Fixes a010bdbe719 ("extend GByteArray to read register helpers")

Message-Id: <[email protected]>

---
 target/i386/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/gdbstub.c +1 -1
index f3d23b614ee..b98a99500ae 100644
@@ -106,7 +106,7 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
     } else if (n >= IDX_FP_REGS && n < IDX_FP_REGS + 8) {
         floatx80 *fp = (floatx80 *) &env->fpregs[n - IDX_FP_REGS];
         int len = gdb_get_reg64(mem_buf, cpu_to_le64(fp->low));
-        len += gdb_get_reg16(mem_buf + len, cpu_to_le16(fp->high));
+        len += gdb_get_reg16(mem_buf, cpu_to_le16(fp->high));
         return len;
     } else if (n >= IDX_XMM_REGS && n < IDX_XMM_REGS + CPU_NB_REGS) {
         n -= IDX_XMM_REGS;
Signature · 1 line
2.20.1

I had the following issue while attaching to qemu started with gdbserver listening:

(gdb) target remote :1234
Remote debugging using :1234
Remote communication error. Target disconnected.: Connection reset by peer.

$ qemu-system-x86_64 -m 1G -smp 4 ... -s
ERROR:qemu/gdbstub.c:1843:handle_read_all_regs: assertion failed: (len == gdbserver_state.mem_buf->len)
Bail out! ERROR:qemu/gdbstub.c:1843:handle_read_all_regs: assertion failed: (len == gdbserver_state.mem_buf->len)

Thanks to Philippe, I tried this patch and it solves my issue:

Thanks,
Stefano

#20 lore raw

Re: [PATCH v1 09/11] gdbstub: i386: Fix gdb_get_reg16() parameter to unbreak gdb

Quoted 37 lines · Stefano Garzarella
Quoted 32 lines · Alex Bennée

From: Peter Xu <[email protected]>

We should only pass in gdb_get_reg16() with the GByteArray* object itself, no need to shift. Without this patch, gdb remote attach will crash QEMU.

Fixes a010bdbe719 ("extend GByteArray to read register helpers")

Message-Id: <[email protected]>

---
 target/i386/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/gdbstub.c +1 -1
index f3d23b614ee..b98a99500ae 100644
@@ -106,7 +106,7 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
     } else if (n >= IDX_FP_REGS && n < IDX_FP_REGS + 8) {
         floatx80 *fp = (floatx80 *) &env->fpregs[n - IDX_FP_REGS];
         int len = gdb_get_reg64(mem_buf, cpu_to_le64(fp->low));
-        len += gdb_get_reg16(mem_buf + len, cpu_to_le16(fp->high));
+        len += gdb_get_reg16(mem_buf, cpu_to_le16(fp->high));
         return len;
     } else if (n >= IDX_XMM_REGS && n < IDX_XMM_REGS + CPU_NB_REGS) {
         n -= IDX_XMM_REGS;
Signature · 1 line
2.20.1

I had the following issue while attaching to qemu started with gdbserver listening:

Quoted 8 lines

(gdb) target remote :1234
Remote debugging using :1234
Remote communication error. Target disconnected.: Connection reset by peer.

$ qemu-system-x86_64 -m 1G -smp 4 ... -s
ERROR:qemu/gdbstub.c:1843:handle_read_all_regs: assertion failed: (len == gdbserver_state.mem_buf->len)
Bail out! ERROR:qemu/gdbstub.c:1843:handle_read_all_regs: assertion
failed: (len == gdbserver_state.mem_buf->len)

I'll see if the new gdb testcases can be generalised - they would have caught these snafus.

Quoted 8 lines

Thanks to Philippe, I tried this patch and it solves my issue:

Thanks,
Stefano

Signature · 1 line
Alex Bennée
#21 lore raw

Re: [PATCH v1 09/11] gdbstub: i386: Fix gdb_get_reg16() parameter to unbreak gdb

Quoted 44 lines · Alex Bennée
Quoted 41 lines · Stefano Garzarella
Quoted 32 lines · Alex Bennée

From: Peter Xu <[email protected]>

We should only pass in gdb_get_reg16() with the GByteArray* object itself, no need to shift. Without this patch, gdb remote attach will crash QEMU.

Fixes a010bdbe719 ("extend GByteArray to read register helpers")

Message-Id: <[email protected]>

---
 target/i386/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/gdbstub.c +1 -1
index f3d23b614ee..b98a99500ae 100644
@@ -106,7 +106,7 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
     } else if (n >= IDX_FP_REGS && n < IDX_FP_REGS + 8) {
         floatx80 *fp = (floatx80 *) &env->fpregs[n - IDX_FP_REGS];
         int len = gdb_get_reg64(mem_buf, cpu_to_le64(fp->low));
-        len += gdb_get_reg16(mem_buf + len, cpu_to_le16(fp->high));
+        len += gdb_get_reg16(mem_buf, cpu_to_le16(fp->high));
         return len;
     } else if (n >= IDX_XMM_REGS && n < IDX_XMM_REGS + CPU_NB_REGS) {
         n -= IDX_XMM_REGS;
Signature · 1 line
2.20.1

I had the following issue while attaching to qemu started with gdbserver listening:

(gdb) target remote :1234
Remote debugging using :1234
Remote communication error. Target disconnected.: Connection reset by peer.

Quoted 7 lines
Quoted 4 lines
$ qemu-system-x86_64 -m 1G -smp 4 ... -s
ERROR:qemu/gdbstub.c:1843:handle_read_all_regs: assertion failed: (len == gdbserver_state.mem_buf->len)
Bail out! ERROR:qemu/gdbstub.c:1843:handle_read_all_regs: assertion
failed: (len == gdbserver_state.mem_buf->len)

I'll see if the new gdb testcases can be generalised - they would have caught these snafus.

Yeah, that would be great!

Thanks,
Stefano

#22 lore raw

Re: [PATCH v1 09/11] gdbstub: i386: Fix gdb_get_reg16() parameter to unbreak gdb

In reply to Stefano Garzarella
Quoted 28 lines · Stefano Garzarella
Quoted 27 lines · Alex Bennée

From: Peter Xu <[email protected]>

We should only pass in gdb_get_reg16() with the GByteArray* object itself, no need to shift. Without this patch, gdb remote attach will crash QEMU.

Fixes a010bdbe719 ("extend GByteArray to read register helpers")

Message-Id: <[email protected]>

---
  target/i386/gdbstub.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/gdbstub.c +1 -1
index f3d23b614ee..b98a99500ae 100644
@@ -106,7 +106,7 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
      } else if (n >= IDX_FP_REGS && n < IDX_FP_REGS + 8) {
          floatx80 *fp = (floatx80 *) &env->fpregs[n - IDX_FP_REGS];
          int len = gdb_get_reg64(mem_buf, cpu_to_le64(fp->low));
-        len += gdb_get_reg16(mem_buf + len, cpu_to_le16(fp->high));
+        len += gdb_get_reg16(mem_buf, cpu_to_le16(fp->high));
          return len;
      } else if (n >= IDX_XMM_REGS && n < IDX_XMM_REGS + CPU_NB_REGS) {
Quoted 9 lines
Quoted 5 lines
target/i386/gdbstub.c +0 -0
          n -= IDX_XMM_REGS;
Signature · 1 line
2.20.1

I had the following issue while attaching to qemu started with gdbserver listening:

Alex, if possible can you amend this info please?

<---

Quoted 7 lines

(gdb) target remote :1234
Remote debugging using :1234
Remote communication error. Target disconnected.: Connection reset by peer.

$ qemu-system-x86_64 -m 1G -smp 4 ... -s
ERROR:qemu/gdbstub.c:1843:handle_read_all_regs: assertion failed: (len == gdbserver_state.mem_buf->len)
Bail out! ERROR:qemu/gdbstub.c:1843:handle_read_all_regs: assertion failed: (len == gdbserver_state.mem_buf->len)

--->

Thanks!

Quoted 10 lines

Thanks to Philippe, I tried this patch and it solves my issue:

Thanks,
Stefano

Reviewed-by on v1 9/11
#23 lore raw

Re: [PATCH v1 09/11] gdbstub: i386: Fix gdb_get_reg16() parameter to unbreak gdb

In reply to Alex Bennée
Quoted 6 lines · Alex Bennée

From: Peter Xu <[email protected]>

We should only pass in gdb_get_reg16() with the GByteArray* object itself, no need to shift. Without this patch, gdb remote attach will crash QEMU.

Quoted 8 lines
Fixes a010bdbe719 ("extend GByteArray to read register helpers")

Message-Id: <[email protected]>

---
 target/i386/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

r~

#24 lore raw

PATCH 10/11 linux-user: fix /proc/self/stat handling

In reply to Alex Bennée

In the original bug report long files names in Guix caused /proc/self/stat be truncated without the trailing ") " as specified in proc manpage which says:
(2) comm %s
The filename of the executable, in parentheses. This is visible whether or not the executable is swapped out.

Additionally it should only be reporting the executable name rather than the full path. Fix both these failings while cleaning up the code to use GString to build up the reported values. As the whole function is cleaned up also adjust the white space to the current coding style.

Message-ID: <[email protected]>

---
 linux-user/syscall.c | 43 +++++++++++++++++++------------------------
 1 file changed, 19 insertions(+), 24 deletions(-)
linux-user/syscall.c +19 -24
index 6495ddc4cda..674f70e70a5 100644
@@ -7295,34 +7295,29 @@ static int open_self_stat(void *cpu_env, int fd)
 {
     CPUState *cpu = env_cpu((CPUArchState *)cpu_env);
     TaskState *ts = cpu->opaque;
-    abi_ulong start_stack = ts->info->start_stack;
+    g_autoptr(GString) buf = g_string_new(NULL);
     int i;
 
     for (i = 0; i < 44; i++) {
-      char buf[128];
-      int len;
-      uint64_t val = 0;
-
-      if (i == 0) {
-        /* pid */
-        val = getpid();
-        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
-      } else if (i == 1) {
-        /* app name */
-        snprintf(buf, sizeof(buf), "(%s) ", ts->bprm->argv[0]);
-      } else if (i == 27) {
-        /* stack bottom */
-        val = start_stack;
-        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
-      } else {
-        /* for the rest, there is MasterCard */
-        snprintf(buf, sizeof(buf), "0%c", i == 43 ? '\n' : ' ');
-      }
+        if (i == 0) {
+            /* pid */
+            g_string_printf(buf, FMT_pid " ", getpid());
+        } else if (i == 1) {
+            /* app name */
+            gchar *bin = g_strrstr(ts->bprm->argv[0], "/");
+            bin = bin ? bin + 1 : ts->bprm->argv[0];
+            g_string_printf(buf, "(%.15s) ", bin);
+        } else if (i == 27) {
+            /* stack bottom */
+            g_string_printf(buf, TARGET_ABI_FMT_ld " ", ts->info->start_stack);
+        } else {
+            /* for the rest, there is MasterCard */
+            g_string_printf(buf, "0%c", i == 43 ? '\n' : ' ');
+        }
 
-      len = strlen(buf);
-      if (write(fd, buf, len) != len) {
-          return -1;
-      }
+        if (write(fd, buf->str, buf->len) != buf->len) {
+            return -1;
+        }
     }
 
     return 0;
Signature · 1 line
2.20.1
#25 lore raw

Re: [PATCH v1 10/11] linux-user: fix /proc/self/stat handling

Cc'ing Ludovic in case he can test with Guix-HPC.

Quoted 51 lines · Alex Bennée

In the original bug report long files names in Guix caused /proc/self/stat be truncated without the trailing ") " as specified in proc manpage which says:
(2) comm %s
The filename of the executable, in parentheses. This is visible whether or not the executable is swapped out.

Additionally it should only be reporting the executable name rather than the full path. Fix both these failings while cleaning up the code to use GString to build up the reported values. As the whole function is cleaned up also adjust the white space to the current coding style.

Message-ID: <[email protected]>

---
  linux-user/syscall.c | 43 +++++++++++++++++++------------------------
  1 file changed, 19 insertions(+), 24 deletions(-)
linux-user/syscall.c +1 -18
index 6495ddc4cda..674f70e70a5 100644
@@ -7295,34 +7295,29 @@ static int open_self_stat(void *cpu_env, int fd)
  {
      CPUState *cpu = env_cpu((CPUArchState *)cpu_env);
      TaskState *ts = cpu->opaque;
-    abi_ulong start_stack = ts->info->start_stack;
+    g_autoptr(GString) buf = g_string_new(NULL);
      int i;
 
      for (i = 0; i < 44; i++) {
-      char buf[128];
-      int len;
-      uint64_t val = 0;
-
-      if (i == 0) {
-        /* pid */
-        val = getpid();
-        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
-      } else if (i == 1) {
-        /* app name */
-        snprintf(buf, sizeof(buf), "(%s) ", ts->bprm->argv[0]);
-      } else if (i == 27) {
-        /* stack bottom */
-        val = start_stack;
-        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
-      } else {
-        /* for the rest, there is MasterCard */

linux-user/syscall.c static int open_self_stat(void *cpu_env, int fd) · line 7309

Quoted 10 lines
linux-user/syscall.c +8 -2
-        snprintf(buf, sizeof(buf), "0%c", i == 43 ? '\n' : ' ');
-      }
+        if (i == 0) {
+            /* pid */
+            g_string_printf(buf, FMT_pid " ", getpid());
+        } else if (i == 1) {
+            /* app name */
+            gchar *bin = g_strrstr(ts->bprm->argv[0], "/");
+            bin = bin ? bin + 1 : ts->bprm->argv[0];
+            g_string_printf(buf, "(%.15s) ", bin);

15 or 125? 15 seems short. From your previous test I understood it was 124, for sizeof("cat_with9_12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890___40").

Quoted 19 lines
linux-user/syscall.c +10 -4
+        } else if (i == 27) {
+            /* stack bottom */
+            g_string_printf(buf, TARGET_ABI_FMT_ld " ", ts->info->start_stack);
+        } else {
+            /* for the rest, there is MasterCard */
+            g_string_printf(buf, "0%c", i == 43 ? '\n' : ' ');
+        }
 
-      len = strlen(buf);
-      if (write(fd, buf, len) != len) {
-          return -1;
-      }
+        if (write(fd, buf->str, buf->len) != buf->len) {
+            return -1;
+        }
      }
 
      return 0;
#26 lore raw

Re: [PATCH v1 10/11] linux-user: fix /proc/self/stat handling

That was by inspection on my system which seems to truncate a lot earlier. It would be nice to find where in the Linux kernel it is output but I failed to grep the relevant function last night.

Quoted 92 lines · On Fri, 10 Apr 2020, 12:11 Philippe Mathieu-Daudé, <[email protected]> wrote:

Cc'ing Ludovic in case he can test with Guix-HPC.

Quoted 51 lines · Alex Bennée

In the original bug report long files names in Guix caused /proc/self/stat be truncated without the trailing ") " as specified in proc manpage which says:
(2) comm %s
The filename of the executable, in parentheses. This is visible whether or not the executable is swapped out.

Additionally it should only be reporting the executable name rather than the full path. Fix both these failings while cleaning up the code to use GString to build up the reported values. As the whole function is cleaned up also adjust the white space to the current coding style.

Message-ID: <[email protected]>

---
  linux-user/syscall.c | 43 +++++++++++++++++++------------------------
  1 file changed, 19 insertions(+), 24 deletions(-)
linux-user/syscall.c +1 -18
index 6495ddc4cda..674f70e70a5 100644
@@ -7295,34 +7295,29 @@ static int open_self_stat(void *cpu_env, int fd)
  {
      CPUState *cpu = env_cpu((CPUArchState *)cpu_env);
      TaskState *ts = cpu->opaque;
-    abi_ulong start_stack = ts->info->start_stack;
+    g_autoptr(GString) buf = g_string_new(NULL);
      int i;
 
      for (i = 0; i < 44; i++) {
-      char buf[128];
-      int len;
-      uint64_t val = 0;
-
-      if (i == 0) {
-        /* pid */
-        val = getpid();
-        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
-      } else if (i == 1) {
-        /* app name */
-        snprintf(buf, sizeof(buf), "(%s) ", ts->bprm->argv[0]);
-      } else if (i == 27) {
-        /* stack bottom */
-        val = start_stack;
-        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
-      } else {
-        /* for the rest, there is MasterCard */

linux-user/syscall.c static int open_self_stat(void *cpu_env, int fd) · line 7309

Quoted 10 lines
linux-user/syscall.c +8 -2
-        snprintf(buf, sizeof(buf), "0%c", i == 43 ? '\n' : ' ');
-      }
+        if (i == 0) {
+            /* pid */
+            g_string_printf(buf, FMT_pid " ", getpid());
+        } else if (i == 1) {
+            /* app name */
+            gchar *bin = g_strrstr(ts->bprm->argv[0], "/");
+            bin = bin ? bin + 1 : ts->bprm->argv[0];
+            g_string_printf(buf, "(%.15s) ", bin);

15 or 125? 15 seems short. From your previous test I understood it was 124, for

sizeof("cat_with9_12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890___40").

linux-user/syscall.c static int open_self_stat(void *cpu_env, int fd)

Quoted 3 lines
linux-user/syscall.c +3 -0
+        } else if (i == 27) {
+            /* stack bottom */
+            g_string_printf(buf, TARGET_ABI_FMT_ld " ",

ts->info->start_stack);

Quoted 16 lines
linux-user/syscall.c +7 -4
+        } else {
+            /* for the rest, there is MasterCard */
+            g_string_printf(buf, "0%c", i == 43 ? '\n' : ' ');
+        }
 
-      len = strlen(buf);
-      if (write(fd, buf, len) != len) {
-          return -1;
-      }
+        if (write(fd, buf->str, buf->len) != buf->len) {
+            return -1;
+        }
      }
 
      return 0;
#27 lore raw

Re: [PATCH v1 10/11] linux-user: fix /proc/self/stat handling

Quoted 1 line · Alex Bennée

That was by inspection on my system which seems to truncate a lot earlier. It would be nice to find where in the Linux kernel it is output but I failed to grep the relevant function last night.

OK. Patch is correct with this value, so:

Quoted 79 lines · On Fri, 10 Apr 2020, 12:11 Philippe Mathieu-Daudé, <[email protected]…
    Cc'ing Ludovic in case he can test with Guix-HPC.

    On 4/9/20 11:15 PM, Alex Bennée wrote:
     > In the original bug report long files names in Guix caused
     > /proc/self/stat be truncated without the trailing ") " as
    specified in
     > proc manpage which says:
     >      (2) comm  %s
     >             The  filename of the executable, in parentheses.  This
     >             is visible whether or not the  executable  is  swapped
     >             out.
     >
     > Additionally it should only be reporting the executable name rather
     > than the full path. Fix both these failings while cleaning up the
    code
     > to use GString to build up the reported values. As the whole function
     > is cleaned up also adjust the white space to the current coding
    style.
     >
     > Message-ID: <[email protected]
    <mailto:[email protected]>>
     > Reported-by: Brice Goglin <[email protected]
    <mailto:[email protected]>>
     > Cc: Philippe_Mathieu-Daudé <[email protected]
    <mailto:[email protected]>>
     > Signed-off-by: Alex Bennée <[email protected]
    <mailto:[email protected]>>
     > ---
     >   linux-user/syscall.c | 43
    +++++++++++++++++++------------------------
     >   1 file changed, 19 insertions(+), 24 deletions(-)
     >
     > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
     > index 6495ddc4cda..674f70e70a5 100644
     > --- a/linux-user/syscall.c
     > +++ b/linux-user/syscall.c
     > @@ -7295,34 +7295,29 @@ static int open_self_stat(void *cpu_env,
    int fd)
     >   {
     >       CPUState *cpu = env_cpu((CPUArchState *)cpu_env);
     >       TaskState *ts = cpu->opaque;
     > -    abi_ulong start_stack = ts->info->start_stack;
     > +    g_autoptr(GString) buf = g_string_new(NULL);
     >       int i;
     >
     >       for (i = 0; i < 44; i++) {
     > -      char buf[128];
     > -      int len;
     > -      uint64_t val = 0;
     > -
     > -      if (i == 0) {
     > -        /* pid */
     > -        val = getpid();
     > -        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
     > -      } else if (i == 1) {
     > -        /* app name */
     > -        snprintf(buf, sizeof(buf), "(%s) ", ts->bprm->argv[0]);
     > -      } else if (i == 27) {
     > -        /* stack bottom */
     > -        val = start_stack;
     > -        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
     > -      } else {
     > -        /* for the rest, there is MasterCard */
     > -        snprintf(buf, sizeof(buf), "0%c", i == 43 ? '\n' : ' ');
     > -      }
     > +        if (i == 0) {
     > +            /* pid */
     > +            g_string_printf(buf, FMT_pid " ", getpid());
     > +        } else if (i == 1) {
     > +            /* app name */
     > +            gchar *bin = g_strrstr(ts->bprm->argv[0], "/");
     > +            bin = bin ? bin + 1 : ts->bprm->argv[0];
     > +            g_string_printf(buf, "(%.15s) ", bin);

    15 or 125? 15 seems short. From your previous test I understood it was
    124, for
Quoted 8 lines
    sizeof("cat_with9_12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890___40").

     > +        } else if (i == 27) {
     > +            /* stack bottom */
     > +            g_string_printf(buf, TARGET_ABI_FMT_ld " ",
    ts->info->start_stack);
     > +        } else {
     > +            /* for the rest, there is MasterCard */

Already 23 years =)

Quoted 15 lines
     > +            g_string_printf(buf, "0%c", i == 43 ? '\n' : ' ');
     > +        }
     >
     > -      len = strlen(buf);
     > -      if (write(fd, buf, len) != len) {
     > -          return -1;
     > -      }
     > +        if (write(fd, buf->str, buf->len) != buf->len) {
     > +            return -1;
     > +        }
     >       }
     >
     >       return 0;
     >
#28 lore raw

Re: [PATCH v1 10/11] linux-user: fix /proc/self/stat handling

In reply to Alex Bennée

Le 10/04/2020 à 14:33, Alex Bennée a écrit :

Quoted 3 lines

That was by inspection on my system which seems to truncate a lot earlier. It would be nice to find where in the Linux kernel it is output but I failed to grep the relevant function last night.

It's in proc/array.c, do_task_stat() calls proc_task_name(). In the end, it seems to use task->tcomm or task->comm which is limited by

#define TASK_COMM_LEN 16

Brice

Quoted 105 lines

On Fri, 10 Apr 2020, 12:11 Philippe Mathieu-Daudé, <[email protected] <mailto:[email protected]>> wrote:

    Cc'ing Ludovic in case he can test with Guix-HPC.

    On 4/9/20 11:15 PM, Alex Bennée wrote:
    > In the original bug report long files names in Guix caused
    > /proc/self/stat be truncated without the trailing ") " as
    specified in
    > proc manpage which says:
    >      (2) comm  %s
    >             The  filename of the executable, in parentheses.  This
    >             is visible whether or not the  executable  is  swapped
    >             out.
    >
    > Additionally it should only be reporting the executable name rather
    > than the full path. Fix both these failings while cleaning up
    the code
    > to use GString to build up the reported values. As the whole
    function
    > is cleaned up also adjust the white space to the current coding
    style.
    >
    > Message-ID: <[email protected]
    <mailto:[email protected]>>
    > Reported-by: Brice Goglin <[email protected]
    <mailto:[email protected]>>
    > Cc: Philippe_Mathieu-Daudé <[email protected]
    <mailto:[email protected]>>
    > Signed-off-by: Alex Bennée <[email protected]
    <mailto:[email protected]>>
    > ---
    >   linux-user/syscall.c | 43
    +++++++++++++++++++------------------------
    >   1 file changed, 19 insertions(+), 24 deletions(-)
    >
    > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
    > index 6495ddc4cda..674f70e70a5 100644
    > --- a/linux-user/syscall.c
    > +++ b/linux-user/syscall.c
    > @@ -7295,34 +7295,29 @@ static int open_self_stat(void *cpu_env,
    int fd)
    >   {
    >       CPUState *cpu = env_cpu((CPUArchState *)cpu_env);
    >       TaskState *ts = cpu->opaque;
    > -    abi_ulong start_stack = ts->info->start_stack;
    > +    g_autoptr(GString) buf = g_string_new(NULL);
    >       int i;
    >   
    >       for (i = 0; i < 44; i++) {
    > -      char buf[128];
    > -      int len;
    > -      uint64_t val = 0;
    > -
    > -      if (i == 0) {
    > -        /* pid */
    > -        val = getpid();
    > -        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
    > -      } else if (i == 1) {
    > -        /* app name */
    > -        snprintf(buf, sizeof(buf), "(%s) ", ts->bprm->argv[0]);
    > -      } else if (i == 27) {
    > -        /* stack bottom */
    > -        val = start_stack;
    > -        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
    > -      } else {
    > -        /* for the rest, there is MasterCard */
    > -        snprintf(buf, sizeof(buf), "0%c", i == 43 ? '\n' : ' ');
    > -      }
    > +        if (i == 0) {
    > +            /* pid */
    > +            g_string_printf(buf, FMT_pid " ", getpid());
    > +        } else if (i == 1) {
    > +            /* app name */
    > +            gchar *bin = g_strrstr(ts->bprm->argv[0], "/");
    > +            bin = bin ? bin + 1 : ts->bprm->argv[0];
    > +            g_string_printf(buf, "(%.15s) ", bin);

    15 or 125? 15 seems short. From your previous test I understood it
    was
    124, for
    sizeof("cat_with9_12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890___40").

    > +        } else if (i == 27) {
    > +            /* stack bottom */
    > +            g_string_printf(buf, TARGET_ABI_FMT_ld " ",
    ts->info->start_stack);
    > +        } else {
    > +            /* for the rest, there is MasterCard */
    > +            g_string_printf(buf, "0%c", i == 43 ? '\n' : ' ');
    > +        }
    >   
    > -      len = strlen(buf);
    > -      if (write(fd, buf, len) != len) {
    > -          return -1;
    > -      }
    > +        if (write(fd, buf->str, buf->len) != buf->len) {
    > +            return -1;
    > +        }
    >       }
    >   
    >       return 0;
    >
#29 lore raw

Re: [PATCH v1 10/11] linux-user: fix /proc/self/stat handling

Quoted 10 lines · Brice Goglin
Quoted 3 lines · Alex Bennée

That was by inspection on my system which seems to truncate a lot earlier. It would be nice to find where in the Linux kernel it is output but I failed to grep the relevant function last night.

It's in proc/array.c, do_task_stat() calls proc_task_name(). In the end, it seems to use task->tcomm or task->comm which is limited by

#define TASK_COMM_LEN 16

Thanks. I'll amend the commit message. Are you happy with the fix on your end?

Quoted 110 lines

Brice

Quoted 105 lines

On Fri, 10 Apr 2020, 12:11 Philippe Mathieu-Daudé, <[email protected] <mailto:[email protected]>> wrote:

    Cc'ing Ludovic in case he can test with Guix-HPC.

    On 4/9/20 11:15 PM, Alex Bennée wrote:
    > In the original bug report long files names in Guix caused
    > /proc/self/stat be truncated without the trailing ") " as
    specified in
    > proc manpage which says:
    >      (2) comm  %s
    >             The  filename of the executable, in parentheses.  This
    >             is visible whether or not the  executable  is  swapped
    >             out.
    >
    > Additionally it should only be reporting the executable name rather
    > than the full path. Fix both these failings while cleaning up
    the code
    > to use GString to build up the reported values. As the whole
    function
    > is cleaned up also adjust the white space to the current coding
    style.
    >
    > Message-ID: <[email protected]
    <mailto:[email protected]>>
    > Reported-by: Brice Goglin <[email protected]
    <mailto:[email protected]>>
    > Cc: Philippe_Mathieu-Daudé <[email protected]
    <mailto:[email protected]>>
    > Signed-off-by: Alex Bennée <[email protected]
    <mailto:[email protected]>>
    > ---
    >   linux-user/syscall.c | 43
    +++++++++++++++++++------------------------
    >   1 file changed, 19 insertions(+), 24 deletions(-)
    >
    > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
    > index 6495ddc4cda..674f70e70a5 100644
    > --- a/linux-user/syscall.c
    > +++ b/linux-user/syscall.c
    > @@ -7295,34 +7295,29 @@ static int open_self_stat(void *cpu_env,
    int fd)
    >   {
    >       CPUState *cpu = env_cpu((CPUArchState *)cpu_env);
    >       TaskState *ts = cpu->opaque;
    > -    abi_ulong start_stack = ts->info->start_stack;
    > +    g_autoptr(GString) buf = g_string_new(NULL);
    >       int i;
    >   
    >       for (i = 0; i < 44; i++) {
    > -      char buf[128];
    > -      int len;
    > -      uint64_t val = 0;
    > -
    > -      if (i == 0) {
    > -        /* pid */
    > -        val = getpid();
    > -        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
    > -      } else if (i == 1) {
    > -        /* app name */
    > -        snprintf(buf, sizeof(buf), "(%s) ", ts->bprm->argv[0]);
    > -      } else if (i == 27) {
    > -        /* stack bottom */
    > -        val = start_stack;
    > -        snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
    > -      } else {
    > -        /* for the rest, there is MasterCard */
    > -        snprintf(buf, sizeof(buf), "0%c", i == 43 ? '\n' : ' ');
    > -      }
    > +        if (i == 0) {
    > +            /* pid */
    > +            g_string_printf(buf, FMT_pid " ", getpid());
    > +        } else if (i == 1) {
    > +            /* app name */
    > +            gchar *bin = g_strrstr(ts->bprm->argv[0], "/");
    > +            bin = bin ? bin + 1 : ts->bprm->argv[0];
    > +            g_string_printf(buf, "(%.15s) ", bin);

    15 or 125? 15 seems short. From your previous test I understood it
    was
    124, for
    sizeof("cat_with9_12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890___40").

    > +        } else if (i == 27) {
    > +            /* stack bottom */
    > +            g_string_printf(buf, TARGET_ABI_FMT_ld " ",
    ts->info->start_stack);
    > +        } else {
    > +            /* for the rest, there is MasterCard */
    > +            g_string_printf(buf, "0%c", i == 43 ? '\n' : ' ');
    > +        }
    >   
    > -      len = strlen(buf);
    > -      if (write(fd, buf, len) != len) {
    > -          return -1;
    > -      }
    > +        if (write(fd, buf->str, buf->len) != buf->len) {
    > +            return -1;
    > +        }
    >       }
    >   
    >       return 0;
    >
Signature · 1 line
Alex Bennée
Reviewed-by on v1 10/11
#30 lore raw

Re: [PATCH v1 10/11] linux-user: fix /proc/self/stat handling

In reply to Alex Bennée
Quoted 13 lines · Alex Bennée

In the original bug report long files names in Guix caused /proc/self/stat be truncated without the trailing ") " as specified in proc manpage which says:
(2) comm %s
The filename of the executable, in parentheses. This is visible whether or not the executable is swapped out.

Additionally it should only be reporting the executable name rather than the full path. Fix both these failings while cleaning up the code to use GString to build up the reported values. As the whole function is cleaned up also adjust the white space to the current coding style.

Quoted 7 lines

Message-ID: <[email protected]>

---
 linux-user/syscall.c | 43 +++++++++++++++++++------------------------
 1 file changed, 19 insertions(+), 24 deletions(-)

r~

#31 lore raw

PATCH 11/11 .travis.yml: Build OSX 10.14 with Xcode 10.0

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

Travis recently made a change which generates various warnings such [*]:

CC utils.o
In file included from cs.c:11:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdio.h:64:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/_stdio.h:93:16: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]

          unsigned char   *_base;
                          ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/_stdio.h:93:16: note: insert '_Nullable' if the pointer may be null
          unsigned char   *_base;
                          ^
                            _Nullable

We only aim to support MacOS 10.14 and 10.15. 10.14 comes with Xcode 10.0. These warnings are not emitted with this Xcode version, so switch back to it.

[*] https://travis-ci.org/github/qemu/qemu/jobs/673000302#L1387

Message-Id: <[email protected]>

---
 .travis.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
.travis.yml +2 -2
index 2fd63eceaac..7c92206ea33 100644
@@ -272,12 +272,12 @@ jobs:
 
     # MacOSX builds - cirrus.yml also tests some MacOS builds including latest Xcode
 
-    - name: "OSX Xcode 10.3"
+    - name: "OSX 10.14 (Xcode 10.0)"
       env:
         - BASE_CONFIG="--disable-docs --enable-tools"
         - CONFIG="--target-list=i386-softmmu,ppc-softmmu,ppc64-softmmu,m68k-softmmu,x86_64-softmmu"
       os: osx
-      osx_image: xcode10.3
+      osx_image: xcode10
       compiler: clang
       addons:
         homebrew:
Signature · 1 line
2.20.1
#32 lore raw

Re: [PATCH v1 11/11] .travis.yml: Build OSX 10.14 with Xcode 10.0

Quoted 16 lines · Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

Travis recently made a change which generates various warnings such [*]:

CC utils.o
In file included from cs.c:11:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdio.h:64:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/_stdio.h:93:16: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]

          unsigned char   *_base;
                          ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/_stdio.h:93:16: note: insert '_Nullable' if the pointer may be null
          unsigned char   *_base;
                          ^
                            _Nullable
Quoted 3 lines

We only aim to support MacOS 10.14 and 10.15. 10.14 comes with Xcode 10.0. These warnings are not emitted with this Xcode version, so switch back to it.

It appears Travis have fixed the flaw in 10.3, as both QEMU and libvirt are building correctly on 10.3 again. So I think you can drop this patch.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#33 lore raw
In reply to Alex Bennée
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Subject: [PATCH for 5.0-rc3 v1 00/11] more random fixes
Message-id: [email protected]
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Switched to a new branch 'test'
2779bae .travis.yml: Build OSX 10.14 with Xcode 10.0
ffa69ee linux-user: fix /proc/self/stat handling
da73496 gdbstub: i386: Fix gdb_get_reg16() parameter to unbreak gdb a7392db target/m68k/helper: Fix m68k_fpu_gdb_get_reg() use of GByteArray 6cdbe4b configure: disable PIE for Windows builds
e70b41a configure: redirect sphinx-build check to config.log 84b0026 tests/docker: add docs FEATURE flag and use for test-misc e991630 linux-user/ppc: Fix padding in mcontext_t for ppc64 3fe0015 accel/tcg: Relax va restrictions on 64-bit guests 3a50414 exec/cpu-all: Use bool for have_guest_base
8327d01 linux-user: completely re-write init_guest_space

=== OUTPUT BEGIN ===
1/11 Checking commit 8327d0183d84 (linux-user: completely re-write init_guest_space)
ERROR: trailing whitespace
#715: FILE: linux-user/qemu.h:229:
+ * $

total: 1 errors, 0 warnings, 681 lines checked

Patch 1/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

2/11 Checking commit 3a504143c770 (exec/cpu-all: Use bool for have_guest_base) 3/11 Checking commit 3fe00151c0e3 (accel/tcg: Relax va restrictions on 64-bit guests)
ERROR: Macros with complex values should be enclosed in parenthesis #91: FILE: include/exec/cpu-all.h:182:
+# define GUEST_ADDR_MAX_ ~0ul

total: 1 errors, 0 warnings, 88 lines checked

Patch 3/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

4/11 Checking commit e99163099022 (linux-user/ppc: Fix padding in mcontext_t for ppc64) 5/11 Checking commit 84b002680ba0 (tests/docker: add docs FEATURE flag and use for test-misc) 6/11 Checking commit e70b41a4ac1e (configure: redirect sphinx-build check to config.log) 7/11 Checking commit 6cdbe4bcdb6b (configure: disable PIE for Windows builds)
8/11 Checking commit a7392db3e091 (target/m68k/helper: Fix m68k_fpu_gdb_get_reg() use of GByteArray) 9/11 Checking commit da73496e5afd (gdbstub: i386: Fix gdb_get_reg16() parameter to unbreak gdb) 10/11 Checking commit ffa69ee03e63 (linux-user: fix /proc/self/stat handling)
11/11 Checking commit 2779baef4f14 (.travis.yml: Build OSX 10.14 with Xcode 10.0) === OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]