xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Elena Ufimtseva <elena.ufimtseva@oracle.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: kevin.tian@intel.com, wei.liu2@citrix.com,
	george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
	tim@xen.org, xen-devel@lists.xen.org, yang.z.zhang@intel.com,
	tiejun.chen@intel.com
Subject: Re: [PATCH v12 3/3] iommu: add rmrr Xen command line option for extra rmrrs
Date: Fri, 6 Nov 2015 12:25:21 -0500	[thread overview]
Message-ID: <20151106172521.GA12570@elena.ufimtseva> (raw)
In-Reply-To: <563C978502000078000B26A7@prv-mh.provo.novell.com>

On Fri, Nov 06, 2015 at 04:05:25AM -0700, Jan Beulich wrote:
> >>> On 06.11.15 at 05:22, <elena.ufimtseva@oracle.com> wrote:
> > On Wed, Oct 28, 2015 at 10:05:31AM -0600, Jan Beulich wrote:
> >> >>> On 27.10.15 at 21:36, <elena.ufimtseva@oracle.com> wrote:
> >> > +static void __init add_extra_rmrr(void)
> >> > +{
> >> > +    struct acpi_rmrr_unit *acpi_rmrr;
> >> > +    struct acpi_rmrr_unit *rmrru;
> >> > +    unsigned int dev, seg, i;
> >> > +    unsigned long pfn;
> >> > +    bool_t overlap;
> >> > +
> >> > +    for ( i = 0; i < nr_rmrr; i++ )
> >> > +    {
> >> > +        if ( extra_rmrr_units[i].base_pfn > extra_rmrr_units[i].end_pfn )
> >> > +        {
> >> > +            printk(XENLOG_ERR VTDPREFIX
> >> > +                   "Invalid RMRR Range "ERMRRU_FMT"\n",
> >> > +                   ERMRRU_ARG(extra_rmrr_units[i]));
> >> > +            continue;
> >> > +        }
> >> > +
> >> > +        if ( extra_rmrr_units[i].end_pfn - extra_rmrr_units[i].base_pfn >=
> >> > +             MAX_EXTRA_RMRR_PAGES )
> >> > +        {
> >> > +            printk(XENLOG_ERR VTDPREFIX
> >> > +                   "RMRR range "ERMRRU_FMT" exceeds "__stringify(MAX_EXTRA_RMRR_PAGES)" pages\n",
> >> > +                   ERMRRU_ARG(extra_rmrr_units[i]));
> >> > +            continue;
> >> > +        }
> >> > +
> >> > +        overlap = 0;
> >> > +        list_for_each_entry(rmrru, &acpi_rmrr_units, list)
> >> > +        {
> >> > +            if ( pfn_to_paddr(extra_rmrr_units[i].base_pfn) < rmrru->end_address &&
> >> > +                 rmrru->base_address < pfn_to_paddr(extra_rmrr_units[i].end_pfn + 1) )
> >> 
> >> Aren't both ranges inclusive? I.e. shouldn't the first one be <= (and
> >> the second one could be <= too when dropping the +1), matching
> >> the check acpi_parse_one_rmrr() does?
> > 
> > The end_address is not inclusive, while the start_address is.
> > These to from  rmrr_identity_mapping()
> >     ...
> >     ASSERT(rmrr->base_address < rmrr->end_address);                             
> 
> These are byte-granular addresses.
> 
> > and:
> >     ...
> >     while ( base_pfn < end_pfn )
> >     {
> >         int err = set_identity_p2m_entry(d, base_pfn, p2m_access_rw, flag);
> >                                                                              
> >    
> >         if ( err )                                                           
> >    
> >             return err;                                                      
> >    
> >         base_pfn++;                                                          
> >    
> >     }
> >     ...
> > 
> > I think this condition should not be a problem. But yes, its not uniform 
> > with acpi_parse_one_rmrr.
> 
> Did you actually pay attention to how end_pfn gets calculated?
> 
> > I guess I should send another version then?
> 
> Yes of course.

Ok, I see your point.
> 
> >> > +        }
> >> > +        if ( seg != PCI_SEG(extra_rmrr_units[i].sbdf[0]) )
> >> > +        {
> >> > +            printk(XENLOG_ERR VTDPREFIX
> >> > +                   "Segments are not equal for RMRR range "ERMRRU_FMT"\n",
> >> > +                   ERMRRU_ARG(extra_rmrr_units[i]));
> >> > +            scope_devices_free(&acpi_rmrr->scope);
> >> > +            xfree(acpi_rmrr);
> >> > +            continue;
> >> > +        }
> >> > +
> >> > +        acpi_rmrr->segment = seg;
> >> > +        acpi_rmrr->base_address = 
> > pfn_to_paddr(extra_rmrr_units[i].base_pfn);
> >> > +        acpi_rmrr->end_address = pfn_to_paddr(extra_rmrr_units[i].end_pfn + 
> > 1);
> >> 
> >> And this seems wrong too, unless I'm mistaken with the inclusive-ness.
> >>
> > The end_address is exclusive, see above.

> No - see above.

You are right, I actually meant to say end_pfn for extra rmrr in not inclusive.
And this case is only valid when base_pfn == end_pfn as the parser does
not take care of the case where there is only one pfn specified. The
assumption in this case is that user meant [base_pfn, base_pfn + 1].
I think it will be safe to add the condition when incrementing.


> 
> Jan
> 

  reply	other threads:[~2015-11-06 17:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-27 20:36 [PATCH v12 0/3] iommu: add rmrr Xen command line option elena.ufimtseva
2015-10-27 20:36 ` [PATCH v12 1/3] iommu VT-d: separate rmrr addition function elena.ufimtseva
2015-10-29  8:09   ` Tian, Kevin
2015-10-27 20:36 ` [PATCH v12 2/3] pci: add wrapper for parse_pci elena.ufimtseva
2015-10-29  8:09   ` Tian, Kevin
2015-10-27 20:36 ` [PATCH v12 3/3] iommu: add rmrr Xen command line option for extra rmrrs elena.ufimtseva
2015-10-28 16:05   ` Jan Beulich
2015-11-06  4:22     ` Elena Ufimtseva
2015-11-06 11:05       ` Jan Beulich
2015-11-06 17:25         ` Elena Ufimtseva [this message]
2015-10-29  8:08   ` Tian, Kevin

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=20151106172521.GA12570@elena.ufimtseva \
    --to=elena.ufimtseva@oracle.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=kevin.tian@intel.com \
    --cc=tiejun.chen@intel.com \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    --cc=yang.z.zhang@intel.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).