Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1406770imu; Tue, 11 Dec 2018 19:39:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/V9vexOkhx5tfXyoip/Q4LGotPykp/x1GcxOJ+o/ByG00B/Nv/0yxjBENSAQR/2pvL5lbbo X-Received: by 2002:a62:c101:: with SMTP id i1mr18756004pfg.80.1544585986896; Tue, 11 Dec 2018 19:39:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544585986; cv=none; d=google.com; s=arc-20160816; b=wRi02YulVLa9Q/ZXTGqud2Xc8aNikFMMx7IdLfAJQXZmLSN/y5b1YnTYeEI4Ca7fiZ FptpjC+Rz3zS7aOMGZeBDmGwECJ9m48ylF49r/spx0IRV2PM3dMHnMbR1m540p/Ig/OV BObgPKF7Y2Zrn52JMHlufoP5WAuSOKdxyGgk3QriBK+nZeLd/STzunX/7e0l4/e3fstl tPJq4qrWzITO7s9UtmX+MTA9OlhpLEcsvJcCoieRg8JPJDEdN1LNSO+itkYc8khEFCaJ /ieYIhj3KFIl24DfVjnC/h9g2UNkZ5i4bJKwY7ihmxLfd7jKNdeg9t0Z1V3/6XLg6TRN ezVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=+AjJRBBovO6FqqRjvQnpne3JoZnvW6kG5Zty2S0pCUw=; b=B6wMcKi9MBlDHvmC+kLaU9QwcaXDkFSTPhbZXRTsJluYv/erkvsclVgzvqzR2py9Bk gmR/VgdWh3D8bdNHo4FYUOPMPhI6sVF2YaoDAtwrXbvKTP7f9pWL9shUskGyygydhAPE PxI0977n8CIYSDvNYnBiez/2SQDEqaVZXdU66ZxjknI0DroEIHKcCs4xO+YFfOpth8HC 80kkz+GNuz97Ezw+AyvJhkwBqozYCOhc+3+WquOjJsvuQL2aK0dbIdzbCcAiEsa3N/XZ cy6Io5mHyg7NMpXiHOUNUDm5fr0G2aWqqgekDEbaZO38sVBbUjMsXYGUd8l9HJXPsh7y mJbA== ARC-Authentication-Results: i=1; mx.google.com; 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 j12si13396751pgq.26.2018.12.11.19.39.31; Tue, 11 Dec 2018 19:39:46 -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; 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 S1726370AbeLLDhr (ORCPT + 99 others); Tue, 11 Dec 2018 22:37:47 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:40962 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbeLLDhr (ORCPT ); Tue, 11 Dec 2018 22:37:47 -0500 Received: from [67.139.178.66] (helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gWvL9-0000II-QL; Wed, 12 Dec 2018 04:37:40 +0100 Date: Tue, 11 Dec 2018 19:37:26 -0800 (PST) From: Thomas Gleixner To: Borislav Petkov cc: "Lendacky, Thomas" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , Andrea Arcangeli , Konrad Rzeszutek Wilk , Jiri Kosina , Ingo Molnar , Tim Chen , David Woodhouse Subject: Re: [PATCH v2] x86/speculation: Add support for STIBP always-on preferred mode In-Reply-To: <20181212000518.GX27375@zn.tnic> Message-ID: References: <20181211224615.5373.65736.stgit@tlendack-t1.amdoffice.net> <20181212000518.GX27375@zn.tnic> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 12 Dec 2018, Borislav Petkov wrote: > On Tue, Dec 11, 2018 at 10:46:16PM +0000, Lendacky, Thomas wrote: > > + /* > > + * At this point, an STIBP mode other than "off" has been set. > > + * If STIBP support is not being forced, check if STIBP always-on > > + * is preferred. > > + */ > > + if (mode != SPECTRE_V2_USER_STRICT && > > + boot_cpu_has(X86_FEATURE_AMD_STIBP_ALWAYS_ON)) { > > + stibp_always_on = true; > > + mode = SPECTRE_V2_USER_STRICT; > > + pr_info("mitigation: STIBP always-on is preferred\n"); > > + } > > + > > /* Initialize Indirect Branch Prediction Barrier */ > > if (boot_cpu_has(X86_FEATURE_IBPB)) { > > setup_force_cpu_cap(X86_FEATURE_USE_IBPB); > > @@ -1088,7 +1102,8 @@ static char *stibp_state(void) > > case SPECTRE_V2_USER_NONE: > > return ", STIBP: disabled"; > > case SPECTRE_V2_USER_STRICT: > > - return ", STIBP: forced"; > > + return stibp_always_on ? ", STIBP: always-on" > > + : ", STIBP: forced"; > > I still don't like that separate stibp_always_on variable when we can do > all the querying just by using mode and X86_FEATURE_AMD_STIBP_ALWAYS_ON. Hmmm. I've not seen the V1 of this (it's not in my inbox) but the v1->v2 changes contain: > > - Removed explicit SPECTRE_V2_USER_STRICT_PREFERRED mode Now I really have to ask why? Neither the extra variable nor the cpu feature check are pretty. An explicit mode is way better in terms of code clarity and you get the proper printout via spectre_v2_user_strings. Hmm? tglx