mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 21:21:09 -04:00
x86/mm: move protection_map[] inside the platform
This moves protection_map[] inside the platform and makes it a static. This also defines a helper function add_encrypt_protection_map() that can update the protection_map[] array with pgprot_encrypted(). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Anshuman Khandual <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Brian Cain <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Chris Zankel <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Dinh Nguyen <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Guo Ren <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Huacai Chen <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: Jeff Dike <[email protected]> Cc: Jonas Bonn <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michal Simek <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Rich Felker <[email protected]> Cc: Russell King <[email protected]> Cc: Sam Ravnborg <[email protected]> Cc: Stafford Horne <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: WANG Xuerui <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yoshinori Sato <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
@@ -89,6 +89,8 @@ static inline void mem_encrypt_free_decrypted_mem(void) { }
|
||||
/* Architecture __weak replacement functions */
|
||||
void __init mem_encrypt_init(void);
|
||||
|
||||
void add_encrypt_protection_map(void);
|
||||
|
||||
/*
|
||||
* The __sme_pa() and __sme_pa_nodebug() macros are meant for use when
|
||||
* writing to or comparing values from the cr3 register. Having the
|
||||
|
||||
@@ -230,25 +230,6 @@ enum page_cache_mode {
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
/* xwr */
|
||||
#define __P000 PAGE_NONE
|
||||
#define __P001 PAGE_READONLY
|
||||
#define __P010 PAGE_COPY
|
||||
#define __P011 PAGE_COPY
|
||||
#define __P100 PAGE_READONLY_EXEC
|
||||
#define __P101 PAGE_READONLY_EXEC
|
||||
#define __P110 PAGE_COPY_EXEC
|
||||
#define __P111 PAGE_COPY_EXEC
|
||||
|
||||
#define __S000 PAGE_NONE
|
||||
#define __S001 PAGE_READONLY
|
||||
#define __S010 PAGE_SHARED
|
||||
#define __S011 PAGE_SHARED
|
||||
#define __S100 PAGE_READONLY_EXEC
|
||||
#define __S101 PAGE_READONLY_EXEC
|
||||
#define __S110 PAGE_SHARED_EXEC
|
||||
#define __S111 PAGE_SHARED_EXEC
|
||||
|
||||
/*
|
||||
* early identity mapping pte attrib macros.
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <asm/tlbflush.h>
|
||||
#include <asm/fixmap.h>
|
||||
#include <asm/setup.h>
|
||||
#include <asm/mem_encrypt.h>
|
||||
#include <asm/bootparam.h>
|
||||
#include <asm/set_memory.h>
|
||||
#include <asm/cacheflush.h>
|
||||
@@ -486,8 +487,6 @@ void __init early_set_mem_enc_dec_hypercall(unsigned long vaddr, int npages, boo
|
||||
|
||||
void __init sme_early_init(void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!sme_me_mask)
|
||||
return;
|
||||
|
||||
@@ -496,8 +495,7 @@ void __init sme_early_init(void)
|
||||
__supported_pte_mask = __sme_set(__supported_pte_mask);
|
||||
|
||||
/* Update the protection map with memory encryption mask */
|
||||
for (i = 0; i < ARRAY_SIZE(protection_map); i++)
|
||||
protection_map[i] = pgprot_encrypted(protection_map[i]);
|
||||
add_encrypt_protection_map();
|
||||
|
||||
x86_platform.guest.enc_status_change_prepare = amd_enc_status_change_prepare;
|
||||
x86_platform.guest.enc_status_change_finish = amd_enc_status_change_finish;
|
||||
|
||||
@@ -3,6 +3,34 @@
|
||||
#include <linux/export.h>
|
||||
#include <linux/mm.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <asm/mem_encrypt.h>
|
||||
|
||||
static pgprot_t protection_map[16] __ro_after_init = {
|
||||
[VM_NONE] = PAGE_NONE,
|
||||
[VM_READ] = PAGE_READONLY,
|
||||
[VM_WRITE] = PAGE_COPY,
|
||||
[VM_WRITE | VM_READ] = PAGE_COPY,
|
||||
[VM_EXEC] = PAGE_READONLY_EXEC,
|
||||
[VM_EXEC | VM_READ] = PAGE_READONLY_EXEC,
|
||||
[VM_EXEC | VM_WRITE] = PAGE_COPY_EXEC,
|
||||
[VM_EXEC | VM_WRITE | VM_READ] = PAGE_COPY_EXEC,
|
||||
[VM_SHARED] = PAGE_NONE,
|
||||
[VM_SHARED | VM_READ] = PAGE_READONLY,
|
||||
[VM_SHARED | VM_WRITE] = PAGE_SHARED,
|
||||
[VM_SHARED | VM_WRITE | VM_READ] = PAGE_SHARED,
|
||||
[VM_SHARED | VM_EXEC] = PAGE_READONLY_EXEC,
|
||||
[VM_SHARED | VM_EXEC | VM_READ] = PAGE_READONLY_EXEC,
|
||||
[VM_SHARED | VM_EXEC | VM_WRITE] = PAGE_SHARED_EXEC,
|
||||
[VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = PAGE_SHARED_EXEC
|
||||
};
|
||||
|
||||
void add_encrypt_protection_map(void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(protection_map); i++)
|
||||
protection_map[i] = pgprot_encrypted(protection_map[i]);
|
||||
}
|
||||
|
||||
pgprot_t vm_get_page_prot(unsigned long vm_flags)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user