All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	xen-devel@lists.xenproject.org, Tim Deegan <tim@xen.org>,
	Wei Liu <wl@xen.org>, Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [Xen-devel] [PATCH v5 4/7] x86/tlb: introduce a flush guests TLB flag
Date: Fri, 28 Feb 2020 17:50:48 +0100	[thread overview]
Message-ID: <20200228165048.GE24458@Air-de-Roger.citrite.net> (raw)
In-Reply-To: <cdb97977-2bae-5067-623d-76409fa643a2@suse.com>

On Fri, Feb 28, 2020 at 05:14:05PM +0100, Jan Beulich wrote:
> On 19.02.2020 18:43, Roger Pau Monne wrote:
> > Introduce a specific flag to request a HVM guest TLB flush, which is
> > an ASID/VPID tickle that forces a linear TLB flush for all HVM guests.
> 
> Here and below, what do you mean by "linear"? I guess you mean
> TLBs holding translations from guest linear to guest physical,
> but I think this could do with then also saying so, even if it's
> more words.

Yes, will change.

> > This was previously unconditionally done in each pre_flush call, but
> > that's not required: HVM guests not using shadow don't require linear
> > TLB flushes as Xen doesn't modify the guest page tables in that case
> > (ie: when using HAP).
> 
> This explains the correctness in one direction. What about the
> removal of this from the switch_cr3_cr4() path?

AFAICT that's never used by shadow code to modify cr3 or cr4, and
hence doesn't require a guest linear TLB flush.

> And what about
> our safety assumptions from the ticking of tlbflush_clock,
> where we then imply that pages e.g. about to be freed can't
> have any translations left in any TLBs anymore?

I'm slightly confused. That flush only affects HVM guests linear TLB,
and hence is not under Xen control unless shadow mode is used. Pages
to be freed in the HAP case need to be flushed from the EPT/NPT, but
whether there are references left in the guest TLB to point to that
gfn really doesn't matter to Xen at all, since the guest is in full
control of it's MMU and TLB in that case.

For shadow any change in the guest page-tables should already be
accompanied by a guest TLB flush, or else the guest could access no
longer present entries, regardless of whether the affected pages are
freed or not.

> > --- a/xen/include/asm-x86/flushtlb.h
> > +++ b/xen/include/asm-x86/flushtlb.h
> > @@ -105,6 +105,8 @@ void switch_cr3_cr4(unsigned long cr3, unsigned long cr4);
> >  #define FLUSH_VCPU_STATE 0x1000
> >   /* Flush the per-cpu root page table */
> >  #define FLUSH_ROOT_PGTBL 0x2000
> > + /* Flush all HVM guests linear TLB (using ASID/VPID) */
> > +#define FLUSH_GUESTS_TLB 0x4000
> 
> For one, the "all" is pretty misleading. A single such request
> doesn't do this for all vCPU-s of all HVM guests, does it?

It kind of does because it tickles the pCPU ASID/VPID generation ID,
so any vCPU scheduled on the selected pCPUs will get a new ASID/VPID
allocated and thus a clean TLB.

> I'm
> also struggling with the 'S' in "GUESTS" - why is it not just
> "GUEST"? 

Any guest vCPUs running on the selected pCPUs will get a new ASID/VPID
ID and thus a clean TLB.

> I admit the names of the involved functions
> (hvm_flush_guest_tlbs(), hvm_asid_flush_core()) are somewhat
> misleading, as they don't actually do any flushing, they merely
> arrange for what is in the TLB to no longer be able to be used,
> so giving this a suitable name is "historically" complicated.
> What if we did away with the hvm_flush_guest_tlbs() wrapper,
> naming the constant here then after hvm_asid_flush_core(), e.g.
> FLUSH_ASID_CORE?

I'm not opposed to renaming. The comment before the definition was
also meant to clarify it's usage, and hence the explicit mention of
ASID/VPID.

> I also think this constant might better be zero when !HVM.

Yes, that's a good idea.

Thanks, Roger.

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

  reply	other threads:[~2020-02-28 16:51 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19 17:43 [Xen-devel] [PATCH v5 0/7] x86: improve assisted tlb flush and use it in guest mode Roger Pau Monne
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 1/7] x86/hvm: allow ASID flush when v != current Roger Pau Monne
2020-02-28 13:29   ` Jan Beulich
2020-02-28 15:27     ` Roger Pau Monné
2020-02-28 15:47       ` Jan Beulich
2020-02-28 16:20         ` Roger Pau Monné
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 2/7] x86/paging: add TLB flush hooks Roger Pau Monne
2020-02-28 14:50   ` Jan Beulich
2020-02-28 16:19     ` Roger Pau Monné
2020-02-28 16:40       ` Jan Beulich
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 3/7] x86/hap: improve hypervisor assisted guest TLB flush Roger Pau Monne
2020-02-28 13:58   ` Jan Beulich
2020-02-28 16:31     ` Roger Pau Monné
2020-02-28 16:44       ` Jan Beulich
2020-02-28 16:57         ` Roger Pau Monné
2020-02-28 17:02           ` Jan Beulich
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 4/7] x86/tlb: introduce a flush guests TLB flag Roger Pau Monne
2020-02-28 16:14   ` Jan Beulich
2020-02-28 16:50     ` Roger Pau Monné [this message]
2020-03-02 10:31       ` Jan Beulich
2020-03-02 16:50         ` Roger Pau Monné
2020-03-03  8:50           ` Jan Beulich
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 5/7] x86/tlb: allow disabling the TLB clock Roger Pau Monne
2020-02-28 16:25   ` Jan Beulich
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 6/7] xen/guest: prepare hypervisor ops to use alternative calls Roger Pau Monne
2020-02-28 16:29   ` Jan Beulich
2020-02-28 16:52     ` Roger Pau Monné
2020-03-02 10:43       ` Jan Beulich
2020-03-02 11:48         ` Roger Pau Monné
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 7/7] x86/tlb: use Xen L0 assisted TLB flush when available Roger Pau Monne
2020-02-28 17:00   ` Jan Beulich
2020-02-28 17:23     ` Roger Pau Monné
2020-03-02 10:52       ` 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=20200228165048.GE24458@Air-de-Roger.citrite.net \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --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.