Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9176559pxu; Mon, 28 Dec 2020 08:29:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyN4x2p/xz/TBV1Pi75LOhppFU8AgRob6F5+Ex40zEbS32umhAq7YXADsnPqcnA2yVe+wWG X-Received: by 2002:a17:906:5fc9:: with SMTP id k9mr41143697ejv.70.1609172948240; Mon, 28 Dec 2020 08:29:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609172948; cv=none; d=google.com; s=arc-20160816; b=Gjcm8BhWf+ghiciZvLO6Uam51ms1eX4aKGI2RxbJUtNdpHfydVvegazOrlFnrgZcSy QkeeI3ZgwFZMU8IuOAL7KRM20cGJHLPlJ+C6na8fGz8oxfTmttKdkV09jv84w6LOV9ik TVHA8FJAxKO8mqSjr9HRPchDhnh6jSeVJ0FVD5VponOszv31n5S7YIJ7PPL6lPz/3NxP NFZC9Qf40MIegTKkjcBlP3YiJM4YQQLcIGvF7okJ1KhJAKRU5g6sgW7RcmyRNfP4sqkC LJPYgdIySR6zXM04Ou6sgC35Z9lnzDsWu6/u2LRA/lgC3JvvbsL073CxTg+aHIn1XDkV oD2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H07x42hNYleB3sVFPYSQT4N4ethqy/LNQ1w3GAijico=; b=NWFRxNrWxnAyRpKUV29Z1tZbfnKL0X/KYJwdIuNvbuwCTfgdE6Iwo7FIX3tBQZT2tA s1b61oduUICts7qFoivAaQfcjgLoTQKp0DC9nzlk2pH7bN242T6gMSWaCLSyTaFiOJfA GTnbkwWiJ0oKBSl8V8LNlMQuCzvW6UX2DPvss+woLCFNllu4eJK454MKrIgP6RCUJpX2 xKZ9BDmtROhkkrxBpsECLhhFcbbXd1PlXFzVB/VD/mWWGxJjs2HWes5H6/Vdj5ecZc6W RNPvJJEfezayXzRhGcEqrBvXwljktnpNzHkjeLI6xO9zciWIWiYbcffi5ly7wChTMHUP X2gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QsuW50L1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gz21si19218152ejb.604.2020.12.28.08.28.45; Mon, 28 Dec 2020 08:29:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QsuW50L1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731155AbgL1QZY (ORCPT + 99 others); Mon, 28 Dec 2020 11:25:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:37396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729566AbgL1NJj (ORCPT ); Mon, 28 Dec 2020 08:09:39 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CF3FF2076D; Mon, 28 Dec 2020 13:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160938; bh=jlEoGlvam1dqY/S4LvxCZltUWdzE35GaNWLiSc1IZGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QsuW50L1PF+T6Jzaw+/OguA3E/UleUobvvvCaJJP3hzDawtRRCDulVb6zMlnn2DiR zkcGbWAwCybVqSv5QmLW2FMmLlVIyKGcurvYL3n50SgxOBVp3jNDtzK+wNLsV6hhb5 hk+PVNmfjN04/X0WoeCtiQnIovVEI+v1AySVi/Kg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arvind Sankar , Borislav Petkov , Tom Lendacky Subject: [PATCH 4.14 015/242] x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP Date: Mon, 28 Dec 2020 13:47:00 +0100 Message-Id: <20201228124905.415751134@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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: Arvind Sankar commit 29ac40cbed2bc06fa218ca25d7f5e280d3d08a25 upstream. The PAT bit is in different locations for 4k and 2M/1G page table entries. Add a definition for _PAGE_LARGE_CACHE_MASK to represent the three caching bits (PWT, PCD, PAT), similar to _PAGE_CACHE_MASK for 4k pages, and use it in the definition of PMD_FLAGS_DEC_WP to get the correct PAT index for write-protected pages. Fixes: 6ebcb060713f ("x86/mm: Add support to encrypt the kernel in-place") Signed-off-by: Arvind Sankar Signed-off-by: Borislav Petkov Tested-by: Tom Lendacky Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20201111160946.147341-1-nivedita@alum.mit.edu Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/pgtable_types.h | 1 + arch/x86/mm/mem_encrypt.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -148,6 +148,7 @@ enum page_cache_mode { #endif #define _PAGE_CACHE_MASK (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT) +#define _PAGE_LARGE_CACHE_MASK (_PAGE_PWT | _PAGE_PCD | _PAGE_PAT_LARGE) #define _PAGE_NOCACHE (cachemode2protval(_PAGE_CACHE_MODE_UC)) #define _PAGE_CACHE_WP (cachemode2protval(_PAGE_CACHE_MODE_WP)) --- a/arch/x86/mm/mem_encrypt.c +++ b/arch/x86/mm/mem_encrypt.c @@ -248,8 +248,8 @@ static void __init sme_clear_pgd(struct #define PMD_FLAGS_LARGE (__PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL) #define PMD_FLAGS_DEC PMD_FLAGS_LARGE -#define PMD_FLAGS_DEC_WP ((PMD_FLAGS_DEC & ~_PAGE_CACHE_MASK) | \ - (_PAGE_PAT | _PAGE_PWT)) +#define PMD_FLAGS_DEC_WP ((PMD_FLAGS_DEC & ~_PAGE_LARGE_CACHE_MASK) | \ + (_PAGE_PAT_LARGE | _PAGE_PWT)) #define PMD_FLAGS_ENC (PMD_FLAGS_LARGE | _PAGE_ENC)