Re: [akpm-mm:mm-unstable 206/222] arch/x86/include/asm/pgtable.h:1420:10: error: invalid output size for constraint '+q'

Peter Xu
2024-08-12T17:47:43Z

On Sun, Aug 11, 2024 at 06:14:39PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable
> head: 7d7894afcca68b40bfca49f4d1303167d224919e
> commit: a5c1d6b162e7568305f50186568d6e033ad6d81f [206/222] mm/x86: add missing pud helpers
> config: i386-randconfig-002-20240811 (https://download.01.org/0day-ci/archive/20240811/202408111850.Y7rbVXOo-lkp@intel.com/config)
> compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240811/202408111850.Y7rbVXOo-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202408111850.Y7rbVXOo-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> In file included from arch/x86/kernel/asm-offsets.c:14:
> In file included from include/linux/suspend.h:5:
> In file included from include/linux/swap.h:9:
> In file included from include/linux/memcontrol.h:13:
> In file included from include/linux/cgroup.h:17:
> In file included from include/linux/fs.h:33:
> In file included from include/linux/percpu-rwsem.h:7:
> In file included from include/linux/rcuwait.h:6:
> In file included from include/linux/sched/signal.h:9:
> In file included from include/linux/sched/task.h:13:
> In file included from include/linux/uaccess.h:12:
> In file included from arch/x86/include/asm/uaccess.h:17:
> In file included from arch/x86/include/asm/tlbflush.h:16:
> >> arch/x86/include/asm/pgtable.h:1420:10: error: invalid output size for constraint '+q'
> 1420 | return xchg(pudp, pud);
> | ^
> include/linux/atomic/atomic-instrumented.h:4758:2: note: expanded from macro 'xchg'
> 4758 | raw_xchg(__ai_ptr, __VA_ARGS__); \
> | ^
> include/linux/atomic/atomic-arch-fallback.h:12:18: note: expanded from macro 'raw_xchg'
> 12 | #define raw_xchg arch_xchg
> | ^
> arch/x86/include/asm/cmpxchg.h:78:27: note: expanded from macro 'arch_xchg'
> 78 | #define arch_xchg(ptr, v) __xchg_op((ptr), (v), xchg, "")
> | ^
> arch/x86/include/asm/cmpxchg.h:48:19: note: expanded from macro '__xchg_op'
> 48 | : "+q" (__ret), "+m" (*(ptr)) \
> | ^
> 1 error generated.
> make[3]: *** [scripts/Makefile.build:117: arch/x86/kernel/asm-offsets.s] Error 1 shuffle=3464415616
> make[3]: Target 'prepare' not remade because of errors.
> make[2]: *** [Makefile:1193: prepare0] Error 2 shuffle=3464415616
> make[2]: Target 'prepare' not remade because of errors.
> make[1]: *** [Makefile:224: __sub-make] Error 2 shuffle=3464415616
> make[1]: Target 'prepare' not remade because of errors.
> make: *** [Makefile:224: __sub-make] Error 2 shuffle=3464415616
> make: Target 'prepare' not remade because of errors.
>
>
> vim +1420 arch/x86/include/asm/pgtable.h
>
> 1414
> 1415 static inline pud_t pudp_establish(struct vm_area_struct *vma,
> 1416 unsigned long address, pud_t *pudp, pud_t pud)
> 1417 {
> 1418 page_table_check_pud_set(vma->vm_mm, pudp, pud);
> 1419 if (IS_ENABLED(CONFIG_SMP)) {
> > 1420 return xchg(pudp, pud);
> 1421 } else {
> 1422 pud_t old = *pudp;
> 1423 WRITE_ONCE(*pudp, pud);
> 1424 return old;
> 1425 }
> 1426 }
> 1427

It's a bit weird that the build won't fail if with gcc, but only trigger
this if with clang.

The issue reported here seems to be real, where it's still the i386 PAE
config and pud here should be u64. We may need below to fix it:

===========8<============
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 1e463c9a650f..4c2d080d26b4 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -1436,6 +1436,7 @@ static inline pmd_t pmdp_establish(struct vm_area_struct *vma,
}
#endif

+#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
static inline pud_t pudp_establish(struct vm_area_struct *vma,
unsigned long address, pud_t *pudp, pud_t pud)
{
@@ -1448,6 +1449,7 @@ static inline pud_t pudp_establish(struct vm_area_struct *vma,
return old;
}
}
+#endif

#define __HAVE_ARCH_PMDP_INVALIDATE_AD
extern pmd_t pmdp_invalidate_ad(struct vm_area_struct *vma,
===========8<============

I'll squash this when I repost the whole 1g pud series soon (with quite a
few commit message enhancements, and English fixes).

Thanks,

--
Peter Xu