Skip to contentSkip to conversation

arm64: rsi: use linear-map alias for realm config buffer

PATCH Applied Aneesh Kumar K.V (Arm) 2 participants 2 messages Apr 7 – Apr 10 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: rsi: use linear-map alias for realm config buffer

rsi_get_realm_config() passes its argument to virt_to_phys(), but &config is a kernel image address and not a linear-map alias. On arm64 this triggers the below warning:

virt_to_phys used for non-linear address: (____ptrval____) (config+0x0/0x1000)

 WARNING: arch/arm64/mm/physaddr.c:15 at __virt_to_phys+0x50/0x70, CPU#0: swapper/0
 Modules linked in:
 .....
 Hardware name: linux,dummy-virt (DT)
 pstate: 200000c5 (nzCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
 pc : __virt_to_phys+0x50/0x70
 lr : __virt_to_phys+0x4c/0x70
 .....
 ......
 Call trace:
  __virt_to_phys+0x50/0x70 (P)
  arm64_rsi_init+0xa0/0x1b8
  setup_arch+0x13c/0x1a0
  start_kernel+0x68/0x398
  __primary_switched+0x88/0x90

Pass lm_alias(&config) instead so the RSI call uses the linear-map alias of the same buffer and avoids the boot-time warning.

---
Cc: Catalin Marinas <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Suzuki K Poulose <[email protected]>
Cc: Steven Price <[email protected]>
Cc: Gavin Shan <[email protected]>

---
 arch/arm64/kernel/rsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/rsi.c +1 -1
index 9e846ce4ef9c..92160f2e57ff 100644
@@ -145,7 +145,7 @@ void __init arm64_rsi_init(void)
 		return;
 	if (!rsi_version_matches())
 		return;
-	if (WARN_ON(rsi_get_realm_config(&config)))
+	if (WARN_ON(rsi_get_realm_config(lm_alias(&config))))
 		return;
 	prot_ns_shared = __phys_to_pte_val(BIT(config.ipa_bits - 1));
 
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 21 lines · Aneesh Kumar K.V (Arm)

rsi_get_realm_config() passes its argument to virt_to_phys(), but &config is a kernel image address and not a linear-map alias. On arm64 this triggers the below warning:

virt_to_phys used for non-linear address: (____ptrval____) (config+0x0/0x1000)

 WARNING: arch/arm64/mm/physaddr.c:15 at __virt_to_phys+0x50/0x70, CPU#0: swapper/0
 Modules linked in:
 .....
 Hardware name: linux,dummy-virt (DT)
 pstate: 200000c5 (nzCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
 pc : __virt_to_phys+0x50/0x70
 lr : __virt_to_phys+0x4c/0x70
 .....
 ......
 Call trace:
  __virt_to_phys+0x50/0x70 (P)
  arm64_rsi_init+0xa0/0x1b8
  setup_arch+0x13c/0x1a0
  start_kernel+0x68/0x398
  __primary_switched+0x88/0x90
Quoted 1 line

[...]

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64: rsi: use linear-map alias for realm config buffer

      https://git.kernel.org/arm64/c/34e563947c76

I did not add a Fixes tag, it's just a debug warning, otherwise it functions correctly.

Signature · 1 line
Catalin