From: "Michael S. Tsirkin" <mst@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] rtl8139: fix regression in TxStatus/TxAddr read
Date: Mon, 7 May 2012 16:10:29 +0300 [thread overview]
Message-ID: <20120507131028.GA20357@redhat.com> (raw)
In-Reply-To: <1336392045-31211-1-git-send-email-avi@redhat.com>
On Mon, May 07, 2012 at 03:00:45PM +0300, Avi Kivity wrote:
> 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 <avi@redhat.com>
Applied, thanks
> ---
> 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;
> --
> 1.7.10.1
prev parent reply other threads:[~2012-05-07 13:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-07 12:00 [Qemu-devel] [PATCH] rtl8139: fix regression in TxStatus/TxAddr read Avi Kivity
2012-05-07 13:10 ` Michael S. Tsirkin [this message]
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=20120507131028.GA20357@redhat.com \
--to=mst@redhat.com \
--cc=avi@redhat.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.