From: Naphtali Sprei <nsprei@redhat.com>
To: "Reimar Döffinger" <Reimar.Doeffinger@gmx.de>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Fix for commit 3f9cb1c14dc368f41447db5f78d6248c4f100ad4
Date: Mon, 31 Aug 2009 19:20:58 +0300 [thread overview]
Message-ID: <4A9BF86A.70903@redhat.com> (raw)
In-Reply-To: <20090829181755.GA8977@1und1.de>
Here's a patch to fix the issue introduced by me, as Reimar Döffinger pointed out,
Reimar Döffinger wrote:
> On Thu, Aug 13, 2009 at 03:01:20PM +0300, Naphtali Sprei wrote:
>> Bug fix for segfault when run as i82551 HW:
>> Use Extended TBD only when HW supports it (i82558 and up).
>>
>> Added assertions to guard from such buffer overflow
>> Introduce the MAX_TCB_BYTE_COUNT macro
>> Allocate buf big enough as HW needs (MAX_ETH_FRAME_SIZE -> MAX_TCB_BYTE_COUNT)
>>
>>
>> I don't feel 100% OK with the "s->device >= i82558B" condition
>> since it relies on the numeric (hex) value of those defines, which currently
>> is correct, but changes (which I don't forsee now) might break it.
>
> It seems this was applied. Unfortunately this breaks things on FreeBSD.
> There seem to be multiple issues.
> First, the intel document says the 82551, 82550, 82559 models are all
> supersets of the 82558. Or in other words: they all support this
> feature.
> Only the 82557 does not.
> But then even for that the FreeBSD driver will fail.
> The reason for that is this line:
> eeprom_contents[0xa] = 0x4000;
> the value here must be 0x01000 for all 82557 models it seems.
Correct the logic of determining devices that supports
extended TxCB: only the 82557 do not support it.
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
---
hw/eepro100.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/hw/eepro100.c b/hw/eepro100.c
index c374931..287b462 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -575,6 +575,11 @@ static uint16_t eepro100_read_command(EEPRO100State * s)
}
#endif
+static bool device_supports_eTxCB(EEPRO100State * s)
+{
+ return (s->device != i82557B && s->device != i82557C);
+}
+
/* Commands that can be put in a command list entry. */
enum commands {
CmdNOp = 0,
@@ -717,7 +722,7 @@ static void eepro100_cu_command(EEPRO100State * s, uint8_t val)
} else {
/* Flexible mode. */
uint8_t tbd_count = 0;
- if ((s->device >= i82558B) && !(s->configuration[6] & BIT(4))) {
+ if (device_supports_eTxCB(s) && !(s->configuration[6] & BIT(4))) {
/* Extended Flexible TCB. */
assert(tcb_bytes == 0);
for (; tbd_count < 2; tbd_count++) {
--
1.6.3.3
prev parent reply other threads:[~2009-08-31 16:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-13 12:01 [Qemu-devel] [PATCH] hw/eepro100.c: Use extended TBD only where applicable Naphtali Sprei
2009-08-13 13:06 ` Reimar Döffinger
2009-08-29 18:17 ` Reimar Döffinger
2009-08-29 18:50 ` Reimar Döffinger
2009-08-31 16:20 ` Naphtali Sprei [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=4A9BF86A.70903@redhat.com \
--to=nsprei@redhat.com \
--cc=Reimar.Doeffinger@gmx.de \
--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 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).