Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp472525pxb; Wed, 11 Nov 2020 08:12:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJztVdF0dwNpnBj17aLpE/3NbjQg4Q94WyiNlfbn4d//TsNcfQqUH7Kd3QMvbNuXZo2s1Bmp X-Received: by 2002:a05:6402:370:: with SMTP id s16mr174308edw.50.1605111150530; Wed, 11 Nov 2020 08:12:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605111150; cv=none; d=google.com; s=arc-20160816; b=AT+OH6d0VUz7To/Pi1Q0DMWOpVK6/UsS/dtZ5BvRcSL6Df9sJIVS11h/cZVq+sQg/N n8hPGuSr9xeZ0e3FZMh6id8DD/76usKOKbJd6ix2kyki7BGhHt446qKdhsWJR/slauCR ZuaLqpds0yolJS4PjMqnI8lAqrFGHUo2ZgcEOyLTPT070gEky+nB9dfyZ3ux1gKBoXLB Lb9vFSf0ybvgm1MkonFbdbPVaQ63LO9Odj3Zf21TIEinmzfLF7Odm/pPA+NdtjZZ/XWt v1Kkttw0BzmsUgJKHNy6SM7M89ZriPycBXhyh1Qteb/MOSHQ708/3wHnuJ2L7iY3yqJi 0jEg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rhNBtKMLkmOYknLswvSNLsfkudWIW4FsRnAgJTp7U74=; b=rNJKhvomQ8sxvg54mL1e7NZMqGcY9TVh62pjv2F71F+kqji54rxEsbZTpkfD99Tj44 8K+lI6e5yTQbh8mVoQJrRYQk1PAkLlFmJHavME4c2oqubVbPWsVz6KzbY6HMaz2R4abQ He3tvtD0EpKBRmOsJqBqaHttadl7td+RuGGhlAVebEjUQyzZUS+Kd4E/qzDb/L9HLA/0 XC/T5WJpSzGCAxZ9l0meRf3ZQJhadrvWCzpKRMAShUoJiN/6J4OFcOn+/5Wh7Eamwizk PBRk3nRT9D7fEZGdjhiwRNsqXZlR9jSp2Z8ADvXg7bapkCpqANzymzXMPKYkV5Mt0Hdf ZvmA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s8si2026247edh.227.2020.11.11.08.11.58; Wed, 11 Nov 2020 08:12:30 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726664AbgKKQJy (ORCPT + 99 others); Wed, 11 Nov 2020 11:09:54 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:33724 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726900AbgKKQJt (ORCPT ); Wed, 11 Nov 2020 11:09:49 -0500 Received: by mail-qk1-f196.google.com with SMTP id l2so2166807qkf.0; Wed, 11 Nov 2020 08:09:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rhNBtKMLkmOYknLswvSNLsfkudWIW4FsRnAgJTp7U74=; b=poT5Jn4Z0hBZuSqufkTl2E9ZxpGdb3aUdpI8dcFJY3PbdAmeSwCjg0Ec3Rjrud/znT YfKPNZAI4OZkzM15eG5C9KUk9SwcMXqPpCX3lMg3O9Z31lpzUbIdXQAWuHEQMYkjuV/W MTDx4UppXgyceFgvqQiUJDcXc+7cgZPsaoaWtz5GbC381qvw3oh0+iYp4A18/7NfJonb Y2+TczkVcXnseh3OeNf+x/sIqwf1VBMMwQ2p70l61MphO/blBPdmGgALjGri7DPU7TcC UAeXrfx+QvjR8Lem92SIX3Wa5VoMa45obyE/5ZWpb88S3ONpEN7LCl/s/ytet4QkWScD n3AA== X-Gm-Message-State: AOAM531xWcZ9YXHBhNYpms+Qc5BXaLH0muYASPMZw9aBGjWyOom35ZGM 7Yig+pDQHfYFofUouC/tYf0= X-Received: by 2002:a05:620a:80d:: with SMTP id s13mr2278856qks.133.1605110987976; Wed, 11 Nov 2020 08:09:47 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id d82sm2459710qkc.14.2020.11.11.08.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 08:09:47 -0800 (PST) From: Arvind Sankar To: Tom Lendacky , Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: x86@kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/2] x86/mm/sme: Fix definition of PMD_FLAGS_DEC_WP Date: Wed, 11 Nov 2020 11:09:45 -0500 Message-Id: <20201111160946.147341-1-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <13073a85-24c1-6efa-578b-54218d21f49d@amd.com> References: <13073a85-24c1-6efa-578b-54218d21f49d@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Arvind Sankar Fixes: 6ebcb060713f ("x86/mm: Add support to encrypt the kernel in-place") Tested-by: Tom Lendacky Cc: stable@vger.kernel.org --- 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 816b31c68550..394757ee030a 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 733b983f3a89..6c5eb6f3f14f 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) -- 2.26.2