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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Dec 2020 09:58:38 +0000 (10:58 +0100)
commitc31a444c48981106aab63ca4297d285e47d260cf
treebbc8bac951664913e73c071f0061abbeea123e54
parent7882c999402d508c9f5719def5aef35fb5c68a94
x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP

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 <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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/include/asm/pgtable_types.h
arch/x86/mm/mem_encrypt_identity.c