The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v1 1/1] x86/mm: Check if PTRS_PER_PMD is defined before use
@ 2025-02-24 17:39 Andy Shevchenko
  2025-02-24 17:59 ` Dave Hansen
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2025-02-24 17:39 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, kernel test robot

Compiler is not happy about PTRS_PER_PMD being undefined

In file included from arch/x86/kernel/head_32.S:29:
arch/x86/include/asm/pgtable_32.h:59:5: error: "PTRS_PER_PMD" is not defined, evaluates to 0 [-Werror=undef]
   59 | #if PTRS_PER_PMD > 1

Add a check to make sure PTRS_PER_PMD is defined before use.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202412152358.l9RJiVaH-lkp@intel.com/
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/pgtable_32.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
index 7d4ad8907297..3c0523588f59 100644
--- a/arch/x86/include/asm/pgtable_32.h
+++ b/arch/x86/include/asm/pgtable_32.h
@@ -56,7 +56,7 @@ do {						\
  * With PAE paging (PTRS_PER_PMD > 1), we allocate PTRS_PER_PGD == 4 pages for
  * the PMD's in addition to the pages required for the last level pagetables.
  */
-#if PTRS_PER_PMD > 1
+#if defined(PTRS_PER_PMD) && (PTRS_PER_PMD > 1)
 #define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
 #else
 #define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
-- 
2.45.1.3035.g276e886db78b


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

* Re: [PATCH v1 1/1] x86/mm: Check if PTRS_PER_PMD is defined before use
  2025-02-24 17:39 [PATCH v1 1/1] x86/mm: Check if PTRS_PER_PMD is defined before use Andy Shevchenko
@ 2025-02-24 17:59 ` Dave Hansen
  2025-02-24 18:11   ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Hansen @ 2025-02-24 17:59 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, kernel test robot

On 2/24/25 09:39, Andy Shevchenko wrote:
> Compiler is not happy about PTRS_PER_PMD being undefined
> 
> In file included from arch/x86/kernel/head_32.S:29:
> arch/x86/include/asm/pgtable_32.h:59:5: error: "PTRS_PER_PMD" is not defined, evaluates to 0 [-Werror=undef]
>    59 | #if PTRS_PER_PMD > 1
> 
> Add a check to make sure PTRS_PER_PMD is defined before use.

Hi Andy,

From reading the "Closes:" link, it appears this is a new issue that
originates from a new compile flag. So it doesn't seem like it's worth
backporting.

Also, the _behavior_ of "#if PTRS_PER_PMD > 1" was fine, right? It
didn't cause the logic to go backwards from what was intended, does it?

This:

	https://gcc.gnu.org/onlinedocs/gcc-3.0.2/cpp_4.html

says: "Identifiers that are not macros, which are all considered to be
the number zero."

Which would yield the correct behavior.

So I think this is purely a fix for new warning in new kernels. We
shouldn't need to backport this anywhere at all.

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

* Re: [PATCH v1 1/1] x86/mm: Check if PTRS_PER_PMD is defined before use
  2025-02-24 17:59 ` Dave Hansen
@ 2025-02-24 18:11   ` Andy Shevchenko
  2025-02-24 18:37     ` Dave Hansen
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2025-02-24 18:11 UTC (permalink / raw)
  To: Dave Hansen
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, kernel test robot

On Mon, Feb 24, 2025 at 09:59:23AM -0800, Dave Hansen wrote:
> On 2/24/25 09:39, Andy Shevchenko wrote:
> > Compiler is not happy about PTRS_PER_PMD being undefined
> > 
> > In file included from arch/x86/kernel/head_32.S:29:
> > arch/x86/include/asm/pgtable_32.h:59:5: error: "PTRS_PER_PMD" is not defined, evaluates to 0 [-Werror=undef]
> >    59 | #if PTRS_PER_PMD > 1
> > 
> > Add a check to make sure PTRS_PER_PMD is defined before use.
> 
> Hi Andy,
> 
> From reading the "Closes:" link, it appears this is a new issue that
> originates from a new compile flag. So it doesn't seem like it's worth
> backporting.

FWIW, I haven't put any Fixes tag nor Cc: stable@ :-)
Also note this looks like both compilers complain about the same.

> Also, the _behavior_ of "#if PTRS_PER_PMD > 1" was fine, right? It
> didn't cause the logic to go backwards from what was intended, does it?
> 
> This:
> 
> 	https://gcc.gnu.org/onlinedocs/gcc-3.0.2/cpp_4.html
> 
> says: "Identifiers that are not macros, which are all considered to be
> the number zero."
> 
> Which would yield the correct behavior.
> 
> So I think this is purely a fix for new warning in new kernels. We
> shouldn't need to backport this anywhere at all.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/1] x86/mm: Check if PTRS_PER_PMD is defined before use
  2025-02-24 18:11   ` Andy Shevchenko
@ 2025-02-24 18:37     ` Dave Hansen
  2025-02-24 20:36       ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Hansen @ 2025-02-24 18:37 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, kernel test robot

On 2/24/25 10:11, Andy Shevchenko wrote:
>> From reading the "Closes:" link, it appears this is a new issue that
>> originates from a new compile flag. So it doesn't seem like it's worth
>> backporting.
> FWIW, I haven't put any Fixes tag nor Cc: stable@ 🙂
> Also note this looks like both compilers complain about the same.

Yeah, I did note that.

I see a lot of patches where folks simply forget about stable and Fixes.
Unfortunately, I'm not super clairvoyant and when I see an ambiguous
changelog without stable and Fixes, I can't tell if it was an oversight
or intentional.

It would be great if contributors could be less ambiguous and save us
the trouble of having to ask!

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

* Re: [PATCH v1 1/1] x86/mm: Check if PTRS_PER_PMD is defined before use
  2025-02-24 18:37     ` Dave Hansen
@ 2025-02-24 20:36       ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-02-24 20:36 UTC (permalink / raw)
  To: Dave Hansen
  Cc: Andy Shevchenko, linux-kernel, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	kernel test robot

Mon, Feb 24, 2025 at 10:37:50AM -0800, Dave Hansen kirjoitti:
> On 2/24/25 10:11, Andy Shevchenko wrote:
> >> From reading the "Closes:" link, it appears this is a new issue that
> >> originates from a new compile flag. So it doesn't seem like it's worth
> >> backporting.
> > FWIW, I haven't put any Fixes tag nor Cc: stable@ 🙂
> > Also note this looks like both compilers complain about the same.
> 
> Yeah, I did note that.
> 
> I see a lot of patches where folks simply forget about stable and Fixes.
> Unfortunately, I'm not super clairvoyant and when I see an ambiguous
> changelog without stable and Fixes, I can't tell if it was an oversight
> or intentional.

In this case it was intentional.

> It would be great if contributors could be less ambiguous and save us
> the trouble of having to ask!

Sure. For _this_ change as it's clear now, can we proceed for v6.15?

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2025-02-24 20:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-24 17:39 [PATCH v1 1/1] x86/mm: Check if PTRS_PER_PMD is defined before use Andy Shevchenko
2025-02-24 17:59 ` Dave Hansen
2025-02-24 18:11   ` Andy Shevchenko
2025-02-24 18:37     ` Dave Hansen
2025-02-24 20:36       ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox