All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Lev Kujawski" <lkujaw@mailbox.org>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"John Snow" <jsnow@redhat.com>, "Thomas Huth" <thuth@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	qemu-block@nongnu.org
Subject: Re: [PULL 68/86] hw/ide/piix: Ignore writes of hardwired PCI command register bits
Date: Fri, 4 Nov 2022 12:36:31 -0400	[thread overview]
Message-ID: <20221104123545-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20221031124928.128475-69-mst@redhat.com>

On Mon, Oct 31, 2022 at 08:53:57AM -0400, Michael S. Tsirkin wrote:
> From: Lev Kujawski <lkujaw@mailbox.org>
> 
> 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 PIIX 3/4 specifications nor actual PIIX 3 hardware (a Tyan S1686D
> system) permit setting the Memory Space Enable (MSE) bit, thus the
> command register would be left in an unspecified state without this
> patch.
> 
> * hw/core/machine.c
>   Facilitate migration by not masking writes to the PIIX 3/4 PCICMD
>   register for machine states of QEMU versions prior to 7.2.
> * hw/ide/piix.c
>   a) Add a reference to the PIIX 4 data sheet.
>   b) Mask the MSE bit using the QEMU PCI device wmask field.
>   c) Define a new boolean property, x-filter-pcicmd, to control
>      whether the write mask is enabled and enable it by default
>      for both the PIIX 3 and PIIX 4 IDE controllers.
> * include/hw/ide/pci.h
>   Add the boolean filter_pcicmd field to the PCIIDEState structure,
>   because the PIIX IDE controllers do not define their own state.
> * tests/qtest/ide-test.c
>   Use the command_disabled field of the QPCIDevice testing model to
>   indicate that PCI_COMMAND_MEMORY is hardwired within PIIX 3/4 IDE
>   controllers.
> 
> Signed-off-by: Lev Kujawski <lkujaw@mailbox.org>
> Message-Id: <20221024094621.512806-3-lkujaw@mailbox.org>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>


Caused test asserts reported by Stefan. Dropped for now,
pls figure the issue out and resubmit. Thanks!
> ---
>  include/hw/ide/pci.h   |  1 +
>  hw/core/machine.c      |  2 ++
>  hw/ide/piix.c          | 24 ++++++++++++++++++++++++
>  tests/qtest/ide-test.c |  1 +
>  4 files changed, 28 insertions(+)
> 
> diff --git a/include/hw/ide/pci.h b/include/hw/ide/pci.h
> index d8384e1c42..5424b00a9e 100644
> --- a/include/hw/ide/pci.h
> +++ b/include/hw/ide/pci.h
> @@ -53,6 +53,7 @@ struct PCIIDEState {
>      MemoryRegion bmdma_bar;
>      MemoryRegion cmd_bar[2];
>      MemoryRegion data_bar[2];
> +    bool filter_pcicmd; /* used only for piix3/4 */
>  };
>  
>  static inline IDEState *bmdma_active_if(BMDMAState *bmdma)
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 907fa78ff0..65fdfe2fed 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -42,6 +42,8 @@
>  
>  GlobalProperty hw_compat_7_1[] = {
>      { "virtio-device", "queue_reset", "false" },
> +    { "piix3-ide", "x-filter-pcicmd", "false" },
> +    { "piix4-ide", "x-filter-pcicmd", "false" },
>  };
>  const size_t hw_compat_7_1_len = G_N_ELEMENTS(hw_compat_7_1);
>  
> diff --git a/hw/ide/piix.c b/hw/ide/piix.c
> index de1f4f0efb..a3af32e126 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"
> @@ -160,6 +162,21 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp)
>      uint8_t *pci_conf = dev->config;
>      int rc;
>  
> +    /*
> +     * Mask all IDE PCI command register bits except for Bus Master
> +     * Function Enable (bit 2) and I/O Space Enable (bit 0), 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 1) 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 (d->filter_pcicmd) {
> +        pci_set_word(dev->wmask + PCI_COMMAND,
> +                     PCI_COMMAND_MASTER | PCI_COMMAND_IO);
> +    }
> +
>      pci_conf[PCI_CLASS_PROG] = 0x80; // legacy ATA mode
>  
>      bmdma_setup_bar(d);
> @@ -185,6 +202,11 @@ static void pci_piix_ide_exitfn(PCIDevice *dev)
>      }
>  }
>  
> +static Property pci_piix_ide_properties[] = {
> +    DEFINE_PROP_BOOL("x-filter-pcicmd", PCIIDEState, filter_pcicmd, TRUE),
> +    DEFINE_PROP_END_OF_LIST(),
> +};
> +
>  /* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */
>  static void piix3_ide_class_init(ObjectClass *klass, void *data)
>  {
> @@ -198,6 +220,7 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data)
>      k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
>      k->class_id = PCI_CLASS_STORAGE_IDE;
>      set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
> +    device_class_set_props(dc, pci_piix_ide_properties);
>      dc->hotpluggable = false;
>  }
>  
> @@ -220,6 +243,7 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data)
>      k->device_id = PCI_DEVICE_ID_INTEL_82371AB;
>      k->class_id = PCI_CLASS_STORAGE_IDE;
>      set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
> +    device_class_set_props(dc, pci_piix_ide_properties);
>      dc->hotpluggable = false;
>  }
>  
> diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c
> index dbe1563b23..d5cec7c14c 100644
> --- a/tests/qtest/ide-test.c
> +++ b/tests/qtest/ide-test.c
> @@ -174,6 +174,7 @@ static QPCIDevice *get_pci_device(QTestState *qts, QPCIBar *bmdma_bar,
>  
>      *ide_bar = qpci_legacy_iomap(dev, IDE_BASE);
>  
> +    dev->command_disabled = PCI_COMMAND_MEMORY;
>      qpci_device_enable(dev);
>  
>      return dev;
> -- 
> MST
> 



  reply	other threads:[~2022-11-04 16:37 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31 12:50 [PULL 00/86] pci,pc,virtio: features, tests, fixes, cleanups Michael S. Tsirkin
2022-10-31 12:50 ` [PULL 01/86] bios-tables-test: do not ignore allowed diff list Michael S. Tsirkin
2022-10-31 13:25   ` Ani Sinha
2022-10-31 15:01     ` Michael S. Tsirkin
2022-10-31 12:50 ` [PULL 02/86] hw/i386/e820: remove legacy reserved entries for e820 Michael S. Tsirkin
2022-10-31 12:50 ` [PULL 03/86] tests/acpi: allow SSDT changes Michael S. Tsirkin
2022-10-31 12:50 ` [PULL 04/86] acpi/ssdt: Fix aml_or() and aml_and() in if clause Michael S. Tsirkin
2022-10-31 12:50 ` [PULL 05/86] acpi/nvdimm: define macro for NVDIMM Device _DSM Michael S. Tsirkin
2022-10-31 12:50 ` [PULL 06/86] acpi/nvdimm: Implement ACPI NVDIMM Label Methods Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 07/86] test/acpi/bios-tables-test: SSDT: update golden master binaries Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 08/86] virtio-crypto: Support asynchronous mode Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 09/86] crypto: Support DER encodings Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 10/86] crypto: Support export akcipher to pkcs8 Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 11/86] cryptodev: Add a lkcf-backend for cryptodev Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 12/86] acpi/tests/avocado/bits: initial commit of test scripts that are run by biosbits Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 13/86] acpi/tests/avocado/bits: disable acpi PSS tests that are failing in biosbits Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 14/86] acpi/tests/avocado/bits: add biosbits config file for running bios tests Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 15/86] acpi/tests/avocado/bits: add acpi and smbios avocado tests that uses biosbits Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 16/86] acpi/tests/avocado/bits/doc: add a doc file to describe the acpi bits test Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 17/86] MAINTAINERS: add myself as the maintainer for acpi biosbits avocado tests Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 18/86] hw/smbios: add core_count2 to smbios table type 4 Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 19/86] bios-tables-test: teach test to use smbios 3.0 tables Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 20/86] tests/acpi: allow changes for core_count2 test Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 21/86] bios-tables-test: add test for number of cores > 255 Michael S. Tsirkin
2022-11-01 13:52   ` Jonathan Cameron via
2022-11-01 13:55     ` Ani Sinha
2022-11-02 12:51       ` Ani Sinha
2022-11-01 14:07     ` Igor Mammedov
2022-10-31 12:51 ` [PULL 22/86] tests/acpi: update tables for new core count test Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 23/86] tests/acpi: virt: allow acpi MADT and FADT changes Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 24/86] acpi: fadt: support revision 6.0 of the ACPI specification Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 25/86] acpi: arm/virt: madt: bump to revision 4 accordingly to ACPI 6.0 Errata A Michael S. Tsirkin
2022-10-31 12:51 ` [PULL 26/86] tests/acpi: virt: update ACPI MADT and FADT binaries Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 27/86] hw/pci: PCIe Data Object Exchange emulation Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 28/86] hw/mem/cxl-type3: Add MSIX support Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 29/86] hw/cxl/cdat: CXL CDAT Data Object Exchange implementation Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 30/86] hw/mem/cxl-type3: Add CXL CDAT Data Object Exchange Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 31/86] hw/pci-bridge/cxl-upstream: Add a CDAT table access DOE Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 32/86] tests/qtest/cxl-test: Remove temporary directories after testing Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 33/86] vhost: Change the sequence of device start Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 34/86] vhost-user: Support vhost_dev_start Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 35/86] hw/virtio/virtio-iommu-pci: Enforce the device is plugged on the root bus Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 36/86] virtio: re-order vm_running and use_started checks Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 37/86] virtio: introduce __virtio_queue_reset() Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 38/86] virtio: introduce virtio_queue_reset() Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 39/86] virtio: introduce virtio_queue_enable() Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 40/86] virtio: core: vq reset feature negotation support Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 41/86] virtio-pci: support queue reset Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 42/86] virtio-pci: support queue enable Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 43/86] vhost: expose vhost_virtqueue_start() Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 44/86] vhost: expose vhost_virtqueue_stop() Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 45/86] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_reset() Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 46/86] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_restart() Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 47/86] virtio-net: introduce flush_or_purge_queued_packets() Michael S. Tsirkin
2022-10-31 12:52 ` [PULL 48/86] virtio-net: support queue reset Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 49/86] virtio-net: support queue_enable Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 50/86] vhost: vhost-kernel: enable vq reset feature Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 51/86] virtio-net: " Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 52/86] virtio-rng-pci: Allow setting nvectors, so we can use MSI-X Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 53/86] vhost-user: Fix out of order vring host notification handling Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 54/86] acpi: pc: vga: use AcpiDevAmlIf interface to build VGA device descriptors Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 55/86] tests: acpi: whitelist DSDT before generating PCI-ISA bridge AML automatically Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 56/86] acpi: pc/q35: drop ad-hoc PCI-ISA bridge AML routines and let bus ennumeration generate AML Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 57/86] tests: acpi: update expected DSDT after ISA bridge is moved directly under PCI host bridge Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 58/86] tests: acpi: whitelist DSDT before generating ICH9_SMB AML automatically Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 59/86] acpi: add get_dev_aml_func() helper Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 60/86] acpi: enumerate SMB bridge automatically along with other PCI devices Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 61/86] tests: acpi: update expected blobs Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 62/86] tests: acpi: pc/q35 whitelist DSDT before \_GPE cleanup Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 63/86] acpi: pc/35: sanitize _GPE declaration order Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 64/86] tests: acpi: update expected blobs Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 65/86] hw/acpi/erst.c: Fix memory handling issues Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 66/86] MAINTAINERS: Add qapi/virtio.json to section "virtio" Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 67/86] qpci_device_enable: Allow for command bits hardwired to 0 Michael S. Tsirkin
2022-10-31 12:53 ` [PULL 68/86] hw/ide/piix: Ignore writes of hardwired PCI command register bits Michael S. Tsirkin
2022-11-04 16:36   ` Michael S. Tsirkin [this message]
2022-10-31 12:53 ` [PULL 69/86] msix: Assert that specified vector is in range Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 70/86] hw/i386/pc.c: CXL Fixed Memory Window should not reserve e820 in bios Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 71/86] hw/i386/acpi-build: Remove unused struct Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 72/86] hw/i386/acpi-build: Resolve redundant attribute Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 73/86] hw/i386/acpi-build: Resolve north rather than south bridges Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 74/86] hmat acpi: Don't require initiator value in -numa Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 75/86] tests: acpi: add and whitelist *.hmat-noinitiator expected blobs Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 76/86] tests: acpi: q35: add test for hmat nodes without initiators Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 77/86] tests: acpi: q35: update expected blobs *.hmat-noinitiators expected HMAT: Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 78/86] tests: Add HMAT AArch64/virt empty table files Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 79/86] hw/arm/virt: Enable HMAT on arm virt machine Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 80/86] tests: acpi: aarch64/virt: add a test for hmat nodes with no initiators Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 81/86] tests: virt: Update expected *.acpihmatvirt tables Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 82/86] vfio: move implement of vfio_get_xlat_addr() to memory.c Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 83/86] intel-iommu: don't warn guest errors when getting rid2pasid entry Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 84/86] intel-iommu: drop VTDBus Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 85/86] intel-iommu: convert VTD_PE_GET_FPD_ERR() to be a function Michael S. Tsirkin
2022-10-31 12:54 ` [PULL 86/86] intel-iommu: PASID support Michael S. Tsirkin
2022-10-31 15:03 ` [PULL 00/86] pci,pc,virtio: features, tests, fixes, cleanups Michael S. Tsirkin
2022-10-31 19:14 ` Stefan Hajnoczi
2022-10-31 19:19   ` Stefan Hajnoczi
2022-10-31 19:31     ` Michael S. Tsirkin
2022-10-31 19:35       ` Michael S. Tsirkin
2022-10-31 19:41         ` Michael S. Tsirkin
2022-10-31 19:57           ` Stefan Hajnoczi
2022-10-31 19:56 ` Stefan Hajnoczi
2022-10-31 20:06 ` Stefan Hajnoczi
2022-10-31 20:12   ` Stefan Hajnoczi
2022-10-31 20:36     ` Michael S. Tsirkin
2022-10-31 20:40       ` Stefan Hajnoczi
2022-11-01 10:32   ` HMAT patches failure (was Re: [PULL 00/86] pci,pc,virtio: features, tests, fixes, cleanups) Michael S. Tsirkin
2022-11-01 15:55     ` Jonathan Cameron via
2022-11-01 17:56       ` [PATCH 1/2] tests: q35: acpi: Fixup for tables in noinitiator test Hesham Almatary via
2022-11-01 17:56         ` [PATCH 2/2] tests: acpi: Fixup for tables in Arm HMAT series Hesham Almatary via
2022-11-01 13:48   ` [PATCH] fixup! bios-tables-test: add test for number of cores > 255 Igor Mammedov
2022-11-01 13:49     ` Stefan Hajnoczi
2022-11-01 13:25 ` [PULL 00/86] pci,pc,virtio: features, tests, fixes, cleanups Igor Mammedov

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=20221104123545-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=jsnow@redhat.com \
    --cc=lkujaw@mailbox.org \
    --cc=lvivier@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=wangyanan55@huawei.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.