From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTsfh-0005am-3L for qemu-devel@nongnu.org; Thu, 01 Nov 2012 07:10:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTsfa-0007sl-MO for qemu-devel@nongnu.org; Thu, 01 Nov 2012 07:10:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9863) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTsfa-0007sY-2J for qemu-devel@nongnu.org; Thu, 01 Nov 2012 07:10:42 -0400 From: Stefan Hajnoczi Date: Thu, 1 Nov 2012 12:10:18 +0100 Message-Id: <1351768218-21466-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1351768218-21466-1-git-send-email-stefanha@redhat.com> References: <1351768218-21466-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH 4/4] e1000: pre-initialize RAH/RAL registers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Gabriel Somlo , "Gabriel L. Somlo" , qemu-devel@nongnu.org, Stefan Hajnoczi From: "Gabriel L. Somlo" 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 Signed-off-by: Stefan Hajnoczi --- 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