Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp413733pxb; Tue, 3 Nov 2020 03:01:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOD8aMuOgbonMdjvui3Z0Kga4KDl01vKm4st7fpT0Lq9Gl9l58P4gVAuQeNipYSHuZDMd2 X-Received: by 2002:a2e:8092:: with SMTP id i18mr8007792ljg.314.1604401314311; Tue, 03 Nov 2020 03:01:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604401314; cv=none; d=google.com; s=arc-20160816; b=V3Fjw7gnXwXfSGvnUHbW6vxiruitSTCcGp6/Ut67GF6OQ3WJ01brJhKuMdGnLmHgmA /y//mmNJZfNrWzoF4WMOB3D6/lnZmFRWpkeKRRccZs/pki0qApRsAnGBPnNN79/maevs qrwaXQ57sb4mql1fLD32iCTMcsyni0lg8A5SA4APBMwm0OpcNAnLsr9FWmfAIrc5XgpE 3VJ9bnDDcxpPySQV79vy+no7vIv++25WgmNiweUyKYfSyvYtX8f6uQCz/LZO3EqbBwdA TpQ34/64fJodW+O6cNIYzqIQOqh+718ihSoC7Y3q39JPQZLBzPsY9eGbsqkllHOhkJdP mcsg== 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=0eBb3iz1k3ff6oq56+v0Kv7pCTv1NKfu1eGxm6iHIkw=; b=BV6eqvRxSZrF2AOdaZx6W97THgzyp9Y9KKBmGlAx1idJezm2LGGhe1BiD9sKUeC343 /WGON6Rry5AmNUPrXOEGZ0o9BmUOb96YWZVkTmMuFS1zPV58lX7dGvWJM7zO0Vg+gvf7 EZFjuhr3g9u1zV+OPoM9MeVnL3PAVanHYXD3F4FmE4ylS9Wq/gPGd/HpliIZgzxxGbTy p1rpUAiOD//OzRQh/Ftw4NG38RLfLHE+sqF7FF2g3rPETZWqWVWbnE5pxCqlk42CgJul IsTC78x9xr73WFzjhpYDLnKqXgV6hhunZ0hBmJB9ItmrrB+Ey5zSWq+AFfIw3C39JtmH XaNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=I7gx60bF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o6si11895203eju.647.2020.11.03.03.01.31; Tue, 03 Nov 2020 03:01:54 -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=@alien8.de header.s=dkim header.b=I7gx60bF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728100AbgKCK6K (ORCPT + 99 others); Tue, 3 Nov 2020 05:58:10 -0500 Received: from mail.skyhub.de ([5.9.137.197]:50384 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgKCK6K (ORCPT ); Tue, 3 Nov 2020 05:58:10 -0500 Received: from zn.tnic (p200300ec2f10e0003c085ddaf11537c5.dip0.t-ipconnect.de [IPv6:2003:ec:2f10:e000:3c08:5dda:f115:37c5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 24C661EC02E6; Tue, 3 Nov 2020 11:58:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1604401089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=0eBb3iz1k3ff6oq56+v0Kv7pCTv1NKfu1eGxm6iHIkw=; b=I7gx60bFgf5QXE+FwMSrWylpE6J7ELZCLfIhjJFDV2uLKE2NeTIDveyGroKNbygbJLKq/U TUYO2lPj1CbSqmSmbEG79dcSHXpAq0KrlKr879C5jsRbaMVCxKdjHlC2Odhlp2j7QZwXia OaKlCNjVV31ejUaWDS2ivLlU+GJgXZE= Date: Tue, 3 Nov 2020 11:57:57 +0100 From: Borislav Petkov To: "Anand K. Mistry" Cc: Tom Lendacky , x86@kernel.org, Joel Fernandes , 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: <20201103105757.GC6310@zn.tnic> References: <20201029065133.3027749-1-amistry@google.com> <20201029175120.1.Ifd7243cd3e2c2206a893ad0a5b9a4f19549e22c6@changeid> <839fad53-4377-592a-a0da-2cf18b5c6027@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? :-))) Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette