* [Qemu-devel] [PATCH] e1000: pre-initialize RAH/RAL registers @ 2012-10-30 17:20 Gabriel L. Somlo 2012-10-31 8:03 ` Stefan Hajnoczi 0 siblings, 1 reply; 4+ messages in thread From: Gabriel L. Somlo @ 2012-10-30 17:20 UTC (permalink / raw) To: qemu-devel; +Cc: qemu-trivial, rene, somlo, agraf Some guest operating systems' drivers (Mac OS X in particular) fail to properly initialize the Receive Address registers (probably expecting them to be pre-initialized by an earlier component, such as a proprietary BIOS). This patch pre-initializes the RA registers, allowing OS X networking to function properly. Other guest operating systems are not affected, and free to (re)initialize these registers during boot. Signed-off-by: Gabriel Somlo <somlo@cmu.edu> --- hw/e1000.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index e4f1ffe..6478ff3 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -278,6 +278,10 @@ static void e1000_reset(void *opaque) if (d->nic->nc.link_down) { e1000_link_down(d); } + + /* Some guests expect pre-initialized RAH/RAL (AddrValid flag + MACaddr) */ + d->mac_reg[RA+1] = E1000_RAH_AV; + memmove(&d->mac_reg[RA], &d->conf.macaddr, sizeof(struct MACAddr)); } static void -- 1.7.7.6 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] e1000: pre-initialize RAH/RAL registers 2012-10-30 17:20 [Qemu-devel] [PATCH] e1000: pre-initialize RAH/RAL registers Gabriel L. Somlo @ 2012-10-31 8:03 ` Stefan Hajnoczi 2012-10-31 18:15 ` [Qemu-devel] [PATCH v2] " Gabriel L. Somlo 0 siblings, 1 reply; 4+ messages in thread From: Stefan Hajnoczi @ 2012-10-31 8:03 UTC (permalink / raw) To: Gabriel L. Somlo; +Cc: qemu-trivial, rene, somlo, qemu-devel, agraf On Tue, Oct 30, 2012 at 01:20:40PM -0400, Gabriel L. Somlo wrote: > Some guest operating systems' drivers (Mac OS X in particular) fail to > properly initialize the Receive Address registers (probably expecting > them to be pre-initialized by an earlier component, such as a proprietary > BIOS). This patch pre-initializes the RA registers, allowing OS X > networking to function properly. Other guest operating systems are not > affected, and free to (re)initialize these registers during boot. > > Signed-off-by: Gabriel Somlo <somlo@cmu.edu> > --- > hw/e1000.c | 4 ++++ > 1 files changed, 4 insertions(+), 0 deletions(-) > > diff --git a/hw/e1000.c b/hw/e1000.c > index e4f1ffe..6478ff3 100644 > --- a/hw/e1000.c > +++ b/hw/e1000.c > @@ -278,6 +278,10 @@ static void e1000_reset(void *opaque) > if (d->nic->nc.link_down) { > e1000_link_down(d); > } > + > + /* Some guests expect pre-initialized RAH/RAL (AddrValid flag + MACaddr) */ > + d->mac_reg[RA+1] = E1000_RAH_AV; Please use 4 space indentation (QEMU coding style). > + memmove(&d->mac_reg[RA], &d->conf.macaddr, sizeof(struct MACAddr)); When the host is big-endian the filter code will byteswap and the MAC address will not match: for (rp = s->mac_reg + RA; rp < s->mac_reg + RA + 32; rp += 2) { if (!(rp[1] & E1000_RAH_AV)) continue; ra[0] = cpu_to_le32(rp[0]); ra[1] = cpu_to_le32(rp[1]); if (!memcmp(buf, (uint8_t *)ra, 6)) { Stefan ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH v2] e1000: pre-initialize RAH/RAL registers 2012-10-31 8:03 ` Stefan Hajnoczi @ 2012-10-31 18:15 ` Gabriel L. Somlo 2012-11-01 12:28 ` Stefan Hajnoczi 0 siblings, 1 reply; 4+ messages in thread From: Gabriel L. Somlo @ 2012-10-31 18:15 UTC (permalink / raw) To: Stefan Hajnoczi; +Cc: qemu-trivial, rene, somlo, qemu-devel, agraf Some guest operating systems' drivers (Mac OS X in particular) fail to properly initialize the Receive Address registers (probably expecting them to be pre-initialized by an earlier component, such as a specific proprietary BIOS). This patch pre-initializes the RA registers, allowing OS X networking to function properly. Other guest operating systems are not affected, and free to (re)initialize these registers during boot. Signed-off-by: Gabriel Somlo <somlo@cmu.edu> --- On Wed, Oct 31, 2012 at 09:03:51AM +0100, Stefan Hajnoczi wrote: > Please use 4 space indentation (QEMU coding style). My bad, fixed in this version. > > + memmove(&d->mac_reg[RA], &d->conf.macaddr, sizeof(struct MACAddr)); > > When the host is big-endian the filter code will byteswap and the MAC address > will not match: > > for (rp = s->mac_reg + RA; rp < s->mac_reg + RA + 32; rp += 2) { > if (!(rp[1] & E1000_RAH_AV)) > continue; > ra[0] = cpu_to_le32(rp[0]); > ra[1] = cpu_to_le32(rp[1]); > if (!memcmp(buf, (uint8_t *)ra, 6)) { OK, I guess I could just memmove from d->eeprom_data instead of d->conf.macaddr.a, on the assumption that pci_e1000_init() already did the endian-proofing for me. But probably the safest/most paranoid method is best, see below... Thanks, Gabriel hw/e1000.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index e4f1ffe..a29b844 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -266,6 +266,8 @@ rxbufsize(uint32_t v) static void e1000_reset(void *opaque) { E1000State *d = opaque; + uint8_t *macaddr = d->conf.macaddr.a; + int i; qemu_del_timer(d->autoneg_timer); memset(d->phy_reg, 0, sizeof d->phy_reg); @@ -278,6 +280,14 @@ static void e1000_reset(void *opaque) if (d->nic->nc.link_down) { e1000_link_down(d); } + + /* Some guests expect pre-initialized RAH/RAL (AddrValid flag + MACaddr) */ + d->mac_reg[RA] = 0; + d->mac_reg[RA+1] = E1000_RAH_AV; + for (i = 0; i < 4; i++) { + d->mac_reg[RA] |= macaddr[i]<<(8*i); + d->mac_reg[RA+1] |= (i < 2) ? macaddr[i+4]<<(8*i) : 0; + } } static void -- 1.7.7.6 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] e1000: pre-initialize RAH/RAL registers 2012-10-31 18:15 ` [Qemu-devel] [PATCH v2] " Gabriel L. Somlo @ 2012-11-01 12:28 ` Stefan Hajnoczi 0 siblings, 0 replies; 4+ messages in thread From: Stefan Hajnoczi @ 2012-11-01 12:28 UTC (permalink / raw) To: Gabriel L. Somlo; +Cc: qemu-trivial, rene, somlo, qemu-devel, agraf On Wed, Oct 31, 2012 at 02:15:39PM -0400, Gabriel L. Somlo wrote: > Some guest operating systems' drivers (Mac OS X in particular) fail to > properly initialize the Receive Address registers (probably expecting > them to be pre-initialized by an earlier component, such as a specific > proprietary BIOS). This patch pre-initializes the RA registers, allowing > OS X networking to function properly. Other guest operating systems are > not affected, and free to (re)initialize these registers during boot. > > Signed-off-by: Gabriel Somlo <somlo@cmu.edu> > --- > > On Wed, Oct 31, 2012 at 09:03:51AM +0100, Stefan Hajnoczi wrote: > > Please use 4 space indentation (QEMU coding style). > > My bad, fixed in this version. > > > > + memmove(&d->mac_reg[RA], &d->conf.macaddr, sizeof(struct MACAddr)); > > > > When the host is big-endian the filter code will byteswap and the MAC address > > will not match: > > > > for (rp = s->mac_reg + RA; rp < s->mac_reg + RA + 32; rp += 2) { > > if (!(rp[1] & E1000_RAH_AV)) > > continue; > > ra[0] = cpu_to_le32(rp[0]); > > ra[1] = cpu_to_le32(rp[1]); > > if (!memcmp(buf, (uint8_t *)ra, 6)) { > > OK, I guess I could just memmove from d->eeprom_data instead of > d->conf.macaddr.a, on the assumption that pci_e1000_init() already > did the endian-proofing for me. But probably the safest/most paranoid > method is best, see below... > > Thanks, > Gabriel > > hw/e1000.c | 10 ++++++++++ > 1 files changed, 10 insertions(+), 0 deletions(-) Although real hardware doesn't behave like this we can probably get away with it. I will test Linux and Windows guests with e1000 for the QEMU 1.3 release - if we run into problems this patch may be reverted. Thanks, applied to the net tree: https://github.com/stefanha/qemu/commits/net Stefan ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-01 12:28 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-10-30 17:20 [Qemu-devel] [PATCH] e1000: pre-initialize RAH/RAL registers Gabriel L. Somlo 2012-10-31 8:03 ` Stefan Hajnoczi 2012-10-31 18:15 ` [Qemu-devel] [PATCH v2] " Gabriel L. Somlo 2012-11-01 12:28 ` Stefan Hajnoczi
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).