xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Kevin Tian <kevin.tian@intel.com>, Wei Liu <wei.liu2@citrix.com>,
	GeorgeDunlap <george.dunlap@eu.citrix.com>,
	Tim Deegan <tim@xen.org>, Xen-devel <xen-devel@lists.xen.org>,
	Jun Nakajima <jun.nakajima@intel.com>
Subject: Re: [PATCH for-4.7] xen/nested_p2m: Don't walk EPT tables with a regular PT walker
Date: Fri, 13 May 2016 09:19:20 -0600	[thread overview]
Message-ID: <57360C9802000078000EB4A8@prv-mh.provo.novell.com> (raw)
In-Reply-To: <5735EC15.8080906@citrix.com>

>>> On 13.05.16 at 17:00, <andrew.cooper3@citrix.com> wrote:
> On 13/05/16 15:13, Jan Beulich wrote:
>>>>> On 13.05.16 at 15:33, <andrew.cooper3@citrix.com> wrote:
>>> +        unsigned int l1_page_order;
>>> +        int rv;
>>>  
>>>          /* translate l2 guest va into l2 guest gfn */
>>>          p2m = p2m_get_nestedp2m(v, np2m_base);
>>>          mode = paging_get_nestedmode(v);
>>> -        gfn = mode->gva_to_gfn(v, p2m, va, pfec);
>>> +        l2_gfn = mode->gva_to_gfn(v, p2m, va, pfec);
>>> +
>>> +        if ( l2_gfn == INVALID_GFN )
>>> +            return INVALID_GFN;
>>>  
>>>          /* translate l2 guest gfn into l1 guest gfn */
>>> -        return hostmode->p2m_ga_to_gfn(v, hostp2m, np2m_base,
>>> -                                       gfn << PAGE_SHIFT, &pfec_21, NULL);
>>> +        rv = nestedhap_walk_L1_p2m(v, l2_gfn, &l1_gfn, &l1_page_order, &l1_p2ma,
>>> +                                   1,
>>> +                                   !!(*pfec & PFEC_write_access),
>>> +                                   !!(*pfec & PFEC_insn_fetch));
>>> +
>>> +        return rv == NESTEDHVM_PAGEFAULT_DONE ? l1_gfn : INVALID_GFN;
>>>      }
>> I'm really happy to see this getting cleaned up - I've stumbled across
>> the apparent brokenness here more than once, without ever finding
>> the time to help the situation. One question though: Is the return
>> value here correct even for l1_page_order > 0?
> 
> Not completely sure.  This code is messy, and my current testing is "it
> now doesn't crash where it used to crash before".
> 
> The specific path being tripped over was __hvm_copy() performing an
> instruction fetch for emulation from the L2 guest.
> 
> Looking at the code, if your caller only cares about 4K mappings, you
> will get the correct translation, due to the adjustment
> nept_walk_tables() makes.

Ah, indeed. But very odd for it to be done there, the more that "all
callers" is exactly one afaics. In that case may I suggest adding an
assertion to check that the respective bits in L1 and L2 GFN match?

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-05-13 15:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-13 13:33 [PATCH for-4.7] xen/nested_p2m: Don't walk EPT tables with a regular PT walker Andrew Cooper
2016-05-13 14:13 ` Jan Beulich
2016-05-13 15:00   ` Andrew Cooper
2016-05-13 15:19     ` Jan Beulich [this message]
2016-05-13 17:25       ` [PATCH v2 " Andrew Cooper
2016-05-17  6:06         ` Tian, Kevin
2016-05-18 13:36         ` George Dunlap
2016-05-18 13:50         ` Wei Liu
2016-05-13 15:24     ` [PATCH " Andrew Cooper
2016-05-13 15:31       ` 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=57360C9802000078000EB4A8@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.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).