From: Dave Hansen <dave.hansen@linux.intel.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
moritz.lipp@iaik.tugraz.at,
Daniel Gruss <daniel.gruss@iaik.tugraz.at>,
michael.schwarz@iaik.tugraz.at,
richard.fellner@student.tugraz.at,
Linus Torvalds <torvalds@linux-foundation.org>,
Kees Cook <keescook@google.com>, Hugh Dickins <hughd@google.com>,
X86 ML <x86@kernel.org>
Subject: Re: [PATCH 21/30] x86, mm: put mmu-to-h/w ASID translation in one place
Date: Fri, 10 Nov 2017 14:09:06 -0800 [thread overview]
Message-ID: <101307eb-b924-69ef-13dd-05e63fbaf587@linux.intel.com> (raw)
In-Reply-To: <CALCETrXrXpTZE2sceBh=eW5kEP79hWc5iY36QKjfy=U4nTirDw@mail.gmail.com>
On 11/10/2017 02:03 PM, Andy Lutomirski wrote:
>> +static inline u16 kern_asid(u16 asid)
>> +{
>> + VM_WARN_ON_ONCE(asid > MAX_ASID_AVAILABLE);
>> + /*
>> + * If PCID is on, ASID-aware code paths put the ASID+1 into the PCID
>> + * bits. This serves two purposes. It prevents a nasty situation in
>> + * which PCID-unaware code saves CR3, loads some other value (with PCID
>> + * == 0), and then restores CR3, thus corrupting the TLB for ASID 0 if
>> + * the saved ASID was nonzero. It also means that any bugs involving
>> + * loading a PCID-enabled CR3 with CR4.PCIDE off will trigger
>> + * deterministically.
>> + */
>> + return asid + 1;
>> +}
> This seems really error-prone. Maybe we should have a pcid_t type and
> make all the interfaces that want a h/w PCID take pcid_t.
Yeah, totally agree. I actually had a nasty bug or two around this area
because of this.
I divided them among hw_asid_t and sw_asid_t. You can turn a sw_asid_t
into a kernel hw_asid_t or a user hw_asid_t. But, it cause too much
churn across the TLB flushing code so I shelved it for now.
I'd love to come back nd fix this up properly though.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Dave Hansen <dave.hansen@linux.intel.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
moritz.lipp@iaik.tugraz.at,
Daniel Gruss <daniel.gruss@iaik.tugraz.at>,
michael.schwarz@iaik.tugraz.at,
richard.fellner@student.tugraz.at,
Linus Torvalds <torvalds@linux-foundation.org>,
Kees Cook <keescook@google.com>, Hugh Dickins <hughd@google.com>,
X86 ML <x86@kernel.org>
Subject: Re: [PATCH 21/30] x86, mm: put mmu-to-h/w ASID translation in one place
Date: Fri, 10 Nov 2017 14:09:06 -0800 [thread overview]
Message-ID: <101307eb-b924-69ef-13dd-05e63fbaf587@linux.intel.com> (raw)
In-Reply-To: <CALCETrXrXpTZE2sceBh=eW5kEP79hWc5iY36QKjfy=U4nTirDw@mail.gmail.com>
On 11/10/2017 02:03 PM, Andy Lutomirski wrote:
>> +static inline u16 kern_asid(u16 asid)
>> +{
>> + VM_WARN_ON_ONCE(asid > MAX_ASID_AVAILABLE);
>> + /*
>> + * If PCID is on, ASID-aware code paths put the ASID+1 into the PCID
>> + * bits. This serves two purposes. It prevents a nasty situation in
>> + * which PCID-unaware code saves CR3, loads some other value (with PCID
>> + * == 0), and then restores CR3, thus corrupting the TLB for ASID 0 if
>> + * the saved ASID was nonzero. It also means that any bugs involving
>> + * loading a PCID-enabled CR3 with CR4.PCIDE off will trigger
>> + * deterministically.
>> + */
>> + return asid + 1;
>> +}
> This seems really error-prone. Maybe we should have a pcid_t type and
> make all the interfaces that want a h/w PCID take pcid_t.
Yeah, totally agree. I actually had a nasty bug or two around this area
because of this.
I divided them among hw_asid_t and sw_asid_t. You can turn a sw_asid_t
into a kernel hw_asid_t or a user hw_asid_t. But, it cause too much
churn across the TLB flushing code so I shelved it for now.
I'd love to come back nd fix this up properly though.
next prev parent reply other threads:[~2017-11-10 22:09 UTC|newest]
Thread overview: 151+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 19:30 [PATCH 00/30] [v3] KAISER: unmap most of the kernel from userspace page tables Dave Hansen
2017-11-10 19:30 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 01/30] x86, mm: do not set _PAGE_USER for init_mm " Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 02/30] x86, tlb: Make CR4-based TLB flushes more robust Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 03/30] x86/mm: Document X86_CR4_PGE toggling behavior Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 04/30] x86, kaiser: disable global pages by default with KAISER Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-14 19:38 ` Rik van Riel
2017-11-26 14:48 ` Ingo Molnar
2017-11-26 14:48 ` Ingo Molnar
2017-11-27 11:37 ` Thomas Gleixner
2017-11-27 11:37 ` Thomas Gleixner
2017-11-27 13:20 ` [PATCH v2] x86/mm/kaiser: Disable " Ingo Molnar
2017-11-27 13:20 ` Ingo Molnar
2017-11-27 13:23 ` Thomas Gleixner
2017-11-27 13:23 ` Thomas Gleixner
2017-11-27 13:27 ` Ingo Molnar
2017-11-27 13:27 ` Ingo Molnar
2017-11-10 19:31 ` [PATCH 05/30] x86, kaiser: prepare assembly for entry/exit CR3 switching Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-20 12:17 ` Thomas Gleixner
2017-11-20 12:17 ` Thomas Gleixner
2017-11-10 19:31 ` [PATCH 06/30] x86, kaiser: introduce user-mapped per-cpu areas Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 07/30] x86, kaiser: mark per-cpu data structures required for entry/exit Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 08/30] x86, kaiser: unmap kernel from userspace page tables (core patch) Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-20 17:21 ` Thomas Gleixner
2017-11-20 17:21 ` Thomas Gleixner
2017-11-22 22:45 ` Dave Hansen
2017-11-22 22:45 ` Dave Hansen
2017-11-22 22:50 ` Dave Hansen
2017-11-22 22:50 ` Dave Hansen
2017-11-22 22:54 ` Dave Hansen
2017-11-22 22:54 ` Dave Hansen
2017-11-22 23:11 ` Dave Hansen
2017-11-22 23:11 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 09/30] x86, kaiser: only populate shadow page tables for userspace Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-20 20:12 ` Thomas Gleixner
2017-11-20 20:12 ` Thomas Gleixner
2017-11-21 7:05 ` Ingo Molnar
2017-11-21 7:05 ` Ingo Molnar
2017-11-21 22:09 ` Dave Hansen
2017-11-21 22:09 ` Dave Hansen
2017-11-22 3:44 ` Andy Lutomirski
2017-11-22 3:44 ` Andy Lutomirski
2017-11-22 23:30 ` Dave Hansen
2017-11-22 23:30 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 10/30] x86, kaiser: allow NX poison to be set in p4d/pgd Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 11/30] x86, kaiser: make sure static PGDs are 8k in size Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 12/30] x86, kaiser: map GDT into user page tables Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-20 20:22 ` Thomas Gleixner
2017-11-20 20:22 ` Thomas Gleixner
2017-11-20 20:46 ` Andy Lutomirski
2017-11-20 20:46 ` Andy Lutomirski
2017-11-20 20:55 ` Thomas Gleixner
2017-11-20 20:55 ` Thomas Gleixner
2017-11-21 21:19 ` Dave Hansen
2017-11-21 21:19 ` Dave Hansen
2017-11-21 22:46 ` Andy Lutomirski
2017-11-21 22:46 ` Andy Lutomirski
2017-11-21 23:17 ` Dave Hansen
2017-11-21 23:17 ` Dave Hansen
2017-11-21 23:32 ` Andy Lutomirski
2017-11-21 23:32 ` Andy Lutomirski
2017-11-21 23:42 ` Dave Hansen
2017-11-21 23:42 ` Dave Hansen
2017-11-22 0:17 ` Andy Lutomirski
2017-11-22 0:17 ` Andy Lutomirski
2017-11-22 0:37 ` Dave Hansen
2017-11-22 0:37 ` Dave Hansen
2017-11-21 22:12 ` Dave Hansen
2017-11-21 22:12 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 13/30] x86, kaiser: map dynamically-allocated LDTs Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 14/30] x86, kaiser: map espfix structures Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 15/30] x86, kaiser: map entry stack variables Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 16/30] x86, kaiser: map trace interrupt entry Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 17/30] x86, kaiser: map debug IDT tables Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-20 20:40 ` Thomas Gleixner
2017-11-20 20:40 ` Thomas Gleixner
2017-11-21 22:16 ` Dave Hansen
2017-11-21 22:16 ` Dave Hansen
2017-11-20 20:44 ` Andy Lutomirski
2017-11-20 20:44 ` Andy Lutomirski
2017-11-20 20:54 ` Thomas Gleixner
2017-11-20 20:54 ` Thomas Gleixner
2017-11-10 19:31 ` [PATCH 18/30] x86, kaiser: map virtually-addressed performance monitoring buffers Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-14 18:20 ` Peter Zijlstra
2017-11-14 18:20 ` Peter Zijlstra
2017-11-14 18:28 ` Dave Hansen
2017-11-14 18:28 ` Dave Hansen
2017-11-14 19:10 ` Hugh Dickins
2017-11-14 19:10 ` Hugh Dickins
2017-11-14 19:24 ` Andy Lutomirski
2017-11-14 19:24 ` Andy Lutomirski
2017-11-15 9:41 ` Peter Zijlstra
2017-11-15 9:41 ` Peter Zijlstra
2017-11-10 19:31 ` [PATCH 19/30] x86, mm: Move CR3 construction functions Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 20/30] x86, mm: remove hard-coded ASID limit checks Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-20 20:47 ` Thomas Gleixner
2017-11-20 20:47 ` Thomas Gleixner
2017-11-10 19:31 ` [PATCH 21/30] x86, mm: put mmu-to-h/w ASID translation in one place Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 22:03 ` Andy Lutomirski
2017-11-10 22:03 ` Andy Lutomirski
2017-11-10 22:09 ` Dave Hansen [this message]
2017-11-10 22:09 ` Dave Hansen
2017-11-10 22:10 ` Andy Lutomirski
2017-11-10 22:10 ` Andy Lutomirski
2017-11-10 19:31 ` [PATCH 22/30] x86, pcid, kaiser: allow flushing for future ASID switches Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 23/30] x86, kaiser: use PCID feature to make user and kernel switches faster Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-16 19:19 ` Andrea Arcangeli
2017-11-16 19:19 ` Andrea Arcangeli
2017-11-16 19:25 ` Dave Hansen
2017-11-16 19:25 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 24/30] x86, kaiser: disable native VSYSCALL Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 25/30] x86, kaiser: add debugfs file to turn KAISER on/off at runtime Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 26/30] x86, kaiser: add a function to check for KAISER being enabled Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 27/30] x86, kaiser: un-poison PGDs at runtime Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:31 ` [PATCH 28/30] x86, kaiser: allow KAISER to be enabled/disabled " Dave Hansen
2017-11-10 19:31 ` Dave Hansen
2017-11-10 19:32 ` [PATCH 29/30] x86, kaiser: add Kconfig Dave Hansen
2017-11-10 19:32 ` Dave Hansen
2017-11-10 19:32 ` [PATCH 30/30] x86, kaiser, xen: Dynamically disable KAISER when running under Xen PV Dave Hansen
2017-11-10 19:32 ` Dave Hansen
2017-11-20 16:02 ` [PATCH 00/30] [v3] KAISER: unmap most of the kernel from userspace page tables Juerg Haefliger
2017-11-20 16:02 ` Juerg Haefliger
-- strict thread matches above, loose matches on Subject: below --
2017-11-08 19:46 [PATCH 00/30] [v2] " Dave Hansen
2017-11-08 19:47 ` [PATCH 21/30] x86, mm: put mmu-to-h/w ASID translation in one place Dave Hansen
2017-11-08 19:47 ` Dave Hansen
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=101307eb-b924-69ef-13dd-05e63fbaf587@linux.intel.com \
--to=dave.hansen@linux.intel.com \
--cc=daniel.gruss@iaik.tugraz.at \
--cc=hughd@google.com \
--cc=keescook@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=michael.schwarz@iaik.tugraz.at \
--cc=moritz.lipp@iaik.tugraz.at \
--cc=richard.fellner@student.tugraz.at \
--cc=torvalds@linux-foundation.org \
--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 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.