qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Gabriel Somlo <somlo@cmu.edu>,
	"Gabriel L. Somlo" <gsomlo@gmail.com>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 4/4] e1000: pre-initialize RAH/RAL registers
Date: Thu,  1 Nov 2012 12:10:18 +0100	[thread overview]
Message-ID: <1351768218-21466-5-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1351768218-21466-1-git-send-email-stefanha@redhat.com>

From: "Gabriel L. Somlo" <gsomlo@gmail.com>

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.

[According to the datasheet the Address Valid bits in the RA registers
are cleared on PCI or software reset.  This patch adds the NIC's MAC
address and sets Address Valid on reset.  So we diverge from real
hardware behavior here. -- Stefan]

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/e1000.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/e1000.c b/hw/e1000.c
index ec32f59..cb7e7e8 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -265,6 +265,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);
@@ -277,6 +279,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.12.1

  parent reply	other threads:[~2012-11-01 11:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-01 11:10 [Qemu-devel] [PULL 1.3 0/4] Net patches Stefan Hajnoczi
2012-11-01 11:10 ` [Qemu-devel] [PATCH 1/4] e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty Stefan Hajnoczi
2012-11-01 11:10 ` [Qemu-devel] [PATCH 2/4] net: use "socket" model name for UDP sockets Stefan Hajnoczi
2012-11-01 11:10 ` [Qemu-devel] [PATCH 3/4] net: Reject non-netdevs in qmp_netdev_del() Stefan Hajnoczi
2012-11-01 11:10 ` Stefan Hajnoczi [this message]
2012-11-01 19:33 ` [Qemu-devel] [PULL 1.3 0/4] Net patches Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351768218-21466-5-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=gsomlo@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=somlo@cmu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).