Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp27749imu; Fri, 14 Dec 2018 12:52:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/UjmCuHyWfhPK+VPJcnBMZpynBTGUYAqXbjkpHg0xqQ/jd2hQLqxxhWrIvNga9w7nG47POb X-Received: by 2002:a62:2082:: with SMTP id m2mr4121216pfj.163.1544820744633; Fri, 14 Dec 2018 12:52:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544820744; cv=none; d=google.com; s=arc-20160816; b=rdkpv1YqW/ReuU7jBd55DyRV+TkQvldttb7dzVWKOzOmWSnbVq2qlfCVOTIq/pcg65 Zc6W9Gs/yksUlfiuEiCJNVlfkREdpfTCv5ETe6qLDYP+eUbFdvp08P+28dK0mBZydHZf gZTpSdljn6Vs982Kqc4Y5F7q4Lha7abKbNmR1FOcD+Dj5gne2COrPfguFT/XjXRSd7sn BxxCv7XqtCxPBl5h7gDFSVCLNkP9Ar78sJEKV1cDokRugNzC5GZd///qhb4XpISPJbcW DgwEB6T0gGAYb6MF6YopJt62JEi/uLKDTrEwM9iiD82l1vWVXwuyUN2S/toAA+23YwzV XTAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sLnbk5UGQnKmWHIISghc80ciweUo0kju6QHbwoEfotE=; b=kE8oVSmZBIZGW2iR1C2LlV3cdIr/APCpJ017tB8x9tu+HMsRF6vinZJDG0Tycv5mtE WGpcMEFanYYL3CWRLqF8sjySh05jpUzztaB4EkFVbmqSBnxHLBa836EXbR7tBn5spMKv TsLoE+IDJcuY0aPW1kry9GU/zucPoUU9AR0aV68H4CqM2kpZpq7H9NiR77Q4+B+uUfLI 6c0evIujECCd7XVutQImCCLpka5+DrTNPdX/wZZ6QMWsYNQBs/kW76X8BRnWXdr25fs+ ur1mAT13Tuv9V1DTSuxp7bGtGfTZHmgpYRvX1gyMf0bUlwUxBTWNb/HVHbWRmuDtPHor RuTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=Owk5wntK; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si4571375plt.273.2018.12.14.12.52.09; Fri, 14 Dec 2018 12:52:24 -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; dkim=pass header.i=@alien8.de header.s=dkim header.b=Owk5wntK; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731124AbeLNUud (ORCPT + 99 others); Fri, 14 Dec 2018 15:50:33 -0500 Received: from mail.skyhub.de ([5.9.137.197]:33900 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730822AbeLNUud (ORCPT ); Fri, 14 Dec 2018 15:50:33 -0500 Received: from zn.tnic (p200300EC2BCFEF006DA1B19390C695FF.dip0.t-ipconnect.de [IPv6:2003:ec:2bcf:ef00:6da1:b193:90c6:95ff]) (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 C9AAF1EC0BE1; Fri, 14 Dec 2018 21:50:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1544820632; 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=sLnbk5UGQnKmWHIISghc80ciweUo0kju6QHbwoEfotE=; b=Owk5wntK+DA3ithE9IyYxxSU8kXE6ZvsoXkKZ+dROF9BAB2mIXXOq2JDq28LjALzamCTFv l5W4BFDykfiGJ8euDFFLR6e10Za/O6tHqBusryU8pMOE87N7Q1+gKdknUBUjMIRfIyeBOF by6M1WHKJXvLzvwacypDMd0Wle5fQeE= Date: Fri, 14 Dec 2018 21:50:23 +0100 From: Borislav Petkov To: "Lendacky, Thomas" Cc: "x86@kernel.org" , "linux-kernel@vger.kernel.org" , Andrea Arcangeli , Konrad Rzeszutek Wilk , Jiri Kosina , Ingo Molnar , Thomas Gleixner , Tim Chen , David Woodhouse Subject: Re: [PATCH v3] x86/speculation: Add support for STIBP always-on preferred mode Message-ID: <20181214205023.GJ11710@zn.tnic> References: <20181213230352.6937.74943.stgit@tlendack-t1.amdoffice.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181213230352.6937.74943.stgit@tlendack-t1.amdoffice.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 13, 2018 at 11:03:54PM +0000, Lendacky, Thomas wrote: > Different AMD processors may have different implementations of STIBP. > When STIBP is conditionally enabled, some implementations would benefit > from having STIBP always on instead of toggling the STIBP bit through MSR > writes. This preference is advertised through a CPUID feature bit. > > When conditional STIBP support is requested at boot and the CPU advertises > STIBP always-on mode as preferred, switch to STIBP "on" support. To show > that this transition has occurred, create a new spectre_v2_user_mitigation > value and a new spectre_v2_user_strings message. The new mitigation value > is used in spectre_v2_user_select_mitigation() to print the new mitigation > message as well as to return a new string from stibp_state(). > > Signed-off-by: Tom Lendacky > --- > > This patch is against the x86/pti branch of the tip tree: > git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/pti > > Changes from v2: > - Reverted back to original version of the patch > - Updated the messages that are issued. I'm not terribly happy with the > wording, so if there are any suggestions... > > Changes from v1: > - Removed explicit SPECTRE_V2_USER_STRICT_PREFERRED mode > - Added a message when switching to always-on mode > - Set and used a static boolean for the string in stibp_state() > > arch/x86/include/asm/cpufeatures.h | 1 + > arch/x86/include/asm/nospec-branch.h | 1 + > arch/x86/kernel/cpu/bugs.c | 28 ++++++++++++++++++++++------ > 3 files changed, 24 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h > index 28c4a50..df8e94e2 100644 > --- a/arch/x86/include/asm/cpufeatures.h > +++ b/arch/x86/include/asm/cpufeatures.h > @@ -284,6 +284,7 @@ > #define X86_FEATURE_AMD_IBPB (13*32+12) /* "" Indirect Branch Prediction Barrier */ > #define X86_FEATURE_AMD_IBRS (13*32+14) /* "" Indirect Branch Restricted Speculation */ > #define X86_FEATURE_AMD_STIBP (13*32+15) /* "" Single Thread Indirect Branch Predictors */ > +#define X86_FEATURE_AMD_STIBP_ALWAYS_ON (13*32+17) /* "" Single Thread Indirect Branch Predictors always-on preferred */ > #define X86_FEATURE_AMD_SSBD (13*32+24) /* "" Speculative Store Bypass Disable */ > #define X86_FEATURE_VIRT_SSBD (13*32+25) /* Virtualized Speculative Store Bypass Disable */ > #define X86_FEATURE_AMD_SSB_NO (13*32+26) /* "" Speculative Store Bypass is fixed in hardware. */ > diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h > index 032b600..dad12b7 100644 > --- a/arch/x86/include/asm/nospec-branch.h > +++ b/arch/x86/include/asm/nospec-branch.h > @@ -232,6 +232,7 @@ enum spectre_v2_mitigation { > enum spectre_v2_user_mitigation { > SPECTRE_V2_USER_NONE, > SPECTRE_V2_USER_STRICT, > + SPECTRE_V2_USER_STRICT_PREFERRED, > SPECTRE_V2_USER_PRCTL, > SPECTRE_V2_USER_SECCOMP, > }; > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > index 58689ac..77bf225 100644 > --- a/arch/x86/kernel/cpu/bugs.c > +++ b/arch/x86/kernel/cpu/bugs.c > @@ -262,10 +262,11 @@ enum spectre_v2_user_cmd { > }; > > static const char * const spectre_v2_user_strings[] = { > - [SPECTRE_V2_USER_NONE] = "User space: Vulnerable", > - [SPECTRE_V2_USER_STRICT] = "User space: Mitigation: STIBP protection", > - [SPECTRE_V2_USER_PRCTL] = "User space: Mitigation: STIBP via prctl", > - [SPECTRE_V2_USER_SECCOMP] = "User space: Mitigation: STIBP via seccomp and prctl", > + [SPECTRE_V2_USER_NONE] = "User space: Vulnerable", > + [SPECTRE_V2_USER_STRICT] = "User space: Mitigation: STIBP protection", > + [SPECTRE_V2_USER_STRICT_PREFERRED] = "User space: Mitigation: STIBP always-on protection", Barring the "preferred" vs "always-on" bikeshed controversy :-P, I don't see anything wrong with this version. The only thing that could be improved maybe is having the mode name and the user visible string match for ease of code staring during bug hunting... -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.