Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73E0EC2D0A3 for ; Thu, 12 Nov 2020 06:47:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0553208FE for ; Thu, 12 Nov 2020 06:47:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kroah.com header.i=@kroah.com header.b="Gq7Yv3ap"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="N5FaYZBV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725920AbgKLGrL (ORCPT ); Thu, 12 Nov 2020 01:47:11 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:45769 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725898AbgKLGrK (ORCPT ); Thu, 12 Nov 2020 01:47:10 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 35D285C01E2; Thu, 12 Nov 2020 01:47:09 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 12 Nov 2020 01:47:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=L/VcdorDp9JE+pqeZaPOyqZZAuh HDIcmdpu8X5mEc6E=; b=Gq7Yv3apjBkIvWYD337ESJfweP8TCtTP2ZHRA10KeDY ci//M1M7OMmph4UPK5m8n0lwAers67+njrEc5SICe7iJgPdMxd3/0Q0FhP0gODiu mLr1eq+6GH2hf9Hw92zxWiYXPe+Q7ydgOZTo5OMe/pU5LVqRbSqN6qi9lAw8y0Ao fLxg0WVQAAoLa1sLvdI6QwzHg9uVci6OwbnnYqmTUaJx4Glo80lz6z+vaYawVstV +2ilncktdbs1tLPgw1LlF94cn4MT6ktun44FbsoiVGkUnzNIjXufaU0e83kQX8JJ So4OOw0f6V/xUudcnID2t+WuTO8E87PgMLk+yK+hoSQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=L/Vcdo rDp9JE+pqeZaPOyqZZAuhHDIcmdpu8X5mEc6E=; b=N5FaYZBV4VkvImvDh0hxVN +cuHemH0y25tCytoIO6aHblUT94MoX1u8KWJbn3Q1eFm3gl376XMBFQaLjGcpdV5 UECnDP/QmYfgA/vg9wHbp97tApLUXPhmLRBSMvpWohzgqWsCFc/Uu0h6jjMVCJcV YAvVvRgWHvRdymrZjCXrsm6KCucsZVhWbKahs6SvXzanUcSEgkySnYokkvrrXyTi f41iYoLT47+yW/KD5d1XoAAPYHlsMLmIs6qkEAscEasErHME+N1SRj7/UqOYOSLr drduQz9Pdvg86LS1EVjKTb0w+9Ven10SgwHa4v1KgCug11CZsEnC7WTxzkHXteVg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvuddguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepifhrvghg ucfmjfcuoehgrhgvgheskhhrohgrhhdrtghomheqnecuggftrfgrthhtvghrnhepueelle dtheekleethfeludduvdfhffeuvdffudevgeehkeegieffveehgeeftefgnecuffhomhgr ihhnpehkvghrnhgvlhdrohhrghenucfkphepkeefrdekiedrjeegrdeigeenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvgheskhhrohgr hhdrtghomh X-ME-Proxy: Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) by mail.messagingengine.com (Postfix) with ESMTPA id 686E03065269; Thu, 12 Nov 2020 01:47:08 -0500 (EST) Date: Thu, 12 Nov 2020 07:48:07 +0100 From: Greg KH To: Anand K Mistry Cc: stable@vger.kernel.org, Borislav Petkov , Thomas Gleixner , Tom Lendacky Subject: Re: [PATCH] x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP Message-ID: References: <20201112001535.2960453-1-amistry@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201112001535.2960453-1-amistry@google.com> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Thu, Nov 12, 2020 at 11:15:34AM +1100, Anand K Mistry wrote: > commit 1978b3a53a74e3230cd46932b149c6e62e832e9a upstream. > > On AMD CPUs which have the feature X86_FEATURE_AMD_STIBP_ALWAYS_ON, > STIBP is set to on and > > spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED > > At the same time, IBPB can be set to conditional. > > However, this leads to the case where it's impossible to turn on IBPB > for a process because in the PR_SPEC_DISABLE case in ib_prctl_set() the > > spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED > > condition leads to a return before the task flag is set. Similarly, > ib_prctl_get() will return PR_SPEC_DISABLE even though IBPB is set to > conditional. > > More generally, the following cases are possible: > > 1. STIBP = conditional && IBPB = on for spectre_v2_user=seccomp,ibpb > 2. STIBP = on && IBPB = conditional for AMD CPUs with > X86_FEATURE_AMD_STIBP_ALWAYS_ON > > The first case functions correctly today, but only because > spectre_v2_user_ibpb isn't updated to reflect the IBPB mode. > > At a high level, this change does one thing. If either STIBP or IBPB > is set to conditional, allow the prctl to change the task flag. > Also, reflect that capability when querying the state. This isn't > perfect since it doesn't take into account if only STIBP or IBPB is > unconditionally on. But it allows the conditional feature to work as > expected, without affecting the unconditional one. > > [ bp: Massage commit message and comment; space out statements for > better readability. ] > > Fixes: 21998a351512 ("x86/speculation: Avoid force-disabling IBPB based on STIBP and enhanced IBRS.") > Signed-off-by: Anand K Mistry > Signed-off-by: Borislav Petkov > Acked-by: Thomas Gleixner > Acked-by: Tom Lendacky > Link: https://lkml.kernel.org/r/20201105163246.v2.1.Ifd7243cd3e2c2206a893ad0a5b9a4f19549e22c6@changeid > > Conflicts: > arch/x86/kernel/cpu/bugs.c > > Superfluous newline which was removed in upstream commit a5ce9f2bb665 In the future, No need for the conflicts or this line in the changelog text, that just requires me to edit it out :( thanks, greg k-h