LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] arch: Move page table config macros out of `#ifndef __ASSEMBLY__` condition
@ 2021-07-19 21:03 Wende Tan
  2021-07-20 11:42 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Wende Tan @ 2021-07-19 21:03 UTC (permalink / raw)
  To: arnd, linux-arch; +Cc: Wende Tan, linux-kernel

Move page table configuration macros like `P4D_SHIFT` out of
`#ifndef __ASSEMBLY__` condition, so that they can be used by assembly
code or linker scripts.  For example, the `TEXT_CFI_JT` macro in
`include/asm-generic/vmlinux.lds.h` needs `PMD_SIZE` when Clang CFI is
enabled.

Signed-off-by: Wende Tan <twd2.me@gmail.com>
---
 include/asm-generic/pgtable-nop4d.h | 10 ++++++----
 include/asm-generic/pgtable-nopmd.h | 19 ++++++++++---------
 include/asm-generic/pgtable-nopud.h | 15 ++++++++-------
 3 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/include/asm-generic/pgtable-nop4d.h b/include/asm-generic/pgtable-nop4d.h
index 03b7dae47dd4..a3de2e358ebc 100644
--- a/include/asm-generic/pgtable-nop4d.h
+++ b/include/asm-generic/pgtable-nop4d.h
@@ -2,17 +2,19 @@
 #ifndef _PGTABLE_NOP4D_H
 #define _PGTABLE_NOP4D_H
 
-#ifndef __ASSEMBLY__
+#include <linux/const.h>
 
 #define __PAGETABLE_P4D_FOLDED 1
 
-typedef struct { pgd_t pgd; } p4d_t;
-
 #define P4D_SHIFT		PGDIR_SHIFT
 #define PTRS_PER_P4D		1
-#define P4D_SIZE		(1UL << P4D_SHIFT)
+#define P4D_SIZE		(_UL(1) << P4D_SHIFT)
 #define P4D_MASK		(~(P4D_SIZE-1))
 
+#ifndef __ASSEMBLY__
+
+typedef struct { pgd_t pgd; } p4d_t;
+
 /*
  * The "pgd_xxx()" functions here are trivial for a folded two-level
  * setup: the p4d is never bad, and a p4d always exists (as it's folded
diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
index 10789cf51d16..cacaa454f97b 100644
--- a/include/asm-generic/pgtable-nopmd.h
+++ b/include/asm-generic/pgtable-nopmd.h
@@ -2,14 +2,20 @@
 #ifndef _PGTABLE_NOPMD_H
 #define _PGTABLE_NOPMD_H
 
-#ifndef __ASSEMBLY__
-
 #include <asm-generic/pgtable-nopud.h>
-
-struct mm_struct;
+#include <linux/const.h>
 
 #define __PAGETABLE_PMD_FOLDED 1
 
+#define PMD_SHIFT	PUD_SHIFT
+#define PTRS_PER_PMD	1
+#define PMD_SIZE  	(_UL(1) << PMD_SHIFT)
+#define PMD_MASK  	(~(PMD_SIZE-1))
+
+#ifndef __ASSEMBLY__
+
+struct mm_struct;
+
 /*
  * Having the pmd type consist of a pud gets the size right, and allows
  * us to conceptually access the pud entry that this pmd is folded into
@@ -17,11 +23,6 @@ struct mm_struct;
  */
 typedef struct { pud_t pud; } pmd_t;
 
-#define PMD_SHIFT	PUD_SHIFT
-#define PTRS_PER_PMD	1
-#define PMD_SIZE  	(1UL << PMD_SHIFT)
-#define PMD_MASK  	(~(PMD_SIZE-1))
-
 /*
  * The "pud_xxx()" functions here are trivial for a folded two-level
  * setup: the pmd is never bad, and a pmd always exists (as it's folded
diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
index eb70c6d7ceff..dd9239073a86 100644
--- a/include/asm-generic/pgtable-nopud.h
+++ b/include/asm-generic/pgtable-nopud.h
@@ -2,12 +2,18 @@
 #ifndef _PGTABLE_NOPUD_H
 #define _PGTABLE_NOPUD_H
 
-#ifndef __ASSEMBLY__
-
 #include <asm-generic/pgtable-nop4d.h>
+#include <linux/const.h>
 
 #define __PAGETABLE_PUD_FOLDED 1
 
+#define PUD_SHIFT	P4D_SHIFT
+#define PTRS_PER_PUD	1
+#define PUD_SIZE  	(_UL(1) << PUD_SHIFT)
+#define PUD_MASK  	(~(PUD_SIZE-1))
+
+#ifndef __ASSEMBLY__
+
 /*
  * Having the pud type consist of a p4d gets the size right, and allows
  * us to conceptually access the p4d entry that this pud is folded into
@@ -15,11 +21,6 @@
  */
 typedef struct { p4d_t p4d; } pud_t;
 
-#define PUD_SHIFT	P4D_SHIFT
-#define PTRS_PER_PUD	1
-#define PUD_SIZE  	(1UL << PUD_SHIFT)
-#define PUD_MASK  	(~(PUD_SIZE-1))
-
 /*
  * The "p4d_xxx()" functions here are trivial for a folded two-level
  * setup: the pud is never bad, and a pud always exists (as it's folded
-- 
2.25.1


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

* Re: [PATCH] arch: Move page table config macros out of `#ifndef __ASSEMBLY__` condition
  2021-07-19 21:03 [PATCH] arch: Move page table config macros out of `#ifndef __ASSEMBLY__` condition Wende Tan
@ 2021-07-20 11:42 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2021-07-20 11:42 UTC (permalink / raw)
  To: Wende Tan, arnd, linux-arch; +Cc: kbuild-all, Wende Tan, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 12224 bytes --]

Hi Wende,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on soc/for-next]
[also build test WARNING on linux/master linus/master v5.14-rc2 next-20210720]
[cannot apply to asm-generic/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Wende-Tan/arch-Move-page-table-config-macros-out-of-ifndef-__ASSEMBLY__-condition/20210720-151850
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
config: m68k-randconfig-m031-20210720 (attached as .config)
compiler: m68k-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/65ec31db75ded2f0754aa4153d9aa8bbc7ac9f96
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Wende-Tan/arch-Move-page-table-config-macros-out-of-ifndef-__ASSEMBLY__-condition/20210720-151850
        git checkout 65ec31db75ded2f0754aa4153d9aa8bbc7ac9f96
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross O=build_dir ARCH=m68k SHELL=/bin/bash drivers/iio/accel/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from arch/m68k/include/asm/pgtable.h:5,
                    from include/linux/pgtable.h:6,
                    from include/linux/mm.h:33,
                    from include/linux/scatterlist.h:8,
                    from include/linux/spi/spi.h:15,
                    from drivers/iio/accel/adxl372.c:14:
>> arch/m68k/include/asm/pgtable_mm.h:41: warning: "PMD_SIZE" redefined
      41 | #define PMD_SIZE (1UL << PMD_SHIFT)
         | 
   In file included from arch/m68k/include/asm/pgtable_mm.h:7,
                    from arch/m68k/include/asm/pgtable.h:5,
                    from include/linux/pgtable.h:6,
                    from include/linux/mm.h:33,
                    from include/linux/scatterlist.h:8,
                    from include/linux/spi/spi.h:15,
                    from drivers/iio/accel/adxl372.c:14:
   include/asm-generic/pgtable-nopmd.h:12: note: this is the location of the previous definition
      12 | #define PMD_SIZE   (_UL(1) << PMD_SHIFT)
         | 
--
   In file included from arch/m68k/include/asm/pgtable.h:5,
                    from include/linux/pgtable.h:6,
                    from include/linux/mm.h:33,
                    from include/linux/kallsyms.h:13,
                    from include/linux/bpf.h:20,
                    from include/linux/bpf-cgroup.h:5,
                    from include/linux/cgroup-defs.h:22,
                    from include/linux/cgroup.h:28,
                    from include/linux/memcontrol.h:13,
                    from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from include/linux/regulator/consumer.h:35,
                    from include/linux/i2c.h:18,
                    from drivers/iio/accel/kxcjk-1013.c:8:
>> arch/m68k/include/asm/pgtable_mm.h:41: warning: "PMD_SIZE" redefined
      41 | #define PMD_SIZE (1UL << PMD_SHIFT)
         | 
   In file included from arch/m68k/include/asm/pgtable_mm.h:7,
                    from arch/m68k/include/asm/pgtable.h:5,
                    from include/linux/pgtable.h:6,
                    from include/linux/mm.h:33,
                    from include/linux/kallsyms.h:13,
                    from include/linux/bpf.h:20,
                    from include/linux/bpf-cgroup.h:5,
                    from include/linux/cgroup-defs.h:22,
                    from include/linux/cgroup.h:28,
                    from include/linux/memcontrol.h:13,
                    from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from include/linux/regulator/consumer.h:35,
                    from include/linux/i2c.h:18,
                    from drivers/iio/accel/kxcjk-1013.c:8:
   include/asm-generic/pgtable-nopmd.h:12: note: this is the location of the previous definition
      12 | #define PMD_SIZE   (_UL(1) << PMD_SHIFT)
         | 
   drivers/iio/accel/kxcjk-1013.c:321:3: warning: 'odr_start_up_times' defined but not used [-Wunused-const-variable=]
     321 | } odr_start_up_times[KX_MAX_CHIPS][12] = {
         |   ^~~~~~~~~~~~~~~~~~
--
   In file included from arch/m68k/include/asm/pgtable.h:5,
                    from include/linux/pgtable.h:6,
                    from include/linux/mm.h:33,
                    from include/linux/kallsyms.h:13,
                    from include/linux/bpf.h:20,
                    from include/linux/bpf-cgroup.h:5,
                    from include/linux/cgroup-defs.h:22,
                    from include/linux/cgroup.h:28,
                    from include/linux/memcontrol.h:13,
                    from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from include/linux/regulator/consumer.h:35,
                    from include/linux/i2c.h:18,
                    from drivers/iio/accel/bmc150-accel-core.c:8:
>> arch/m68k/include/asm/pgtable_mm.h:41: warning: "PMD_SIZE" redefined
      41 | #define PMD_SIZE (1UL << PMD_SHIFT)
         | 
   In file included from arch/m68k/include/asm/pgtable_mm.h:7,
                    from arch/m68k/include/asm/pgtable.h:5,
                    from include/linux/pgtable.h:6,
                    from include/linux/mm.h:33,
                    from include/linux/kallsyms.h:13,
                    from include/linux/bpf.h:20,
                    from include/linux/bpf-cgroup.h:5,
                    from include/linux/cgroup-defs.h:22,
                    from include/linux/cgroup.h:28,
                    from include/linux/memcontrol.h:13,
                    from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from include/linux/regulator/consumer.h:35,
                    from include/linux/i2c.h:18,
                    from drivers/iio/accel/bmc150-accel-core.c:8:
   include/asm-generic/pgtable-nopmd.h:12: note: this is the location of the previous definition
      12 | #define PMD_SIZE   (_UL(1) << PMD_SHIFT)
         | 
   drivers/iio/accel/bmc150-accel-core.c:168:3: warning: 'bmc150_accel_sample_upd_time' defined but not used [-Wunused-const-variable=]
     168 | } bmc150_accel_sample_upd_time[] = { {0x08, 64},
         |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
   In file included from arch/m68k/include/asm/pgtable.h:5,
                    from include/linux/pgtable.h:6,
                    from include/linux/mm.h:33,
                    from include/linux/kallsyms.h:13,
                    from include/linux/bpf.h:20,
                    from include/linux/bpf-cgroup.h:5,
                    from include/linux/cgroup-defs.h:22,
                    from include/linux/cgroup.h:28,
                    from include/linux/memcontrol.h:13,
                    from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from include/linux/regulator/consumer.h:35,
                    from include/linux/i2c.h:18,
                    from drivers/iio/accel/bmc150-accel-i2c.c:9:
>> arch/m68k/include/asm/pgtable_mm.h:41: warning: "PMD_SIZE" redefined
      41 | #define PMD_SIZE (1UL << PMD_SHIFT)
         | 
   In file included from arch/m68k/include/asm/pgtable_mm.h:7,
                    from arch/m68k/include/asm/pgtable.h:5,
                    from include/linux/pgtable.h:6,
                    from include/linux/mm.h:33,
                    from include/linux/kallsyms.h:13,
                    from include/linux/bpf.h:20,
                    from include/linux/bpf-cgroup.h:5,
                    from include/linux/cgroup-defs.h:22,
                    from include/linux/cgroup.h:28,
                    from include/linux/memcontrol.h:13,
                    from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from include/linux/regulator/consumer.h:35,
                    from include/linux/i2c.h:18,
                    from drivers/iio/accel/bmc150-accel-i2c.c:9:
   include/asm-generic/pgtable-nopmd.h:12: note: this is the location of the previous definition
      12 | #define PMD_SIZE   (_UL(1) << PMD_SHIFT)
         | 
   drivers/iio/accel/bmc150-accel-i2c.c:215:36: warning: 'bmc150_accel_acpi_match' defined but not used [-Wunused-const-variable=]
     215 | static const struct acpi_device_id bmc150_accel_acpi_match[] = {
         |                                    ^~~~~~~~~~~~~~~~~~~~~~~
--
   In file included from arch/m68k/include/asm/pgtable.h:5,
                    from include/linux/pgtable.h:6,
                    from include/linux/mm.h:33,
                    from include/linux/kallsyms.h:13,
                    from include/linux/bpf.h:20,
                    from include/linux/bpf-cgroup.h:5,
                    from include/linux/cgroup-defs.h:22,
                    from include/linux/cgroup.h:28,
                    from include/linux/memcontrol.h:13,
                    from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from include/linux/regulator/consumer.h:35,
                    from include/linux/i2c.h:18,
                    from drivers/iio/accel/mxc6255.c:11:
>> arch/m68k/include/asm/pgtable_mm.h:41: warning: "PMD_SIZE" redefined
      41 | #define PMD_SIZE (1UL << PMD_SHIFT)
         | 
   In file included from arch/m68k/include/asm/pgtable_mm.h:7,
                    from arch/m68k/include/asm/pgtable.h:5,
                    from include/linux/pgtable.h:6,
                    from include/linux/mm.h:33,
                    from include/linux/kallsyms.h:13,
                    from include/linux/bpf.h:20,
                    from include/linux/bpf-cgroup.h:5,
                    from include/linux/cgroup-defs.h:22,
                    from include/linux/cgroup.h:28,
                    from include/linux/memcontrol.h:13,
                    from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from include/linux/regulator/consumer.h:35,
                    from include/linux/i2c.h:18,
                    from drivers/iio/accel/mxc6255.c:11:
   include/asm-generic/pgtable-nopmd.h:12: note: this is the location of the previous definition
      12 | #define PMD_SIZE   (_UL(1) << PMD_SHIFT)
         | 
   drivers/iio/accel/mxc6255.c:168:36: warning: 'mxc6255_acpi_match' defined but not used [-Wunused-const-variable=]
     168 | static const struct acpi_device_id mxc6255_acpi_match[] = {
         |                                    ^~~~~~~~~~~~~~~~~~


vim +/PMD_SIZE +41 arch/m68k/include/asm/pgtable_mm.h

^1da177e4c3f41 include/asm-m68k/pgtable.h         Linus Torvalds 2005-04-16  35  
^1da177e4c3f41 include/asm-m68k/pgtable.h         Linus Torvalds 2005-04-16  36  
^1da177e4c3f41 include/asm-m68k/pgtable.h         Linus Torvalds 2005-04-16  37  /* PMD_SHIFT determines the size of the area a second-level page table can map */
60e50f34b13e9e arch/m68k/include/asm/pgtable_mm.h Mike Rapoport  2019-12-04  38  #if CONFIG_PGTABLE_LEVELS == 3
ef22d8abd876e8 arch/m68k/include/asm/pgtable_mm.h Peter Zijlstra 2020-01-31  39  #define PMD_SHIFT	18
^1da177e4c3f41 include/asm-m68k/pgtable.h         Linus Torvalds 2005-04-16  40  #endif
^1da177e4c3f41 include/asm-m68k/pgtable.h         Linus Torvalds 2005-04-16 @41  #define PMD_SIZE	(1UL << PMD_SHIFT)
^1da177e4c3f41 include/asm-m68k/pgtable.h         Linus Torvalds 2005-04-16  42  #define PMD_MASK	(~(PMD_SIZE-1))
^1da177e4c3f41 include/asm-m68k/pgtable.h         Linus Torvalds 2005-04-16  43  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 24797 bytes --]

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

end of thread, other threads:[~2021-07-20 11:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19 21:03 [PATCH] arch: Move page table config macros out of `#ifndef __ASSEMBLY__` condition Wende Tan
2021-07-20 11:42 ` kernel test robot

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).