Skip to contentSkip to conversation

Linux user for 4.1 patches

GIT PULL Laurent Vivier 2 participants 10 messages May 10, 2019

lore
Share & tools
lore
#0 lore raw

The following changes since commit 68a7b9724fe80bedb85060bde605213ce3f9baec:

Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-pull-request' into staging (2019-05-09 13:36:10 +0100)

are available in the Git repository at:

git://github.com/vivier/qemu.git tags/linux-user-for-4.1-pull-request

for you to fetch changes up to 6b333239ab1a4fa98f07f907f6268484a8514d1e:

linux-user: fix GPROF build failure (2019-05-09 19:08:13 +0200)

----------------------------------------------------------------
GPROF fixes, GCC9 fixes, SIOCGIFNAME fix, new IPV6 sockopts, elf fix

----------------------------------------------------------------

Alex Bennée (2):
linux-user: avoid treading on gprof's SIGPROF signals
linux-user: fix GPROF build failure

Alistair Francis (1):
linux-user/elfload: Fix GCC 9 build warnings

Daniel P. Berrangé (1):
linux-user: avoid string truncation warnings in uname field copying

Erik Kline via Qemu-devel (1):
The ioctl(SIOCGIFNAME) call requires a struct ifreq.

Giuseppe Musacchio (1):
linux-user: elf: Map empty PT_LOAD segments

Helge Deller (1):
linux-user: Add missing IPV6 sockopts

 linux-user/ioctls.h  |  2 +-
 linux-user/elfload.c | 20 +++++++++++++------
 linux-user/exit.c    |  3 +++
 linux-user/signal.c  |  5 +++++
 linux-user/syscall.c | 47 +++++++++++++++++++++++++++++++++++++++++---
 linux-user/uname.c   |  5 ++---
 6 files changed, 69 insertions(+), 13 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

[Qemu-devel] [PULL 7/7] linux-user: fix GPROF build failure

From: Alex Bennée <[email protected]>

When linux-user/exit was introduced we failed to move the gprof include at the same time. The CI didn't notice because it only builds system emulation. Fix it for those that still find gprof useful.

Message-Id: <[email protected]>

---
 linux-user/exit.c    | 3 +++
 linux-user/syscall.c | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)
linux-user/exit.c +3 -0
index 14e94e28faf8..bdda7205532e 100644
@@ -18,6 +18,9 @@
  */
 #include "qemu/osdep.h"
 #include "qemu.h"
+#ifdef TARGET_GPROF
+#include <sys/gmon.h>
+#endif
 
 #ifdef CONFIG_GCOV
 extern void __gcov_dump(void);
linux-user/syscall.c +0 -3
index 44b593b81161..f5ff6f5dc8a8 100644
@@ -59,9 +59,6 @@
 #ifdef CONFIG_TIMERFD
 #include <sys/timerfd.h>
 #endif
-#ifdef TARGET_GPROF
-#include <sys/gmon.h>
-#endif
 #ifdef CONFIG_EVENTFD
 #include <sys/eventfd.h>
 #endif
Signature · 1 line
2.20.1
#2 lore raw

[Qemu-devel] [PULL 1/7] linux-user: Add missing IPV6 sockopts

In reply to Laurent Vivier

From: Helge Deller <[email protected]>

When running ssh over IPv6 with linux-user I faced this warning:
Unsupported setsockopt level=41 optname=67
setsockopt IPV6_TCLASS 32: Protocol not available:

This patch adds code to the linux-user emulatation for setting and retrieving of a few missing IPV6 options, including IPV6_TCLASS.

---
 linux-user/syscall.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
linux-user/syscall.c +44 -0
index 96cd4bf86dd3..44b593b81161 100644
@@ -1864,6 +1864,28 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
         case IPV6_RECVHOPLIMIT:
         case IPV6_2292HOPLIMIT:
         case IPV6_CHECKSUM:
+        case IPV6_ADDRFORM:
+        case IPV6_2292PKTINFO:
+        case IPV6_RECVTCLASS:
+        case IPV6_RECVRTHDR:
+        case IPV6_2292RTHDR:
+        case IPV6_RECVHOPOPTS:
+        case IPV6_2292HOPOPTS:
+        case IPV6_RECVDSTOPTS:
+        case IPV6_2292DSTOPTS:
+        case IPV6_TCLASS:
+#ifdef IPV6_RECVPATHMTU
+        case IPV6_RECVPATHMTU:
+#endif
+#ifdef IPV6_TRANSPARENT
+        case IPV6_TRANSPARENT:
+#endif
+#ifdef IPV6_FREEBIND
+        case IPV6_FREEBIND:
+#endif
+#ifdef IPV6_RECVORIGDSTADDR
+        case IPV6_RECVORIGDSTADDR:
+#endif
             val = 0;
             if (optlen < sizeof(uint32_t)) {
                 return -TARGET_EINVAL;
@@ -2358,6 +2380,28 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
         case IPV6_RECVHOPLIMIT:
         case IPV6_2292HOPLIMIT:
         case IPV6_CHECKSUM:
+        case IPV6_ADDRFORM:
+        case IPV6_2292PKTINFO:
+        case IPV6_RECVTCLASS:
+        case IPV6_RECVRTHDR:
+        case IPV6_2292RTHDR:
+        case IPV6_RECVHOPOPTS:
+        case IPV6_2292HOPOPTS:
+        case IPV6_RECVDSTOPTS:
+        case IPV6_2292DSTOPTS:
+        case IPV6_TCLASS:
+#ifdef IPV6_RECVPATHMTU
+        case IPV6_RECVPATHMTU:
+#endif
+#ifdef IPV6_TRANSPARENT
+        case IPV6_TRANSPARENT:
+#endif
+#ifdef IPV6_FREEBIND
+        case IPV6_FREEBIND:
+#endif
+#ifdef IPV6_RECVORIGDSTADDR
+        case IPV6_RECVORIGDSTADDR:
+#endif
             if (get_user_u32(len, optlen))
                 return -TARGET_EFAULT;
             if (len < 0)
Signature · 1 line
2.20.1
#3 lore raw

[Qemu-devel] [PULL 6/7] linux-user: avoid treading on gprof's SIGPROF signals

In reply to Laurent Vivier

From: Alex Bennée <[email protected]>

The guest tends to get confused when it receives signals it doesn't know about. Given the gprof magic has also set up it's own handler we would do well to avoid stomping on it as well.

Message-Id: <[email protected]>

---
 linux-user/signal.c | 5 +++++
 1 file changed, 5 insertions(+)
linux-user/signal.c +5 -0
index e2c0b3717357..44b2d3b35a0d 100644
@@ -508,6 +508,11 @@ void signal_init(void)
     act.sa_flags = SA_SIGINFO;
     act.sa_sigaction = host_signal_handler;
     for(i = 1; i <= TARGET_NSIG; i++) {
+#ifdef TARGET_GPROF
+        if (i == SIGPROF) {
+            continue;
+        }
+#endif
         host_sig = target_to_host_signal(i);
         sigaction(host_sig, NULL, &oact);
         if (oact.sa_sigaction == (void *)SIG_IGN) {
Signature · 1 line
2.20.1
#4 lore raw

[Qemu-devel] [PULL 4/7] The ioctl(SIOCGIFNAME) call requires a struct ifreq.

In reply to Laurent Vivier

From: Erik Kline via Qemu-devel <[email protected]>

Message-Id: <[email protected]>

---
 linux-user/ioctls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/ioctls.h +1 -1
index ae8951625ffe..37501f575cdd 100644
@@ -178,7 +178,7 @@
 #endif /* CONFIG_USBFS */
 
   IOCTL(SIOCATMARK, IOC_R, MK_PTR(TYPE_INT))
-  IOCTL(SIOCGIFNAME, IOC_RW, MK_PTR(TYPE_INT))
+  IOCTL(SIOCGIFNAME, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_int_ifreq)))
   IOCTL(SIOCGIFFLAGS, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_short_ifreq)))
   IOCTL(SIOCSIFFLAGS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_short_ifreq)))
   IOCTL(SIOCGIFADDR, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_sockaddr_ifreq)))
Signature · 1 line
2.20.1
#5 lore raw

[Qemu-devel] [PULL 5/7] linux-user: elf: Map empty PT_LOAD segments

In reply to Laurent Vivier

From: Giuseppe Musacchio <[email protected]>

Some PT_LOAD segments may be completely zeroed out and their p_filesize is zero, in that case the loader should just allocate a page that's at least p_memsz bytes large (plus eventual alignment padding).

Calling zero_bss does this job for us, all we have to do is make sure we don't try to mmap a zero-length page.

Message-Id: <20190503122007.lkjsvztgt4ycovac@debian>

---
 linux-user/elfload.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
linux-user/elfload.c +13 -5
index d08fe2346683..ef42e02d8233 100644
@@ -2366,11 +2366,19 @@ static void load_elf_image(const char *image_name, int image_fd,
             vaddr_ps = TARGET_ELF_PAGESTART(vaddr);
             vaddr_len = TARGET_ELF_PAGELENGTH(eppnt->p_filesz + vaddr_po);
 
-            error = target_mmap(vaddr_ps, vaddr_len,
-                                elf_prot, MAP_PRIVATE | MAP_FIXED,
-                                image_fd, eppnt->p_offset - vaddr_po);
-            if (error == -1) {
-                goto exit_perror;
+            /*
+             * Some segments may be completely empty without any backing file
+             * segment, in that case just let zero_bss allocate an empty buffer
+             * for it.
+             */
+            if (eppnt->p_filesz != 0) {
+                error = target_mmap(vaddr_ps, vaddr_len, elf_prot,
+                                    MAP_PRIVATE | MAP_FIXED,
+                                    image_fd, eppnt->p_offset - vaddr_po);
+
+                if (error == -1) {
+                    goto exit_perror;
+                }
             }
 
             vaddr_ef = vaddr + eppnt->p_filesz;
Signature · 1 line
2.20.1
#6 lore raw

[Qemu-devel] [PULL 3/7] linux-user: avoid string truncation warnings in uname field copying

In reply to Laurent Vivier

From: Daniel P. Berrangé <[email protected]>

In file included from /usr/include/string.h:494,

                 from include/qemu/osdep.h:101,
                 from linux-user/uname.c:20:
In function ‘strncpy’,
    inlined from ‘sys_uname’ at linux-user/uname.c:94:3:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output may be truncated copying 64 bytes from a string of length 64 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We don't care where the NUL terminator in the original uname field was. It suffices to copy the entire original field and simply force a NUL terminator at the end of the new field.

Message-Id: <[email protected]>

---
 linux-user/uname.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
linux-user/uname.c +2 -3
index 313b79dbad47..1c05f95387f4 100644
@@ -72,9 +72,8 @@ const char *cpu_to_uname_machine(void *cpu_env)
 
 #define COPY_UTSNAME_FIELD(dest, src) \
   do { \
-      /* __NEW_UTS_LEN doesn't include terminating null */ \
-      (void) strncpy((dest), (src), __NEW_UTS_LEN); \
-      (dest)[__NEW_UTS_LEN] = '\0'; \
+      memcpy((dest), (src), MIN(sizeof(src), sizeof(dest))); \
+      (dest)[sizeof(dest) - 1] = '\0'; \
   } while (0)
 
 int sys_uname(struct new_utsname *buf)
Signature · 1 line
2.20.1
#7 lore raw

[Qemu-devel] [PULL 2/7] linux-user/elfload: Fix GCC 9 build warnings

In reply to Laurent Vivier

From: Alistair Francis <[email protected]>

Fix this warning when building with GCC9 on Fedora 30:
In function ‘strncpy’,
inlined from ‘fill_psinfo’ at /home/alistair/qemu/linux-user/elfload.c:3208:12,
inlined from ‘fill_note_info’ at /home/alistair/qemu/linux-user/elfload.c:3390:5,
inlined from ‘elf_core_dump’ at /home/alistair/qemu/linux-user/elfload.c:3539:9:
/usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 16 equals destination size [-Werror=stringop-truncation]

  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Message-Id: <c4d2b1de9efadcf1c900b91361af9302823a72a9.1556666645.git.alistair.francis@wdc.com>

---
 linux-user/elfload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/elfload.c +1 -1
index c1a26021f8d7..d08fe2346683 100644
@@ -2872,7 +2872,7 @@ struct target_elf_prpsinfo {
     target_gid_t pr_gid;
     target_pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
     /* Lots missing */
-    char    pr_fname[16];           /* filename of executable */
+    char    pr_fname[16] QEMU_NONSTRING; /* filename of executable */
     char    pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
 };
 
Signature · 1 line
2.20.1
#8 lore raw
In reply to Laurent Vivier
Quoted 22 lines · Laurent Vivier

The following changes since commit 68a7b9724fe80bedb85060bde605213ce3f9baec:

Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-pull-request' into staging (2019-05-09 13:36:10 +0100)

are available in the Git repository at:

git://github.com/vivier/qemu.git tags/linux-user-for-4.1-pull-request

for you to fetch changes up to 6b333239ab1a4fa98f07f907f6268484a8514d1e:

linux-user: fix GPROF build failure (2019-05-09 19:08:13 +0200)

----------------------------------------------------------------
GPROF fixes, GCC9 fixes, SIOCGIFNAME fix, new IPV6 sockopts, elf fix

----------------------------------------------------------------

Alex Bennée (2):
linux-user: avoid treading on gprof's SIGPROF signals
linux-user: fix GPROF build failure

Quoted 8 lines

Alistair Francis (1):
linux-user/elfload: Fix GCC 9 build warnings

Daniel P. Berrangé (1):
linux-user: avoid string truncation warnings in uname field copying

Erik Kline via Qemu-devel (1):
The ioctl(SIOCGIFNAME) call requires a struct ifreq.

Hi Laurent -- it looks like you forgot to fix up the author email in this patch, so my pullreq-application script complains:

[staging 181447e27a] Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-4.1-pull-request' into staging
Date: Fri May 10 10:06:35 2019 +0100
Erik Kline via Qemu-devel (1):
The ioctl(SIOCGIFNAME) call requires a struct ifreq.
ERROR: pull request includes commits attributed to list

Could you fix it up and resubmit the pull, please?

thanks
-- PMM

#9 lore raw
Quoted 36 lines · Peter Maydell
Quoted 22 lines · Laurent Vivier

The following changes since commit 68a7b9724fe80bedb85060bde605213ce3f9baec:

   Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-pull-request' into staging (2019-05-09 13:36:10 +0100)

are available in the Git repository at:

git://github.com/vivier/qemu.git tags/linux-user-for-4.1-pull-request

for you to fetch changes up to 6b333239ab1a4fa98f07f907f6268484a8514d1e:

   linux-user: fix GPROF build failure (2019-05-09 19:08:13 +0200)

----------------------------------------------------------------
GPROF fixes, GCC9 fixes, SIOCGIFNAME fix, new IPV6 sockopts, elf fix

----------------------------------------------------------------

Alex Bennée (2):
linux-user: avoid treading on gprof's SIGPROF signals
linux-user: fix GPROF build failure

Quoted 8 lines

Alistair Francis (1):
linux-user/elfload: Fix GCC 9 build warnings

Daniel P. Berrangé (1):
linux-user: avoid string truncation warnings in uname field copying

Erik Kline via Qemu-devel (1):
The ioctl(SIOCGIFNAME) call requires a struct ifreq.

Hi Laurent -- it looks like you forgot to fix up the author email in this patch, so my pullreq-application script complains:

Quoted 8 lines

[staging 181447e27a] Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-4.1-pull-request' into staging
Date: Fri May 10 10:06:35 2019 +0100
Erik Kline via Qemu-devel (1):
The ioctl(SIOCGIFNAME) call requires a struct ifreq.
ERROR: pull request includes commits attributed to list

Could you fix it up and resubmit the pull, please?

Done.

And thank you to have checked that.

Laurent