From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "Aravindh Puthiyaparambil (aravindp)" <aravindp@cisco.com>,
Jan Beulich <JBeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Keir Fraser <keir@xen.org>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>, Tim Deegan <tim@xen.org>
Subject: Re: [PATCH RFC v2 1/4] x86/mm: Shadow and p2m changes for PV mem_access
Date: Fri, 22 Aug 2014 21:02:11 +0100 [thread overview]
Message-ID: <53F7A1C3.3060007@citrix.com> (raw)
In-Reply-To: <97A500D504438F4ABC02EBA81613CC63318E057E@xmb-aln-x02.cisco.com>
On 22/08/14 20:48, Aravindh Puthiyaparambil (aravindp) wrote:
>>>> As Andrew already pointed out, you absolutely need to deal with page
>>>> crossing accesses,
>>> Is this for say an unsigned long that lives across two pages? Off the top of
>> my head, I think always allowing writes to the page in question and the next
>> followed by reverting to default for both pages at the end of the write should
>> take care of this. I would have to walk the page tables to figure out the next
>> mfn. Or am I on the wrong track here?
>>
>> create_bounce_frame puts several adjacent words on a guest stack, and this
>> is very capable of crossing a page boundary.
>>
>> Even an unaligned uint16_t can cross a page boundary.
> OK, so marking two adjacent pages as writable and reverting after the write went through should solve this problem.
>
>>>> and I think you also need to deal with hypervisor accesses extending
>>>> beyond a page worth of memory (I'm not sure we have a firmly
>>>> determined upper bound of how much memory we may copy in one go).
>>> Let me try to understand what happens in the non-mem_access case. Say
>> the hypervisor is writing to three pages and all of them are not accessible in
>> the guest. Which one of the following is true?
>>> 1. There is a pagefault for the first page which is resolved. The write is then
>> retried which causes a fault for the second page which is resolved. Then the
>> write is retried starting from the second page and so on for the third page too.
>>> 2. Or does the write get retried starting from the first page each time the
>> page fault is resolved?
>>
>> For the non-mem_access case, all faults cause failures.
>>
>> copy_to/from_user() will typically result in an -EFAULT being handed back to
>> the hypercaller. For create_bounce_frame, the results are more severe and
>> might result in a domain crash or an injection of a failsafe callback.
>>
>> No attempt is made to play with the page permissions, as it is the guests fault
>> that the pages have the wrong permissions.
>>
>> What mem_access introduces is a case where it is Xen's fault that a write fault
>> occured, and the fault should be worked around as the guest is unaware that
>> its pages are actually read-only.
> Ouch, this does make things complicated. The only thing I can think of trying is your suggestion "Alternatively, locate the page in question and use map_domain_page() to get a supervisor rw mapping.". Do this only in __copy_to_user_ll() for copies that span multiple pages in the cases where a mem_access listener is present and listening for write violations.
>
> Sigh, if only I could bound the CR0.WP solution :-(
I wonder whether, in the case that mem_access is enabled, it would be
reasonable to perform the CR0.WP sections with interrupts disabled?
The user/admin is already taking a performance hit from mem_access in
the first place, and delaying hardware interrupts a little almost
certainly a lesser evil than whatever mad scheme we devise to fix these
issues.
With interrupts disabled, the CR0.WP problem is very well bounded. The
only faults which will occur will be as a direct result of the actions
performed, where the fault handlers will follow the extable redirection
and return quickly.
~Andrew
next prev parent reply other threads:[~2014-08-22 20:02 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-08 2:50 [PATCH RFC v2 0/4] Add mem_access support for PV domains Aravindh Puthiyaparambil
2014-07-08 2:50 ` [PATCH RFC v2 1/4] x86/mm: Shadow and p2m changes for PV mem_access Aravindh Puthiyaparambil
2014-07-24 14:29 ` Jan Beulich
2014-07-24 23:34 ` Aravindh Puthiyaparambil (aravindp)
2014-07-25 7:19 ` Jan Beulich
2014-07-25 21:39 ` Aravindh Puthiyaparambil (aravindp)
2014-07-28 6:49 ` Jan Beulich
2014-07-28 21:14 ` Aravindh Puthiyaparambil (aravindp)
2014-07-30 4:05 ` Aravindh Puthiyaparambil (aravindp)
2014-07-30 7:11 ` Jan Beulich
2014-07-30 18:35 ` Aravindh Puthiyaparambil (aravindp)
2014-08-01 6:39 ` Jan Beulich
2014-08-01 18:08 ` Aravindh Puthiyaparambil (aravindp)
2014-08-04 7:03 ` Jan Beulich
2014-08-05 0:14 ` Aravindh Puthiyaparambil (aravindp)
2014-08-05 6:33 ` Jan Beulich
2014-08-13 22:14 ` Aravindh Puthiyaparambil (aravindp)
2014-08-22 2:29 ` Aravindh Puthiyaparambil (aravindp)
2014-08-22 9:34 ` Andrew Cooper
2014-08-22 10:02 ` Jan Beulich
2014-08-22 10:14 ` Andrew Cooper
2014-08-22 18:28 ` Aravindh Puthiyaparambil (aravindp)
2014-08-22 18:52 ` Andrew Cooper
2014-08-25 12:45 ` Gianluca Guida
2014-08-25 13:01 ` Jan Beulich
2014-08-25 13:02 ` Andrew Cooper
2014-08-25 13:59 ` Gianluca Guida
2014-08-22 15:33 ` Jan Beulich
2014-08-22 19:07 ` Aravindh Puthiyaparambil (aravindp)
2014-08-22 19:24 ` Andrew Cooper
2014-08-22 19:48 ` Aravindh Puthiyaparambil (aravindp)
2014-08-22 20:02 ` Andrew Cooper [this message]
2014-08-22 20:13 ` Aravindh Puthiyaparambil (aravindp)
2014-08-25 7:34 ` Jan Beulich
2014-08-25 7:33 ` Jan Beulich
2014-08-25 12:49 ` Andrew Cooper
2014-08-25 13:09 ` Jan Beulich
2014-08-25 16:56 ` Aravindh Puthiyaparambil (aravindp)
2014-08-26 7:08 ` Jan Beulich
2014-08-26 22:27 ` Aravindh Puthiyaparambil (aravindp)
2014-08-26 23:30 ` Andrew Cooper
2014-08-28 9:34 ` Tim Deegan
2014-08-28 18:33 ` Aravindh Puthiyaparambil (aravindp)
2014-08-27 6:33 ` Jan Beulich
2014-08-27 7:49 ` Tim Deegan
2014-08-27 17:29 ` Aravindh Puthiyaparambil (aravindp)
2014-08-25 17:44 ` Andrew Cooper
2014-08-26 7:12 ` Jan Beulich
2014-08-25 7:29 ` Jan Beulich
2014-08-25 16:40 ` Aravindh Puthiyaparambil (aravindp)
2014-08-28 9:14 ` Tim Deegan
2014-08-28 18:31 ` Aravindh Puthiyaparambil (aravindp)
2014-08-28 19:00 ` Tim Deegan
2014-08-28 19:23 ` Aravindh Puthiyaparambil (aravindp)
2014-08-28 20:37 ` Tim Deegan
2014-08-28 21:35 ` Aravindh Puthiyaparambil (aravindp)
2014-08-28 22:20 ` Aravindh Puthiyaparambil (aravindp)
2014-08-29 9:52 ` Tim Deegan
2014-08-29 17:52 ` Aravindh Puthiyaparambil (aravindp)
2014-08-29 19:03 ` Aravindh Puthiyaparambil (aravindp)
2014-09-01 10:38 ` Jan Beulich
2014-09-02 21:57 ` Aravindh Puthiyaparambil (aravindp)
2014-09-03 8:31 ` Jan Beulich
2014-09-03 18:50 ` Aravindh Puthiyaparambil (aravindp)
2014-09-04 6:39 ` Jan Beulich
2014-09-04 18:24 ` Aravindh Puthiyaparambil (aravindp)
2014-09-05 8:11 ` Jan Beulich
2014-09-05 22:49 ` Aravindh Puthiyaparambil (aravindp)
[not found] ` <20140904083906.GA86555@deinos.phlegethon.org>
[not found] ` <540849430200007800030C47@mail.emea.novell.com>
2014-09-11 19:40 ` Aravindh Puthiyaparambil (aravindp)
2014-09-12 7:21 ` Jan Beulich
2014-09-12 18:01 ` Aravindh Puthiyaparambil (aravindp)
2014-08-28 9:09 ` Tim Deegan
2014-08-28 18:23 ` Aravindh Puthiyaparambil (aravindp)
2014-07-08 2:50 ` [PATCH RFC v2 2/4] x86/mem_access: mem_access and mem_event changes to support PV domains Aravindh Puthiyaparambil
2014-07-24 14:38 ` Jan Beulich
2014-07-24 23:52 ` Aravindh Puthiyaparambil (aravindp)
2014-07-25 7:23 ` Jan Beulich
2014-07-25 21:47 ` Aravindh Puthiyaparambil (aravindp)
2014-07-28 6:56 ` Jan Beulich
2014-07-28 21:16 ` Aravindh Puthiyaparambil (aravindp)
2014-07-08 2:50 ` [PATCH RFC v2 3/4] tools/libxc: Add APIs for PV mem_access Aravindh Puthiyaparambil
2014-07-08 2:50 ` [PATCH RFC v2 4/4] tool/xen-access: Add support for PV domains Aravindh Puthiyaparambil
2014-07-08 16:27 ` [PATCH RFC v2 0/4] Add mem_access " Konrad Rzeszutek Wilk
2014-07-08 17:57 ` Aravindh Puthiyaparambil (aravindp)
2014-07-09 0:31 ` Aravindh Puthiyaparambil (aravindp)
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=53F7A1C3.3060007@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=aravindp@cisco.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=keir@xen.org \
--cc=tim@xen.org \
--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).