From patchwork Mon May 7 12:00:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 157298 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 46B93B6FAF for ; Mon, 7 May 2012 22:01:08 +1000 (EST) Received: from localhost ([::1]:46150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRMck-0001PZ-0m for incoming@patchwork.ozlabs.org; Mon, 07 May 2012 08:01:06 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRMcd-0001PT-Ti for qemu-devel@nongnu.org; Mon, 07 May 2012 08:01:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SRMcZ-0006Lt-7N for qemu-devel@nongnu.org; Mon, 07 May 2012 08:00:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRMcY-0006Lh-Va for qemu-devel@nongnu.org; Mon, 07 May 2012 08:00:55 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q47C0rQe002019 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 7 May 2012 08:00:53 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q47C0nYZ029155; Mon, 7 May 2012 08:00:50 -0400 From: Avi Kivity To: qemu-devel@nongnu.org Date: Mon, 7 May 2012 15:00:45 +0300 Message-Id: <1336392045-31211-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Jason Wang , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH] rtl8139: fix regression in TxStatus/TxAddr read X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Commit afe0a595356192 added byte reads for TxStatus/TxAddr, but broke 32-bit reads; the mask generation (1 << (8 * size)) - 1 is unspecified in C for size >= sizeof(int), and in fact returns 0 on x86. Fix by using a larger type. Fixes (at least) Fedora 9 i386 with -machine kernel_irqchip=on. I didn't see it with the qemu APIC implementation; may be due to timing or (more likely) a tester error. Signed-off-by: Avi Kivity --- hw/rtl8139.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/rtl8139.c b/hw/rtl8139.c index 4d0f5ba..eb22d04 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -2500,7 +2500,7 @@ static uint32_t rtl8139_TxStatus_TxAddr_read(RTL8139State *s, uint32_t regs[], case 1: /* fall through */ case 2: /* fall through */ case 4: - ret = (regs[reg] >> offset * 8) & ((1 << (size * 8)) - 1); + ret = (regs[reg] >> offset * 8) & (((uint64_t)1 << (size * 8)) - 1); DPRINTF("TxStatus/TxAddr[%d] read addr=0x%x size=0x%x val=0x%08x\n", reg, addr, size, ret); break;