[fedora-virt-maint] rpms/etherboot/F-11 etherboot-5.4.4-e1000-tx-volatile.patch, NONE, 1.1 etherboot.spec, 1.16, 1.17

Mark McLoughlin markmc at fedoraproject.org
Tue Jun 23 11:46:50 UTC 2009


Author: markmc

Update of /cvs/pkgs/rpms/etherboot/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv29259

Modified Files:
	etherboot.spec 
Added Files:
	etherboot-5.4.4-e1000-tx-volatile.patch 
Log Message:
* Tue Jun 23 2009 Mark McLoughlin <markmc at redhat.com> - 5.4.4-16
- Fix e1000 PXE boot - caused by compiler optimization (bug #507391)


etherboot-5.4.4-e1000-tx-volatile.patch:

--- NEW FILE etherboot-5.4.4-e1000-tx-volatile.patch ---
From: Mark McLoughlin <markmc at redhat.com>
Subject: [PATCH] Use volatile for eth_hdr in e1000_transmit()

With gcc-4.4.0 and etherboot-5.4.4 we're seeing e1000 send packets
where the type field in the ethernet header is (incorrectly) zero.

Enabling debugging in drivers/net/e1000.c made the problem go away,
which was the first clue.

The code is as follows:

    struct eth_hdr {
        unsigned char dst_addr[ETH_ALEN];
 unsigned char src_addr[ETH_ALEN];
        unsigned short type;
    } hdr;
    ...
    hdr.type = htons (type);
    txhd = tx_base + tx_tail;
    tx_tail = (tx_tail + 1) % 8;
    ...
    txhd->buffer_addr = virt_to_bus (&hdr);
    ...
    E1000_WRITE_REG (&hw, TDT, tx_tail);

i.e. we're setting the type in the header on the stack, setting up a tx
descriptor to point to header on the stack and then writing the descriptor
number to the device queue.

Looking at the assembly, we see:

     36d:       8b 4c 24 38             mov    0x38(%esp),%ecx
     371:       86 cd                   xchg   %cl,%ch
     ...
     3fb:       89 90 18 38 00 00       mov    %edx,0x3818(%eax)
     ...
     407:       66 89 4c 24 1e          mov    %cx,0x1e(%esp)

i.e. we're only actually moving the results of the htons() into the header on
the stack until after we've set the TDT register. At that point the packet has
already been sent.

The problem is that the compiler has no way of knowing this memory is used as a
result of us writing to the register. So, if we do:

-       struct eth_hdr {
+       volatile struct eth_hdr {

we see:

     36c:       8b 44 24 38             mov    0x38(%esp),%eax
     370:       86 c4                   xchg   %al,%ah
     372:       66 89 44 24 1e          mov    %ax,0x1e(%esp)
     ...
     400:       89 90 18 38 00 00       mov    %edx,0x3818(%eax)

This fixes the problem.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>

diff -up etherboot-5.4.4/src/drivers/net/e1000.c.volatile etherboot-5.4.4/src/drivers/net/e1000.c
--- etherboot-5.4.4/src/drivers/net/e1000.c.volatile	2009-06-23 12:19:35.296917613 +0100
+++ etherboot-5.4.4/src/drivers/net/e1000.c	2009-06-23 12:19:48.914663692 +0100
@@ -3733,7 +3733,7 @@ e1000_transmit (struct nic *nic, const c
 		    const char *p)	/* Packet */
 {
 	/* send the packet to destination */
-	struct eth_hdr {
+	volatile struct eth_hdr {
 		unsigned char dst_addr[ETH_ALEN];
 		unsigned char src_addr[ETH_ALEN];
 		unsigned short type;


Index: etherboot.spec
===================================================================
RCS file: /cvs/pkgs/rpms/etherboot/F-11/etherboot.spec,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -p -r1.16 -r1.17
--- etherboot.spec	23 Jun 2009 07:16:02 -0000	1.16
+++ etherboot.spec	23 Jun 2009 11:46:18 -0000	1.17
@@ -7,7 +7,7 @@
 
 Name: etherboot
 Version: 5.4.4
-Release: 15%{?dist}
+Release: 16%{?dist}
 Summary: Etherboot collection of boot roms
 
 Group: Development/Tools
@@ -21,6 +21,8 @@ Source0: %{name}-%{version}-nofsp.tar.gz
 # The script used to remove the proto_fsp.c files:
 Source2: strip-etherboot-tarball.sh
 
+Patch0: etherboot-5.4.4-e1000-tx-volatile.patch
+
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -107,6 +109,9 @@ installed. Etherboot is code that can be
 %setup -q
 
 %ifarch %{ix86}
+
+%patch0 -p1 -b .e1000-tx-volatile
+
 # Enable PXE_DHCP_STRICT (see bug #494541)
 sed -i -e 's/# \(CFLAGS.*PXE_DHCP_STRICT\)/\1/' src/Config
 # Disable ASK_BOOT (see bug #506616)
@@ -178,6 +183,9 @@ rm -rf %{buildroot}
 
 
 %changelog
+* Tue Jun 23 2009 Mark McLoughlin <markmc at redhat.com> - 5.4.4-16
+- Fix e1000 PXE boot - caused by compiler optimization (bug #507391)
+
 * Fri Jun 19 2009 Mark McLoughlin <markmc at redhat.com> - 5.4.4-15
 - Disable ASK_BOOT (bug #506616)
 




More information about the Fedora-virt-maint mailing list