Skip to content

Commit 3993069

Browse files
Steven Pricectmarinas
authored andcommitted
arm64: realm: Query IPA size from the RMM
The top bit of the configured IPA size is used as an attribute to control whether the address is protected or shared. Query the configuration from the RMM to assertain which bit this is. Reviewed-by: Catalin Marinas <[email protected]> Reviewed-by: Gavin Shan <[email protected]> Co-developed-by: Suzuki K Poulose <[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 c077711 commit 3993069

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

arch/arm64/include/asm/pgtable-prot.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@
6868

6969
#include <asm/cpufeature.h>
7070
#include <asm/pgtable-types.h>
71+
#include <asm/rsi.h>
7172

7273
extern bool arm64_use_ng_mappings;
74+
extern unsigned long prot_ns_shared;
75+
76+
#define PROT_NS_SHARED (is_realm_world() ? prot_ns_shared : 0)
7377

7478
#define PTE_MAYBE_NG (arm64_use_ng_mappings ? PTE_NG : 0)
7579
#define PMD_MAYBE_NG (arm64_use_ng_mappings ? PMD_SECT_NG : 0)

arch/arm64/kernel/rsi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
#include <linux/psci.h>
99
#include <asm/rsi.h>
1010

11+
static struct realm_config config;
12+
13+
unsigned long prot_ns_shared;
14+
EXPORT_SYMBOL(prot_ns_shared);
15+
1116
DEFINE_STATIC_KEY_FALSE_RO(rsi_present);
1217
EXPORT_SYMBOL(rsi_present);
1318

@@ -68,6 +73,9 @@ void __init arm64_rsi_init(void)
6873
return;
6974
if (!rsi_version_matches())
7075
return;
76+
if (WARN_ON(rsi_get_realm_config(&config)))
77+
return;
78+
prot_ns_shared = BIT(config.ipa_bits - 1);
7179

7280
arm64_rsi_setup_memory();
7381

0 commit comments

Comments
 (0)