Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp89896pxb; Wed, 4 Nov 2020 15:36:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJx31QwsOM4tq5RCiCbtRdZHb6quu+yI9uqKkgS/u+pg6fRiI3RLZuk7Y5AVf8fmtUHtM1se X-Received: by 2002:a05:6402:54d:: with SMTP id i13mr250657edx.3.1604532966099; Wed, 04 Nov 2020 15:36:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604532966; cv=none; d=google.com; s=arc-20160816; b=D+RnSLhj2XqZ6fguHITsnpstTNcV3PwD1yW4l1eauIiPsx8Klscp0Q4JVAyK5Ps6Dc Vc9jgm6ymJTRRIw2phT8zr99G42egJEmgKwGAZc8fU1fqnyyGr6nSwDZR1RE3bF6BZVJ /zvUNMkqI/JX7E3u59gI6PwDz3N06bBR+RtijobyxpLcuLmNschTmLEzyYt6wPsj7aKh s6uZz/g8mcqEGqqk2eX1Hbzsv4XQftaQdia4KIf2xdP/aE4UgXpqCiW1ZhZ45cNphaa2 nPu1RvlAe/CO2eOhTYoq0Z7kBj4qUW5fyVwKhU2zHFntuZGemjBaXrPysIj/RgnsUFsU Osgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hkU6HJZvR4akq9aNkA/6+X7X6u9jB+w9l/AGXazTlXs=; b=ylW2UBVbmbX3UW3YbEqSq6BUFuWz/FTrrlxYfeyXQ8rKVz/7DUy/gHiPGWj5Sfanic G2goC6lR8G1EiaylZ7YoV5sBuTcMDV0QjeT1o3rLu3PHY6dndVt29jgOhB9CwFvbqZgZ ZzuM/SGhqpoHFYNl2i8WXPS4+4hWdtjRD0Nv3rPy0RevZtZSt71NflUZd/AFQtp6WDaC WdGik4Cdt2CEDHmgt54oz/YK4gDKrD793zqOOswnjn6tkupqYGMY9zEzhWyn53YSKxKa OdgKzlrG2T/ABD2HjemuP7nEqaXECJyHgViN3knCJXlZIv+mQG7bMXX4bZiRUrkDIT0R zV7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=cO23P3Gu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id op24si1619179ejb.355.2020.11.04.15.35.43; Wed, 04 Nov 2020 15:36:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=cO23P3Gu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732391AbgKDXbr (ORCPT + 99 others); Wed, 4 Nov 2020 18:31:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbgKDXbr (ORCPT ); Wed, 4 Nov 2020 18:31:47 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D715DC0613CF for ; Wed, 4 Nov 2020 15:31:45 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id 12so150215qkl.8 for ; Wed, 04 Nov 2020 15:31:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=hkU6HJZvR4akq9aNkA/6+X7X6u9jB+w9l/AGXazTlXs=; b=cO23P3Gu0OtXCB60SEdnjT22M2jYGUl8PSH9Yp3YLIQcEczhcp3zA2VS0kfoKfZYSV cEV5A5Fz0bmmHMIAFwvnrGads7v3MwnfCN8hpnaZzoqNC9BlIZ76psBr4IX+PoUOZ/JJ aiDR+vTSzk99yTR3W1v65xO1lWxTwyrSRTTDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hkU6HJZvR4akq9aNkA/6+X7X6u9jB+w9l/AGXazTlXs=; b=TYgrgqNvF4uQIyX8pB3QTclVBzyontbj5fLEeZoVnhGWwGL94ScsV28w3yuIVHXZXG 17hXK758obHd4h6aEqq/Y8IZKnfOD53u7/jj2iI3/+bSBbMk46tLpWS/vx/4dgTWp3T2 QFaqCFQ5c9BAdjMd3Y8dowmzMsVS5JNMY5+0vVPeR2wwnsjXgwcDvvF5kMxAPOSiC+XU QEu/7q02zNpQcGpoZHrDXUfKhHztXMhAjcxYR1ypTVp6POpqJ5k2zXw4sTpgnnLFmtw3 7HgpxV1goBJ4CLjRhcfHDvNR1SU26cO4WKuTJCeZqPiaSgbtDG30n3qUx+ilcuwYRyIF Us8w== X-Gm-Message-State: AOAM531D+29gnsrvgHsn1O5sKN4b5snm/ZUvvPR76qccvA/A95rBHP1k boYPGe4MiP/1g+Nc7YEgmJq0qg== X-Received: by 2002:ae9:de45:: with SMTP id s66mr596876qkf.281.1604532705003; Wed, 04 Nov 2020 15:31:45 -0800 (PST) Received: from localhost ([2620:15c:6:411:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id 82sm571791qkg.103.2020.11.04.15.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 15:31:44 -0800 (PST) Date: Wed, 4 Nov 2020 18:31:43 -0500 From: Joel Fernandes To: Borislav Petkov Cc: "Anand K. Mistry" , Tom Lendacky , x86@kernel.org, Anthony Steinhauser , tglx@linutronix.de, "H. Peter Anvin" , Ingo Molnar , Josh Poimboeuf , Mark Gross , Mike Rapoport , Pawan Gupta , Tony Luck , Vineela Tummalapalli , Waiman Long , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP Message-ID: <20201104233143.GA2496945@google.com> References: <20201029065133.3027749-1-amistry@google.com> <20201029175120.1.Ifd7243cd3e2c2206a893ad0a5b9a4f19549e22c6@changeid> <839fad53-4377-592a-a0da-2cf18b5c6027@amd.com> <20201103105757.GC6310@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201103105757.GC6310@zn.tnic> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 03, 2020 at 11:57:57AM +0100, Borislav Petkov wrote: > On Mon, Nov 02, 2020 at 11:02:10AM +1100, Anand K. Mistry wrote: > > > I like the idea of passing in the mode you want to check, but it appears > > > they are never used independently. The ibpb and stibp modes are always > > > checked together in one of the if statements below, so you could make this > > > a function that checks both modes and just have a single call. I'll leave > > > that up to the maintainers to see what is preferred. > > > > I can see both sides to this. Personally, I think I prefer it as-is > > since I think it improves readability a bit by making the conditions > > less complicated whilst not hiding too many details. I'll wait to see > > what others say before changing this one. > > Yes, but if you make it a single function with a descriptive name, you'd > make the call sites even more readable: > > if (!is_spec_ib_conditional(..)) > bla; > > or > > if (!is_spec_ib_user_controlled(..)) > blu; > > and that function should simply check both spectre_v2_user_ibpb *and* > spectre_v2_user_stibp in one go. > > Why should we do that? > > Exactly because you both got your brains twisted just from looking at > this. Because this mitigation crap is such an ugly and complex maze that > we would take even the smallest simplification any day of the week! > > Welcome to my life since meltdown. Brain twist feels good, doesn't it? > > :-))) I hate the maze too. In theory we can get rid of STIBP if/when core-scheduling is enabled because the cross-CPU branch predictor poisioning would not be possible. Maybe that will simplify the maze a bit. thanks, - Joel