Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp789052imm; Mon, 21 May 2018 14:29:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr+SZ46SnF2aoAEy3eiKUWQmjWvxME8NpBSoN6JgJFkaKMH3LwGbokTsE8Ptha8gJDosGLf X-Received: by 2002:a17:902:462:: with SMTP id 89-v6mr21665125ple.300.1526938164668; Mon, 21 May 2018 14:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526938164; cv=none; d=google.com; s=arc-20160816; b=qna2wnauEw6G1OmqYlRKX1NClw+nbGxvTI42ulzmsvdQybXtAFGJghSy6XEZNEzw7o 0qrtDAB5rhwbtyRcuDNPo0LhQQP7J5V2NlROEQvESpXlpaF3KpjNx2makvsJVb0TmLBL sny3l73tVTWPTqgNEmmRgJcjCHDGqKigXgfTBlR5A2Ugd7jPc59zGSmos/ZOuhzc860h q76SMCNuMhzq/KpYnS3+6mKfKnhmiXDcZKL2Y+ge3oE3AHJ7WLBy4LpzeVEbaTg4nIHr Lpp6QEry4Nieyttq5Il9q7MrqNlzRwgOjbExKxA5USjP0sPPSnk6up3WekJozEzWy1vc 0tjA== 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 :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=SdB80LOi1zfxiv9lbZQm9RNBVhPIbwX5RBpyBPJGzNg=; b=r3lCnW3agz3FaBjk26GT8y2i/BdI7jafD6Vo7mYGnYwtNlHESOQcqFX+B36JZHG6Fp 3v1wlO89cN+bGfV+lxgmdLAMAOwnSaxlzXz5q/k4fs1GYx8Sg4ux0UloUzVcXt5NHhJL rybTIAwoQqinDnrvkgV8d/QbalD+7iatWdmmOYVkN2CehB+sUsJLSmx6NaZA8KFmK4dD zR57fMgjr4miLbzm1LA2o0hf7KoEAcB4IcEd+j2ZIx2aOnfUVS2TYtO4eE1YIEazerF2 b54R2FHkBRvQsPf9uT6VfnNxIDh8CNu0Rl1jUaAmk0gkUoM82r0LU383hCNX4bAuJjlz qgiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BlTEGo9Y; 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 s6-v6si12061769pgr.369.2018.05.21.14.29.09; Mon, 21 May 2018 14:29:24 -0700 (PDT) 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=@kernel.org header.s=default header.b=BlTEGo9Y; 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 S932736AbeEUV1U (ORCPT + 99 others); Mon, 21 May 2018 17:27:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:42034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932684AbeEUV1M (ORCPT ); Mon, 21 May 2018 17:27:12 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EE5C120853; Mon, 21 May 2018 21:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526938032; bh=qIQqhGxzKbOJiPJlhdLRankKFOHDcAxDgVhAnPhtlhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BlTEGo9Ylapo8fcW4sE/IoKIzTLyFor0ag6oYPmCKYgc8Qruu/F5Hkj8S1h0qfnVb 4XAurPgYV9LwHp5JFmQ+DKhFWvAbUGkpp+fyUl5IEX+qB89nXBH/EvXML/VI+hG8Dq zf/Rymz8LgB8+Wau7f0USaFKArP0doYwb82AJswM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Borislav Petkov , Konrad Rzeszutek Wilk Subject: [PATCH 4.16 104/110] x86/bugs: Expose x86_spec_ctrl_base directly Date: Mon, 21 May 2018 23:12:41 +0200 Message-Id: <20180521210514.816126006@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner commit fa8ac4988249c38476f6ad678a4848a736373403 upstream x86_spec_ctrl_base is the system wide default value for the SPEC_CTRL MSR. x86_spec_ctrl_get_default() returns x86_spec_ctrl_base and was intended to prevent modification to that variable. Though the variable is read only after init and globaly visible already. Remove the function and export the variable instead. Signed-off-by: Thomas Gleixner Reviewed-by: Borislav Petkov Reviewed-by: Konrad Rzeszutek Wilk Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/nospec-branch.h | 16 +++++----------- arch/x86/include/asm/spec-ctrl.h | 3 --- arch/x86/kernel/cpu/bugs.c | 11 +---------- 3 files changed, 6 insertions(+), 24 deletions(-) --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -217,16 +217,7 @@ enum spectre_v2_mitigation { SPECTRE_V2_IBRS, }; -/* - * The Intel specification for the SPEC_CTRL MSR requires that we - * preserve any already set reserved bits at boot time (e.g. for - * future additions that this kernel is not currently aware of). - * We then set any additional mitigation bits that we want - * ourselves and always use this as the base for SPEC_CTRL. - * We also use this when handling guest entry/exit as below. - */ extern void x86_spec_ctrl_set(u64); -extern u64 x86_spec_ctrl_get_default(void); /* The Speculative Store Bypass disable variants */ enum ssb_mitigation { @@ -278,6 +269,9 @@ static inline void indirect_branch_predi alternative_msr_write(MSR_IA32_PRED_CMD, val, X86_FEATURE_USE_IBPB); } +/* The Intel SPEC CTRL MSR base value cache */ +extern u64 x86_spec_ctrl_base; + /* * With retpoline, we must use IBRS to restrict branch prediction * before calling into firmware. @@ -286,7 +280,7 @@ static inline void indirect_branch_predi */ #define firmware_restrict_branch_speculation_start() \ do { \ - u64 val = x86_spec_ctrl_get_default() | SPEC_CTRL_IBRS; \ + u64 val = x86_spec_ctrl_base | SPEC_CTRL_IBRS; \ \ preempt_disable(); \ alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \ @@ -295,7 +289,7 @@ do { \ #define firmware_restrict_branch_speculation_end() \ do { \ - u64 val = x86_spec_ctrl_get_default(); \ + u64 val = x86_spec_ctrl_base; \ \ alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \ X86_FEATURE_USE_IBRS_FW); \ --- a/arch/x86/include/asm/spec-ctrl.h +++ b/arch/x86/include/asm/spec-ctrl.h @@ -47,9 +47,6 @@ void x86_spec_ctrl_restore_host(u64 gues extern u64 x86_amd_ls_cfg_base; extern u64 x86_amd_ls_cfg_ssbd_mask; -/* The Intel SPEC CTRL MSR base value cache */ -extern u64 x86_spec_ctrl_base; - static inline u64 ssbd_tif_to_spec_ctrl(u64 tifn) { BUILD_BUG_ON(TIF_SSBD < SPEC_CTRL_SSBD_SHIFT); --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -36,6 +36,7 @@ static void __init ssb_select_mitigation * writes to SPEC_CTRL contain whatever reserved bits have been set. */ u64 __ro_after_init x86_spec_ctrl_base; +EXPORT_SYMBOL_GPL(x86_spec_ctrl_base); /* * The vendor and possibly platform specific bits which can be modified in @@ -141,16 +142,6 @@ void x86_spec_ctrl_set(u64 val) } EXPORT_SYMBOL_GPL(x86_spec_ctrl_set); -u64 x86_spec_ctrl_get_default(void) -{ - u64 msrval = x86_spec_ctrl_base; - - if (static_cpu_has(X86_FEATURE_SPEC_CTRL)) - msrval |= ssbd_tif_to_spec_ctrl(current_thread_info()->flags); - return msrval; -} -EXPORT_SYMBOL_GPL(x86_spec_ctrl_get_default); - void x86_virt_spec_ctrl(u64 guest_spec_ctrl, u64 guest_virt_spec_ctrl, bool setguest) {