Skip to content

Commit 402fe0c

Browse files
tlendackysuryasaimadhu
authored andcommitted
x86/ioremap: Selectively build arch override encryption functions
In preparation for other uses of the cc_platform_has() function besides AMD's memory encryption support, selectively build the AMD memory encryption architecture override functions only when CONFIG_AMD_MEM_ENCRYPT=y. These functions are: - early_memremap_pgprot_adjust() - arch_memremap_can_ram_remap() Additionally, routines that are only invoked by these architecture override functions can also be conditionally built. These functions are: - memremap_should_map_decrypted() - memremap_is_efi_data() - memremap_is_setup_data() - early_memremap_is_setup_data() And finally, phys_mem_access_encrypted() is conditionally built as well, but requires a static inline version of it when CONFIG_AMD_MEM_ENCRYPT is not set. Signed-off-by: Tom Lendacky <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 9e1ff30 commit 402fe0c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

arch/x86/include/asm/io.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,21 @@ extern void arch_io_free_memtype_wc(resource_size_t start, resource_size_t size)
391391
#define arch_io_reserve_memtype_wc arch_io_reserve_memtype_wc
392392
#endif
393393

394+
#ifdef CONFIG_AMD_MEM_ENCRYPT
394395
extern bool arch_memremap_can_ram_remap(resource_size_t offset,
395396
unsigned long size,
396397
unsigned long flags);
397398
#define arch_memremap_can_ram_remap arch_memremap_can_ram_remap
398399

399400
extern bool phys_mem_access_encrypted(unsigned long phys_addr,
400401
unsigned long size);
402+
#else
403+
static inline bool phys_mem_access_encrypted(unsigned long phys_addr,
404+
unsigned long size)
405+
{
406+
return true;
407+
}
408+
#endif
401409

402410
/**
403411
* iosubmit_cmds512 - copy data to single MMIO location, in 512-bit units

arch/x86/mm/ioremap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
508508
memunmap((void *)((unsigned long)addr & PAGE_MASK));
509509
}
510510

511+
#ifdef CONFIG_AMD_MEM_ENCRYPT
511512
/*
512513
* Examine the physical address to determine if it is an area of memory
513514
* that should be mapped decrypted. If the memory is not part of the
@@ -746,7 +747,6 @@ bool phys_mem_access_encrypted(unsigned long phys_addr, unsigned long size)
746747
return arch_memremap_can_ram_remap(phys_addr, size, 0);
747748
}
748749

749-
#ifdef CONFIG_AMD_MEM_ENCRYPT
750750
/* Remap memory with encryption */
751751
void __init *early_memremap_encrypted(resource_size_t phys_addr,
752752
unsigned long size)

0 commit comments

Comments
 (0)