linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64/mm: Add a fallback stub for pgd_page_paddr()
@ 2025-10-14 11:06 Anshuman Khandual
  2025-11-04 14:31 ` Will Deacon
  0 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2025-10-14 11:06 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: ryan.roberts, Anshuman Khandual, Catalin Marinas, Will Deacon,
	linux-kernel

Add a fallback stub for pgd_page_paddr() when (PGTBALE_LEVELS <= 4) which
helps in intercepting any unintended usage and which is also in line with
existing stubs for similar [pud|p4d]_page_paddr() helpers.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/arm64/include/asm/pgtable.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index aa89c2e67ebc..fb34df92d159 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -1212,6 +1212,8 @@ static inline p4d_t *p4d_offset_kimg(pgd_t *pgdp, u64 addr)
 
 static inline bool pgtable_l5_enabled(void) { return false; }
 
+#define pgd_page_paddr(pgd)	({ BUILD_BUG(); 0; })
+
 #define p4d_index(addr)		(((addr) >> P4D_SHIFT) & (PTRS_PER_P4D - 1))
 
 /* Match p4d_offset folding in <asm/generic/pgtable-nop4d.h> */
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64/mm: Add a fallback stub for pgd_page_paddr()
  2025-10-14 11:06 [PATCH] arm64/mm: Add a fallback stub for pgd_page_paddr() Anshuman Khandual
@ 2025-11-04 14:31 ` Will Deacon
  2025-11-05  2:54   ` Anshuman Khandual
  0 siblings, 1 reply; 6+ messages in thread
From: Will Deacon @ 2025-11-04 14:31 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-arm-kernel, ryan.roberts, Catalin Marinas, linux-kernel

On Tue, Oct 14, 2025 at 12:06:33PM +0100, Anshuman Khandual wrote:
> Add a fallback stub for pgd_page_paddr() when (PGTBALE_LEVELS <= 4) which

typo

> helps in intercepting any unintended usage and which is also in line with
> existing stubs for similar [pud|p4d]_page_paddr() helpers.

Are you saying the kernel compiles in this case without your patch? Which
definition of pgd_page_paddr() does it end up using?

Will


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64/mm: Add a fallback stub for pgd_page_paddr()
  2025-11-04 14:31 ` Will Deacon
@ 2025-11-05  2:54   ` Anshuman Khandual
  2025-11-05 17:03     ` Will Deacon
  0 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2025-11-05  2:54 UTC (permalink / raw)
  To: Will Deacon; +Cc: linux-arm-kernel, ryan.roberts, Catalin Marinas, linux-kernel

On 04/11/25 8:01 PM, Will Deacon wrote:
> On Tue, Oct 14, 2025 at 12:06:33PM +0100, Anshuman Khandual wrote:
>> Add a fallback stub for pgd_page_paddr() when (PGTBALE_LEVELS <= 4) which
> 
> typo

Sure will change - s/Add/Adds
> 
>> helps in intercepting any unintended usage and which is also in line with
>> existing stubs for similar [pud|p4d]_page_paddr() helpers.
> 
> Are you saying the kernel compiles in this case without your patch? Which
> definition of pgd_page_paddr() does it end up using?

Kernel compiles for PGTBALE_LEVELS <= 4 just fine without this patch as both
its current users p4d_offset_phys() and p4d_offset_lockless() are wrapped in
with PGTBALE_LEVELS > 4.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64/mm: Add a fallback stub for pgd_page_paddr()
  2025-11-05  2:54   ` Anshuman Khandual
@ 2025-11-05 17:03     ` Will Deacon
  2025-11-06  1:59       ` Anshuman Khandual
  0 siblings, 1 reply; 6+ messages in thread
From: Will Deacon @ 2025-11-05 17:03 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-arm-kernel, ryan.roberts, Catalin Marinas, linux-kernel

On Wed, Nov 05, 2025 at 08:24:40AM +0530, Anshuman Khandual wrote:
> On 04/11/25 8:01 PM, Will Deacon wrote:
> > On Tue, Oct 14, 2025 at 12:06:33PM +0100, Anshuman Khandual wrote:
> >> Add a fallback stub for pgd_page_paddr() when (PGTBALE_LEVELS <= 4) which
> > 
> > typo
> 
> Sure will change - s/Add/Adds
> > 
> >> helps in intercepting any unintended usage and which is also in line with
> >> existing stubs for similar [pud|p4d]_page_paddr() helpers.
> > 
> > Are you saying the kernel compiles in this case without your patch? Which
> > definition of pgd_page_paddr() does it end up using?
> 
> Kernel compiles for PGTBALE_LEVELS <= 4 just fine without this patch as both
> its current users p4d_offset_phys() and p4d_offset_lockless() are wrapped in
> with PGTBALE_LEVELS > 4.

Ok, but your patch is trying to catch broken users of the macro, right?
So my question is, would such a user compile today? If not, then your
patch is pointless.

Will


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64/mm: Add a fallback stub for pgd_page_paddr()
  2025-11-05 17:03     ` Will Deacon
@ 2025-11-06  1:59       ` Anshuman Khandual
  2025-11-13 16:19         ` Catalin Marinas
  0 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2025-11-06  1:59 UTC (permalink / raw)
  To: Will Deacon; +Cc: linux-arm-kernel, ryan.roberts, Catalin Marinas, linux-kernel



On 05/11/25 10:33 PM, Will Deacon wrote:
> On Wed, Nov 05, 2025 at 08:24:40AM +0530, Anshuman Khandual wrote:
>> On 04/11/25 8:01 PM, Will Deacon wrote:
>>> On Tue, Oct 14, 2025 at 12:06:33PM +0100, Anshuman Khandual wrote:
>>>> Add a fallback stub for pgd_page_paddr() when (PGTBALE_LEVELS <= 4) which
>>>
>>> typo
>>
>> Sure will change - s/Add/Adds
>>>
>>>> helps in intercepting any unintended usage and which is also in line with
>>>> existing stubs for similar [pud|p4d]_page_paddr() helpers.
>>>
>>> Are you saying the kernel compiles in this case without your patch? Which
>>> definition of pgd_page_paddr() does it end up using?
>>
>> Kernel compiles for PGTBALE_LEVELS <= 4 just fine without this patch as both
>> its current users p4d_offset_phys() and p4d_offset_lockless() are wrapped in
>> with PGTBALE_LEVELS > 4.
> 
> Ok, but your patch is trying to catch broken users of the macro, right?

Right but there are no broken users at present because all the users are
wrapped inside #ifdef PGTBALE_LEVELS > 4.

> So my question is, would such a user compile today? If not, then your
> patch is pointless.

The point is this macro is not visible outside #ifdef PGTBALE_LEVELS > 4
where as similar ones such as p4d_page_paddr() and pud_page_paddr() are
always visible via their respective fallback stubs, when PGTABLE_LEVELS
are lower.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64/mm: Add a fallback stub for pgd_page_paddr()
  2025-11-06  1:59       ` Anshuman Khandual
@ 2025-11-13 16:19         ` Catalin Marinas
  0 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2025-11-13 16:19 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Will Deacon, linux-arm-kernel, ryan.roberts, linux-kernel

On Thu, Nov 06, 2025 at 07:29:55AM +0530, Anshuman Khandual wrote:
> On 05/11/25 10:33 PM, Will Deacon wrote:
> > So my question is, would such a user compile today? If not, then your
> > patch is pointless.
> 
> The point is this macro is not visible outside #ifdef PGTBALE_LEVELS > 4
> where as similar ones such as p4d_page_paddr() and pud_page_paddr() are
> always visible via their respective fallback stubs, when PGTABLE_LEVELS
> are lower.

Yes but we needed the p4d/pud fallbacks to be able to use them in
functions like early_fixmap_init_pud() without #ifdefs. We don't have
such a case for pgd_page_paddr(), so I don't think this patch makes
sense on its own.

-- 
Catalin


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-13 16:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-14 11:06 [PATCH] arm64/mm: Add a fallback stub for pgd_page_paddr() Anshuman Khandual
2025-11-04 14:31 ` Will Deacon
2025-11-05  2:54   ` Anshuman Khandual
2025-11-05 17:03     ` Will Deacon
2025-11-06  1:59       ` Anshuman Khandual
2025-11-13 16:19         ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).