From: Peter Zijlstra <peterz@infradead.org>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, Linus Torvalds <torvalds@linux-foundation.org>,
Andy Lutomirsky <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Dave Hansen <dave.hansen@intel.com>,
Borislav Petkov <bpetkov@suse.de>,
Greg KH <gregkh@linuxfoundation.org>,
keescook@google.com, hughd@google.com,
Brian Gerst <brgerst@gmail.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Denys Vlasenko <dvlasenk@redhat.com>,
Rik van Riel <riel@redhat.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Juergen Gross <jgross@suse.com>,
David Laight <David.Laight@aculab.com>,
Eduardo Valentin <eduval@amazon.com>,
aliguori@amazon.com, Will Deacon <will.deacon@arm.com>,
daniel.gruss@iaik.tugraz.at,
Dave Hansen <dave.hansen@linux.intel.com>,
Ingo Molnar <mingo@kernel.org>,
moritz.lipp@iaik.tugraz.at, linux-mm@kvack.org,
Borislav Petkov <bp@alien8.de>,
michael.schwarz@iaik.tugraz.at,
richard.fellner@student.tugraz.at
Subject: [PATCH 3/9] x86/mm: Address feedback
Date: Tue, 05 Dec 2017 13:34:48 +0100 [thread overview]
Message-ID: <20171205123820.034976940@infradead.org> (raw)
In-Reply-To: <20171205123444.990868007@infradead.org>
[-- Attachment #1: peterz-tlb-invalidate-other-fix.patch --]
[-- Type: text/plain, Size: 2007 bytes --]
fold into: ("x86/mm: Allow flushing for future ASID switches")
Andy asked for the KPTI check to be pulled out of the API such that
the function always does as advertised.
Rename to: invalidate_other_asid() because the pcid name is actually
wrong if we consider our ASID to represend two PCID values (as it does
with KPTI). In specific, it will not flush the user PCID of the
current ASID.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/include/asm/tlbflush.h | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
--- a/arch/x86/include/asm/tlbflush.h
+++ b/arch/x86/include/asm/tlbflush.h
@@ -270,16 +270,11 @@ static inline unsigned long cr4_read_sha
return this_cpu_read(cpu_tlbstate.cr4);
}
-static inline void invalidate_pcid_other(void)
+/*
+ * Mark all other ASIDs as invalid, preserves the current.
+ */
+static inline void invalidate_other_asid(void)
{
- /*
- * With global pages, all of the shared kenel page tables
- * are set as _PAGE_GLOBAL. We have no shared nonglobals
- * and nothing to do here.
- */
- if (!static_cpu_has_bug(X86_BUG_CPU_SECURE_MODE_KPTI))
- return;
-
this_cpu_write(cpu_tlbstate.invalidate_other, true);
}
@@ -411,11 +406,16 @@ static inline void __flush_tlb_one(unsig
{
count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ONE);
__flush_tlb_single(addr);
+
+ if (!static_cpu_has_bug(X86_BUG_CPU_SECURE_MODE_KPTI))
+ return;
+
/*
- * Invalidate other address spaces inaccessible to single-page
- * invalidation:
+ * __flush_tlb_single() will have cleared the TLB entry for this ASID,
+ * but since kernel space is replicated across all, we must also
+ * invalidate all others.
*/
- invalidate_pcid_other();
+ invalidate_other_asid();
}
#define TLB_FLUSH_ALL -1UL
--
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>
next prev parent reply other threads:[~2017-12-05 12:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-05 12:34 [PATCH 0/9] Clarify/cleanup/fix tlbflush API/usage Peter Zijlstra
2017-12-05 12:34 ` [PATCH 1/9] x86/mm: Remove superfluous barriers Peter Zijlstra
2017-12-05 12:34 ` [PATCH 2/9] x86/mm: Create asm/invpcid.h Peter Zijlstra
2017-12-05 12:34 ` Peter Zijlstra [this message]
2017-12-05 12:34 ` [PATCH 4/9] x86/mm: Use __flush_tlb_one() for kernel memory Peter Zijlstra
2017-12-05 12:34 ` [PATCH 5/9] x86/uv: Use the right tlbflush API Peter Zijlstra
2017-12-05 21:09 ` Andrew Banman
2017-12-05 21:27 ` Peter Zijlstra
2017-12-05 23:04 ` Andrew Banman
2017-12-05 12:34 ` [PATCH 6/9] x86/microcode: Dont abuse the tlbflush interface Peter Zijlstra
2017-12-05 12:34 ` [PATCH 7/9] x86/mm: Clarify which functions are supposed to flush what Peter Zijlstra
2017-12-05 12:34 ` [PATCH 8/9] x86/mm: Clarify the whole ASID/kernel PCID/user PCID naming Peter Zijlstra
2017-12-05 12:34 ` [PATCH 9/9] x86/doc: Remove obvious weirdness Peter Zijlstra
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=20171205123820.034976940@infradead.org \
--to=peterz@infradead.org \
--cc=David.Laight@aculab.com \
--cc=aliguori@amazon.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=bpetkov@suse.de \
--cc=brgerst@gmail.com \
--cc=daniel.gruss@iaik.tugraz.at \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dvlasenk@redhat.com \
--cc=eduval@amazon.com \
--cc=gregkh@linuxfoundation.org \
--cc=hughd@google.com \
--cc=jgross@suse.com \
--cc=jpoimboe@redhat.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=mingo@kernel.org \
--cc=moritz.lipp@iaik.tugraz.at \
--cc=richard.fellner@student.tugraz.at \
--cc=riel@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=will.deacon@arm.com \
--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