]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP
authorArvind Sankar <nivedita@alum.mit.edu>
Wed, 11 Nov 2020 16:09:45 +0000 (11:09 -0500)
committerBorislav Petkov <bp@suse.de>
Thu, 10 Dec 2020 11:28:06 +0000 (12:28 +0100)
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 <nivedita@alum.mit.edu>
Signed-off-by: Borislav Petkov <bp@suse.de>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
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
arch/x86/mm/mem_encrypt_identity.c

index 816b31c685505fc83f9e82586b8f5f21bc640231..394757ee030a658006f7b49c10d47be1ac1534d6 100644 (file)
@@ -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))
index 733b983f3a891b97ebe41bda959bb76deb1e469a..6c5eb6f3f14f40f9002e2afde0ebbccee1237e75 100644 (file)
@@ -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)