From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62B1DC4167D for ; Thu, 14 Apr 2022 15:20:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347697AbiDNPVL (ORCPT ); Thu, 14 Apr 2022 11:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347656AbiDNN7Z (ORCPT ); Thu, 14 Apr 2022 09:59:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D05852C133; Thu, 14 Apr 2022 06:50:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 466F161D29; Thu, 14 Apr 2022 13:50:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 520EDC385A1; Thu, 14 Apr 2022 13:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649944257; bh=8Em6gnynSwZ+m85AZOR86oda43s0fWVKJiuwZvfVBMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u/0yKewdnzUqaSErn2cakDte95LE4cSVsxtjJbbxIwWp1LOZt/f0xqqRBhaJQyqeg WsnOqET3ABUJRo1wQ7N2jP+JPlbBMjq6XelfCWCyfVzlt/Og8UCzBmTvj49WRLCtjN cmvBcSIMYrfXvRdA/HAf1gs37DdYikqVHElnRRK4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Neelima Krishnan , Pawan Gupta , Borislav Petkov , Dave Hansen , Linus Torvalds Subject: [PATCH 5.4 451/475] x86/speculation: Restore speculation related MSRs during S3 resume Date: Thu, 14 Apr 2022 15:13:56 +0200 Message-Id: <20220414110907.680264423@linuxfoundation.org> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220414110855.141582785@linuxfoundation.org> References: <20220414110855.141582785@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pawan Gupta commit e2a1256b17b16f9b9adf1b6fea56819e7b68e463 upstream. After resuming from suspend-to-RAM, the MSRs that control CPU's speculative execution behavior are not being restored on the boot CPU. These MSRs are used to mitigate speculative execution vulnerabilities. Not restoring them correctly may leave the CPU vulnerable. Secondary CPU's MSRs are correctly being restored at S3 resume by identify_secondary_cpu(). During S3 resume, restore these MSRs for boot CPU when restoring its processor state. Fixes: 772439717dbf ("x86/bugs/intel: Set proper CPU features and setup RDS") Reported-by: Neelima Krishnan Signed-off-by: Pawan Gupta Tested-by: Neelima Krishnan Acked-by: Borislav Petkov Reviewed-by: Dave Hansen Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- arch/x86/power/cpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/arch/x86/power/cpu.c +++ b/arch/x86/power/cpu.c @@ -512,10 +512,24 @@ static int pm_cpu_check(const struct x86 return ret; } +static void pm_save_spec_msr(void) +{ + u32 spec_msr_id[] = { + MSR_IA32_SPEC_CTRL, + MSR_IA32_TSX_CTRL, + MSR_TSX_FORCE_ABORT, + MSR_IA32_MCU_OPT_CTRL, + MSR_AMD64_LS_CFG, + }; + + msr_build_context(spec_msr_id, ARRAY_SIZE(spec_msr_id)); +} + static int pm_check_save_msr(void) { dmi_check_system(msr_save_dmi_table); pm_cpu_check(msr_save_cpu_table); + pm_save_spec_msr(); return 0; }