Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5770533imm; Mon, 23 Jul 2018 05:54:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfY6oem2/0o931+qKTZxhw0QPgeLQ/dURw3JpHFxH74s5CmFWcSLghyeHD01SVoX/cs1Fhg X-Received: by 2002:a17:902:3a3:: with SMTP id d32-v6mr12870117pld.294.1532350490147; Mon, 23 Jul 2018 05:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532350490; cv=none; d=google.com; s=arc-20160816; b=sW2HJjdyoFM3eKavbsX7FSog7IkUd3fVve9KqHAyWR13FYlu6ff/Vtaw8MP8b1stwP Bct7KbUUQLCbO5XvnPTt35283gOelIQd4w1fG3eklwzZxksGqOxyQ7QWtjb69dujPKTs VVAZot4mu0TLRmBQsOUpleaMQZwsgoLuheBEpb1Gru03zHoetDrMyW3tXEaes0XSCTaf lk24BeSmSFt4vLUrS0sdRUdzmJOHeJz5OrXLFF7GNHqwmd1cCJ66nLskCsKb2vdZkcif 1xursfslXFOjR5i53dV2NjQyyzTEcgIgnmgddnEr4euXScGr7dqBeS4zTMyxhRN45j5M wvQw== 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 :arc-authentication-results; bh=QjerbGhTL+CRpNzwf3C2eg9FfRR+atPNbVbyE/AOBWA=; b=sId4QKbWjGtBJdcJgEP2jsy0t5e+zp4575uDW+lTkUz+0DueA/HieAbnfT9r0p9W96 +4IXWmkHovNpVDK7RGHnFeOqQBPinSJsXGCOwM80RH/CF+zKSIkARqY+GPaiONRAwkAb e0LHMg1tVUFCVZdVHg6FxtAz0/VgKAYKRMscnNPGQknoKxdBG71palNTeNUpS8OqvRpl t7t0T4IGzb4U5lJJVFzmvLD5uyINRB4cd0qN9P9gsCJFJ6ZJMv4JbtNRcWofGTWs5YL8 mpGul7bxScUfxw1xSXqXTrGgyf9a5UDHD8tItvHb3f2OTPfr5rIYe08cRvtMZy4w0rpJ 5HpQ== 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 o81-v6si8671178pfj.350.2018.07.23.05.54.35; Mon, 23 Jul 2018 05:54:50 -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; 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 S2388805AbeGWNx6 (ORCPT + 99 others); Mon, 23 Jul 2018 09:53:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50966 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389014AbeGWNrm (ORCPT ); Mon, 23 Jul 2018 09:47:42 -0400 Received: from localhost (LFbn-1-12238-233.w90-92.abo.wanadoo.fr [90.92.53.233]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 18F14BDB; Mon, 23 Jul 2018 12:45:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konrad Rzeszutek Wilk , Thomas Gleixner , Ingo Molnar , David Woodhouse , "Srivatsa S. Bhat" , "Matt Helsley (VMware)" , Alexey Makhalov , Bo Gan Subject: [PATCH 4.4 059/107] x86/bugs: Whitelist allowed SPEC_CTRL MSR values Date: Mon, 23 Jul 2018 14:41:53 +0200 Message-Id: <20180723122415.994188681@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723122413.003644357@linuxfoundation.org> References: <20180723122413.003644357@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Konrad Rzeszutek Wilk commit 1115a859f33276fe8afb31c60cf9d8e657872558 upstream Intel and AMD SPEC_CTRL (0x48) MSR semantics may differ in the future (or in fact use different MSRs for the same functionality). As such a run-time mechanism is required to whitelist the appropriate MSR values. [ tglx: Made the variable __ro_after_init ] [ Srivatsa: Removed __ro_after_init for 4.4.y ] Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Thomas Gleixner Reviewed-by: Ingo Molnar Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman Signed-off-by: Srivatsa S. Bhat Reviewed-by: Matt Helsley (VMware) Reviewed-by: Alexey Makhalov Reviewed-by: Bo Gan Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/bugs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -34,6 +34,12 @@ static void __init ssb_select_mitigation */ static u64 x86_spec_ctrl_base; +/* + * The vendor and possibly platform specific bits which can be modified in + * x86_spec_ctrl_base. + */ +static u64 x86_spec_ctrl_mask = ~SPEC_CTRL_IBRS; + void __init check_bugs(void) { identify_boot_cpu(); @@ -116,7 +122,7 @@ static enum spectre_v2_mitigation spectr void x86_spec_ctrl_set(u64 val) { - if (val & ~(SPEC_CTRL_IBRS | SPEC_CTRL_RDS)) + if (val & x86_spec_ctrl_mask) WARN_ONCE(1, "SPEC_CTRL MSR value 0x%16llx is unknown.\n", val); else wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base | val); @@ -458,6 +464,7 @@ static enum ssb_mitigation_cmd __init __ switch (boot_cpu_data.x86_vendor) { case X86_VENDOR_INTEL: x86_spec_ctrl_base |= SPEC_CTRL_RDS; + x86_spec_ctrl_mask &= ~SPEC_CTRL_RDS; x86_spec_ctrl_set(SPEC_CTRL_RDS); break; case X86_VENDOR_AMD: @@ -481,7 +488,7 @@ static void ssb_select_mitigation() void x86_spec_ctrl_setup_ap(void) { if (boot_cpu_has(X86_FEATURE_IBRS)) - x86_spec_ctrl_set(x86_spec_ctrl_base & (SPEC_CTRL_IBRS | SPEC_CTRL_RDS)); + x86_spec_ctrl_set(x86_spec_ctrl_base & ~x86_spec_ctrl_mask); } #ifdef CONFIG_SYSFS