From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: ARC-Seal: i=1; a=rsa-sha256; t=1516530797; cv=none; d=google.com; s=arc-20160816; b=k2gu874lJfkCcGDeNKjQIcqxJchUU1UVPoHfSs6q12SDr/qMx5BLB+r50GO+1pB68b pD91R8LMZxAsuQdd1IMIJugHBOsmR5jEPzvtuTpXZ85RF/aaez/2naHLhweHNt2uOiY3 Xz5/3bo9zBLOHV0b7vqZa6EAaF3uAzIzISI8u/XAUDKsAmeZ1SHZPbrzeX3QA4Wzg0tc y7bVNpohrraMT3/P9P8/CyJq8sBPzZBnBK6/QUuICOBezjT1k7IGzKdJ6NbMFvlSe6qr 3UXny8ApIy9axwZdCsWI2YH7ZHK5IS7gd3jh2UqNIVZny84cGBz1nt0Rvs2o2OSkrtuz tJ3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:sender:dkim-signature :arc-authentication-results; bh=h73FTbI5tUNLnDeicDg8e0xpp0GlpCs/Vs8RsaqJn5s=; b=RWgJD0t0nBZHero/UF16JGt+1HVYu80Yjn4DOMJ1PbPFGRDrHGNyVS8GKqbLIGxf6V 9zztHcJJeaKK1gLAx18PdqtLURLI/gWLGr/mMtXIVLPb7Qir+uh4AWInUOEat/S9LoVo hRqYxgNxtjVqaA/wgbXVlK5bhJDgGxr1+6KUgKddNhHUn3yXOWmh2vnTNVW0Ouj8uxDx 98KGdQaxuLmIzo3gdvl8ArRqFwJRsl9R19w//OcksNBDUksevM2kn8kzwPaMCnDdxWQJ gvmSxHHpFXE9ceUq1u4oUfGhVUUX++zvQH5/pzogXSTl224V7jZmkrZPNutsaWYvRWKn iG3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YC/iDwE/; spf=pass (google.com: domain of mingo.kernel.org@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mingo.kernel.org@gmail.com Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YC/iDwE/; spf=pass (google.com: domain of mingo.kernel.org@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mingo.kernel.org@gmail.com X-Google-Smtp-Source: AH8x224JJnMhbsryFcIZvDjHS+WED+rq/TGlh/eI9HXILPXid0Wj5ovMXij+6xXW3nd70jkmk2leNw== Sender: Ingo Molnar Date: Sun, 21 Jan 2018 11:33:13 +0100 From: Ingo Molnar To: David Woodhouse Cc: arjan@linux.intel.com, tglx@linutronix.de, karahmed@amazon.de, x86@kernel.org, linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com, bp@alien8.de, peterz@infradead.org, pbonzini@redhat.com, ak@linux.intel.com, torvalds@linux-foundation.org, gregkh@linux-foundation.org Subject: Re: [PATCH v2 8/8] x86/mm: Only flush indirect branches when switching into non dumpable process Message-ID: <20180121103313.iiv7qejl7hlwbnqr@gmail.com> References: <1516528149-9370-1-git-send-email-dwmw@amazon.co.uk> <1516528149-9370-9-git-send-email-dwmw@amazon.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516528149-9370-9-git-send-email-dwmw@amazon.co.uk> User-Agent: NeoMutt/20170609 (1.8.3) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590195052643423989?= X-GMAIL-MSGID: =?utf-8?q?1590197797439629548?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: * David Woodhouse wrote: > From: Andi Kleen > > Flush indirect branches when switching into a process that marked > itself non dumpable. This protects high value processes like gpg > better, without having too high performance overhead. > > Signed-off-by: Andi Kleen > Signed-off-by: David Woodhouse > Signed-off-by: KarimAllah Ahmed > --- > arch/x86/mm/tlb.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c > index 304de7d..f64e80c 100644 > --- a/arch/x86/mm/tlb.c > +++ b/arch/x86/mm/tlb.c > @@ -225,8 +225,19 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, > * Avoid user/user BTB poisoning by flushing the branch predictor > * when switching between processes. This stops one process from > * doing Spectre-v2 attacks on another. > + * > + * As an optimization: Flush indirect branches only when > + * switching into processes that disable dumping. > + * > + * This will not flush when switching into kernel threads. > + * But it would flush when switching into idle and back > + * > + * It might be useful to have a one-off cache here > + * to also not flush the idle case, but we would need some > + * kind of stable sequence number to remember the previous mm. Punctuation and grammar is pretty inconsistent, please change it to something more readable, like: * As an optimization flush indirect branches only when * switching into processes that disable dumping. * * This will not flush branches when switching into kernel * threads, but it would flush them when switching to the * idle thread and back. * * It might be useful to have a one-off cache here * to also not flush the idle case, but we would need some * kind of stable sequence number to remember the previous mm. Thanks, Ingo