From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqAxy-0008NX-Tg for qemu-devel@nongnu.org; Tue, 01 Jan 2013 18:09:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TqAxv-00085n-7c for qemu-devel@nongnu.org; Tue, 01 Jan 2013 18:09:50 -0500 Received: from moutng.kundenserver.de ([212.227.17.9]:52899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqAxu-00085j-UD for qemu-devel@nongnu.org; Tue, 01 Jan 2013 18:09:47 -0500 Message-ID: <1357081778.31530.7.camel@Quad> From: Laurent Vivier Date: Wed, 02 Jan 2013 00:09:38 +0100 In-Reply-To: <1356036973-19376-1-git-send-email-laurent@vivier.eu> References: <1356036973-19376-1-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] linux-user: add string type in rtentry struct List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio Ping ! Le jeudi 20 d=C3=A9cembre 2012 =C3=A0 21:56 +0100, Laurent Vivier a =C3=A9c= rit : > This allows to pass the device name. >=20 > You can test this with the "route" command. >=20 > WITHOUT this patch: >=20 > $ sudo route add -net default gw 10.0.3.1 eth0 > SIOCADDRT: Bad address > $ netstat -nr > Kernel IP routing table > Destination Gateway Genmask Flags MSS Window irtt = Iface > 10.0.3.0 0.0.0.0 255.255.255.0 U 0 0 0 = eth0 >=20 > WITH this patch: >=20 > $ sudo route add -net default gw 10.0.3.1 eth0 > $ netstat -nr > Kernel IP routing table > Destination Gateway Genmask Flags MSS Window irtt = Iface > 0.0.0.0 10.0.3.1 0.0.0.0 UG 0 0 0 = eth0 > 10.0.3.0 0.0.0.0 255.255.255.0 U 0 0 0 = eth0 >=20 > Signed-off-by: Laurent Vivier > --- > linux-user/syscall.c | 64 ++++++++++++++++++++++++++++++++++++++= ++++++ > linux-user/syscall_types.h | 4 ++- > 2 files changed, 67 insertions(+), 1 deletion(-) >=20 > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index 501002b..c2a2343 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -3691,6 +3691,70 @@ static IOCTLEntry ioctl_entries[] =3D { > { 0, 0, }, > }; > =20 > +static void target_to_host_string (void *dst, const void *src) > +{ > +#if HOST_LONG_BITS =3D=3D 32 && TARGET_ABI_BITS =3D=3D 32 > + if (*(uint32_t*)src =3D=3D 0) { > + *(uint32_t*)dst =3D 0; > + return; > + } > + *(uint32_t *)dst =3D (uint32_t)g2h(tswap32(*(uint32_t *)src)); > +#elif HOST_LONG_BITS =3D=3D 64 && TARGET_ABI_BITS =3D=3D 32 > + if (*(uint32_t*)src =3D=3D 0) { > + *(uint64_t*)dst =3D 0; > + return; > + } > + *(uint64_t *)dst =3D (uint64_t)g2h(tswap32(*(uint32_t *)src)); > +#elif HOST_LONG_BITS =3D=3D 64 && TARGET_ABI_BITS =3D=3D 64 > + if (*(uint64_t*)src =3D=3D 0) { > + *(uint64_t*)dst =3D 0; > + return; > + } > + *(uint64_t *)dst =3D (uint64_t)g2h(tswap64(*(uint64_t *)src)); > +#elif HOST_LONG_BITS =3D=3D 32 && TARGET_ABI_BITS =3D=3D 64 > + if (*(uint64_t*)src =3D=3D 0) { > + *(uint32_t*)dst =3D 0; > + return; > + } > + *(uint32_t *)dst =3D (uint32_t)g2h(tswap64(*(uint64_t *)src)); > +#endif > +} > + > +static void host_to_target_string (void *dst, const void *src) > +{ > +#if HOST_LONG_BITS =3D=3D 32 && TARGET_ABI_BITS =3D=3D 32 > + if (*(uint32_t*)src =3D=3D 0) { > + *(uint32_t*)dst =3D 0; > + return; > + } > + *(uint32_t *)dst =3D tswap32(h2g(*(uint32_t *)src)); > +#elif HOST_LONG_BITS =3D=3D 64 && TARGET_ABI_BITS =3D=3D 32 > + if (*(uint64_t*)src =3D=3D 0) { > + *(uint32_t*)dst =3D 0; > + return; > + } > + *(uint32_t *)dst =3D tswap32(h2g(*(uint64_t *)src)); > +#elif HOST_LONG_BITS =3D=3D 64 && TARGET_ABI_BITS =3D=3D 64 > + if (*(uint64_t*)src =3D=3D 0) { > + *(uint64_t*)dst =3D 0; > + return; > + } > + *(uint64_t *)dst =3D tswap64(h2g(*(uint64_t *)src)); > +#elif HOST_LONG_BITS =3D=3D 32 && TARGET_ABI_BITS =3D=3D 64 > + if (*(uint32_t*)src =3D=3D 0) { > + *(uint64_t*)dst =3D 0; > + return; > + } > + *(uint64_t *)dst =3D tswap64(h2g(*(uint32_t *)src)); > +#endif > +} > + > +static const StructEntry struct_string_def =3D { > + .convert =3D { host_to_target_string, target_to_host_string }, > + .size =3D { sizeof(target_long), sizeof(long) }, > + .align =3D { __alignof__(target_long), __alignof__(long) }, > +}; > + > /* ??? Implement proper locking for ioctls. */ > /* do_ioctl() Must return target values and target errnos. */ > static abi_long do_ioctl(int fd, abi_long cmd, abi_long arg) > diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h > index 44b6a58..51fc023 100644 > --- a/linux-user/syscall_types.h > +++ b/linux-user/syscall_types.h > @@ -14,9 +14,11 @@ STRUCT(serial_icounter_struct, > STRUCT(sockaddr, > TYPE_SHORT, MK_ARRAY(TYPE_CHAR, 14)) > =20 > +STRUCT_SPECIAL(string) > + > STRUCT(rtentry, > TYPE_ULONG, MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr= ), MK_STRUCT(STRUCT_sockaddr), > - TYPE_SHORT, TYPE_SHORT, TYPE_ULONG, TYPE_PTRVOID, TYPE_SHORT, TYP= E_PTRVOID, > + TYPE_SHORT, TYPE_SHORT, TYPE_ULONG, TYPE_PTRVOID, TYPE_SHORT, MK_= STRUCT(STRUCT_string), > TYPE_ULONG, TYPE_ULONG, TYPE_SHORT) > =20 > STRUCT(ifmap, --=20 "Just play. Have fun. Enjoy the game." - Michael Jordan "Just play. Have fun. Enjoy the game." - Michael Jordan