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 <gshan@redhat.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Steven Price <steven.price@arm.com> Link: https://lore.kernel.org/r/20241017131434.40935-6-steven.price@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 3715894 commit 3c6c706

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

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)