qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: arei.gonglei@huawei.com
Cc: ChenLiang <chenliang88@huawei.com>,
	weidong.huang@huawei.com, qemu-devel@nongnu.org,
	qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] pci: do not pci_update_mappings when guest gets bar size
Date: Tue, 14 Oct 2014 14:20:34 +0300	[thread overview]
Message-ID: <20141014112034.GA9470@redhat.com> (raw)
In-Reply-To: <1413284654-13420-1-git-send-email-arei.gonglei@huawei.com>

On Tue, Oct 14, 2014 at 07:04:14PM +0800, arei.gonglei@huawei.com wrote:
> From: ChenLiang <chenliang88@huawei.com>
> 
> Power-up software can determine how much address space the device
> requires by writing a value of all 1's to the register and then
> reading the value back(PCI specification). Qemu should not do
> pci_update_mappings. Qemu may exit, because the wrong address of
> this bar is overlap with other memslots.
> 
> Signed-off-by: ChenLiang <chenliang88@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>

This is at best a work-around.
Overlapping is observed in practice, qemu really shouldn't exit when
this happens.
So we should find the root cause and fix it there instead of
adding work-arounds in PCI core.

With which device do you observe this?


> ---
>  hw/pci/pci.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 6ce75aa..4d44b44 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -1158,12 +1158,12 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val_in, int
>          d->config[addr + i] = (d->config[addr + i] & ~wmask) | (val & wmask);
>          d->config[addr + i] &= ~(val & w1cmask); /* W1C: Write 1 to Clear */
>      }
> -    if (ranges_overlap(addr, l, PCI_BASE_ADDRESS_0, 24) ||
> +    if (((ranges_overlap(addr, l, PCI_BASE_ADDRESS_0, 24) ||
>          ranges_overlap(addr, l, PCI_ROM_ADDRESS, 4) ||
> -        ranges_overlap(addr, l, PCI_ROM_ADDRESS1, 4) ||
> -        range_covers_byte(addr, l, PCI_COMMAND))
> +        ranges_overlap(addr, l, PCI_ROM_ADDRESS1, 4)) &&
> +        val_in != 0xffffffff) || range_covers_byte(addr, l, PCI_COMMAND)) {
>          pci_update_mappings(d);
> -
> +    }
>      if (range_covers_byte(addr, l, PCI_COMMAND)) {
>          pci_update_irq_disabled(d, was_irq_disabled);
>          memory_region_set_enabled(&d->bus_master_enable_region,
> -- 
> 1.7.12.4
> 

  reply	other threads:[~2014-10-14 11:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-14 11:04 [Qemu-devel] [PATCH] pci: do not pci_update_mappings when guest gets bar size arei.gonglei
2014-10-14 11:20 ` Michael S. Tsirkin [this message]
2014-10-14 11:41   ` ChenLiang
2014-10-14 11:48     ` Michael S. Tsirkin
2014-10-14 12:15       ` ChenLiang
2014-10-14 12:23         ` Gonglei
2014-10-14 12:31           ` Michael S. Tsirkin
2014-10-14 12:27         ` Michael S. Tsirkin
2014-10-14 12:59           ` ChenLiang
2014-10-14 14:31             ` Michael S. Tsirkin
2014-10-14 11:58     ` Michael S. Tsirkin
2014-10-14 12:19       ` ChenLiang
2014-10-14 12:19       ` ChenLiang
2014-10-14 12:28         ` Michael S. Tsirkin
2014-10-14 12:27           ` ChenLiang
2014-10-14 14:21             ` Michael S. Tsirkin

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=20141014112034.GA9470@redhat.com \
    --to=mst@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=chenliang88@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=weidong.huang@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 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).