qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Feng Wu <feng.wu@intel.com>
To: stefano.stabellini@eu.citrix.com
Cc: xen-devel@lists.xensource.com, Feng Wu <feng.wu@intel.com>,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v1] xenpt: Properly handle 64-bit bar with more than 4G size
Date: Wed,  5 Aug 2015 10:02:21 +0800	[thread overview]
Message-ID: <1438740141-19905-1-git-send-email-feng.wu@intel.com> (raw)

This patch corrects a logic error when handling 64-bt bar with
more than 4G size.

With 64-bit Bar, it has two items in PCIDevice: io_regions[x]
and io_regions[x+1], io_regions[x] has all the informations for
this BAR, while io_regions[x+1] contains nothing, so we need to
get the size from io_regions[x] when handling XEN_PT_BAR_FLAG_UPPER.

Signed-off-by: Feng Wu <feng.wu@intel.com>
---
I cannot test this patch sicne I don't have such a device, if
someone have it, it would be highly appreicated if he can help
to verfiy this patch.

 hw/xen/xen_pt_config_init.c |   22 +++-------------------
 1 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index dd37be3..6fcef66 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -326,23 +326,6 @@ static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
 #define XEN_PT_BAR_IO_RO_MASK     0x00000003  /* BAR ReadOnly mask(I/O) */
 #define XEN_PT_BAR_IO_EMU_MASK    0xFFFFFFFC  /* BAR emul mask(I/O) */
 
-static bool is_64bit_bar(PCIIORegion *r)
-{
-    return !!(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64);
-}
-
-static uint64_t xen_pt_get_bar_size(PCIIORegion *r)
-{
-    if (is_64bit_bar(r)) {
-        uint64_t size64;
-        size64 = (r + 1)->size;
-        size64 <<= 32;
-        size64 += r->size;
-        return size64;
-    }
-    return r->size;
-}
-
 static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s,
                                          int index)
 {
@@ -365,7 +348,7 @@ static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s,
 
     /* check unused BAR */
     r = &d->io_regions[index];
-    if (!xen_pt_get_bar_size(r)) {
+    if (r->size == 0) {
         return XEN_PT_BAR_FLAG_UNUSED;
     }
 
@@ -491,8 +474,9 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
         bar_ro_mask = XEN_PT_BAR_IO_RO_MASK | (r_size - 1);
         break;
     case XEN_PT_BAR_FLAG_UPPER:
+        r = &d->io_regions[index-1];
         bar_emu_mask = XEN_PT_BAR_ALLF;
-        bar_ro_mask = r_size ? r_size - 1 : 0;
+        bar_ro_mask = (r->size - 1) >> 32;
         break;
     default:
         break;
-- 
1.7.1

             reply	other threads:[~2015-08-05  2:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-05  2:02 Feng Wu [this message]
2015-08-06 10:43 ` [Qemu-devel] [PATCH v1] xenpt: Properly handle 64-bit bar with more than 4G size Stefano Stabellini
2015-08-06 13:27   ` Wu, Feng
2015-08-12  6:58 ` [Qemu-devel] [Xen-devel] " Jan Beulich
2015-08-12  7:10   ` Wu, Feng
2015-08-12  8:43     ` Jan Beulich
2015-08-12  8:53       ` Wu, Feng
2015-08-12 14:29         ` Konrad Rzeszutek Wilk

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=1438740141-19905-1-git-send-email-feng.wu@intel.com \
    --to=feng.wu@intel.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.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).