qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches
@ 2018-08-19 22:17 Laurent Vivier
  2018-08-19 22:17 ` [Qemu-devel] [PULL 1/6] qemu-binfmt-conf.sh: add x86_64 target Laurent Vivier
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Laurent Vivier @ 2018-08-19 22:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Crosthwaite, Riku Voipio, Laurent Vivier, Richard Henderson,
	Paolo Bonzini, Aurelien Jarno

The following changes since commit 0abaa41d936becd914a16ee1fe2a981d96d19428:

  Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging (2018-08-17 09:46:00 +0100)

are available in the Git repository at:

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

for you to fetch changes up to c072a24c11e713f14ab969799433218d8ceebe19:

  linux-user: add QEMU_IFLA_INFO_KIND nested type for tun (2018-08-20 00:11:06 +0200)

----------------------------------------------------------------
linux-user fixes:
- netlink fixes (add missing types, fix MSG_TRUNC)
- sh4 fix (tcg state)
- sparc32plus fix (truncate address space to 32bit)
- add x86_64 binfmt data

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

Laurent Vivier (6):
  qemu-binfmt-conf.sh: add x86_64 target
  linux-user: fix 32bit g2h()/h2g()
  sh4: fix use_icount with linux-user
  linux-user: fix recvmsg()/recvfrom() with netlink and MSG_TRUNC
  linux-user: update netlink route types
  linux-user: add QEMU_IFLA_INFO_KIND nested type for tun

 include/exec/cpu_ldst.h                   | 23 +++++--
 include/exec/cpu_ldst_useronly_template.h | 12 ++--
 linux-user/syscall.c                      | 78 ++++++++++++++++++++++-
 scripts/qemu-binfmt-conf.sh               |  6 +-
 target/sh4/translate.c                    |  1 +
 5 files changed, 105 insertions(+), 15 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PULL 1/6] qemu-binfmt-conf.sh: add x86_64 target
  2018-08-19 22:17 [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches Laurent Vivier
@ 2018-08-19 22:17 ` Laurent Vivier
  2018-08-19 22:17 ` [Qemu-devel] [PULL 2/6] linux-user: fix 32bit g2h()/h2g() Laurent Vivier
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2018-08-19 22:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Crosthwaite, Riku Voipio, Laurent Vivier, Richard Henderson,
	Paolo Bonzini, Aurelien Jarno

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20180801102944.23457-1-laurent@vivier.eu>
---
 scripts/qemu-binfmt-conf.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
index b0dc8a714a..b5a16742a1 100755
--- a/scripts/qemu-binfmt-conf.sh
+++ b/scripts/qemu-binfmt-conf.sh
@@ -4,7 +4,7 @@
 qemu_target_list="i386 i486 alpha arm armeb sparc32plus ppc ppc64 ppc64le m68k \
 mips mipsel mipsn32 mipsn32el mips64 mips64el \
 sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb \
-microblaze microblazeel or1k"
+microblaze microblazeel or1k x86_64"
 
 i386_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'
 i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
@@ -14,6 +14,10 @@ i486_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\
 i486_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
 i486_family=i386
 
+x86_64_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00'
+x86_64_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+x86_64_family=i386
+
 alpha_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90'
 alpha_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
 alpha_family=alpha
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PULL 2/6] linux-user: fix 32bit g2h()/h2g()
  2018-08-19 22:17 [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches Laurent Vivier
  2018-08-19 22:17 ` [Qemu-devel] [PULL 1/6] qemu-binfmt-conf.sh: add x86_64 target Laurent Vivier
@ 2018-08-19 22:17 ` Laurent Vivier
  2018-08-19 22:17 ` [Qemu-devel] [PULL 3/6] sh4: fix use_icount with linux-user Laurent Vivier
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2018-08-19 22:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Crosthwaite, Riku Voipio, Laurent Vivier, Richard Henderson,
	Paolo Bonzini, Aurelien Jarno

sparc32plus has 64bit long type but only 32bit virtual address space.

For instance, "apt-get upgrade" failed because of a mmap()/msync()
sequence.

mmap() returned 0xff252000 but msync() used g2h(0xffffffffff252000)
to find the host address. The "(target_ulong)" in g2h() doesn't fix the
address because it is 64bit long.

This patch introduces an "abi_ptr" that is set to uint32_t
if the virtual address space is addressed using 32bit in the linux-user
case. It stays set to target_ulong with softmmu case.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20180814171217.14680-1-laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
[lv: added "%" in TARGET_ABI_FMT_ptr "%"PRIx64]
---
 include/exec/cpu_ldst.h                   | 23 ++++++++++++++++++-----
 include/exec/cpu_ldst_useronly_template.h | 12 ++++++------
 linux-user/syscall.c                      |  2 +-
 3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index 0f2cb717b1..41ed0526e2 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -48,8 +48,19 @@
 #define CPU_LDST_H
 
 #if defined(CONFIG_USER_ONLY)
+/* sparc32plus has 64bit long but 32bit space address
+ * this can make bad result with g2h() and h2g()
+ */
+#if TARGET_VIRT_ADDR_SPACE_BITS <= 32
+typedef uint32_t abi_ptr;
+#define TARGET_ABI_FMT_ptr "%x"
+#else
+typedef uint64_t abi_ptr;
+#define TARGET_ABI_FMT_ptr "%"PRIx64
+#endif
+
 /* All direct uses of g2h and h2g need to go away for usermode softmmu.  */
-#define g2h(x) ((void *)((unsigned long)(target_ulong)(x) + guest_base))
+#define g2h(x) ((void *)((unsigned long)(abi_ptr)(x) + guest_base))
 
 #define guest_addr_valid(x) ((x) <= GUEST_ADDR_MAX)
 #define h2g_valid(x) guest_addr_valid((unsigned long)(x) - guest_base)
@@ -61,7 +72,7 @@ static inline int guest_range_valid(unsigned long start, unsigned long len)
 
 #define h2g_nocheck(x) ({ \
     unsigned long __ret = (unsigned long)(x) - guest_base; \
-    (abi_ulong)__ret; \
+    (abi_ptr)__ret; \
 })
 
 #define h2g(x) ({ \
@@ -69,7 +80,9 @@ static inline int guest_range_valid(unsigned long start, unsigned long len)
     assert(h2g_valid(x)); \
     h2g_nocheck(x); \
 })
-
+#else
+typedef target_ulong abi_ptr;
+#define TARGET_ABI_FMT_ptr TARGET_ABI_FMT_lx
 #endif
 
 #if defined(CONFIG_USER_ONLY)
@@ -397,7 +410,7 @@ extern __thread uintptr_t helper_retaddr;
  * This is the equivalent of the initial fast-path code used by
  * TCG backends for guest load and store accesses.
  */
-static inline void *tlb_vaddr_to_host(CPUArchState *env, target_ulong addr,
+static inline void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr,
                                       int access_type, int mmu_idx)
 {
 #if defined(CONFIG_USER_ONLY)
@@ -405,7 +418,7 @@ static inline void *tlb_vaddr_to_host(CPUArchState *env, target_ulong addr,
 #else
     int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
     CPUTLBEntry *tlbentry = &env->tlb_table[mmu_idx][index];
-    target_ulong tlb_addr;
+    abi_ptr tlb_addr;
     uintptr_t haddr;
 
     switch (access_type) {
diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h
index e30e58ed4a..0fd6019af0 100644
--- a/include/exec/cpu_ldst_useronly_template.h
+++ b/include/exec/cpu_ldst_useronly_template.h
@@ -62,7 +62,7 @@
 #endif
 
 static inline RES_TYPE
-glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
+glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
 {
 #if !defined(CODE_ACCESS)
     trace_guest_mem_before_exec(
@@ -74,7 +74,7 @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
 
 static inline RES_TYPE
 glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
-                                                  target_ulong ptr,
+                                                  abi_ptr ptr,
                                                   uintptr_t retaddr)
 {
     RES_TYPE ret;
@@ -86,7 +86,7 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
 
 #if DATA_SIZE <= 2
 static inline int
-glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
+glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
 {
 #if !defined(CODE_ACCESS)
     trace_guest_mem_before_exec(
@@ -98,7 +98,7 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
 
 static inline int
 glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
-                                                  target_ulong ptr,
+                                                  abi_ptr ptr,
                                                   uintptr_t retaddr)
 {
     int ret;
@@ -111,7 +111,7 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
 
 #ifndef CODE_ACCESS
 static inline void
-glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
+glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
                                       RES_TYPE v)
 {
 #if !defined(CODE_ACCESS)
@@ -124,7 +124,7 @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
 
 static inline void
 glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
-                                                  target_ulong ptr,
+                                                  abi_ptr ptr,
                                                   RES_TYPE v,
                                                   uintptr_t retaddr)
 {
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index bb42a225eb..1806b33b02 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7644,7 +7644,7 @@ static int open_self_maps(void *cpu_env, int fd)
             if (h2g(min) == ts->info->stack_limit) {
                 pstrcpy(path, sizeof(path), "      [stack]");
             }
-            dprintf(fd, TARGET_ABI_FMT_lx "-" TARGET_ABI_FMT_lx
+            dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr
                     " %c%c%c%c %08" PRIx64 " %02x:%02x %d %s%s\n",
                     h2g(min), h2g(max - 1) + 1, flag_r, flag_w,
                     flag_x, flag_p, offset, dev_maj, dev_min, inode,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PULL 3/6] sh4: fix use_icount with linux-user
  2018-08-19 22:17 [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches Laurent Vivier
  2018-08-19 22:17 ` [Qemu-devel] [PULL 1/6] qemu-binfmt-conf.sh: add x86_64 target Laurent Vivier
  2018-08-19 22:17 ` [Qemu-devel] [PULL 2/6] linux-user: fix 32bit g2h()/h2g() Laurent Vivier
@ 2018-08-19 22:17 ` Laurent Vivier
  2018-08-19 22:17 ` [Qemu-devel] [PULL 4/6] linux-user: fix recvmsg()/recvfrom() with netlink and MSG_TRUNC Laurent Vivier
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2018-08-19 22:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Crosthwaite, Riku Voipio, Laurent Vivier, Richard Henderson,
	Paolo Bonzini, Aurelien Jarno

This fixes java in a linux-user chroot:
  $ java --version
  qemu-sh4: .../accel/tcg/cpu-exec.c:634: cpu_loop_exec_tb: Assertion `use_icount' failed.
  qemu: uncaught target signal 6 (Aborted) - core dumped
  Aborted (core dumped)

In gen_conditional_jump() in the GUSA_EXCLUSIVE part, we must reset
base.is_jmp to DISAS_NEXT after the gen_goto_tb() as it is done in
gen_delayed_conditional_jump() after the gen_jump().

Bug: https://bugs.launchpad.net/qemu/+bug/1768246
Fixes: 4834871bc95b67343248100e2a75ae0d287bc08b
       ("target/sh4: Convert to DisasJumpType")
Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Message-Id: <20180811082328.11268-1-laurent@vivier.eu>
---
 target/sh4/translate.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 1b9a201d6d..ab254b0e8d 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -293,6 +293,7 @@ static void gen_conditional_jump(DisasContext *ctx, target_ulong dest,
            disallow it in use_goto_tb, but it handles exit + singlestep.  */
         gen_goto_tb(ctx, 0, dest);
         gen_set_label(l1);
+        ctx->base.is_jmp = DISAS_NEXT;
         return;
     }
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PULL 4/6] linux-user: fix recvmsg()/recvfrom() with netlink and MSG_TRUNC
  2018-08-19 22:17 [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches Laurent Vivier
                   ` (2 preceding siblings ...)
  2018-08-19 22:17 ` [Qemu-devel] [PULL 3/6] sh4: fix use_icount with linux-user Laurent Vivier
@ 2018-08-19 22:17 ` Laurent Vivier
  2018-08-19 22:17 ` [Qemu-devel] [PULL 5/6] linux-user: update netlink route types Laurent Vivier
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2018-08-19 22:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Crosthwaite, Riku Voipio, Laurent Vivier, Richard Henderson,
	Paolo Bonzini, Aurelien Jarno

If recvmsg()/recvfrom() are used with the MSG_TRUNC flag, they return the
real length even if it was longer than the passed buffer.
So when we translate the buffer we must check we don't go beyond the
end of the buffer.

Bug: https://github.com/vivier/qemu-m68k/issues/33
Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20180806211806.29845-1-laurent@vivier.eu>
---
 linux-user/syscall.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1806b33b02..e66faf1c62 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3892,7 +3892,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
             len = ret;
             if (fd_trans_host_to_target_data(fd)) {
                 ret = fd_trans_host_to_target_data(fd)(msg.msg_iov->iov_base,
-                                                       len);
+                                               MIN(msg.msg_iov->iov_len, len));
             } else {
                 ret = host_to_target_cmsg(msgp, &msg);
             }
@@ -4169,7 +4169,12 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags,
     }
     if (!is_error(ret)) {
         if (fd_trans_host_to_target_data(fd)) {
-            ret = fd_trans_host_to_target_data(fd)(host_msg, ret);
+            abi_long trans;
+            trans = fd_trans_host_to_target_data(fd)(host_msg, MIN(ret, len));
+            if (is_error(trans)) {
+                ret = trans;
+                goto fail;
+            }
         }
         if (target_addr) {
             host_to_target_sockaddr(target_addr, addr, addrlen);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PULL 5/6] linux-user: update netlink route types
  2018-08-19 22:17 [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches Laurent Vivier
                   ` (3 preceding siblings ...)
  2018-08-19 22:17 ` [Qemu-devel] [PULL 4/6] linux-user: fix recvmsg()/recvfrom() with netlink and MSG_TRUNC Laurent Vivier
@ 2018-08-19 22:17 ` Laurent Vivier
  2018-08-19 22:17 ` [Qemu-devel] [PULL 6/6] linux-user: add QEMU_IFLA_INFO_KIND nested type for tun Laurent Vivier
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2018-08-19 22:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Crosthwaite, Riku Voipio, Laurent Vivier, Richard Henderson,
	Paolo Bonzini, Aurelien Jarno

Add RTA_PREF and RTA_CACHEINFO.

Fix following errors when we start gedit:

  Unknown host RTA type: 12
  Unknown host RTA type: 20

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20180814161904.12216-3-laurent@vivier.eu>
---
 linux-user/syscall.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e66faf1c62..da1fcaf4ca 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2659,12 +2659,17 @@ static abi_long host_to_target_data_addr_rtattr(struct rtattr *rtattr)
 static abi_long host_to_target_data_route_rtattr(struct rtattr *rtattr)
 {
     uint32_t *u32;
+    struct rta_cacheinfo *ci;
+
     switch (rtattr->rta_type) {
     /* binary: depends on family type */
     case RTA_GATEWAY:
     case RTA_DST:
     case RTA_PREFSRC:
         break;
+    /* u8 */
+    case RTA_PREF:
+        break;
     /* u32 */
     case RTA_PRIORITY:
     case RTA_TABLE:
@@ -2672,6 +2677,20 @@ static abi_long host_to_target_data_route_rtattr(struct rtattr *rtattr)
         u32 = RTA_DATA(rtattr);
         *u32 = tswap32(*u32);
         break;
+    /* struct rta_cacheinfo */
+    case RTA_CACHEINFO:
+        ci = RTA_DATA(rtattr);
+        ci->rta_clntref = tswap32(ci->rta_clntref);
+        ci->rta_lastuse = tswap32(ci->rta_lastuse);
+        ci->rta_expires = tswap32(ci->rta_expires);
+        ci->rta_error = tswap32(ci->rta_error);
+        ci->rta_used = tswap32(ci->rta_used);
+#if defined(RTNETLINK_HAVE_PEERINFO)
+        ci->rta_id = tswap32(ci->rta_id);
+        ci->rta_ts = tswap32(ci->rta_ts);
+        ci->rta_tsage = tswap32(ci->rta_tsage);
+#endif
+        break;
     default:
         gemu_log("Unknown host RTA type: %d\n", rtattr->rta_type);
         break;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PULL 6/6] linux-user: add QEMU_IFLA_INFO_KIND nested type for tun
  2018-08-19 22:17 [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches Laurent Vivier
                   ` (4 preceding siblings ...)
  2018-08-19 22:17 ` [Qemu-devel] [PULL 5/6] linux-user: update netlink route types Laurent Vivier
@ 2018-08-19 22:17 ` Laurent Vivier
  2018-08-19 22:38 ` [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches no-reply
  2018-08-20 14:44 ` Peter Maydell
  7 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2018-08-19 22:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Crosthwaite, Riku Voipio, Laurent Vivier, Richard Henderson,
	Paolo Bonzini, Aurelien Jarno

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20180814161904.12216-4-laurent@vivier.eu>
---
 linux-user/syscall.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index da1fcaf4ca..424296d1a1 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -501,6 +501,20 @@ enum {
     QEMU___IFLA_BRPORT_MAX
 };
 
+enum {
+    QEMU_IFLA_TUN_UNSPEC,
+    QEMU_IFLA_TUN_OWNER,
+    QEMU_IFLA_TUN_GROUP,
+    QEMU_IFLA_TUN_TYPE,
+    QEMU_IFLA_TUN_PI,
+    QEMU_IFLA_TUN_VNET_HDR,
+    QEMU_IFLA_TUN_PERSIST,
+    QEMU_IFLA_TUN_MULTI_QUEUE,
+    QEMU_IFLA_TUN_NUM_QUEUES,
+    QEMU_IFLA_TUN_NUM_DISABLED_QUEUES,
+    QEMU___IFLA_TUN_MAX,
+};
+
 enum {
     QEMU_IFLA_INFO_UNSPEC,
     QEMU_IFLA_INFO_KIND,
@@ -2315,6 +2329,34 @@ static abi_long host_to_target_slave_data_bridge_nlattr(struct nlattr *nlattr,
     return 0;
 }
 
+static abi_long host_to_target_data_tun_nlattr(struct nlattr *nlattr,
+                                                  void *context)
+{
+    uint32_t *u32;
+
+    switch (nlattr->nla_type) {
+    /* uint8_t */
+    case QEMU_IFLA_TUN_TYPE:
+    case QEMU_IFLA_TUN_PI:
+    case QEMU_IFLA_TUN_VNET_HDR:
+    case QEMU_IFLA_TUN_PERSIST:
+    case QEMU_IFLA_TUN_MULTI_QUEUE:
+        break;
+    /* uint32_t */
+    case QEMU_IFLA_TUN_NUM_QUEUES:
+    case QEMU_IFLA_TUN_NUM_DISABLED_QUEUES:
+    case QEMU_IFLA_TUN_OWNER:
+    case QEMU_IFLA_TUN_GROUP:
+        u32 = NLA_DATA(nlattr);
+        *u32 = tswap32(*u32);
+        break;
+    default:
+        gemu_log("Unknown QEMU_IFLA_TUN type %d\n", nlattr->nla_type);
+        break;
+    }
+    return 0;
+}
+
 struct linkinfo_context {
     int len;
     char *name;
@@ -2349,6 +2391,12 @@ static abi_long host_to_target_data_linkinfo_nlattr(struct nlattr *nlattr,
                                                   nlattr->nla_len,
                                                   NULL,
                                              host_to_target_data_bridge_nlattr);
+        } else if (strncmp(li_context->name, "tun",
+                    li_context->len) == 0) {
+            return host_to_target_for_each_nlattr(NLA_DATA(nlattr),
+                                                  nlattr->nla_len,
+                                                  NULL,
+                                                host_to_target_data_tun_nlattr);
         } else {
             gemu_log("Unknown QEMU_IFLA_INFO_KIND %s\n", li_context->name);
         }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches
  2018-08-19 22:17 [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches Laurent Vivier
                   ` (5 preceding siblings ...)
  2018-08-19 22:17 ` [Qemu-devel] [PULL 6/6] linux-user: add QEMU_IFLA_INFO_KIND nested type for tun Laurent Vivier
@ 2018-08-19 22:38 ` no-reply
  2018-08-20 14:44 ` Peter Maydell
  7 siblings, 0 replies; 10+ messages in thread
From: no-reply @ 2018-08-19 22:38 UTC (permalink / raw)
  To: laurent
  Cc: famz, qemu-devel, crosthwaite.peter, riku.voipio, pbonzini,
	aurelien, rth

Hi,

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

Type: series
Message-id: 20180819221707.20693-1-laurent@vivier.eu
Subject: [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20180819221707.20693-1-laurent@vivier.eu -> patchew/20180819221707.20693-1-laurent@vivier.eu
Switched to a new branch 'test'
7978cedd2d linux-user: add QEMU_IFLA_INFO_KIND nested type for tun
627fe9cda1 linux-user: update netlink route types
221a2f81a7 linux-user: fix recvmsg()/recvfrom() with netlink and MSG_TRUNC
47ed6a6db6 sh4: fix use_icount with linux-user
7d2dc89f58 linux-user: fix 32bit g2h()/h2g()
fce4efcc3d qemu-binfmt-conf.sh: add x86_64 target

=== OUTPUT BEGIN ===
Checking PATCH 1/6: qemu-binfmt-conf.sh: add x86_64 target...
WARNING: line over 80 characters
#29: FILE: scripts/qemu-binfmt-conf.sh:17:
+x86_64_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00'

ERROR: line over 90 characters
#30: FILE: scripts/qemu-binfmt-conf.sh:18:
+x86_64_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'

total: 1 errors, 1 warnings, 18 lines checked

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

Checking PATCH 2/6: linux-user: fix 32bit g2h()/h2g()...
Checking PATCH 3/6: sh4: fix use_icount with linux-user...
Checking PATCH 4/6: linux-user: fix recvmsg()/recvfrom() with netlink and MSG_TRUNC...
Checking PATCH 5/6: linux-user: update netlink route types...
Checking PATCH 6/6: linux-user: add QEMU_IFLA_INFO_KIND nested type for tun...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches
  2018-08-19 22:17 [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches Laurent Vivier
                   ` (6 preceding siblings ...)
  2018-08-19 22:38 ` [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches no-reply
@ 2018-08-20 14:44 ` Peter Maydell
  2018-08-20 15:27   ` Laurent Vivier
  7 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2018-08-20 14:44 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: QEMU Developers, Peter Crosthwaite, Riku Voipio, Paolo Bonzini,
	Aurelien Jarno, Richard Henderson

On 19 August 2018 at 23:17, Laurent Vivier <laurent@vivier.eu> wrote:
> The following changes since commit 0abaa41d936becd914a16ee1fe2a981d96d19428:
>
>   Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging (2018-08-17 09:46:00 +0100)
>
> are available in the Git repository at:
>
>   git://github.com/vivier/qemu.git tags/linux-user-for-3.1-pull-request
>
> for you to fetch changes up to c072a24c11e713f14ab969799433218d8ceebe19:
>
>   linux-user: add QEMU_IFLA_INFO_KIND nested type for tun (2018-08-20 00:11:06 +0200)
>
> ----------------------------------------------------------------
> linux-user fixes:
> - netlink fixes (add missing types, fix MSG_TRUNC)
> - sh4 fix (tcg state)
> - sparc32plus fix (truncate address space to 32bit)
> - add x86_64 binfmt data
>
> ----------------------------------------------------------------

Hi -- I'm afraid this doesn't build on my ppc64 test box:

/home/pm215/qemu/linux-user/syscall.c: In function
‘host_to_target_data_route_rtattr’:
/home/pm215/qemu/linux-user/syscall.c:2719:10: error: ‘RTA_PREF’
undeclared (first use in this function)
     case RTA_PREF:
          ^

thanks
-- PMM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches
  2018-08-20 14:44 ` Peter Maydell
@ 2018-08-20 15:27   ` Laurent Vivier
  0 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2018-08-20 15:27 UTC (permalink / raw)
  To: Peter Maydell
  Cc: QEMU Developers, Peter Crosthwaite, Riku Voipio, Paolo Bonzini,
	Aurelien Jarno, Richard Henderson

Le 20/08/2018 à 16:44, Peter Maydell a écrit :
> On 19 August 2018 at 23:17, Laurent Vivier <laurent@vivier.eu> wrote:
>> The following changes since commit 0abaa41d936becd914a16ee1fe2a981d96d19428:
>>
>>   Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging (2018-08-17 09:46:00 +0100)
>>
>> are available in the Git repository at:
>>
>>   git://github.com/vivier/qemu.git tags/linux-user-for-3.1-pull-request
>>
>> for you to fetch changes up to c072a24c11e713f14ab969799433218d8ceebe19:
>>
>>   linux-user: add QEMU_IFLA_INFO_KIND nested type for tun (2018-08-20 00:11:06 +0200)
>>
>> ----------------------------------------------------------------
>> linux-user fixes:
>> - netlink fixes (add missing types, fix MSG_TRUNC)
>> - sh4 fix (tcg state)
>> - sparc32plus fix (truncate address space to 32bit)
>> - add x86_64 binfmt data
>>
>> ----------------------------------------------------------------

Hi

> Hi -- I'm afraid this doesn't build on my ppc64 test box:
> 
> /home/pm215/qemu/linux-user/syscall.c: In function
> ‘host_to_target_data_route_rtattr’:
> /home/pm215/qemu/linux-user/syscall.c:2719:10: error: ‘RTA_PREF’
> undeclared (first use in this function)
>      case RTA_PREF:

I've tested this on ppc64 box too before the p-l, and it has worked. The
macro is in /usr/include/linux/rtnetlink.h that comes with
kernel-headers-4.17.14-3.fc28.ppc64.

I've checked in the kernel sources and the macro appears in the file in
kernel v4.1 (c78ba6d64c78 ipv6: expose RFC4191 route preference via
rtnetlink).

I'm going to fix that. Thank you.

Laurent

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-08-20 15:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-19 22:17 [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches Laurent Vivier
2018-08-19 22:17 ` [Qemu-devel] [PULL 1/6] qemu-binfmt-conf.sh: add x86_64 target Laurent Vivier
2018-08-19 22:17 ` [Qemu-devel] [PULL 2/6] linux-user: fix 32bit g2h()/h2g() Laurent Vivier
2018-08-19 22:17 ` [Qemu-devel] [PULL 3/6] sh4: fix use_icount with linux-user Laurent Vivier
2018-08-19 22:17 ` [Qemu-devel] [PULL 4/6] linux-user: fix recvmsg()/recvfrom() with netlink and MSG_TRUNC Laurent Vivier
2018-08-19 22:17 ` [Qemu-devel] [PULL 5/6] linux-user: update netlink route types Laurent Vivier
2018-08-19 22:17 ` [Qemu-devel] [PULL 6/6] linux-user: add QEMU_IFLA_INFO_KIND nested type for tun Laurent Vivier
2018-08-19 22:38 ` [Qemu-devel] [PULL 0/6] Linux user for 3.1 patches no-reply
2018-08-20 14:44 ` Peter Maydell
2018-08-20 15:27   ` Laurent Vivier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).