From: Konrad Rzeszutek Wilk <konrad@kernel.org>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
xen-devel@lists.xenproject.org, Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH v2 2/2] hvmloader, pci: Don't try to relocate memory if 64-bit BAR is bigger than ~2GB
Date: Fri, 30 Sep 2016 10:55:59 -0400 [thread overview]
Message-ID: <20160930145559.GA12985@localhost.localdomain> (raw)
In-Reply-To: <20160929104843.GQ16004@citrix.com>
On Thu, Sep 29, 2016 at 11:48:43AM +0100, Wei Liu wrote:
> On Thu, Sep 29, 2016 at 03:36:00AM -0600, Jan Beulich wrote:
> > >>> On 29.09.16 at 11:23, <konrad.wilk@oracle.com> wrote:
> > > On Thu, Sep 29, 2016 at 01:03:02AM -0600, Jan Beulich wrote:
> > >> >>> On 29.09.16 at 01:48, <konrad.wilk@oracle.com> wrote:
> > >> > @@ -265,11 +266,30 @@ void pci_setup(void)
> > >> > bars[i].devfn = devfn;
> > >> > bars[i].bar_reg = bar_reg;
> > >> > bars[i].bar_sz = bar_sz;
> > >> > + bars[i].above_4gb = false;
> > >> >
> > >> > if ( ((bar_data & PCI_BASE_ADDRESS_SPACE) ==
> > >> > PCI_BASE_ADDRESS_SPACE_MEMORY) ||
> > >> > (bar_reg == PCI_ROM_ADDRESS) )
> > >> > - mmio_total += bar_sz;
> > >> > + {
> > >> > + /*
> > >> > + * If bigger than 2GB minus emulated devices BAR space and
> > >> > + * APIC space, then don't try to put under 4GB.
> > >> > + */
> > >> > + if ( is_64bar && (mmio_total >= GB(2) || bar_sz >=
> > >> > + (GB(2) - HVM_BELOW_4G_MMIO_LENGTH - mmio_total)) )
> > >>
> > >> As mentioned in the reply to your earlier mail already, the
> > >> subtraction of mmio_total here is risking wrap through zero (the
> > >> >= GB(2) check doesn't fully guard against that).
> > >
> > > I am still waking up so bear with me, but is the reason the mmio_total
> > >>= GB(2) check does not guard is because the compiler may choose
> > > to execute _both_ parts of the '||' conditional (or swap them and
> > > execute the 'mmio_total >= GB(2)' second)?
> >
> > No, it's because you subtract more than just mmio_total from GB(2).
> >
> > >> Furthermore you're now making behavior dependent on the order
> > >> devices appear on the bus: The same device appearing early may
> > >> get its BAR placed below 4Gb whereas when it appears late, it'll
> > >> get placed high. IOW I think this needs further refinement: We
> > >> should in a first pass place only 32-bit BARs. In a second pass we
> > >> can then see which 64-bit BARs still fit (and I think we then ought
> > >> to prefer small ones). Which means we should presumably account
> > >> 32- and 64-bit BARs here independent of any other considerations,
> > >> deferring the decision which 64-bit ones to place low until after this
> > >> first pass.
> > >
> > > Ok, that is going to require some surgery and movement of code to add
> > > some functions in that giant piece of code. Expect more patches next
> > > week (or would it be easier if I just sent them out for the next release
> > > considering the amount of patches that are floating this week that need
> > > review?)
> >
> > Well, I would view this as a bug fix, so it might still be allowed in.
> > Ask Wei if in doubt.
> >
>
> Before RC1, sure. After we cut RCs, anything that changes memory layout
> of the guests need to be considered carefully.
OK. I will try my best to get it done before then. But if I fail we can
always look at this for the next release. (Along with other patches
that I need to redo).
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
prev parent reply other threads:[~2016-09-30 14:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-28 23:48 [PATCH v2] Enhancements to hvmloader for Xen 4.8 Konrad Rzeszutek Wilk
2016-09-28 23:48 ` [PATCH v2 1/2] hvmloader: Use MB(x) and GB(x) macros Konrad Rzeszutek Wilk
2016-09-29 6:44 ` Jan Beulich
2016-09-28 23:48 ` [PATCH v2 2/2] hvmloader, pci: Don't try to relocate memory if 64-bit BAR is bigger than ~2GB Konrad Rzeszutek Wilk
2016-09-29 7:03 ` Jan Beulich
2016-09-29 9:23 ` Konrad Rzeszutek Wilk
2016-09-29 9:36 ` Jan Beulich
2016-09-29 10:48 ` Wei Liu
2016-09-30 14:55 ` Konrad Rzeszutek Wilk [this message]
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=20160930145559.GA12985@localhost.localdomain \
--to=konrad@kernel.org \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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).