From mboxrd@z Thu Jan 1 00:00:00 1970 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=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 6E5E2C2D0A3 for ; Tue, 3 Nov 2020 10:58:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBE6C22403 for ; Tue, 3 Nov 2020 10:58:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alien8.de header.i=@alien8.de header.b="I7gx60bF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728125AbgKCK6K (ORCPT ); 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