qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1
@ 2014-07-15 14:24 riku.voipio
  2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 1/5] SIOCGIFINDEX: fix typo riku.voipio
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: riku.voipio @ 2014-07-15 14:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Riku Voipio

From: Riku Voipio <riku.voipio@linaro.org>

The following changes since commit 0a9934eef166836c8100fce72f7f837cb8b2ed2b:

  Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2014-07-14 17:01:45 +0100)

are available in the git repository at:


  git://git.linaro.org/people/riku.voipio/qemu.git linux-user-for-upstream

for you to fetch changes up to b545f63fa974ebffd55d70ca615572d497e543dc:

  linux-user: use TARGET_SA_ONSTACK in get_sigframe (2014-07-15 17:08:41 +0300)

----------------------------------------------------------------
Joakim Tjernlund (4):
  SIOCGIFINDEX: fix typo
  qemu-user: Impl. setsockopt(SO_BINDTODEVICE)
  linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr
  alloca one extra byte sockets

Riku Voipio (1):
  linux-user: use TARGET_SA_ONSTACK in get_sigframe

 linux-user/ioctls.h       |  2 +-
 linux-user/signal.c       |  7 ++++---
 linux-user/syscall.c      | 32 +++++++++++++++++++++++++++++---
 linux-user/syscall_defs.h | 10 ++++++++++
 4 files changed, 44 insertions(+), 7 deletions(-)

-- 
2.0.0

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

* [Qemu-devel] [PULL for-2.1 1/5] SIOCGIFINDEX: fix typo
  2014-07-15 14:24 [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1 riku.voipio
@ 2014-07-15 14:24 ` riku.voipio
  2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 2/5] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) riku.voipio
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: riku.voipio @ 2014-07-15 14:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Joakim Tjernlund

From: Joakim Tjernlund <joakim.tjernlund@transmode.se>

Wrong type was used in ioctl definition.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/ioctls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 07a00da..609b27c 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -118,7 +118,7 @@
   IOCTL(SIOCSIFMEM, IOC_W, MK_PTR(MK_STRUCT(STRUCT_ptr_ifreq)))
   IOCTL(SIOCADDMULTI, IOC_W, MK_PTR(MK_STRUCT(STRUCT_sockaddr_ifreq)))
   IOCTL(SIOCDELMULTI, IOC_W, MK_PTR(MK_STRUCT(STRUCT_sockaddr_ifreq)))
-  IOCTL(SIOCGIFINDEX, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_sockaddr_ifreq)))
+  IOCTL(SIOCGIFINDEX, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_int_ifreq)))
   IOCTL(SIOCSIFLINK, 0, TYPE_NULL)
   IOCTL_SPECIAL(SIOCGIFCONF, IOC_W | IOC_R, do_ioctl_ifconf,
                 MK_PTR(MK_STRUCT(STRUCT_ifconf)))
-- 
2.0.0

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

* [Qemu-devel] [PULL for-2.1 2/5] qemu-user: Impl. setsockopt(SO_BINDTODEVICE)
  2014-07-15 14:24 [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1 riku.voipio
  2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 1/5] SIOCGIFINDEX: fix typo riku.voipio
@ 2014-07-15 14:24 ` riku.voipio
  2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 3/5] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr riku.voipio
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: riku.voipio @ 2014-07-15 14:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Joakim Tjernlund

From: Joakim Tjernlund <joakim.tjernlund@transmode.se>

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 5a272d3..dcf1323 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1497,6 +1497,25 @@ set_timeout:
                 unlock_user_struct(tfprog, optval_addr, 1);
                 return ret;
         }
+	case TARGET_SO_BINDTODEVICE:
+	{
+		char *dev_ifname, *addr_ifname;
+
+		if (optlen > IFNAMSIZ - 1) {
+		    optlen = IFNAMSIZ - 1;
+		}
+		dev_ifname = lock_user(VERIFY_READ, optval_addr, optlen, 1);
+		if (!dev_ifname) {
+		    return -TARGET_EFAULT;
+		}
+		optname = SO_BINDTODEVICE;
+		addr_ifname = alloca(IFNAMSIZ);
+		memcpy(addr_ifname, dev_ifname, optlen);
+		addr_ifname[optlen] = 0;
+		ret = get_errno(setsockopt(sockfd, level, optname, addr_ifname, optlen));
+		unlock_user (dev_ifname, optval_addr, 0);
+		return ret;
+	}
             /* Options with 'int' argument.  */
         case TARGET_SO_DEBUG:
 		optname = SO_DEBUG;
-- 
2.0.0

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

* [Qemu-devel] [PULL for-2.1 3/5] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr
  2014-07-15 14:24 [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1 riku.voipio
  2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 1/5] SIOCGIFINDEX: fix typo riku.voipio
  2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 2/5] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) riku.voipio
@ 2014-07-15 14:24 ` riku.voipio
  2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 4/5] alloca one extra byte sockets riku.voipio
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: riku.voipio @ 2014-07-15 14:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Joakim Tjernlund

From: Joakim Tjernlund <joakim.tjernlund@transmode.se>

Implement conversion of the AF_PACKET sockaddr subtype
in target_to_host_sockaddr.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c      |  7 +++++++
 linux-user/syscall_defs.h | 10 ++++++++++
 2 files changed, 17 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index dcf1323..7163ade 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1140,6 +1140,13 @@ static inline abi_long target_to_host_sockaddr(struct sockaddr *addr,
 
     memcpy(addr, target_saddr, len);
     addr->sa_family = sa_family;
+    if (sa_family == AF_PACKET) {
+	struct target_sockaddr_ll *lladdr;
+
+	lladdr = (struct target_sockaddr_ll *)addr;
+	lladdr->sll_ifindex = tswap32(lladdr->sll_ifindex);
+	lladdr->sll_hatype = tswap16(lladdr->sll_hatype);
+    }
     unlock_user(target_saddr, target_addr, 0);
 
     return 0;
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 8563027..c9e6323 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -121,6 +121,16 @@ struct target_sockaddr {
     uint8_t sa_data[14];
 };
 
+struct target_sockaddr_ll {
+    uint16_t sll_family;   /* Always AF_PACKET */
+    uint16_t sll_protocol; /* Physical layer protocol */
+    int      sll_ifindex;  /* Interface number */
+    uint16_t sll_hatype;   /* ARP hardware type */
+    uint8_t  sll_pkttype;  /* Packet type */
+    uint8_t  sll_halen;    /* Length of address */
+    uint8_t  sll_addr[8];  /* Physical layer address */
+};
+
 struct target_sock_filter {
     abi_ushort code;
     uint8_t jt;
-- 
2.0.0

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

* [Qemu-devel] [PULL for-2.1 4/5] alloca one extra byte sockets
  2014-07-15 14:24 [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1 riku.voipio
                   ` (2 preceding siblings ...)
  2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 3/5] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr riku.voipio
@ 2014-07-15 14:24 ` riku.voipio
  2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 5/5] linux-user: use TARGET_SA_ONSTACK in get_sigframe riku.voipio
  2014-07-15 17:09 ` [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1 Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: riku.voipio @ 2014-07-15 14:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Joakim Tjernlund

From: Joakim Tjernlund <joakim.tjernlund@transmode.se>

target_to_host_sockaddr() may increase the lenth with 1 byte
for AF_UNIX sockets so allocate 1 extra byte.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7163ade..a50229d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1984,7 +1984,7 @@ static abi_long do_connect(int sockfd, abi_ulong target_addr,
         return -TARGET_EINVAL;
     }
 
-    addr = alloca(addrlen);
+    addr = alloca(addrlen+1);
 
     ret = target_to_host_sockaddr(addr, target_addr, addrlen);
     if (ret)
@@ -2005,7 +2005,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
 
     if (msgp->msg_name) {
         msg.msg_namelen = tswap32(msgp->msg_namelen);
-        msg.msg_name = alloca(msg.msg_namelen);
+        msg.msg_name = alloca(msg.msg_namelen+1);
         ret = target_to_host_sockaddr(msg.msg_name, tswapal(msgp->msg_name),
                                 msg.msg_namelen);
         if (ret) {
@@ -2268,7 +2268,7 @@ static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags,
     if (!host_msg)
         return -TARGET_EFAULT;
     if (target_addr) {
-        addr = alloca(addrlen);
+        addr = alloca(addrlen+1);
         ret = target_to_host_sockaddr(addr, target_addr, addrlen);
         if (ret) {
             unlock_user(host_msg, msg, 0);
-- 
2.0.0

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

* [Qemu-devel] [PULL for-2.1 5/5] linux-user: use TARGET_SA_ONSTACK in get_sigframe
  2014-07-15 14:24 [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1 riku.voipio
                   ` (3 preceding siblings ...)
  2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 4/5] alloca one extra byte sockets riku.voipio
@ 2014-07-15 14:24 ` riku.voipio
  2014-07-15 17:09 ` [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1 Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: riku.voipio @ 2014-07-15 14:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Riku Voipio

From: Riku Voipio <riku.voipio@linaro.org>

As reported by Laurent, which should use TARGET_SA_ONSTACK
on arm, microblaze and openrisc targets like we do on all
others. Practical matter is minimal as for almost all archs
SA_ONSTACK is 0x08000000:

http://lxr.free-electrons.com/ident?i=SA_ONSTACK

Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/signal.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index f3b4378..1141054 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -1305,7 +1305,7 @@ static abi_ulong get_sigframe(struct target_sigaction *ka, CPUARMState *env)
     /*
      * This is the X/Open sanctioned signal stack switching.
      */
-    if ((ka->sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) {
+    if ((ka->sa_flags & TARGET_SA_ONSTACK) && !sas_ss_flags(sp)) {
         sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
     }
 
@@ -3509,8 +3509,9 @@ static abi_ulong get_sigframe(struct target_sigaction *ka,
 {
     abi_ulong sp = env->regs[1];
 
-    if ((ka->sa_flags & SA_ONSTACK) != 0 && !on_sig_stack(sp))
+    if ((ka->sa_flags & TARGET_SA_ONSTACK) != 0 && !on_sig_stack(sp)) {
         sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+    }
 
     return ((sp - frame_size) & -8UL);
 }
@@ -3891,7 +3892,7 @@ static inline abi_ulong get_sigframe(struct target_sigaction *ka,
 
     /* redzone */
     /* This is the X/Open sanctioned signal stack switching.  */
-    if ((ka->sa_flags & SA_ONSTACK) != 0 && !onsigstack) {
+    if ((ka->sa_flags & TARGET_SA_ONSTACK) != 0 && !onsigstack) {
         sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
     }
 
-- 
2.0.0

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

* Re: [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1
  2014-07-15 14:24 [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1 riku.voipio
                   ` (4 preceding siblings ...)
  2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 5/5] linux-user: use TARGET_SA_ONSTACK in get_sigframe riku.voipio
@ 2014-07-15 17:09 ` Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2014-07-15 17:09 UTC (permalink / raw)
  To: Riku Voipio; +Cc: QEMU Developers

On 15 July 2014 15:24,  <riku.voipio@linaro.org> wrote:
> From: Riku Voipio <riku.voipio@linaro.org>
>
> The following changes since commit 0a9934eef166836c8100fce72f7f837cb8b2ed2b:
>
>   Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2014-07-14 17:01:45 +0100)
>
> are available in the git repository at:
>
>
>   git://git.linaro.org/people/riku.voipio/qemu.git linux-user-for-upstream
>
> for you to fetch changes up to b545f63fa974ebffd55d70ca615572d497e543dc:
>
>   linux-user: use TARGET_SA_ONSTACK in get_sigframe (2014-07-15 17:08:41 +0300)

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2014-07-15 17:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-15 14:24 [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1 riku.voipio
2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 1/5] SIOCGIFINDEX: fix typo riku.voipio
2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 2/5] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) riku.voipio
2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 3/5] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr riku.voipio
2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 4/5] alloca one extra byte sockets riku.voipio
2014-07-15 14:24 ` [Qemu-devel] [PULL for-2.1 5/5] linux-user: use TARGET_SA_ONSTACK in get_sigframe riku.voipio
2014-07-15 17:09 ` [Qemu-devel] [PULL for-2.1 0/5] linux-user fixes for 2.1 Peter Maydell

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).