From nobody Tue Apr 7 02:37:14 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27A74334C1C for ; Mon, 16 Mar 2026 16:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773677953; cv=none; b=KKNuGJw75PZr7zn5C2tfRdTIAZ3gv8iy3ZQFCt5YjVmzEOihjdJ6ZCsswD9tN/S4LPHm5DIZ7EYxiYopgV3HGUtusYn8R17gW1Bhd1j2wBe4kMWwpwQIwuUSeEQmg2y2u7x0CSQLDG+8HD1JWOFWdzkaE4/qGkm9aIxv2rIWzEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773677953; c=relaxed/simple; bh=TVptBP1e+73bnnd8HVBXs7cdgBucTFvDao+G69mxt+k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UlmoCjMNHD1JOO7o1BAzBxmoIT4ouw7hlYrTnUsb4OuhOPU0A040JNpAE2SfjcGnsnNCDY4i94hfVeviOko3KYBH7Hszt9+CiUSvBXZbS5ontDDT0rLT38XBMJ+bo3cQA+8IQ3gszDigBCPhhS8NMi+SOJN4LLVAnfsOt6q+BtE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 850B71477; Mon, 16 Mar 2026 09:19:05 -0700 (PDT) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7FA3F3F73B; Mon, 16 Mar 2026 09:19:10 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, maz@kernel.org, linux-kernel@vger.kernel.org, aneesh.kumar@kernel.org, steven.price@arm.com, Suzuki K Poulose , Catalin Marinas , Will Deacon Subject: [PATCH] arm64: realm: Fix PTE_NS_SHARED for 52bit PA support Date: Mon, 16 Mar 2026 16:19:01 +0000 Message-ID: <20260316161901.2410354-1-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With LPA/LPA2, the top bits of the PFN (Bits[51:48]) end up in the lower bi= ts of the PTE. So, simply creating a mask of the "top IPA bit" doesn't work we= ll 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 @). 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 (L= PA2) Fixes: 399306954996 ("arm64: realm: Query IPA size from the RMM") Cc: Catalin Marinas Cc: Steven Price Cc: Will Deacon Signed-off-by: Suzuki K Poulose Reviewed-by: Catalin Marinas Reviewed-by: Steven Price --- arch/arm64/kernel/rsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c index c64a06f58c0b..9e846ce4ef9c 100644 --- a/arch/arm64/kernel/rsi.c +++ b/arch/arm64/kernel/rsi.c @@ -12,6 +12,7 @@ =20 #include #include +#include #include =20 static struct realm_config config; @@ -146,7 +147,7 @@ void __init arm64_rsi_init(void) return; if (WARN_ON(rsi_get_realm_config(&config))) return; - prot_ns_shared =3D BIT(config.ipa_bits - 1); + prot_ns_shared =3D __phys_to_pte_val(BIT(config.ipa_bits - 1)); =20 if (arm64_ioremap_prot_hook_register(realm_ioremap_hook)) return; --=20 2.43.0