From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB9333C5522 for ; Wed, 18 Mar 2026 11:36:57 +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=1773833819; cv=none; b=NM5gLbMckLryAjPxpfbVf4l53zJoGcGn/O39DxXpM+YeKOL3IntQrrsj3aRNIzZUQeZFX8npVKLfUToj2nq1hlKeIfJQHIRVIPctwtEWI41Jj6gnXBV97JjFp0VwrwFeGAkUS3wpFgB4FSby3PpI5JahqJ8w7PdhDpFTK07qYVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773833819; c=relaxed/simple; bh=sM2PLBb+zlYauRgnFaeupHDZnGNP5GH69e3JtAQx54s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mrQk/RX4MWRBas3GHLOaagXz6p4JqCdDI3FuqwqOjC1p30RXYlFLguoTlXHOWWZUVsvXtGL8Bjaj/LKEtTdmepit4yba+SGV/i9DStfCWWfdX1ZQMtMBX+2Po7XjvwlI05zBRkQS0TAl5wdRk13IyOAp/nXraliOfCV3svBhT5E= 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 DE7101E2F; Wed, 18 Mar 2026 04:36:50 -0700 (PDT) Received: from [10.57.61.122] (unknown [10.57.61.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 39AF83F73B; Wed, 18 Mar 2026 04:36:53 -0700 (PDT) Message-ID: Date: Wed, 18 Mar 2026 11:36:50 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] arm64: realm: Fix PTE_NS_SHARED for 52bit PA support To: Suzuki K Poulose , linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, maz@kernel.org, linux-kernel@vger.kernel.org, aneesh.kumar@kernel.org, Catalin Marinas , Will Deacon References: <20260316161901.2410354-1-suzuki.poulose@arm.com> From: Steven Price Content-Language: en-GB In-Reply-To: <20260316161901.2410354-1-suzuki.poulose@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 16/03/2026 16:19, Suzuki K Poulose wrote: > 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 @). > > 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: 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: 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 @@ > > #include > #include > +#include > #include > > 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 = BIT(config.ipa_bits - 1); > + prot_ns_shared = __phys_to_pte_val(BIT(config.ipa_bits - 1)); > > if (arm64_ioremap_prot_hook_register(realm_ioremap_hook)) > return;