Skip to content

Commit 3c6c706

Browse files
Suzuki K Poulosectmarinas
authored andcommitted
arm64: rsi: Map unprotected MMIO as decrypted
Instead of marking every MMIO as shared, check if the given region is "Protected" and apply the permissions accordingly. Reviewed-by: Gavin Shan <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Signed-off-by: Steven Price <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 3715894 commit 3c6c706

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

arch/arm64/kernel/rsi.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <linux/jump_label.h>
77
#include <linux/memblock.h>
88
#include <linux/psci.h>
9+
10+
#include <asm/io.h>
911
#include <asm/rsi.h>
1012

1113
static struct realm_config config;
@@ -93,6 +95,16 @@ bool __arm64_is_protected_mmio(phys_addr_t base, size_t size)
9395
}
9496
EXPORT_SYMBOL(__arm64_is_protected_mmio);
9597

98+
static int realm_ioremap_hook(phys_addr_t phys, size_t size, pgprot_t *prot)
99+
{
100+
if (__arm64_is_protected_mmio(phys, size))
101+
*prot = pgprot_encrypted(*prot);
102+
else
103+
*prot = pgprot_decrypted(*prot);
104+
105+
return 0;
106+
}
107+
96108
void __init arm64_rsi_init(void)
97109
{
98110
if (arm_smccc_1_1_get_conduit() != SMCCC_CONDUIT_SMC)
@@ -103,6 +115,9 @@ void __init arm64_rsi_init(void)
103115
return;
104116
prot_ns_shared = BIT(config.ipa_bits - 1);
105117

118+
if (arm64_ioremap_prot_hook_register(realm_ioremap_hook))
119+
return;
120+
106121
arm64_rsi_setup_memory();
107122

108123
static_branch_enable(&rsi_present);

0 commit comments

Comments
 (0)