Skip to contentSkip to conversation

Kconfig-induced build errors: CONFIG_PAGE_OFFSET

PATCH Randy Dunlap 4 participants 6 messages Jan 28, 2021 – Feb 3, 2021 RISC-V

lore
Share & tools
lore
#0 lore raw

Hi,

I took a riscv-32 .config from kernel test robot (it was for a clang build) and did a "make olddefconfig" (using gcc tools) and got build errors due to this config item from arch/riscv/Kconfig;

config PAGE_OFFSET

	hex
	default 0xC0000000 if 32BIT && MAXPHYSMEM_1GB
	default 0x80000000 if 64BIT && !MMU
	default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
	default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB

PAGE_OFFSET is undefined for the case of 32BIT && MAXPHYSMEM_2GB. That causes lots of errors when _AC() is used to paste CONFIG_PAGE_OFFSET to "UL", like these:

In file included from ../include/vdso/const.h:5,

                 from ../include/linux/const.h:4,
                 from ../include/linux/bits.h:5,
                 from ../include/linux/bitops.h:6,
                 from ../include/linux/kernel.h:11,
                 from ../init/do_mounts_initrd.c:3:

../arch/riscv/include/asm/uaccess.h: In function '__access_ok':
../arch/riscv/include/asm/page.h:34:46: error: 'UL' undeclared (first use in this function)
34 | #define PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)
| ^~
../include/uapi/linux/const.h:20:23: note: in definition of macro '__AC'
20 | #define __AC(X,Y) (X##Y)
| ^
../arch/riscv/include/asm/page.h:34:22: note: in expansion of macro '_AC'

   34 | #define PAGE_OFFSET  _AC(CONFIG_PAGE_OFFSET, UL)
      |                      ^~~
../arch/riscv/include/asm/pgtable.h:26:27: note: in expansion of macro 'PAGE_OFFSET'
   26 | #define VMALLOC_START    (PAGE_OFFSET - VMALLOC_SIZE)
      |                           ^~~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:41:24: note: in expansion of macro 'VMALLOC_START'
   41 | #define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)
      |                        ^~~~~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:50:26: note: in expansion of macro 'VMEMMAP_START'
   50 | #define PCI_IO_END       VMEMMAP_START
      |                          ^~~~~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:51:27: note: in expansion of macro 'PCI_IO_END'
   51 | #define PCI_IO_START     (PCI_IO_END - PCI_IO_SIZE)
      |                           ^~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:53:26: note: in expansion of macro 'PCI_IO_START'
   53 | #define FIXADDR_TOP      PCI_IO_START
      |                          ^~~~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:59:27: note: in expansion of macro 'FIXADDR_TOP'
   59 | #define FIXADDR_START    (FIXADDR_TOP - FIXADDR_SIZE)
      |                           ^~~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:471:19: note: in expansion of macro 'FIXADDR_START'
  471 | #define TASK_SIZE FIXADDR_START
      |                   ^~~~~~~~~~~~~

../arch/riscv/include/asm/uaccess.h:56:17: note: in expansion of macro 'TASK_SIZE'
56 | return size <= TASK_SIZE && addr <= TASK_SIZE - size;

I suppose that it wants something like this, but someone else can fix/use the correct default value here:

---

From: Randy Dunlap <[email protected]>

Provide a default value for PAGE_OFFSET for the case of 32BIT and MAXPHYSMEM_2GB.

Fixes many build errors.

---
 arch/riscv/Kconfig |    1 +
 1 file changed, 1 insertion(+)
arch/riscv/Kconfig +1 -0
@@ -143,6 +143,7 @@ config PA_BITS
 config PAGE_OFFSET
 	hex
 	default 0xC0000000 if 32BIT && MAXPHYSMEM_1GB
+	default 0x80000000 if 32BIT && MAXPHYSMEM_2GB
 	default 0x80000000 if 64BIT && !MMU
 	default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
 	default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB
Signature · 8 lines
~Randy
Reported-by: Randy Dunlap <[email protected]>


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#1 lore raw
Quoted 8 lines · Randy Dunlap

Hi,

I took a riscv-32 .config from kernel test robot (it was for a clang build) and did a "make olddefconfig" (using gcc tools) and got build errors due to this config item from arch/riscv/Kconfig;

Quoted 8 lines

config PAGE_OFFSET

        hex
        default 0xC0000000 if 32BIT && MAXPHYSMEM_1GB
        default 0x80000000 if 64BIT && !MMU
        default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
        default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB

PAGE_OFFSET is undefined for the case of 32BIT && MAXPHYSMEM_2GB.

Because, RV32 doesn't support 2GB physical memory yet.

The compilation errors can be fixed by not allowing MAXPHYSMEM_2GB for RV32 and MAXPHYSMEM_1GB for RV64. How about this ?

arch/riscv/Kconfig +2 -0
@@ -253,8 +253,10 @@ choice
        default MAXPHYSMEM_128GB if 64BIT && CMODEL_MEDANY
 
        config MAXPHYSMEM_1GB
+               depends on 32BIT
                bool "1GiB"
        config MAXPHYSMEM_2GB
+               depends on 64BIT && CMODEL_MEDLOW
                bool "2GiB"
        config MAXPHYSMEM_128GB
                depends on 64BIT && CMODEL_MEDANY
Quoted 83 lines

That causes lots of errors when _AC() is used to paste CONFIG_PAGE_OFFSET to "UL", like these:

In file included from ../include/vdso/const.h:5,

                 from ../include/linux/const.h:4,
                 from ../include/linux/bits.h:5,
                 from ../include/linux/bitops.h:6,
                 from ../include/linux/kernel.h:11,
                 from ../init/do_mounts_initrd.c:3:

../arch/riscv/include/asm/uaccess.h: In function '__access_ok':
../arch/riscv/include/asm/page.h:34:46: error: 'UL' undeclared (first use in this function)
34 | #define PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)
| ^~
../include/uapi/linux/const.h:20:23: note: in definition of macro '__AC'
20 | #define __AC(X,Y) (X##Y)
| ^
../arch/riscv/include/asm/page.h:34:22: note: in expansion of macro '_AC'

   34 | #define PAGE_OFFSET  _AC(CONFIG_PAGE_OFFSET, UL)
      |                      ^~~
../arch/riscv/include/asm/pgtable.h:26:27: note: in expansion of macro 'PAGE_OFFSET'
   26 | #define VMALLOC_START    (PAGE_OFFSET - VMALLOC_SIZE)
      |                           ^~~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:41:24: note: in expansion of macro 'VMALLOC_START'
   41 | #define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)
      |                        ^~~~~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:50:26: note: in expansion of macro 'VMEMMAP_START'
   50 | #define PCI_IO_END       VMEMMAP_START
      |                          ^~~~~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:51:27: note: in expansion of macro 'PCI_IO_END'
   51 | #define PCI_IO_START     (PCI_IO_END - PCI_IO_SIZE)
      |                           ^~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:53:26: note: in expansion of macro 'PCI_IO_START'
   53 | #define FIXADDR_TOP      PCI_IO_START
      |                          ^~~~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:59:27: note: in expansion of macro 'FIXADDR_TOP'
   59 | #define FIXADDR_START    (FIXADDR_TOP - FIXADDR_SIZE)
      |                           ^~~~~~~~~~~
../arch/riscv/include/asm/pgtable.h:471:19: note: in expansion of macro 'FIXADDR_START'
  471 | #define TASK_SIZE FIXADDR_START
      |                   ^~~~~~~~~~~~~

../arch/riscv/include/asm/uaccess.h:56:17: note: in expansion of macro 'TASK_SIZE'
56 | return size <= TASK_SIZE && addr <= TASK_SIZE - size;

I suppose that it wants something like this, but someone else can fix/use the correct default value here:

---

From: Randy Dunlap <[email protected]>

Provide a default value for PAGE_OFFSET for the case of 32BIT and MAXPHYSMEM_2GB.

Fixes many build errors.

---
 arch/riscv/Kconfig |    1 +
 1 file changed, 1 insertion(+)
arch/riscv/Kconfig +1 -1
@@ -143,6 +143,7 @@ config PA_BITS
 config PAGE_OFFSET
        hex
        default 0xC0000000 if 32BIT && MAXPHYSMEM_1GB
+       default 0x80000000 if 32BIT && MAXPHYSMEM_2GB
        default 0x80000000 if 64BIT && !MMU
        default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
        default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB
 
 
 
--

~Randy

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

Signature · 7 lines
Regards,
Atish

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
author Acked-by
#2 lore raw
Quoted 26 lines · Atish Patra
Quoted 8 lines · Randy Dunlap

Hi,

I took a riscv-32 .config from kernel test robot (it was for a clang build) and did a "make olddefconfig" (using gcc tools) and got build errors due to this config item from arch/riscv/Kconfig;

Quoted 8 lines

config PAGE_OFFSET

        hex
        default 0xC0000000 if 32BIT && MAXPHYSMEM_1GB
        default 0x80000000 if 64BIT && !MMU
        default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
        default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB

PAGE_OFFSET is undefined for the case of 32BIT && MAXPHYSMEM_2GB.

Because, RV32 doesn't support 2GB physical memory yet.

The compilation errors can be fixed by not allowing MAXPHYSMEM_2GB for RV32 and MAXPHYSMEM_1GB for RV64. How about this ?

arch/riscv/Kconfig choice · line 262

Quoted 10 lines
arch/riscv/Kconfig +2 -0
@@ -253,8 +253,10 @@ choice
        default MAXPHYSMEM_128GB if 64BIT && CMODEL_MEDANY
 
        config MAXPHYSMEM_1GB
+               depends on 32BIT
                bool "1GiB"
        config MAXPHYSMEM_2GB
+               depends on 64BIT && CMODEL_MEDLOW
                bool "2GiB"
        config MAXPHYSMEM_128GB
                depends on 64BIT && CMODEL_MEDANY

Looks good. Thanks.

Signature · 7 lines
~Randy


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#3 lore raw
In reply to Atish Patra

Hi Atish,

Quoted 23 lines · Atish Patra
Quoted 5 lines · Randy Dunlap

I took a riscv-32 .config from kernel test robot (it was for a clang build) and did a "make olddefconfig" (using gcc tools) and got build errors due to this config item from arch/riscv/Kconfig;

Quoted 8 lines

config PAGE_OFFSET

        hex
        default 0xC0000000 if 32BIT && MAXPHYSMEM_1GB
        default 0x80000000 if 64BIT && !MMU
        default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
        default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB

PAGE_OFFSET is undefined for the case of 32BIT && MAXPHYSMEM_2GB.

Because, RV32 doesn't support 2GB physical memory yet.

The compilation errors can be fixed by not allowing MAXPHYSMEM_2GB for RV32 and MAXPHYSMEM_1GB for RV64. How about this ?

arch/riscv/Kconfig choice · line 262

Quoted 10 lines
arch/riscv/Kconfig +2 -0
@@ -253,8 +253,10 @@ choice
        default MAXPHYSMEM_128GB if 64BIT && CMODEL_MEDANY
 
        config MAXPHYSMEM_1GB
+               depends on 32BIT
                bool "1GiB"
        config MAXPHYSMEM_2GB
+               depends on 64BIT && CMODEL_MEDLOW
                bool "2GiB"
        config MAXPHYSMEM_128GB
                depends on 64BIT && CMODEL_MEDANY

Thanks, works fine on litex-vexriscv.

Gr{oetje,eeting}s,

Geert

Signature · 10 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
maintainer
#4 lore raw
Quoted 38 lines · On Fri, 29 Jan 2021 05:52:51 PST (-0800), [email protected] wrote:

Hi Atish,

Quoted 23 lines · Atish Patra
Quoted 5 lines · Randy Dunlap

I took a riscv-32 .config from kernel test robot (it was for a clang build) and did a "make olddefconfig" (using gcc tools) and got build errors due to this config item from arch/riscv/Kconfig;

Quoted 8 lines

config PAGE_OFFSET

        hex
        default 0xC0000000 if 32BIT && MAXPHYSMEM_1GB
        default 0x80000000 if 64BIT && !MMU
        default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
        default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB

PAGE_OFFSET is undefined for the case of 32BIT && MAXPHYSMEM_2GB.

Because, RV32 doesn't support 2GB physical memory yet.

The compilation errors can be fixed by not allowing MAXPHYSMEM_2GB for RV32 and MAXPHYSMEM_1GB for RV64. How about this ?

arch/riscv/Kconfig choice · line 262

Quoted 10 lines
arch/riscv/Kconfig +2 -0
@@ -253,8 +253,10 @@ choice
        default MAXPHYSMEM_128GB if 64BIT && CMODEL_MEDANY
 
        config MAXPHYSMEM_1GB
+               depends on 32BIT
                bool "1GiB"
        config MAXPHYSMEM_2GB
+               depends on 64BIT && CMODEL_MEDLOW
                bool "2GiB"
        config MAXPHYSMEM_128GB
                depends on 64BIT && CMODEL_MEDANY

Thanks, works fine on litex-vexriscv.

Quoted 1 line

Atish: did I miss an actual patch? I just see diff here.

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer
#5 lore raw
Quoted 41 lines · Palmer Dabbelt
Quoted 38 lines · On Fri, 29 Jan 2021 05:52:51 PST (-0800), [email protected] wrote:

Hi Atish,

Quoted 23 lines · Atish Patra
Quoted 5 lines · Randy Dunlap

I took a riscv-32 .config from kernel test robot (it was for a clang build) and did a "make olddefconfig" (using gcc tools) and got build errors due to this config item from arch/riscv/Kconfig;

Quoted 8 lines

config PAGE_OFFSET

        hex
        default 0xC0000000 if 32BIT && MAXPHYSMEM_1GB
        default 0x80000000 if 64BIT && !MMU
        default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
        default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB

PAGE_OFFSET is undefined for the case of 32BIT && MAXPHYSMEM_2GB.

Because, RV32 doesn't support 2GB physical memory yet.

The compilation errors can be fixed by not allowing MAXPHYSMEM_2GB for RV32 and MAXPHYSMEM_1GB for RV64. How about this ?

arch/riscv/Kconfig choice · line 262

Quoted 10 lines
arch/riscv/Kconfig +2 -0
@@ -253,8 +253,10 @@ choice
        default MAXPHYSMEM_128GB if 64BIT && CMODEL_MEDANY
 
        config MAXPHYSMEM_1GB
+               depends on 32BIT
                bool "1GiB"
        config MAXPHYSMEM_2GB
+               depends on 64BIT && CMODEL_MEDLOW
                bool "2GiB"
        config MAXPHYSMEM_128GB
                depends on 64BIT && CMODEL_MEDANY

Thanks, works fine on litex-vexriscv.

Quoted 1 line
Quoted 1 line

Atish: did I miss an actual patch? I just see diff here.

Never mind, I found it. Thanks!

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv