Skip to content

Commit

Permalink
arm64: rsi: Map unprotected MMIO as decrypted
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Suzuki K Poulose authored and Catalin Marinas committed Oct 23, 2024
1 parent 3715894 commit 3c6c706
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions arch/arm64/kernel/rsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <linux/jump_label.h>
#include <linux/memblock.h>
#include <linux/psci.h>

#include <asm/io.h>
#include <asm/rsi.h>

static struct realm_config config;
Expand Down Expand Up @@ -93,6 +95,16 @@ bool __arm64_is_protected_mmio(phys_addr_t base, size_t size)
}
EXPORT_SYMBOL(__arm64_is_protected_mmio);

static int realm_ioremap_hook(phys_addr_t phys, size_t size, pgprot_t *prot)
{
if (__arm64_is_protected_mmio(phys, size))
*prot = pgprot_encrypted(*prot);
else
*prot = pgprot_decrypted(*prot);

return 0;
}

void __init arm64_rsi_init(void)
{
if (arm_smccc_1_1_get_conduit() != SMCCC_CONDUIT_SMC)
Expand All @@ -103,6 +115,9 @@ void __init arm64_rsi_init(void)
return;
prot_ns_shared = BIT(config.ipa_bits - 1);

if (arm64_ioremap_prot_hook_register(realm_ioremap_hook))
return;

arm64_rsi_setup_memory();

static_branch_enable(&rsi_present);
Expand Down

0 comments on commit 3c6c706

Please sign in to comment.