From patchwork Wed Jan 22 09:27:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 233430 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.7 required=3.0 tests=DATE_IN_PAST_03_06, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86062C2D0DB for ; Wed, 22 Jan 2020 13:19:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5C5F72468D for ; Wed, 22 Jan 2020 13:19:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699183; bh=4mZaHo6CGGEjhoLAyszHVHx7u6Ppbk9GFGCtN7ajr8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=DIVAKAk6GNYPsNS9ajN9uWJj53XjHlZUpXYNQctb/OGgFdXCGSgr4qqZGvUekjn1y 81MSXNLAdAugkjCPNdf5JIspsUHb5AOdxOfpDhw+PhBkC2T8wprqo7qWd1cByMiiZl sZqEJarhC8sIFwrw09xmvsZnRECZbCYlAYBlAz0E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729746AbgAVNTi (ORCPT ); Wed, 22 Jan 2020 08:19:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:35606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729732AbgAVNTh (ORCPT ); Wed, 22 Jan 2020 08:19:37 -0500 Received: from localhost (unknown [84.241.205.26]) (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 CFA0324685; Wed, 22 Jan 2020 13:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699177; bh=4mZaHo6CGGEjhoLAyszHVHx7u6Ppbk9GFGCtN7ajr8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0PhzQ381w7pDeE3XHyMn3qRghTCqr/VroqC3Dl7czhNl+ox+QRa4JIC8Virti+JZ BcxgffppOVG1GDwOCWpKUXcc1kZdUYfsuA6UWMdA5mv8vs+2d+x3ymKmUkqzn6WBnj KPJLG6i9YkWgztpMcU/V9ymNhdvsi6WoSrd7lKSk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Lendacky , Borislav Petkov Subject: [PATCH 5.4 063/222] x86/CPU/AMD: Ensure clearing of SME/SEV features is maintained Date: Wed, 22 Jan 2020 10:27:29 +0100 Message-Id: <20200122092838.232080512@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tom Lendacky commit a006483b2f97af685f0e60f3a547c9ad4c9b9e94 upstream. If the SME and SEV features are present via CPUID, but memory encryption support is not enabled (MSR 0xC001_0010[23]), the feature flags are cleared using clear_cpu_cap(). However, if get_cpu_cap() is later called, these feature flags will be reset back to present, which is not desired. Change from using clear_cpu_cap() to setup_clear_cpu_cap() so that the clearing of the flags is maintained. Signed-off-by: Tom Lendacky Signed-off-by: Borislav Petkov Cc: # 4.16.x- Link: https://lkml.kernel.org/r/226de90a703c3c0be5a49565047905ac4e94e8f3.1579125915.git.thomas.lendacky@amd.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/amd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -615,9 +615,9 @@ static void early_detect_mem_encrypt(str return; clear_all: - clear_cpu_cap(c, X86_FEATURE_SME); + setup_clear_cpu_cap(X86_FEATURE_SME); clear_sev: - clear_cpu_cap(c, X86_FEATURE_SEV); + setup_clear_cpu_cap(X86_FEATURE_SEV); } }