From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Lev Kujawski" <lkujaw@member.fsf.org>,
qemu-trival@nongnu.org, "John Snow" <jsnow@redhat.com>,
"open list:IDE" <qemu-block@nongnu.org>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Bernhard Beschow" <shentey@gmail.com>,
"open list:All patches CC here" <qemu-devel@nongnu.org>
Subject: Re: [PATCH 4/4] hw/ide/piix: Ignore writes of hardwired PCI command register bits
Date: Mon, 30 May 2022 14:11:02 -0400 [thread overview]
Message-ID: <20220530140956-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <d80d1bbe-982c-90d8-4a54-ebab6dd36e4a@amsat.org>
On Mon, May 30, 2022 at 03:33:18PM +0200, Philippe Mathieu-Daudé wrote:
> On 28/5/22 22:47, Lev Kujawski wrote:
> > One method to enable PCI bus mastering for IDE controllers, often used
> > by x86 firmware, is to write 0x7 to the PCI command register. Neither
> > the PIIX3 specification nor actual hardware (a Tyan S1686D system)
> > permit modification of the Memory Space Enable (MSE) bit, 1, and thus
> > the command register would be left in an unspecified state without
> > this patch.
> >
> > Signed-off-by: Lev Kujawski <lkujaw@member.fsf.org>
> > ---
> > hw/ide/piix.c | 25 +++++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> >
> > diff --git a/hw/ide/piix.c b/hw/ide/piix.c
> > index 76ea8fd9f6..f1d1168ecd 100644
> > --- a/hw/ide/piix.c
> > +++ b/hw/ide/piix.c
> > @@ -25,6 +25,8 @@
> > * References:
> > * [1] 82371FB (PIIX) AND 82371SB (PIIX3) PCI ISA IDE XCELERATOR,
> > * 290550-002, Intel Corporation, April 1997.
> > + * [2] 82371AB PCI-TO-ISA / IDE XCELERATOR (PIIX4), 290562-001,
> > + * Intel Corporation, April 1997.
> > */
> > #include "qemu/osdep.h"
> > @@ -32,6 +34,7 @@
> > #include "migration/vmstate.h"
> > #include "qapi/error.h"
> > #include "qemu/module.h"
> > +#include "qemu/range.h"
> > #include "sysemu/block-backend.h"
> > #include "sysemu/blockdev.h"
> > #include "sysemu/dma.h"
> > @@ -220,6 +223,26 @@ static void pci_piix_ide_exitfn(PCIDevice *dev)
> > }
> > }
> > +static void piix_pci_config_write(PCIDevice *d, uint32_t addr,
> > + uint32_t val, int l)
> > +{
> > + /*
> > + * Mask all IDE PCI command register bits except for Bus Master
> > + * Function Enable (bit 2) and I/O Space Enable (bit 1), as the
> > + * remainder are hardwired to 0 [1, p.48] [2, p.89-90].
> > + *
> > + * NOTE: According to the PIIX3 datasheet [1], the Memory Space
> > + * Enable (MSE bit) is hardwired to 1, but this is contradicted by
> > + * actual PIIX3 hardware, the datasheet itself (viz., Default
> > + * Value: 0000h), and the PIIX4 datasheet [2].
> > + */
> > + if (range_covers_byte(addr, l, PCI_COMMAND)) {
> > + val &= ~(0xfffa << ((PCI_COMMAND - addr) << 3));
>
> Watch out, len can be 1/2/4.
If there are bits hardwired to 0 the right way to do it is
by clearing a bit in wmask. Might need machine compat machinery
for this.
> > + }
> > +
> > + pci_default_write_config(d, addr, val, l);
> > +}
> > +
> > /* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */
> > static void piix3_ide_class_init(ObjectClass *klass, void *data)
> > {
> > @@ -232,6 +255,7 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data)
> > k->vendor_id = PCI_VENDOR_ID_INTEL;
> > k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
> > k->class_id = PCI_CLASS_STORAGE_IDE;
> > + k->config_write = piix_pci_config_write;
> > set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
> > dc->hotpluggable = false;
> > }
> > @@ -260,6 +284,7 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data)
> > k->vendor_id = PCI_VENDOR_ID_INTEL;
> > k->device_id = PCI_DEVICE_ID_INTEL_82371AB;
> > k->class_id = PCI_CLASS_STORAGE_IDE;
> > + k->config_write = piix_pci_config_write;
> > set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
> > dc->hotpluggable = false;
> > }
next prev parent reply other threads:[~2022-05-30 18:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-28 20:46 [PATCH 1/4] hw/ide/atapi.c: Correct typos (CD-CDROM -> CD-ROM) Lev Kujawski
2022-05-28 20:47 ` [PATCH 2/4] hw/ide/core: Clear LBA and drive bits for EXECUTE DEVICE DIAGNOSTIC Lev Kujawski
2022-05-28 20:47 ` [PATCH 3/4] piix_ide_reset: Use pci_set_* functions instead of direct access Lev Kujawski
2022-05-30 13:24 ` Philippe Mathieu-Daudé via
2022-05-28 20:47 ` [PATCH 4/4] hw/ide/piix: Ignore writes of hardwired PCI command register bits Lev Kujawski
2022-05-30 13:33 ` Philippe Mathieu-Daudé via
2022-05-30 18:11 ` Michael S. Tsirkin [this message]
2022-05-30 13:26 ` [PATCH 1/4] hw/ide/atapi.c: Correct typos (CD-CDROM -> CD-ROM) Philippe Mathieu-Daudé via
-- strict thread matches above, loose matches on Subject: below --
2022-05-28 21:02 Lev Kujawski
2022-05-28 21:02 ` [PATCH 4/4] hw/ide/piix: Ignore writes of hardwired PCI command register bits Lev Kujawski
2022-06-28 10:01 ` Laurent Vivier
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=20220530140956-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=f4bug@amsat.org \
--cc=hpoussin@reactos.org \
--cc=jsnow@redhat.com \
--cc=lkujaw@member.fsf.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trival@nongnu.org \
--cc=shentey@gmail.com \
/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.