Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1111553imw; Thu, 14 Jul 2022 17:54:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uVz7C8ppFptuTs7rLexLp2cPxIqhnRYrtYgr2t3J58hyXyfrIe80EJic30uJAbYSA9Rg/0 X-Received: by 2002:a17:907:2cf2:b0:72b:4a01:e8bb with SMTP id hz18-20020a1709072cf200b0072b4a01e8bbmr11304531ejc.673.1657846457027; Thu, 14 Jul 2022 17:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657846457; cv=none; d=google.com; s=arc-20160816; b=OL6Z5KLkR/J48Kz1en7gc+u3EV5CbsiXhABvloT5kMoic8qnLeSTOHFAlaDSLNwHz6 UDyOg5ZELo3lJC2KhdT7gTPZQMoPtmyFMJkQ1GIkNbV92KQO3K5ZbuVvKtMjC+pV58za eu7NuqYMHpAgNMNCfqaE7yanishtHYCa/o2SfK5Txkc4db90K0uQho82AjEKAC/A9xUL 6s7GQ4azsHN2Sbf8uwo+edsXl28s/SRn0tcLYmZrEN6RVirB7Gev5+bEp/QVADRWgOv/ AsoNJzgQuM8IWB0r26ZKclcc9K7VB0XaYSDfd59A2x3r6lTKJhg0uqKQCNoSBapdy1Ni a5TQ== 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=YwXi59IygxdnRKMz2x3Yekg/0Hgu8GZDs/DudlkeAn8=; b=tcIh/0d/rOAEoxAaKt+79/qYI5uu1PN/uMMSbmdueOyohUwhoNf/rj207uZ9jUoiLA NuF6GSIWd4CIzN/zhf5nk0r1Vijj1s2YUHQNvJzI3G+skkoTPl348coUCHsANBaf4sFy RD811OuwpPJRPcRXcDtQ+4l2ehTnK6YIdTfyShEp5JI8+0U3AP7KMtVjWaCdf+4Go0p2 5t7XVRGcehBG+fU4jHLVv/xHYQSi6dXHK6FbR1gt/ps2BKUe9L0ezg6TvrbKiSKh+G1r CwP8uc/LF8wtcTkcjUTj4IrzzFH0sc8+9wd5OPQYN2FUOU8MUJOdJuYMwON3ahg0HktP 14rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=DGMSldO0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020a1709063a8700b0072b13aacd47si4034401ejd.194.2022.07.14.17.53.31; Thu, 14 Jul 2022 17:54:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=DGMSldO0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241112AbiGOALd (ORCPT + 99 others); Thu, 14 Jul 2022 20:11:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232915AbiGOALb (ORCPT ); Thu, 14 Jul 2022 20:11:31 -0400 Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E0768725; Thu, 14 Jul 2022 17:11:30 -0700 (PDT) Received: from quatroqueijos (unknown [177.9.88.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 7229F3F389; Fri, 15 Jul 2022 00:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1657843886; bh=YwXi59IygxdnRKMz2x3Yekg/0Hgu8GZDs/DudlkeAn8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=DGMSldO0TMibI6Pbq2iTV3lmzZb5c+KEg1Avm05inreTZlkE9gBElpTAH54/307Hk o1gYtcZxZS7RLj6CS+PKe4bjZ56pZYmPqus7tOmUEItB0uwoIWp6rDJ5TjUeJ9+sDx mtFecqweUrQ1euhnDu/acRPTxwRMd2BJ1yNTLKXvqrXKSroNoMHggIj9nvI2BIyD4a K5WCGzPt3jPER4/lEvWnx7f7p8JTc1rj1/K3mbzBsxC/KeDRT35xwKhGQsztkZ+QN6 z512dm/JXBdSQCNTx8xUpdRvyr0zIl+nG46R8bgWWyHmbbc84EqXKSHix+j2HJqflo kduHdqU8a+dGw== Date: Thu, 14 Jul 2022 21:11:18 -0300 From: Thadeu Lima de Souza Cascardo To: Pawan Gupta Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Daniel Sneddon , antonio.gomez.iglesias@linux.intel.com, Josh Poimboeuf Subject: Re: [PATCH v2] x86/bugs: Warn when "ibrs" mitigation is selected on Enhanced IBRS parts Message-ID: References: <0456b35fb9ef957d9a9138e0913fb1a3fd445dff.1657747493.git.pawan.kumar.gupta@linux.intel.com> <2a5eaf54583c2bfe0edc4fea64006656256cca17.1657814857.git.pawan.kumar.gupta@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2a5eaf54583c2bfe0edc4fea64006656256cca17.1657814857.git.pawan.kumar.gupta@linux.intel.com> X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 14, 2022 at 04:15:35PM -0700, Pawan Gupta wrote: > IBRS mitigation for spectre_v2 forces write to MSR_IA32_SPEC_CTRL at > every kernel entry/exit. On Enhanced IBRS parts setting > MSR_IA32_SPEC_CTRL[IBRS] only once at boot is sufficient. MSR writes at > every kernel entry/exit incur unnecessary performance loss. > > When Enhanced IBRS feature is present, print a warning about this > unnecessary performance loss. > > Signed-off-by: Pawan Gupta Reviewed-by: Thadeu Lima de Souza Cascardo > --- > v1->v2: Instead of changing the mitigation, print a warning about the > perf loss. > > v1: https://lore.kernel.org/lkml/0456b35fb9ef957d9a9138e0913fb1a3fd445dff.1657747493.git.pawan.kumar.gupta@linux.intel.com/ > > arch/x86/kernel/cpu/bugs.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > index 0dd04713434b..1c54fad3c54b 100644 > --- a/arch/x86/kernel/cpu/bugs.c > +++ b/arch/x86/kernel/cpu/bugs.c > @@ -975,6 +975,7 @@ static inline const char *spectre_v2_module_string(void) { return ""; } > #define SPECTRE_V2_LFENCE_MSG "WARNING: LFENCE mitigation is not recommended for this CPU, data leaks possible!\n" > #define SPECTRE_V2_EIBRS_EBPF_MSG "WARNING: Unprivileged eBPF is enabled with eIBRS on, data leaks possible via Spectre v2 BHB attacks!\n" > #define SPECTRE_V2_EIBRS_LFENCE_EBPF_SMT_MSG "WARNING: Unprivileged eBPF is enabled with eIBRS+LFENCE mitigation and SMT, data leaks possible via Spectre v2 BHB attacks!\n" > +#define SPECTRE_V2_IBRS_PERF_MSG "WARNING: IBRS mitigation selected on Enhanced IBRS CPU, this may cause unnecessary performance loss\n" > > #ifdef CONFIG_BPF_SYSCALL > void unpriv_ebpf_notify(int new_state) > @@ -1415,6 +1416,8 @@ static void __init spectre_v2_select_mitigation(void) > > case SPECTRE_V2_IBRS: > setup_force_cpu_cap(X86_FEATURE_KERNEL_IBRS); > + if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) > + pr_warn(SPECTRE_V2_IBRS_PERF_MSG); > break; > > case SPECTRE_V2_LFENCE: > > base-commit: 4a57a8400075bc5287c5c877702c68aeae2a033d > -- > 2.35.3 > >