All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>, Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Tim Deegan <tim@xen.org>, Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Jun Nakajima <jun.nakajima@intel.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	Keir Fraser <keir@xen.org>
Subject: Re: [PATCH v5] x86/p2m: use large pages for MMIO mappings
Date: Wed, 27 Jan 2016 14:51:03 +0000	[thread overview]
Message-ID: <56A8D957.5020501@citrix.com> (raw)
In-Reply-To: <56A8E50602000078000CB9CD@prv-mh.provo.novell.com>

On 27/01/16 14:40, Jan Beulich wrote:
>
>>>>>  int set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn,
>>>>> -                       p2m_access_t access)
>>>>> +                       unsigned int order, p2m_access_t access)
>>>>>  {
>>>>> -    return set_typed_p2m_entry(d, gfn, mfn, p2m_mmio_direct, access);
>>>>> +    if ( order &&
>>>>> +         rangeset_overlaps_range(mmio_ro_ranges, mfn_x(mfn),
>>>>> +                                 mfn_x(mfn) + (1UL << order) - 1) &&
>>>>> +         !rangeset_contains_range(mmio_ro_ranges, mfn_x(mfn),
>>>>> +                                  mfn_x(mfn) + (1UL << order) - 1) )
>>>>> +        return order;
>>>> Should this not be a hard error?  Even retrying with a lower order is
>>>> going fail.
>>> Why? The latest when order == 0, rangeset_overlaps_range()
>>> will return the same as rangeset_contains_range(), and hence
>>> the condition above will always be false (one of the two reasons
>>> for checking order first here).
>> It isn't the order check which is an issue.
>>
>> One way or another, if the original (mfn/order) fails the rangeset
>> checks, the overall call is going to fail, but it will be re-executed
>> repeatedly with an order decreasing to 0.  Wouldn't it be better just to
>> short-circuit this back&forth?
> But this won't necessarily go down to order 0. Short-circuiting
> would mean taking PAGE_ORDER_2M and PAGE_ORDER_1G into
> account here, which would imo severely hamper readability.

Even when this check starts passing, the subsequent
set_typed_p2m_entry() will fail for writeable mappings, after having
constructed small pages up to the boundary of the RO region.

>
>> Relatedly, is there actually anything wrong with making a superpage
>> read-only mapping over some scattered read-only 4K pages?
> I'm afraid I don't understand: "scattered pages" and "superpage
> mapping" don't seem to fit together for me.

If there is a single 4K page in the RO region, and the caller attempts
to create a RO 2M superpage which includes the 4K region, these checks
will force the use of 4K mappings even though the 2M mapping would be fine.

~Andrew

  reply	other threads:[~2016-01-27 14:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-22 15:42 [PATCH v4] x86/p2m: use large pages for MMIO mappings Jan Beulich
2016-01-25 12:16 ` Ian Campbell
2016-01-25 13:54   ` Jan Beulich
2016-01-25 14:05     ` Ian Campbell
2016-01-25 14:16       ` Jan Beulich
2016-01-25 14:21         ` Ian Campbell
2016-01-25 16:18           ` [PATCH v5] " Jan Beulich
2016-01-25 17:18             ` Ian Campbell
2016-01-26 22:35             ` Tian, Kevin
2016-01-27 10:22               ` Jan Beulich
2016-01-27 10:28                 ` Andrew Cooper
2016-01-27 12:32             ` Andrew Cooper
2016-01-27 13:37               ` Jan Beulich
2016-01-27 14:28                 ` Andrew Cooper
2016-01-27 14:40                   ` Jan Beulich
2016-01-27 14:51                     ` Andrew Cooper [this message]
2016-01-27 15:20                       ` Jan Beulich

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=56A8D957.5020501@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=ian.campbell@citrix.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=kevin.tian@intel.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.