Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2956591pxu; Mon, 14 Dec 2020 15:55:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcNt9rjuHVhpCxbnJeMNJIAJ9ckccSbyZrBPi4pZ6BnzT2Lw1RRkIhK/nM3MVkj0lY3EF4 X-Received: by 2002:a17:906:1393:: with SMTP id f19mr24380429ejc.431.1607990111610; Mon, 14 Dec 2020 15:55:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607990111; cv=none; d=google.com; s=arc-20160816; b=cqZO4u9xc3sOd1I5GxVGv0wTQ6iIheo0OYt4A26CUg1FlxNLY257mIDzI5nw0Wqr0b EOy9B6xT3nOa+iOjb6NsbHQsDM7pFzDLcXkwfRD59A4ykpujoGXYgzv2Qika1/wjNhK8 4wxij0KZ5b1soqlnR/55msoWTxjta4i/kksFFZum17zAkcaH4MhRUy1QWHZgF+0jCs5u WotYhXz6C/6hYtAY7oq8N3xWs0mCPsod8Qiok1QB6G8D0jlq/WbaQG1F5LOzJxdtqQWA 95wKZkIZd7T/cywhMxNduLSDeK/bJXZxJfuSTuWeV/fntrmH+hyNRfBuQQs8SZ7x3OSK upAA== 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; bh=6VnB6OfkOKmJRwgH34dvZY7LgIEZrGu/eTIGczy0XLQ=; b=JxmRez7BI2LnbpMZhTcK25lMh3Y1B3+37YFlQNGsQan/QAyDpilArVWlE1q6h7B88x sR2R/b0wZdRRPpwZlVw6Dn+MguyPLfJDDwkOOrdOR1+l3/3DWv/ekG4+N/U01qhFDy34 ik38T6CYnihPR/2ITkeYLiW37LCpf/5/GSZeuvZjm8iGVFCCxp71zpd5tBWD+GFsSJRk cxvoaeveSIloGU5aT3HzefvwXlerjsAcJH9FQ5tZdT2gr+4KZOQbrbjoHCYa/4qRgJef StEo54ciwdKFN8d35ml2sA4CauyjkvCyDzF3Ok4pm+V8akIGTtEPBSVkNfYJPfVwYlfl MW8w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 t22si20487ejb.186.2020.12.14.15.54.48; Mon, 14 Dec 2020 15:55:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502527AbgLNRmT (ORCPT + 99 others); Mon, 14 Dec 2020 12:42:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:50012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502356AbgLNRjK (ORCPT ); Mon, 14 Dec 2020 12:39:10 -0500 From: Greg Kroah-Hartman Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arvind Sankar , Borislav Petkov , Tom Lendacky Subject: [PATCH 5.9 101/105] x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP Date: Mon, 14 Dec 2020 18:29:15 +0100 Message-Id: <20201214172600.147066268@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201214172555.280929671@linuxfoundation.org> References: <20201214172555.280929671@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_identity.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 @@ -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)) --- 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)