All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Julien Grall <julien@xen.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Tim Deegan <tim@xen.org>, Jan Beulich <jbeulich@suse.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [Xen-devel] [PATCH v7 1/3] x86/tlb: introduce a flush HVM ASIDs flag
Date: Fri, 20 Mar 2020 12:18:04 +0100	[thread overview]
Message-ID: <20200320111804.GW24458@Air-de-Roger.citrite.net> (raw)
In-Reply-To: <93c0f6c4-ac3b-0748-0f44-23c8d683f0c3@xen.org>

On Fri, Mar 20, 2020 at 10:36:49AM +0000, Julien Grall wrote:
> Hi,
> 
> On 20/03/2020 10:24, Roger Pau Monné wrote:
> > On Fri, Mar 20, 2020 at 10:08:33AM +0000, Julien Grall wrote:
> > > Hi,
> > > 
> > > On 20/03/2020 10:00, Roger Pau Monné wrote:
> > > > On Fri, Mar 20, 2020 at 10:42:14AM +0100, Roger Pau Monné wrote:
> > > > > On Fri, Mar 20, 2020 at 09:12:16AM +0000, Julien Grall wrote:
> > > > > > Hi Roger,
> > > > > > 
> > > > > > On 20/03/2020 09:01, Roger Pau Monné wrote:
> > > > > > > On Fri, Mar 20, 2020 at 08:21:19AM +0100, Jan Beulich wrote:
> > > > > > > > On 19.03.2020 20:07, Julien Grall wrote:
> > > > > > > > > Hi,
> > > > > > > > > 
> > > > > > > > > On 19/03/2020 18:43, Roger Pau Monné wrote:
> > > > > > > > > > On Thu, Mar 19, 2020 at 06:07:44PM +0000, Julien Grall wrote:
> > > > > > > > > > > 
> > > > > > > > > > > 
> > > > > > > > > > > On 19/03/2020 17:38, Roger Pau Monné wrote:
> > > > > > > > > > > > On Thu, Mar 19, 2020 at 04:21:23PM +0000, Julien Grall wrote:
> > > > > > > > > > > >      >> Why can't you keep flush_tlb_mask() here?
> > > > > > > > > > > > 
> > > > > > > > > > > > Because filtered_flush_tlb_mask is used in populate_physmap, and
> > > > > > > > > > > > changes to the phymap require an ASID flush on AMD hardware.
> > > > > > > > > > > 
> > > > > > > > > > > I am afraid this does not yet explain me why flush_tlb_mask() could not be
> > > > > > > > > > > updated so it flush the ASID on AMD hardware.
> > > > > > > > > > 
> > > > > > > > > > Current behavior previous to this patch is to flush the ASIDs on
> > > > > > > > > > every TLB flush.
> > > > > > > > > > 
> > > > > > > > > > flush_tlb_mask is too widely used on x86 in places where there's no
> > > > > > > > > > need to flush the ASIDs. This prevents using assisted flushes (by L0)
> > > > > > > > > > when running nested, since those assisted flushes performed by L0
> > > > > > > > > > don't flush the L2 guests TLBs.
> > > > > > > > > > 
> > > > > > > > > > I could keep current behavior and leave flush_tlb_mask also flushing the
> > > > > > > > > > ASIDs, but that seems wrong as the function doesn't have anything in
> > > > > > > > > > it's name that suggests it also flushes the in-guest TLBs for HVM.
> > > > > > > > > 
> > > > > > > > > I agree the name is confusing, I had to look at the implementation to understand what it does.
> > > > > > > > > 
> > > > > > > > > How about renaming (or introducing) the function to flush_tlb_all_guests_mask() or flush_tlb_all_guests_cpumask()) ?
> > > > > > > > 
> > > > > > > > And this would then flush _only_ guest TLBs?
> > > > > > > 
> > > > > > > No, I think from Julien's proposal (if I understood it correctly)
> > > > > > > flush_tlb_all_guests_mask would do what flush_tlb_mask currently does
> > > > > > > previous to this patch (flush Xen's TLBs + HVM ASIDs).
> > > > > > 
> > > > > > It looks like there might be confusion on what "guest TLBs" means. In my
> > > > > > view this means any TLBs associated directly or indirectly with the guest.
> > > > > > On Arm, this would be nuke:
> > > > > >      - guest virtual address -> guest physical address TLB entry
> > > > > >      - guest physical address -> host physical address TLB entry
> > > > > >      - guest virtual address -> host physical address TLB entry
> > > > > 
> > > > > AFAICT ASID flush on AMD hardware will flush any of the above, while
> > > > > VPID flush on Intel will only flush the first item (guest linear to
> > > > 
> > > > Sorry, doing too many things at the same time. On Intel VPID flushes
> > > > will get rid of guest virtual to guest physical or host physical, but
> > > > not of guest physical to host physical, you need an EPT flush to
> > > > accomplish that.
> > > Are you suggesting that on x86, flush_tlb_mask() would not nuke the guest
> > > physical to host physical entries? If so, how is it meant to be safe?
> > 
> > You issue EPT flushes in that case when an EPT modification is
> > performed.
> 
> I am getting more and more confused with the goal of flush_tlb_mask() in
> common code.
> 
> Looking at the Arm code, the P2M code should already flush appropriatly the
> guest TLBs before giving back a page to the allocator.
> 
> So what are we trying to protect against with the call of flush_tlb_mask()?

So on x86 there are two completely different nested page table
technologies, NPT from AMD and EPT from Intel. EPT doesn't require a
VPID flush when modifying the nested page tables (it requires an EPT
flush), OTOH AMD NPT requires an ASID flush when modifying the tables,
and this seems to be implemented in common code for populate_physmap.

On x86 populate_physmap could also get rid of the flush, since the NPT
code already performs an ASID flush when modifying a nested page table
entry, but that's part of another patch.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2020-03-20 11:18 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19 15:47 [Xen-devel] [PATCH v7 0/3] x86/guest: use assisted TLB flush in guest mode Roger Pau Monne
2020-03-19 15:47 ` [Xen-devel] [PATCH v7 1/3] x86/tlb: introduce a flush HVM ASIDs flag Roger Pau Monne
2020-03-19 16:21   ` Julien Grall
2020-03-19 17:38     ` Roger Pau Monné
2020-03-19 18:07       ` Julien Grall
2020-03-19 18:43         ` Roger Pau Monné
2020-03-19 19:07           ` Julien Grall
2020-03-20  7:21             ` Jan Beulich
2020-03-20  9:01               ` Roger Pau Monné
2020-03-20  9:12                 ` Julien Grall
2020-03-20  9:42                   ` Roger Pau Monné
2020-03-20 10:00                     ` Roger Pau Monné
2020-03-20 10:08                       ` Julien Grall
2020-03-20 10:24                         ` Roger Pau Monné
2020-03-20 10:36                           ` Julien Grall
2020-03-20 11:18                             ` Roger Pau Monné [this message]
2020-03-20 13:19                   ` Jan Beulich
2020-03-20 14:17                     ` Julien Grall
2020-03-20 14:56                       ` Jan Beulich
2020-03-20 13:16                 ` Jan Beulich
2020-03-20 14:22                   ` Roger Pau Monné
2020-03-20 14:27                     ` Julien Grall
2020-03-20 14:43                       ` Julien Grall
2020-03-20 14:52                         ` Roger Pau Monné
2020-03-20 14:49                       ` Roger Pau Monné
2020-03-20 14:59                         ` Jan Beulich
2020-03-20 15:05                           ` Roger Pau Monné
2020-03-19 15:47 ` [Xen-devel] [PATCH v7 2/3] x86/tlb: allow disabling the TLB clock Roger Pau Monne
2020-03-19 15:47 ` [Xen-devel] [PATCH v7 3/3] x86/tlb: use Xen L0 assisted TLB flush when available Roger Pau Monne

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=20200320111804.GW24458@Air-de-Roger.citrite.net \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wl@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 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.