Skip to content

Commit 96955cf

Browse files
Suzuki K Poulosegregkh
authored andcommitted
arm64: realm: Fix PTE_NS_SHARED for 52bit PA support
[ Upstream commit 8c6e9b60f5c7985a9fe41320556a92d7a33451df ] With LPA/LPA2, the top bits of the PFN (Bits[51:48]) end up in the lower bits of the PTE. So, simply creating a mask of the "top IPA bit" doesn't work well for these configurations to set the "top" bit at the output of Stage1 translation. Fix this by using the __phys_to_pte_val() to do the right thing for all configurations. Tested using, kvmtool, placing the memory at a higher address (-m <size>@<Addr>). e.g: # lkvm run --realm -c 4 -m 512M@@128t -k Image --console serial sh-5.0# dmesg | grep "LPA2\|RSI" [ 0.000000] RME: Using RSI version 1.0 [ 0.000000] CPU features: detected: 52-bit Virtual Addressing (LPA2) [ 0.777354] CPU features: detected: 52-bit Virtual Addressing for KVM (LPA2) Fixes: 3993069 ("arm64: realm: Query IPA size from the RMM") Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Steven Price <steven.price@arm.com> Cc: Will Deacon <will@kernel.org> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Reviewed-by: Steven Price <steven.price@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ef6e648 commit 96955cf

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

arch/arm64/kernel/rsi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <asm/io.h>
1414
#include <asm/mem_encrypt.h>
15+
#include <asm/pgtable.h>
1516
#include <asm/rsi.h>
1617

1718
static struct realm_config config;
@@ -146,7 +147,7 @@ void __init arm64_rsi_init(void)
146147
return;
147148
if (WARN_ON(rsi_get_realm_config(&config)))
148149
return;
149-
prot_ns_shared = BIT(config.ipa_bits - 1);
150+
prot_ns_shared = __phys_to_pte_val(BIT(config.ipa_bits - 1));
150151

151152
if (arm64_ioremap_prot_hook_register(realm_ioremap_hook))
152153
return;

0 commit comments

Comments
 (0)