From: George Dunlap <george.dunlap@eu.citrix.com>
To: xen-devel@lists.xen.org
Cc: Keir Fraser <keir@xen.org>,
Ian Campbell <ian.campbell@citrix.com>,
Hanweidong <hanweidong@huawei.com>,
George Dunlap <george.dunlap@eu.citrix.com>,
Stefano Stabellini <stefano.stabellini@citrix.com>,
Ian Jackson <ian.jackson@citrix.com>
Subject: [PATCH v4 5/8] hvmloader: Correct bug in low mmio region accounting
Date: Fri, 21 Jun 2013 11:46:31 +0100 [thread overview]
Message-ID: <1371811594-31135-6-git-send-email-george.dunlap@eu.citrix.com> (raw)
In-Reply-To: <1371811594-31135-1-git-send-email-george.dunlap@eu.citrix.com>
When deciding whether to map a device in low MMIO space (<4GiB),
hvmloader compares it with "mmio_left", which is set to the size of
the low MMIO range (pci_mem_end - pci_mem_start). However, even if it
does map a device in high MMIO space, it still removes the size of its
BAR from mmio_left.
In reality we don't need to do a separate accounting of the low memory
available -- this can be calculated from mem_resource. Just get rid
of the variable and the duplicate accounting entirely. This will make
the code more robust.
v3:
- Use mem_resource values directly instead of doing duplicate
accounting
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: Ian Jackson <ian.jackson@citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Stefano Stabellini <stefano.stabellini@citrix.com>
CC: Hanweidong <hanweidong@huawei.com>
CC: Keir Fraser <keir@xen.org>
---
tools/firmware/hvmloader/pci.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/tools/firmware/hvmloader/pci.c b/tools/firmware/hvmloader/pci.c
index 6792ed4..80eef76 100644
--- a/tools/firmware/hvmloader/pci.c
+++ b/tools/firmware/hvmloader/pci.c
@@ -42,7 +42,6 @@ void pci_setup(void)
uint32_t vga_devfn = 256;
uint16_t class, vendor_id, device_id;
unsigned int bar, pin, link, isa_irq;
- int64_t mmio_left;
/* Resources assignable to PCI devices via BARs. */
struct resource {
@@ -264,8 +263,6 @@ void pci_setup(void)
io_resource.base = 0xc000;
io_resource.max = 0x10000;
- mmio_left = pci_mem_end - pci_mem_start;
-
/* Assign iomem and ioport resources in descending order of size. */
for ( i = 0; i < nr_bars; i++ )
{
@@ -273,7 +270,8 @@ void pci_setup(void)
bar_reg = bars[i].bar_reg;
bar_sz = bars[i].bar_sz;
- using_64bar = bars[i].is_64bar && bar64_relocate && (mmio_left < bar_sz);
+ using_64bar = bars[i].is_64bar && bar64_relocate
+ && (bar_sz > (mem_resource.max - mem_resource.base));
bar_data = pci_readl(devfn, bar_reg);
if ( (bar_data & PCI_BASE_ADDRESS_SPACE) ==
@@ -295,7 +293,6 @@ void pci_setup(void)
resource = &mem_resource;
bar_data &= ~PCI_BASE_ADDRESS_MEM_MASK;
}
- mmio_left -= bar_sz;
}
else
{
--
1.7.9.5
next prev parent reply other threads:[~2013-06-21 10:46 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-21 10:46 [PATCH 0/8] Relocate devices rather than memory for qemu-xen George Dunlap
2013-06-21 10:46 ` [PATCH v4 1/8] hvmloader: Remove all 64-bit print arguments George Dunlap
2013-06-21 10:48 ` Ian Jackson
2013-06-21 11:20 ` Keir Fraser
2013-06-21 10:55 ` Stefano Stabellini
2013-06-21 10:46 ` [PATCH v4 2/8] hvmloader: Make the printfs more informative George Dunlap
2013-06-21 10:49 ` Ian Jackson
2013-06-21 10:57 ` Stefano Stabellini
2013-06-21 10:46 ` [PATCH v4 3/8] hvmloader: Set up highmem resouce appropriately if there is no RAM above 4G George Dunlap
2013-06-21 10:50 ` Ian Jackson
2013-06-21 11:11 ` Stefano Stabellini
2013-06-21 10:46 ` [PATCH v4 4/8] hvmloader: Fix check for needing a 64-bit bar George Dunlap
2013-06-21 10:51 ` Ian Jackson
2013-06-21 10:46 ` George Dunlap [this message]
2013-06-21 11:19 ` [PATCH v4 5/8] hvmloader: Correct bug in low mmio region accounting Ian Jackson
2013-06-21 12:58 ` Jan Beulich
2013-06-21 13:32 ` Ian Jackson
2013-06-21 13:40 ` George Dunlap
2013-06-21 10:46 ` [PATCH v4 6/8] hvmloader: Load large devices into high MMIO space as needed George Dunlap
2013-06-21 11:21 ` Ian Jackson
2013-06-21 10:46 ` [PATCH v4 7/8] hvmloader: Remove minimum size for BARs to relocate to 64-bit space George Dunlap
2013-06-21 11:22 ` Ian Jackson
2013-06-21 10:46 ` [PATCH v4 8/8] libxl, hvmloader: Don't relocate memory for MMIO hole George Dunlap
2013-06-21 11:15 ` Stefano Stabellini
2013-06-21 11:25 ` Ian Jackson
2013-06-26 10:08 ` Hao, Xudong
2013-06-26 13:36 ` Stefano Stabellini
2013-06-26 14:23 ` Hao, Xudong
2013-06-26 16:21 ` Stefano Stabellini
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=1371811594-31135-6-git-send-email-george.dunlap@eu.citrix.com \
--to=george.dunlap@eu.citrix.com \
--cc=hanweidong@huawei.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@citrix.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@citrix.com \
--cc=xen-devel@lists.xen.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).