From: Razvan Cojocaru <rcojocaru@bitdefender.com>
To: Jan Beulich <JBeulich@suse.com>,
aisaila@bitdefender.com,
xen-devel <xen-devel@lists.xenproject.org>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH v1] Fix p2m_set_suppress_ve
Date: Wed, 3 Apr 2019 18:17:03 +0300 [thread overview]
Message-ID: <aa35ec83-77d2-ffc3-c82a-96c666f97227@bitdefender.com> (raw)
In-Reply-To: <5CA4C9F9020000780022450F@prv1-mh.provo.novell.com>
On 4/3/19 5:58 PM, Jan Beulich wrote:
>>>> On 03.04.19 at 16:29, <aisaila@bitdefender.com> wrote:
>> --- a/xen/arch/x86/mm/p2m.c
>> +++ b/xen/arch/x86/mm/p2m.c
>> @@ -3011,8 +3011,16 @@ int p2m_set_suppress_ve(struct domain *d, gfn_t gfn, bool suppress_ve,
>> mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL, NULL);
>> if ( !mfn_valid(mfn) )
>> {
>> - rc = -ESRCH;
>> - goto out;
>> + unsigned int page_order;
>> +
>> + mfn = __get_gfn_type_access(host_p2m, gfn_x(gfn), &t, &a,
>> + P2M_ALLOC | P2M_UNSHARE, &page_order, 0);
>
> I'm not entirely certain about P2M_ALLOC, but I'm pretty sure that
> at least P2M_UNSHARE is too heavy: Why would you want to force
> un-sharing of a page when all you want to alter is #VE behavior?
That logic was taken from p2m_set_altp2m_mem_access(), we thought the
two cases are very similar.
269 mfn = ap2m->get_entry(ap2m, gfn, &t, &old_a, 0, NULL, NULL);
270
271 /* Check host p2m if no valid entry in alternate */
272 if ( !mfn_valid(mfn) )
273 {
274
275 mfn = __get_gfn_type_access(hp2m, gfn_l, &t, &old_a,
276 P2M_ALLOC | P2M_UNSHARE,
&page_order, 0);
277
278 rc = -ESRCH;
279 if ( !mfn_valid(mfn) || t != p2m_ram_rw )
280 return rc;
281
282 /* If this is a superpage, copy that first */
283 if ( page_order != PAGE_ORDER_4K )
284 {
285 unsigned long mask = ~((1UL << page_order) - 1);
286 gfn_t gfn2 = _gfn(gfn_l & mask);
287 mfn_t mfn2 = _mfn(mfn_x(mfn) & mask);
288
289 rc = ap2m->set_entry(ap2m, gfn2, mfn2, page_order, t,
old_a, 1);
290 if ( rc )
291 return rc;
292 }
293 }
294
295 /*
296 * Inherit the old suppress #VE bit value if it is already set,
or set it
297 * to 1 otherwise
298 */
299 return ap2m->set_entry(ap2m, gfn, mfn, PAGE_ORDER_4K, t, a, -1);
300 }
I wonder if we should put the whole logic in the "if ( !mfn_valid(mfn)
)" body in its own function and reuse that for both functions - although
it doesn't look like the extra superpage logic matters for setting the
suppress #VE bit alone (since even the code above only sets it with
PAGE_ORDER_4K).
> Additionally, when you add such a lookup as error handling attempt,
> I think it is important to leave a code comment. But I wonder
> whether this shouldn't be done before the call to ->get_entry(), or
> whether in fact there's a bug here in how get_entry() behaves in
> this case.
Changes to the hostp2m (also known as altp2m view 0) propagate to all
existing altp2ms, but they do so in a lazy manner, and also that won't
happen for altp2ms created after a while. So altp2ms will not
necessarily know about a page that the hostp2m knows about, which should
not stop us from setting mem access restrictions or the value of the SVE
bit.
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-04-03 15:17 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-03 14:29 [PATCH v1] Fix p2m_set_suppress_ve Alexandru Stefan ISAILA
2019-04-03 14:58 ` Jan Beulich
2019-04-03 15:17 ` Razvan Cojocaru [this message]
2019-04-03 15:30 ` Jan Beulich
2019-04-03 15:48 ` Razvan Cojocaru
2019-04-03 16:04 ` Jan Beulich
2019-04-03 16:16 ` Tamas K Lengyel
2019-04-03 17:07 ` Razvan Cojocaru
2019-04-03 17:12 ` Tamas K Lengyel
2019-04-04 10:16 ` Jan Beulich
2019-04-03 17:41 ` Razvan Cojocaru
2019-04-04 10:47 ` Jan Beulich
2019-04-04 12:46 ` Razvan Cojocaru
2019-04-04 12:49 ` Andrew Cooper
2019-04-04 13:15 ` Tamas K Lengyel
2019-04-04 12:50 ` Razvan Cojocaru
2019-04-04 13:09 ` Tamas K Lengyel
2019-04-04 14:36 ` Jan Beulich
2019-04-04 14:43 ` Tamas K Lengyel
2019-04-04 14:51 ` Jan Beulich
2019-04-04 15:06 ` Tamas K Lengyel
2019-04-04 14:54 ` George Dunlap
2019-04-05 7:36 ` Jan Beulich
2019-04-05 7:36 ` [Xen-devel] " Jan Beulich
2019-04-05 13:59 ` Tamas K Lengyel
2019-04-05 13:59 ` [Xen-devel] " Tamas K Lengyel
2019-04-04 14:32 ` 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=aa35ec83-77d2-ffc3-c82a-96c666f97227@bitdefender.com \
--to=rcojocaru@bitdefender.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=aisaila@bitdefender.com \
--cc=andrew.cooper3@citrix.com \
--cc=roger.pau@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 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.