Semantic conflict between 04b177544a04 in drm-misc-fixes and 0b6b1bb28482 in -mm
Subsystems (5)
Hi Mark and drm and mm folks,
There is a semantic conflict between commit 04b177544a04 ("drm/pagemap:
Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION") in the drm-misc-fixes tree and commit 0b6b1bb28482 ("mm: rename ARCH_ENABLE_THP_MIGRATION to ARCH_HAS_PMD_SOFTLEAVES"), resulting in a lone instance of CONFIG_ARCH_ENABLE_THP_MIGRATION with no way to define it.
$ git grep ARCH_ENABLE_THP_MIGRATION Next/merge.log:Merging drm-misc-fixes/for-linux-next-fixes (04b177544a040 drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION) drivers/gpu/drm/drm_pagemap.c:#if IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION)
This results in an objtool warning (or error with CONFIG_OBJTOOL_WERROR) when building with clang because NR_PAGES(order) results in 1U << -1, which causes clang to stop generating code for drm_pagemap_migrate_to_devmem() when encountering unconditional undefined behavior.
drivers/gpu/drm/drm_gpusvm_helper.o: error: objtool: drm_pagemap_migrate_to_devmem() falls through to next function drm_pagemap_zdd_alloc()
Mark, could please apply the following diff to the -mm merge to avoid this? Obviously, there will need to be further coordination for resolving this upstream when the time comes but it is only an issue in -next currently.
drivers/gpu/drm/drm_pagemap.c +1 -1
@@ -12,7 +12,7 @@#include <drm/drm_pagemap_util.h> #include <drm/drm_print.h> -#if IS_ENABLED (CONFIG_ARCH_ENABLE_THP_MIGRATION ) +#if IS_ENABLED (CONFIG_ARCH_HAS_PMD_SOFTLEAVES )#define DRM_PAGEMAP_PMD_ORDER HPAGE_PMD_ORDER#else #define DRM_PAGEMAP_PMD_ORDER (-1)
Signature · 2 lines
Cheers, Nathan
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Incomplete fix: clang build failure and undefined behavior remain when CONFIG_ARCH_HAS_PMD_SOFTLEAVES is disabled. --
--- Patch [1]: Semantic conflict between 04b177544a04 in drm-misc-fixes and 0b6b1bb28482 in -mm --- commit 7a0a17a611e56673b6f5328de62e23da9f7ca1e8
Author: Nathan Chancellor <[email protected]>
Semantic conflict between 04b177544a04 in drm-misc-fixes and 0b6b1bb28482 in -mm
This commit resolves a semantic conflict by replacing CONFIG_ARCH_ENABLE_THP_MIGRATION with CONFIG_ARCH_HAS_PMD_SOFTLEAVES.
drivers/gpu/drm/drm_pagemap.c line 18
Quoted 13 lines
drivers/gpu/drm/drm_pagemap.c +1
-1@@ -12,7 +12,7 @@#include <drm/drm_pagemap_util.h> #include <drm/drm_print.h> -#if IS_ENABLED (CONFIG_ARCH_ENABLE_THP_MIGRATION ) +#if IS_ENABLED (CONFIG_ARCH_HAS_PMD_SOFTLEAVES )#define DRM_PAGEMAP_PMD_ORDER HPAGE_PMD_ORDER#else #define DRM_PAGEMAP_PMD_ORDER (-1)
^^^^
[Severity: High]
This is a pre-existing issue, but does this still leave an unresolved build failure and undefined behavior when CONFIG_ARCH_HAS_PMD_SOFTLEAVES is disabled?
When the configuration is disabled, the fallback branch defines DRM_PAGEMAP_PMD_ORDER as (-1). Its usage later in drm_pagemap_cpages() and drm_pagemap_migrate_to_devmem() results in undefined behavior:
drivers/gpu/drm/drm_pagemap.c:drm_pagemap_migrate_to_devmem() {
...
order = DRM_PAGEMAP_PMD_ORDER;
...
for (j = 1; j < NR_PAGES(order) && i + j < npages; j++)
...
}NR_PAGES(-1) expands to 1U << 4294967295, causing Clang to stop generating code and emit a trap instruction, which triggers the objtool warning and will panic the kernel at runtime if reached.
Could this fallback be adjusted to prevent the undefined behavior when the config is not enabled?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260722225605.GA1910198@ax162?part=1
Matthew Brost
maintainerQuoted 2 lines · Nathan Chancellor
Hi Mark and drm and mm folks,
Typically to get drm_pagemap.c to compile on various configs this is what is needed:
109 #ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES
110 #define HPAGE_PMD_SHIFT PMD_SHIFT
111 #define HPAGE_PUD_SHIFT PUD_SHIFT
112 #else
113 #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
114 #define HPAGE_PUD_SHIFT ({ BUILD_BUG(); 0; })
115 #endif
So the drm_pagemap.c code could be:
-#if IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION)
+#if IS_ENABLED(CONFIG_PGTABLE_HAS_HUGE_LEAVES)
#define DRM_PAGEMAP_PMD_ORDER HPAGE_PMD_ORDER
#else
#define DRM_PAGEMAP_PMD_ORDER (-1)
This Kconfig has been around since 2024:
git format-patch -1 b979db1611a63
Would it be better for everyone for me to change this in the DRM branches?
Matt
Quoted 40 lines
There is a semantic conflict between commit
04b177544a04("drm/pagemap:
GuardHPAGE_PMD_ORDERuse withCONFIG_ARCH_ENABLE_THP_MIGRATION") in the drm-misc-fixes tree and commit0b6b1bb28482("mm: renameARCH_ENABLE_THP_MIGRATIONtoARCH_HAS_PMD_SOFTLEAVES"), resulting in a lone instance ofCONFIG_ARCH_ENABLE_THP_MIGRATIONwith no way to define it.$ git grep ARCH_ENABLE_THP_MIGRATION Next/merge.log:Merging drm-misc-fixes/for-linux-next-fixes (04b177544a040 drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION) drivers/gpu/drm/drm_pagemap.c:#if IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION)This results in an objtool warning (or error with
CONFIG_OBJTOOL_WERROR) when building with clang becauseNR_PAGES(order)results in 1U << -1, which causes clang to stop generating code fordrm_pagemap_migrate_to_devmem()when encountering unconditional undefined behavior.
drivers/gpu/drm/drm_gpusvm_helper.o: error: objtool:drm_pagemap_migrate_to_devmem()falls through to next functiondrm_pagemap_zdd_alloc()Mark, could please apply the following diff to the -mm merge to avoid this? Obviously, there will need to be further coordination for resolving this upstream when the time comes but it is only an issue in
(quoted diff) +0
-1-next currently.drivers/gpu/drm/drm_pagemap.c +1
-1@@ -12,7 +12,7 @@#include <drm/drm_pagemap_util.h> #include <drm/drm_print.h> -#if IS_ENABLED (CONFIG_ARCH_ENABLE_THP_MIGRATION ) +#if IS_ENABLED (CONFIG_ARCH_HAS_PMD_SOFTLEAVES )#define DRM_PAGEMAP_PMD_ORDER HPAGE_PMD_ORDER#else #define DRM_PAGEMAP_PMD_ORDER (-1)Signature · 2 lines
Cheers, Nathan
Quoted 19 lines · Matthew Brost
Quoted 2 lines · Nathan Chancellor
Hi Mark and drm and mm folks,
Typically to get
drm_pagemap.cto compile on various configs this is what is needed:109 #ifdef
CONFIG_PGTABLE_HAS_HUGE_LEAVES
110 #defineHPAGE_PMD_SHIFTPMD_SHIFT
111 #defineHPAGE_PUD_SHIFTPUD_SHIFT
112 #else
113 #defineHPAGE_PMD_SHIFT({BUILD_BUG(); 0; })
114 #defineHPAGE_PUD_SHIFT({BUILD_BUG(); 0; })
115 #endifSo the
drm_pagemap.ccode could be:(quoted diff) +1
-1-#if IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION) +#if IS_ENABLED(CONFIG_PGTABLE_HAS_HUGE_LEAVES)
Quoted 3 lines
#define
DRM_PAGEMAP_PMD_ORDERHPAGE_PMD_ORDER
#else
#defineDRM_PAGEMAP_PMD_ORDER(-1)
Ah yeah, I probably should have looked at the bigger picture there.
Quoted 4 lines
This
Kconfighas been around since 2024:
git format-patch -1b979db1611a63Would it be better for everyone for me to change this in the DRM branches?
I believe that would render this conflict moot and seems like the correct thing to do anyways but you could wait for input from the mm folks.
Quoted 40 lines
Quoted 40 lines
There is a semantic conflict between commit
04b177544a04("drm/pagemap:
GuardHPAGE_PMD_ORDERuse withCONFIG_ARCH_ENABLE_THP_MIGRATION") in the drm-misc-fixes tree and commit0b6b1bb28482("mm: renameARCH_ENABLE_THP_MIGRATIONtoARCH_HAS_PMD_SOFTLEAVES"), resulting in a lone instance ofCONFIG_ARCH_ENABLE_THP_MIGRATIONwith no way to define it.$ git grep ARCH_ENABLE_THP_MIGRATION Next/merge.log:Merging drm-misc-fixes/for-linux-next-fixes (04b177544a040 drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION) drivers/gpu/drm/drm_pagemap.c:#if IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION)This results in an objtool warning (or error with
CONFIG_OBJTOOL_WERROR) when building with clang becauseNR_PAGES(order)results in 1U << -1, which causes clang to stop generating code fordrm_pagemap_migrate_to_devmem()when encountering unconditional undefined behavior.
drivers/gpu/drm/drm_gpusvm_helper.o: error: objtool:drm_pagemap_migrate_to_devmem()falls through to next functiondrm_pagemap_zdd_alloc()Mark, could please apply the following diff to the -mm merge to avoid this? Obviously, there will need to be further coordination for resolving this upstream when the time comes but it is only an issue in
(quoted diff) +0
-1-next currently.drivers/gpu/drm/drm_pagemap.c +1
-1@@ -12,7 +12,7 @@#include <drm/drm_pagemap_util.h> #include <drm/drm_print.h> -#if IS_ENABLED (CONFIG_ARCH_ENABLE_THP_MIGRATION ) +#if IS_ENABLED (CONFIG_ARCH_HAS_PMD_SOFTLEAVES )#define DRM_PAGEMAP_PMD_ORDER HPAGE_PMD_ORDER#else #define DRM_PAGEMAP_PMD_ORDER (-1)Signature · 2 lines
Cheers, Nathan
Signature · 2 lines
Cheers, Nathan
Andrew Morton
maintainerQuoted 10 lines · On Thu, 23 Jul 2026 14:27:24 -0700 Nathan Chancellor <[email protected]> wrote:
Quoted 7 lines
So the
drm_pagemap.ccode could be:(quoted diff) +1
-1-#if IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION) +#if IS_ENABLED(CONFIG_PGTABLE_HAS_HUGE_LEAVES)#define
DRM_PAGEMAP_PMD_ORDERHPAGE_PMD_ORDER
#else
#defineDRM_PAGEMAP_PMD_ORDER(-1)Ah yeah, I probably should have looked at the bigger picture there.
Quoted 8 lines
Quoted 4 lines
This
Kconfighas been around since 2024:
git format-patch -1b979db1611a63Would it be better for everyone for me to change this in the DRM branches?
I believe that would render this conflict moot and seems like the correct thing to do anyways but you could wait for input from the mm folks.
I'm fine the drm people changing things ;)
Otherwise I can disable "mm: rename ARCH_ENABLE_THP_MIGRATION to ARCH_HAS_PMD_SOFTLEAVES" for now and fix&reintroduce it into mm.git after drm-misc has merge into Linus. Or something like that.
Matthew Brost
maintainerQuoted 15 lines · Andrew Morton
Quoted 13 lines · On Thu, 23 Jul 2026 14:27:24 -0700 Nathan Chancellor <[email protected]> wrote:
Quoted 7 lines
So the
drm_pagemap.ccode could be:(quoted diff) +1
-1-#if IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION) +#if IS_ENABLED(CONFIG_PGTABLE_HAS_HUGE_LEAVES)#define
DRM_PAGEMAP_PMD_ORDERHPAGE_PMD_ORDER
#else
#defineDRM_PAGEMAP_PMD_ORDER(-1)Ah yeah, I probably should have looked at the bigger picture there.
Quoted 3 lines
This
Kconfighas been around since 2024:
git format-patch -1b979db1611a63
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Would it be better for everyone for me to change this in the DRM branches?
I believe that would render this conflict moot and seems like the correct thing to do anyways but you could wait for input from the mm folks.
I'm fine the drm people changing things ;)
I'll jump make a DRM change so this is all worked out when it gets to Linus.
Matt
Quoted 4 lines
Otherwise I can disable "mm: rename
ARCH_ENABLE_THP_MIGRATIONtoARCH_HAS_PMD_SOFTLEAVES" for now and fix&reintroduce it into mm.git after drm-misc has merge into Linus. Or something like that.
Mark Brown
maintainerQuoted 6 lines · Matthew Brost
Quoted 1 line · Andrew Morton
I'm fine the drm people changing things ;)
I'll jump make a DRM change so this is all worked out when it gets to Linus.
So should I drop Nathan's fixup then?
Quoted 9 lines · Mark Brown
Quoted 6 lines · Matthew Brost
Quoted 1 line · Andrew Morton
I'm fine the drm people changing things ;)
I'll jump make a DRM change so this is all worked out when it gets to Linus.
So should I drop Nathan's fixup then?
As you may or may not have seen yet, the drm commit has been reverted in the drm-misc-fixes branch, so my change should no longer apply.
Signature · 2 lines
Cheers, Nathan
Matthew Brost
maintainerQuoted 6 lines · Nathan Chancellor
Quoted 5 lines · Mark Brown
Quoted 3 lines · Matthew Brost
Quoted 1 line · Andrew Morton
I'm fine the drm people changing things ;)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I'll jump make a DRM change so this is all worked out when it gets to Linus.
So should I drop Nathan's fixup then?
As you may or may not have seen yet, the drm commit has been reverted in the drm-misc-fixes branch, so my change should no longer apply.
Yes, I asked to drm-misc-fixes maintainer to revert the change to avoid sending to Linus and will post a non-conflicting follow up drm shortly.
Matt
Quoted 4 lines
Signature · 3 lines
-- Cheers, Nathan