Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4733176pxu; Thu, 10 Dec 2020 04:16:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxa15mtUSuNVv5iKEe0+HcXZxgTpLLZdxGHmSj7oVRBZYtDuOiA04hmX9oWX2JxCUPqFLXe X-Received: by 2002:a17:907:3e17:: with SMTP id hp23mr6097177ejc.545.1607602615799; Thu, 10 Dec 2020 04:16:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607602615; cv=none; d=google.com; s=arc-20160816; b=sykIg9DlaRIMXQdSHrXjavWey0J+b0H+weBpYp6auK49SBpXd2tPjeaPSaM2NwunDa t9TkyETd6u3+kqXDX2JGelQKpjwt+UV7/vU74tlTuDYlSXrrw4mw0Fus4YqtFJ2Y5mMb NOgivuWMfC8otF6x83ES/pMagWg4mZSBNRL1s/m6ajw0MicBrG6h+rervvjj6av/ORDk as5Gn8vVQGOOid7B1w6p4EjwZPiPUJZh3Cp0+FBzgbnqamKvlWhHJf5hG5YthhvQcQBv DVDku61pBQYy3u1w3N0xQvJ5XpVRyAZi48ZKVrtz0AliVbjC4JvCBokvvfgCafnhQbJM C8RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=y9ZggfT5Wgyj7L/mvbAGMIlzUrXCA6F2CAUaSPt1KRk=; b=ntNIOIzpY9IkKJhocj+07CKKeJkIE215j1sHZ3bsJZGjItEFbucswnavBxZ7gtcSl1 zPIFeIo4OX73BuqdD/L/9sOp5eWU26fdjM8HrSPhJw/GkuolFK36aTUQOkKqetH36hTQ PqxQeIOIEMH+kB+F/8Np7VEBGW4aU0IKI3cKiAAizXs3D5u4FSEKkdzvsnPm6UMVXDVX dyfkhNbU9/flPyF9wVYydnKVcHIjuMHcJ5O72yq/o3uDM08PW1TnaRocvwYHpiaJ7jNi 254jzB3j9WxmSKNvs5BSQ+vazlyra2vRHQDjZxwkDLqloU/pfENkBewzS+nvYj8+ytHV L7hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=sQazjDxR; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q21si2362748ejd.515.2020.12.10.04.16.32; Thu, 10 Dec 2020 04:16:55 -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=@linutronix.de header.s=2020 header.b=sQazjDxR; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388184AbgLJLpH (ORCPT + 99 others); Thu, 10 Dec 2020 06:45:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732885AbgLJLo5 (ORCPT ); Thu, 10 Dec 2020 06:44:57 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D8E8C061793; Thu, 10 Dec 2020 03:44:17 -0800 (PST) Date: Thu, 10 Dec 2020 11:44:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1607600655; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y9ZggfT5Wgyj7L/mvbAGMIlzUrXCA6F2CAUaSPt1KRk=; b=sQazjDxRl4zrmcSkTN6t0Cq12Xf0nBHgnx47vuHxCTeqmrSdzAj4eVCyrXIL1kqHAFbQxy mwDMZoYUVOKSzpcMXUM3i1OTfxbjsf0BEfC6uxoRifFSE4ThVzDF14051AR5zhnvfDRmp6 AZtMaJ/Y3yIqWQUubL+snCbJsoCWtn69IDZauWUeqePnBf0936u7simHU+RUDOe1j6lE7y 9CR0HPKZAD/sWvF999z9HLK1w9slJlt/uq7ggJYbrdS49ELT8ScCihZXwT+IhOU/d15djY 6KWKu0cvEVYmbDQZR3DCIr8wmd/DzqvnrPK0hykcS5g/yWixcnzotcT9dMpaiA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1607600655; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y9ZggfT5Wgyj7L/mvbAGMIlzUrXCA6F2CAUaSPt1KRk=; b=mGis3PyEnW+8c6X7LJ725VABMZEi9+mIMLv7Or+XM/YLh0yp6IFycFmACAY5a4CVHMtVe+ ZJP0vQNp7dlittAg== From: "tip-bot2 for Arvind Sankar" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP Cc: Arvind Sankar , Borislav Petkov , Tom Lendacky , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20201111160946.147341-1-nivedita@alum.mit.edu> References: <20201111160946.147341-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Message-ID: <160760065470.3364.9118672083291010559.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 29ac40cbed2bc06fa218ca25d7f5e280d3d08a25 Gitweb: https://git.kernel.org/tip/29ac40cbed2bc06fa218ca25d7f5e280d3d08a25 Author: Arvind Sankar AuthorDate: Wed, 11 Nov 2020 11:09:45 -05:00 Committer: Borislav Petkov CommitterDate: Thu, 10 Dec 2020 12:28:06 +01:00 x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP 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 --- arch/x86/include/asm/pgtable_types.h | 1 + arch/x86/mm/mem_encrypt_identity.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index 816b31c..394757e 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -155,6 +155,7 @@ enum page_cache_mode { #define _PAGE_ENC (_AT(pteval_t, sme_me_mask)) #define _PAGE_CACHE_MASK (_PAGE_PWT | _PAGE_PCD | _PAGE_PAT) +#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)) diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c index 733b983..6c5eb6f 100644 --- a/arch/x86/mm/mem_encrypt_identity.c +++ b/arch/x86/mm/mem_encrypt_identity.c @@ -45,8 +45,8 @@ #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)