From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ1vd-0001Kk-Lt for qemu-devel@nongnu.org; Mon, 14 Nov 2011 14:10:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RQ1vc-0000ZD-Ad for qemu-devel@nongnu.org; Mon, 14 Nov 2011 14:10:49 -0500 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:38978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ1vc-0000QL-2l for qemu-devel@nongnu.org; Mon, 14 Nov 2011 14:10:48 -0500 Message-ID: <4EC16782.304@weilnetz.de> Date: Mon, 14 Nov 2011 20:09:54 +0100 From: Stefan Weil MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------090206000004060501040307" Subject: [Qemu-devel] Fwd: [PATCH 1.0] eepro100: Fix alignment requirement for statistical counters List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: QEMU Developers This is a multi-part message in MIME format. --------------090206000004060501040307 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Sorry, I just noticed that I sent this patch to the wrong list address. It's a patch for QEMU 1.0, so I hope it's not too late for 1.0-rc2. Regards, Stefan Weil -------- Original-Nachricht -------- Betreff: [PATCH] eepro100: Fix alignment requirement for statistical counters Datum: Sat, 5 Nov 2011 12:50:30 +0100 Von: Stefan Weil An: qemu-devel@non-gnu.org CC: Michael S. Tsirkin , Stefan Weil According to Intel's Open Source Software Developer Manual, the dump counters address must be Dword aligned. The new code enforces this alignment, so s->statsaddr may now be used with stw_le_pci_dma() and stl_le_pci_dma(). Signed-off-by: Stefan Weil --- hw/eepro100.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/hw/eepro100.c b/hw/eepro100.c index 7d59e71..29ec5b4 100644 --- a/hw/eepro100.c +++ b/hw/eepro100.c @@ -976,7 +976,15 @@ static void eepro100_cu_command(EEPRO100State * s, uint8_t val) case CU_STATSADDR: /* Load dump counters address. */ s->statsaddr = e100_read_reg4(s, SCBPointer); - TRACE(OTHER, logout("val=0x%02x (status address)\n", val)); + TRACE(OTHER, logout("val=0x%02x (dump counters address)\n", val)); + if (s->statsaddr& 3) { + /* Memory must be Dword aligned. */ + logout("unaligned dump counters address\n"); + /* Handling of misaligned addresses is undefined. + * Here we align the address by ignoring the lower bits. */ + /* TODO: Test unaligned dump counter address on real hardware. */ + s->statsaddr&= ~3; + } break; case CU_SHOWSTATS: /* Dump statistical counters. */ -- 1.7.0.4 --------------090206000004060501040307 Content-Type: text/html; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Sorry, I just noticed that I sent this patch to the wrong list address.
It's a patch for QEMU 1.0, so I hope it's not too late for 1.0-rc2.

Regards,
Stefan Weil



-------- Original-Nachricht --------
Betreff: [PATCH] eepro100: Fix alignment requirement for statistical counters
Datum: Sat, 5 Nov 2011 12:50:30 +0100
Von: Stefan Weil <sw@weilnetz.de>
An: qemu-devel@non-gnu.org
CC: Michael S. Tsirkin <mst@redhat.com>, Stefan Weil <sw@weilnetz.de>


According to Intel's Open Source Software Developer Manual,
the dump counters address must be Dword aligned.

The new code enforces this alignment, so s->statsaddr may now
be used with stw_le_pci_dma() and stl_le_pci_dma().

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/eepro100.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 7d59e71..29ec5b4 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -976,7 +976,15 @@ static void eepro100_cu_command(EEPRO100State * s, uint8_t val)
     case CU_STATSADDR:
         /* Load dump counters address. */
         s->statsaddr = e100_read_reg4(s, SCBPointer);
-        TRACE(OTHER, logout("val=0x%02x (status address)\n", val));
+        TRACE(OTHER, logout("val=0x%02x (dump counters address)\n", val));
+        if (s->statsaddr & 3) {
+            /* Memory must be Dword aligned. */
+            logout("unaligned dump counters address\n");
+            /* Handling of misaligned addresses is undefined.
+             * Here we align the address by ignoring the lower bits. */
+            /* TODO: Test unaligned dump counter address on real hardware. */
+            s->statsaddr &= ~3;
+        }
         break;
     case CU_SHOWSTATS:
         /* Dump statistical counters. */
-- 
1.7.0.4

--------------090206000004060501040307--