From: Dave Hansen <dave.hansen@intel.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: Nadav Amit <namit@vmware.com>,
Peter Zijlstra <peterz@infradead.org>,
Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
"x86@kernel.org" <x86@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Dave Hansen <dave.hansen@linux.intel.com>
Subject: Re: [RFC PATCH v2 11/12] x86/mm/tlb: Use async and inline messages for flushing
Date: Fri, 31 May 2019 14:06:11 -0700 [thread overview]
Message-ID: <90a891a2-6be4-bfa2-5de1-5e36d1bc0b48@intel.com> (raw)
In-Reply-To: <CALCETrVf9dh4GxEXsHbP65x6YuzOBf+7HWqOgBBjUma+7nB6Nw@mail.gmail.com>
On 5/31/19 1:37 PM, Andy Lutomirski wrote:
>> Modulo bugs^Werrata... No. What actually happens is that a
>> try-to-set-dirty-bit page table walk acts just like a TLB miss. The old
>> contents of the TLB are discarded and only the in-memory contents matter
>> for forward progress. If Present=0 when the PTE is reached, you'll get
>> a normal Present=0 page fault.
> Wait, does that mean that you can do a lock cmpxchg or similar to
> clear the dirty and writable bits together and, if the dirty bit was
> clear, skip the TLB flush?
Yeah, in the case that you're going from R/W->R/O, you can be assured
that no writable TLB entries were established if D=0.
Is it totally safe against other things? Hell if I know. :)
I'd want to go look very closely at software things like GUP-for-write
before we went and actually did this. But I can't think of any hardware
reasons off the top of my head why it wouldn't work.
A quick perusal of the SDM didn't have any slam dunks do support doing
this. It's a bit cagey about exactly what can be cached and when. The
supporting reasoning might have escaped my quick scan, though.
> If so, nifty! Modulo errata, of course. And I seem to remember some
> exceptions relating to CET shadow stack involving the dirty bit being
> set on not-present pages.
Yeah: "no processor that supports CET will ever set the dirty flag in a
paging-structure entry in which the R/W flag is 0"
> https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf
Which probably means that the things we were saying above are
technically only architectural on CET-enabled processors. I think the
behavior is actually much more widespread than that, though.
next prev parent reply other threads:[~2019-05-31 21:06 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-31 6:36 [RFC PATCH v2 00/12] x86: Flush remote TLBs concurrently and async Nadav Amit
2019-05-31 6:36 ` [RFC PATCH v2 01/12] smp: Remove smp_call_function() and on_each_cpu() return values Nadav Amit
2019-05-31 6:36 ` [RFC PATCH v2 02/12] smp: Run functions concurrently in smp_call_function_many() Nadav Amit
2019-05-31 6:36 ` [RFC PATCH v2 03/12] x86/mm/tlb: Refactor common code into flush_tlb_on_cpus() Nadav Amit
2019-05-31 6:36 ` [RFC PATCH v2 04/12] x86/mm/tlb: Flush remote and local TLBs concurrently Nadav Amit
2019-05-31 11:48 ` Juergen Gross
2019-05-31 19:44 ` Nadav Amit
2019-05-31 6:36 ` [RFC PATCH v2 05/12] x86/mm/tlb: Optimize local TLB flushes Nadav Amit
2019-05-31 6:36 ` [RFC PATCH v2 06/12] KVM: x86: Provide paravirtualized flush_tlb_multi() Nadav Amit
2019-05-31 6:36 ` [RFC PATCH v2 07/12] smp: Do not mark call_function_data as shared Nadav Amit
2019-05-31 10:17 ` Peter Zijlstra
2019-05-31 17:50 ` Nadav Amit
2019-05-31 6:36 ` [RFC PATCH v2 08/12] x86/tlb: Privatize cpu_tlbstate Nadav Amit
2019-05-31 18:48 ` Andy Lutomirski
2019-05-31 19:42 ` Nadav Amit
2019-05-31 6:36 ` [RFC PATCH v2 09/12] x86/apic: Use non-atomic operations when possible Nadav Amit
2019-05-31 6:36 ` [RFC PATCH v2 10/12] smp: Enable data inlining for inter-processor function call Nadav Amit
2019-05-31 6:36 ` [RFC PATCH v2 11/12] x86/mm/tlb: Use async and inline messages for flushing Nadav Amit
2019-05-31 10:57 ` Peter Zijlstra
2019-05-31 18:29 ` Nadav Amit
2019-05-31 19:20 ` Jann Horn
2019-05-31 20:04 ` Nadav Amit
2019-05-31 20:37 ` Jann Horn
2019-05-31 18:44 ` Andy Lutomirski
2019-05-31 19:31 ` Nadav Amit
2019-05-31 20:13 ` Dave Hansen
2019-05-31 20:37 ` Andy Lutomirski
2019-05-31 20:42 ` Nadav Amit
2019-05-31 21:06 ` Dave Hansen [this message]
2019-05-31 21:14 ` Andy Lutomirski
2019-05-31 21:33 ` Nadav Amit
2019-05-31 21:47 ` Andy Lutomirski
2019-05-31 22:07 ` Nadav Amit
2019-06-07 5:28 ` Nadav Amit
2019-06-07 16:42 ` Andy Lutomirski
2019-05-31 6:36 ` [RFC PATCH v2 12/12] x86/mm/tlb: Reverting the removal of flush_tlb_info from stack Nadav Amit
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=90a891a2-6be4-bfa2-5de1-5e36d1bc0b48@intel.com \
--to=dave.hansen@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=namit@vmware.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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
Powered by JetHome