Received: by 10.223.176.46 with SMTP id f43csp1699133wra; Sun, 21 Jan 2018 02:33:55 -0800 (PST) X-Google-Smtp-Source: AH8x226KcVbxbmsjRHrl7WhlSEW185Sv2iqS+RVlMD3HJmH+Yor5E00WA3dQVsB8tiq4/bPFxYxm X-Received: by 10.98.100.139 with SMTP id y133mr4912811pfb.68.1516530835698; Sun, 21 Jan 2018 02:33:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516530835; cv=none; d=google.com; s=arc-20160816; b=Pt5Qq7XrWdXbUNm8Re/i55uUm9T9+UR30I9hXwuuHU3D/7CJAutKOOChxDfbIhpGRF +NXfdYpkn7PysxxDO9Z0hnfBiJePiDFNBHBgUw5BpnGjr/NKULdPvZ79pkx9NB9ByS6l +ggt5xvQKtvbeM4GgOpvGAuukzbpN16TyG4FughZsQ3+kBDixWqaAoU/t1RnRVW5kYfq IOfPZT8eUSgdQWGrovlcKCuN/oe1LaYPVSx20DJQI5mUdp/W64B/3YE6egB7QowVySzk 7pMYV+hddEDhqUEqsseb4+3YnJrLE4ewVePThegE1LMTAopV0RQYqoGwO99qzkp3bL9U Gh7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=h73FTbI5tUNLnDeicDg8e0xpp0GlpCs/Vs8RsaqJn5s=; b=zh2YThRHOJCJQapjlYNIO0R346yD/nSePpqvPWvUZWUP/l6ntO/nzk+kheZsGucY0G 6O133X9a4UGuedbb1q7+83GHm1Ejplt3zg8rYM5kr0wqgi9dCMfz7Xpltewa7p2aDvCW LLPKCOdg1qKdzvqQWSYAZ3dbSFsr3Id2hMDWauDuJzpVKGVrcxu9jXzgB67/x2oN0QOL dpOGcgtQqcNwFDY0qE0YqX0W86F8kDmJQtWA6NE119WDXN8cT7yQnZiaYx0Pg0sPI7de D9OV57ehqeaAS+tyVVOwc7fbGFpYQjazi0bJzZHhKi+sBXFIGrXXCWxZ2rh1RK7xDsIO 5xrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=YC/iDwE/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10-v6si2456156plz.107.2018.01.21.02.33.41; Sun, 21 Jan 2018 02:33:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=YC/iDwE/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751019AbeAUKdT (ORCPT + 99 others); Sun, 21 Jan 2018 05:33:19 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:38419 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750892AbeAUKdS (ORCPT ); Sun, 21 Jan 2018 05:33:18 -0500 Received: by mail-wm0-f67.google.com with SMTP id 141so11311447wme.3 for ; Sun, 21 Jan 2018 02:33:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=h73FTbI5tUNLnDeicDg8e0xpp0GlpCs/Vs8RsaqJn5s=; b=YC/iDwE/98jmdVnuFZZdOqxlzaPHEO2WImAjNW5zueD5ooZfgIo/FSR5t9MIXUYAeI BuF9IyEafXzJu7E7iWDe3YACl+PRubchZCkiEDW6FNfYmH0irBj932le5fzuFujYCLed p3+5gh0tuoZwqzzEer7MHiMQ9AYF6HABqa6/viRX5T1D8WhtKZ6Y6yxZnr/qFyUBwcY7 cF2gM4EylBhaGd62Kt2tWrK1asKe89xpjre9CmiQcis6IrWjSJvLFDUpIlxrGgQriNWw X9NGr6XW2fEFknZTI5syJTxnLwwMBZIr1kjGdY+7UnMSd2YvHXaf57CjNE3xMZqkm6Cz IVFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=h73FTbI5tUNLnDeicDg8e0xpp0GlpCs/Vs8RsaqJn5s=; b=nkD2Ob3DCP+B6UIEX75Lo4r+gua5Pb/B++rTomTVL8v28xV4QN4IYTdqbT7S+fxPBY nK1iscZzWPKZLMlfOIyaWm1Oc/kw7houANScpwogwhXk5F3XtM13vnxhESqqBTpTfqaQ NOuDn4kQ3Ss6K80Tw2gNYJAFuparQiP+g9fNOWqzrY8xYcNRKeO/AylTgwHb6AIAeIfT oOQC3OidcT9EQuC9zXFueo6Q+3QKlTSVzqb7tzeuAmR+69weXrrXBJRKutIyw91Hgp1D esAJiOxM5s7mC1oTOdjRAWFDzDr61+ZV6ku1hqxsPlxPSCwYal82SFjBqC+52oycL+ZC 14xA== X-Gm-Message-State: AKwxytc4u7AL0mB/6rN2rgl9ooPSzNzeWwGbk/s1uIv/Xd8XTjN+mMU9 nBVSkVLIlJ4tLXvKpc8nZFE= X-Received: by 10.28.214.67 with SMTP id n64mr2405429wmg.25.1516530796969; Sun, 21 Jan 2018 02:33:16 -0800 (PST) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id z99sm40648522wrb.79.2018.01.21.02.33.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 21 Jan 2018 02:33:16 -0800 (PST) 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * 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