Skip to contentSkip to conversation

nics have same hw address (rtl8139)

kvm-Bugs-1802223 SourceForge.net 5 participants 6 messages Sep 25, 2007 – Sep 27, 2007 4 messages not in the archive KVM

lore
Share & tools
lore
#0 lore raw

Bugs item #1802223, was opened at 2007-09-25 22:59
Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=893831&aid=1802223&group_id=180599

Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: xeb (xebd)
Assigned to: Nobody/Anonymous (nobody)
Summary: nics have same hw address (rtl8139)

Initial Comment:
Hello!

Host:Linux 2.6.22-gentoo-r2 #2 SMP Fri Aug 3 07:01:46 MSD 2007 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 5600+ AuthenticAMD GNU/Linux,Gentoo, kvm-44

Guest:Linux 2.6.22-hardened-r4

command line:

qemu-system-x86_64 -hda server_base_x86.img -hdc server_swap.img -localtime -m 128 \
    -net nic,vlan=0,macaddr=52:54:00:12:34:56,model=rtl8139 -net tap,vlan=0,ifname=tap3,script=no \
    -net nic,vlan=1,macaddr=52:54:00:12:34:57,model=rtl8139 -net tap,vlan=1,ifname=tap4,script=no \
    -net nic,vlan=2,macaddr=52:54:00:12:34:58,model=rtl8139 -net tap,vlan=2,ifname=tap5,script=no \
    -nographic

ifconfig on guest:
eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:58
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:11 Base address:0x4000

eth1 Link encap:Ethernet HWaddr 52:54:00:12:34:58
inet addr:192.168.11.1 Bcast:192.168.11.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:9 Base address:0x6100

eth2 Link encap:Ethernet HWaddr 52:54:00:12:34:58
inet addr:192.168.13.1 Bcast:192.168.13.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11 Base address:0x8200

As can you see they have same hwaddr.
With model=ne2k_pci nics have correct hw addresses

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

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=893831&aid=1802223&group_id=180599

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#2 lore raw
In reply to a message not in the archive

Hi,

I think there is a bug in qemu RTL8139.

RTL8139 uses:

cpu_register_physical_memory(addr + 0, 0x100, s->rtl8139_mmio_io_addr);

But in the comment of cpu_register_physical_memory() we have:

"'size' must be a multiple of the target page size."

And I think 0x100 is not a multiple of target page size.... :-P

The attached patch corrects the problem.

Laurent

Quoted 59 lines · SourceForge.net

Bugs item #1802223, was opened at 2007-09-25 22:59
Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=893831&aid=1802223&group_id=180599

Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: xeb (xebd)
Assigned to: Nobody/Anonymous (nobody)
Summary: nics have same hw address (rtl8139)

Initial Comment:
Hello!

Host:Linux 2.6.22-gentoo-r2 #2 SMP Fri Aug 3 07:01:46 MSD 2007 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 5600+ AuthenticAMD GNU/Linux,Gentoo, kvm-44

Guest:Linux 2.6.22-hardened-r4

command line:

qemu-system-x86_64 -hda server_base_x86.img -hdc server_swap.img -localtime -m 128 \
    -net nic,vlan=0,macaddr=52:54:00:12:34:56,model=rtl8139 -net tap,vlan=0,ifname=tap3,script=no \
    -net nic,vlan=1,macaddr=52:54:00:12:34:57,model=rtl8139 -net tap,vlan=1,ifname=tap4,script=no \
    -net nic,vlan=2,macaddr=52:54:00:12:34:58,model=rtl8139 -net tap,vlan=2,ifname=tap5,script=no \
    -nographic

ifconfig on guest:
eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:58
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:11 Base address:0x4000

eth1 Link encap:Ethernet HWaddr 52:54:00:12:34:58
inet addr:192.168.11.1 Bcast:192.168.11.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:9 Base address:0x6100

eth2 Link encap:Ethernet HWaddr 52:54:00:12:34:58
inet addr:192.168.13.1 Bcast:192.168.13.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11 Base address:0x8200

Quoted 2 lines

As can you see they have same hwaddr.
With model=ne2k_pci nics have correct hw addresses

Laurent

Signature · 2 lines
------------- Laurent.Vivier-6ktuUTfB/[email protected]  --------------
          "Software is hard" - Donald Knuth
qemu/hw/rtl8139.c +5 -3
index 94fc2fc..e345888 100644
@@ -408,6 +408,8 @@ typedef struct RTL8139TallyCounters
     uint16_t   TxUndrn;
 } RTL8139TallyCounters;
 
+#define RTL8139_PNPNMIO_SIZE	0x1000
+
 /* Clears all tally counters */
 static void RTL8139TallyCounters_clear(RTL8139TallyCounters* counters);
 
@@ -3325,7 +3327,7 @@ static void rtl8139_mmio_map(PCIDevice *pci_dev, int region_num,
     PCIRTL8139State *d = (PCIRTL8139State *)pci_dev;
     RTL8139State *s = &d->rtl8139;
 
-    cpu_register_physical_memory(addr + 0, 0x100, s->rtl8139_mmio_io_addr);
+    cpu_register_physical_memory(addr + 0, RTL8139_PNPNMIO_SIZE, s->rtl8139_mmio_io_addr);
 }
 
 static void rtl8139_ioport_map(PCIDevice *pci_dev, int region_num, 
@@ -3438,10 +3440,10 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
     s->rtl8139_mmio_io_addr =
     cpu_register_io_memory(0, rtl8139_mmio_read, rtl8139_mmio_write, s);
 
-    pci_register_io_region(&d->dev, 0, 0x100, 
+    pci_register_io_region(&d->dev, 0, RTL8139_PNPNMIO_SIZE, 
                            PCI_ADDRESS_SPACE_IO,  rtl8139_ioport_map);
 
-    pci_register_io_region(&d->dev, 1, 0x100, 
+    pci_register_io_region(&d->dev, 1, RTL8139_PNPNMIO_SIZE, 
                            PCI_ADDRESS_SPACE_MEM, rtl8139_mmio_map);
 
     s->irq = 16; /* PCI interrupt */

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

#4 lore raw
In reply to a message not in the archive
Quoted 6 lines · Laurent Vivier

Hi,

I think there is a bug in qemu RTL8139.

RTL8139 uses:

Quoted 7 lines

cpu_register_physical_memory(addr + 0, 0x100, s->rtl8139_mmio_io_addr);

But in the comment of cpu_register_physical_memory() we have:

"'size' must be a multiple of the target page size."

And I think 0x100 is not a multiple of target page size.... :-P

Latest upstream QEMU has fixed its memory handling so that MMIO regions do not need to be a multiple of page size. Changing RTL8139 to use a block of size 0x1000 is a reasonable short term hack around the problem, but syncing with latest QEMU is the real solution, since there are other places in the code which will have similar issues.

Dan.

Signature · 9 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
#5 lore raw
Quoted 13 lines · Daniel P. Berrange
Quoted 12 lines · Laurent Vivier

Hi,

I think there is a bug in qemu RTL8139.

RTL8139 uses:

cpu_register_physical_memory(addr + 0, 0x100, s->rtl8139_mmio_io_addr);

But in the comment of cpu_register_physical_memory() we have:

"'size' must be a multiple of the target page size."

Quoted 8 lines
Quoted 1 line

And I think 0x100 is not a multiple of target page size.... :-P

Latest upstream QEMU has fixed its memory handling so that MMIO regions do not need to be a multiple of page size. Changing RTL8139 to use a block of size 0x1000 is a reasonable short term hack around the problem, but syncing with latest QEMU is the real solution, since there are other places in the code which will have similar issues.

So this explains why rtl8139.c from QEMU CVS always uses 0x100.

Thank you for the comment.

Avi, you know what you have to do ;-)

Laurent

Signature · 2 lines
------------- [email protected]  --------------
          "Software is hard" - Donald Knuth
#7 lore raw
In reply to a message not in the archive
Quoted 23 lines · Laurent Vivier
Quoted 13 lines · Daniel P. Berrange
Quoted 12 lines · Laurent Vivier

Hi,

I think there is a bug in qemu RTL8139.

RTL8139 uses:

cpu_register_physical_memory(addr + 0, 0x100, s->rtl8139_mmio_io_addr);

But in the comment of cpu_register_physical_memory() we have:

"'size' must be a multiple of the target page size."

Quoted 8 lines
Quoted 1 line

And I think 0x100 is not a multiple of target page size.... :-P

Latest upstream QEMU has fixed its memory handling so that MMIO regions do not need to be a multiple of page size. Changing RTL8139 to use a block of size 0x1000 is a reasonable short term hack around the problem, but syncing with latest QEMU is the real solution, since there are other places in the code which will have similar issues.

Quoted 5 lines

So this explains why rtl8139.c from QEMU CVS always uses 0x100.

Thank you for the comment.

Avi, you know what you have to do ;-)

I did start on back porting the QEMU subpage handling fixes to KVM for Fedora 7, but in the end went for the simpler s/0x100/0x1000/ quick hack. I'm attaching the patch which I started against kvm-24 in case it is useful, though note that the only testing I did with it was to see if a F7 guest booted and saw distinct MAC addrs. It should apply with minor fuzz/offsets to at least kvm-35.

Regards,
Dan.

Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
qemu/cpu-all.h +1 -0
diff -rup kvm-24/qemu/cpu-all.h kvm-24.new/qemu/cpu-all.h
@@ -841,6 +841,7 @@ extern uint8_t *bios_mem;
    exception, the write memory callback gets the ram offset instead of
    the physical address */
 #define IO_MEM_ROMD        (1)
+#define IO_MEM_SUBPAGE     (2)
 
 typedef void CPUWriteMemoryFunc(void *opaque, target_phys_addr_t addr, uint32_t value);
 typedef uint32_t CPUReadMemoryFunc(void *opaque, target_phys_addr_t addr);
qemu/exec.c +222 -6

255 lines not on this page · raw message

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

#9 lore raw
In reply to a message not in the archive
Quoted 34 lines · Daniel P. Berrange
Quoted 25 lines · Laurent Vivier
Quoted 14 lines · Daniel P. Berrange
Quoted 12 lines · Laurent Vivier

Hi,

I think there is a bug in qemu RTL8139.

RTL8139 uses:

cpu_register_physical_memory(addr + 0, 0x100, s->rtl8139_mmio_io_addr);

But in the comment of cpu_register_physical_memory() we have:

"'size' must be a multiple of the target page size."

Quoted 9 lines
Quoted 2 lines

And I think 0x100 is not a multiple of target page size.... :-P

Latest upstream QEMU has fixed its memory handling so that MMIO regions do not need to be a multiple of page size. Changing RTL8139 to use a block of size 0x1000 is a reasonable short term hack around the problem, but syncing with latest QEMU is the real solution, since there are other places in the code which will have similar issues.

Quoted 6 lines

So this explains why rtl8139.c from QEMU CVS always uses 0x100.

Thank you for the comment.

Avi, you know what you have to do ;-)

Quoted 7 lines

I did start on back porting the QEMU subpage handling fixes to KVM for Fedora 7, but in the end went for the simpler s/0x100/0x1000/ quick hack. I'm attaching the patch which I started against kvm-24 in case it is useful, though note that the only testing I did with it was to see if a F7 guest booted and saw distinct MAC addrs. It should apply with minor fuzz/offsets to at least kvm-35.

Everything points to a qemu merge being sorely needed. Does anyone have any experience with recent versions?

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.