From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JKkqV-0003ij-6Q for qemu-devel@nongnu.org; Thu, 31 Jan 2008 20:37:35 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JKkqT-0003iX-CF for qemu-devel@nongnu.org; Thu, 31 Jan 2008 20:37:33 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JKkqT-0003iU-6O for qemu-devel@nongnu.org; Thu, 31 Jan 2008 20:37:33 -0500 Received: from mailwasher.lanl.gov ([204.121.3.2]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JKkqS-0006td-MO for qemu-devel@nongnu.org; Thu, 31 Jan 2008 20:37:32 -0500 Message-ID: <47A277D2.9000604@lanl.gov> Date: Thu, 31 Jan 2008 18:37:22 -0700 From: Scott Pakin MIME-Version: 1.0 References: <479F5E3A.6030506@lanl.gov> <42DFA526FC41B1429CE7279EF83C6BDCD31A15@pdsmsx415.ccr.corp.intel.com> <47A0A90B.50407@lanl.gov> <42DFA526FC41B1429CE7279EF83C6BDCD31F4E@pdsmsx415.ccr.corp.intel.com> <47A215A2.4070407@lanl.gov> In-Reply-To: <47A215A2.4070407@lanl.gov> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [kvm-devel] [PATCH] Making SLIRP code more 64-bit clean Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Scott Pakin Cc: kvm-devel@lists.sourceforge.net, qemu-devel@nongnu.org, kvm-ia64-devel@lists.sourceforge.net I just noticed that my previous patch hit one of the subtleties that Blue Swirl warned about. Changing caddr32_t causes the IP header and IP header overlay to be different sizes, which essentially breaks networking altogether. I humbly offer the following patch, which fixes only the "easy" 32/64-bit bugs but leaves the tricky 32/64-bit bugs in the IP header processing intact for someone abler than I to fix. -- Scott ============= BEGIN tcp_int32_pointer_cast_no_caddr.patch ============== diff -Naur kvm-60-ORIG/qemu/exec-all.h kvm-60/qemu/exec-all.h --- kvm-60-ORIG/qemu/exec-all.h 2008-01-20 05:35:04.000000000 -0700 +++ kvm-60/qemu/exec-all.h 2008-01-31 17:36:34.000000000 -0700 @@ -169,7 +169,7 @@ #ifdef USE_DIRECT_JUMP uint16_t tb_jmp_offset[4]; /* offset of jump instruction */ #else - uint32_t tb_next[2]; /* address of jump generated code */ + uintptr_t tb_next[2]; /* address of jump generated code */ #endif /* list of TBs jumping to this one. This is a circular list using the two least significant bits of the pointers to tell what is diff -Naur kvm-60-ORIG/qemu/slirp/ip.h kvm-60/qemu/slirp/ip.h --- kvm-60-ORIG/qemu/slirp/ip.h 2008-01-20 05:35:04.000000000 -0700 +++ kvm-60/qemu/slirp/ip.h 2008-01-31 17:29:28.000000000 -0700 @@ -193,13 +193,8 @@ #endif #endif -#if SIZEOF_CHAR_P == 4 typedef struct ipq *ipqp_32; typedef struct ipasfrag *ipasfragp_32; -#else -typedef caddr32_t ipqp_32; -typedef caddr32_t ipasfragp_32; -#endif /* * Overlay for ip header used by other protocols (tcp, udp). diff -Naur kvm-60-ORIG/qemu/slirp/misc.c kvm-60/qemu/slirp/misc.c --- kvm-60-ORIG/qemu/slirp/misc.c 2008-01-20 05:35:04.000000000 -0700 +++ kvm-60/qemu/slirp/misc.c 2008-01-31 17:30:14.000000000 -0700 @@ -97,39 +97,6 @@ our_addr.s_addr = loopback_addr.s_addr; } -#if SIZEOF_CHAR_P == 8 - -struct quehead_32 { - u_int32_t qh_link; - u_int32_t qh_rlink; -}; - -inline void -insque_32(a, b) - void *a; - void *b; -{ - register struct quehead_32 *element = (struct quehead_32 *) a; - register struct quehead_32 *head = (struct quehead_32 *) b; - element->qh_link = head->qh_link; - head->qh_link = (u_int32_t)element; - element->qh_rlink = (u_int32_t)head; - ((struct quehead_32 *)(element->qh_link))->qh_rlink - = (u_int32_t)element; -} - -inline void -remque_32(a) - void *a; -{ - register struct quehead_32 *element = (struct quehead_32 *) a; - ((struct quehead_32 *)(element->qh_link))->qh_rlink = element->qh_rlink; - ((struct quehead_32 *)(element->qh_rlink))->qh_link = element->qh_link; - element->qh_rlink = 0; -} - -#endif /* SIZEOF_CHAR_P == 8 */ - struct quehead { struct quehead *qh_link; struct quehead *qh_rlink; diff -Naur kvm-60-ORIG/qemu/slirp/slirp.h kvm-60/qemu/slirp/slirp.h --- kvm-60-ORIG/qemu/slirp/slirp.h 2008-01-20 05:35:04.000000000 -0700 +++ kvm-60/qemu/slirp/slirp.h 2008-01-31 17:30:58.000000000 -0700 @@ -265,13 +265,8 @@ void lprint _P((const char *, ...)); -#if SIZEOF_CHAR_P == 4 -# define insque_32 insque -# define remque_32 remque -#else - inline void insque_32 _P((void *, void *)); - inline void remque_32 _P((void *)); -#endif +#define insque_32 insque +#define remque_32 remque #ifndef _WIN32 #include diff -Naur kvm-60-ORIG/qemu/slirp/tcp_var.h kvm-60/qemu/slirp/tcp_var.h --- kvm-60-ORIG/qemu/slirp/tcp_var.h 2008-01-20 05:35:04.000000000 -0700 +++ kvm-60/qemu/slirp/tcp_var.h 2008-01-31 17:35:03.000000000 -0700 @@ -40,11 +40,7 @@ #include "tcpip.h" #include "tcp_timer.h" -#if SIZEOF_CHAR_P == 4 - typedef struct tcpiphdr *tcpiphdrp_32; -#else - typedef u_int32_t tcpiphdrp_32; -#endif +typedef struct tcpiphdr *tcpiphdrp_32; /* * Tcp control block, one per tcp; fields: @@ -178,11 +174,7 @@ * port numbers (which are no longer needed once we've located the * tcpcb) are overlayed with an mbuf pointer. */ -#if SIZEOF_CHAR_P == 4 typedef struct mbuf *mbufp_32; -#else -typedef u_int32_t mbufp_32; -#endif #define REASS_MBUF(ti) (*(mbufp_32 *)&((ti)->ti_t)) #ifdef LOG_ENABLED ============== END tcp_int32_pointer_cast_no_caddr.patch ===============