Skip to contentSkip to conversation

Add a VMSPLIT_2G_OPT config option.

PATCH In review Christian Melki 4 participants 5 messages Nov 3, 2020 – Nov 10, 2020 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add a VMSPLIT_2G_OPT config option.

This allows 2GB systems to have their RAM entirely mapped as low memory. Needed to avoid CONFIG_HIGHMEM for the last 256M.

Definitely not an uncommon configuration in the industry.
Following the discussions about deprecating CONFIG_HIGHMEM down the line, this is probably a nice addition.

Tested on a Kontron i.MX6 Quad board equipped with 2G RAM.

---

arch/arm/Kconfig +4 -0
index fe2f17eb2b50..b86eab96fd58 100644
@@ -1311,6 +1311,9 @@ choice
 		bool "3G/1G user/kernel split (for full 1G low memory)"
 	config VMSPLIT_2G
 		bool "2G/2G user/kernel split"
+	config VMSPLIT_2G_OPT
+		depends on !ARM_LPAE
+		bool "2G/2G user/kernel split (for full 2G low memory)"
 	config VMSPLIT_1G
 		bool "1G/3G user/kernel split"
 endchoice
@@ -1319,6 +1322,7 @@ config PAGE_OFFSET
 	hex
 	default PHYS_OFFSET if !MMU
 	default 0x40000000 if VMSPLIT_1G
+	default 0x70000000 if VMSPLIT_2G_OPT
 	default 0x80000000 if VMSPLIT_2G
 	default 0xB0000000 if VMSPLIT_3G_OPT
 	default 0xC0000000

--

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

Acked-by on v1 1/1
#1 lore raw

(+ Russell, Arnd, Linus)

Quoted 11 lines · Christian Melki

This allows 2GB systems to have their RAM entirely mapped as low memory. Needed to avoid CONFIG_HIGHMEM for the last 256M.

Definitely not an uncommon configuration in the industry. Following the discussions about deprecating CONFIG_HIGHMEM down the line, this is probably a nice addition.

Tested on a Kontron i.MX6 Quad board equipped with 2G RAM.

Quoted 25 lines

---

arch/arm/Kconfig +4 -1
index fe2f17eb2b50..b86eab96fd58 100644
@@ -1311,6 +1311,9 @@ choice
                bool "3G/1G user/kernel split (for full 1G low memory)"
        config VMSPLIT_2G
                bool "2G/2G user/kernel split"
+       config VMSPLIT_2G_OPT
+               depends on !ARM_LPAE
+               bool "2G/2G user/kernel split (for full 2G low memory)"
        config VMSPLIT_1G
                bool "1G/3G user/kernel split"
  endchoice
@@ -1319,6 +1322,7 @@ config PAGE_OFFSET
        hex
        default PHYS_OFFSET if !MMU
        default 0x40000000 if VMSPLIT_1G
+       default 0x70000000 if VMSPLIT_2G_OPT
        default 0x80000000 if VMSPLIT_2G
        default 0xB0000000 if VMSPLIT_3G_OPT
        default 0xC0000000
--
Quoted 4 lines

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

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

Acked-by
#2 lore raw
Quoted 12 lines · Ard Biesheuvel

(+ Russell, Arnd, Linus)

Quoted 8 lines · Christian Melki

This allows 2GB systems to have their RAM entirely mapped as low memory. Needed to avoid CONFIG_HIGHMEM for the last 256M.

Definitely not an uncommon configuration in the industry. Following the discussions about deprecating CONFIG_HIGHMEM down the line, this is probably a nice addition.

Quoted 5 lines
Quoted 3 lines

Tested on a Kontron i.MX6 Quad board equipped with 2G RAM.

I had wanted to send a patch like this for a long time, but I never got around to doing it, partly as I don't have good hardware to test it on. Thanks a lot for taking care of it!

It would be nice if distros could enable this by default in the non-LPAE kernels, given the increasing interest in eventually removing highmem support. Unfortunately it requires a lot of testing to figure out exactly how bad the impact of the reduced user address range is in practice. It seems that mips32 has always had a 2GB user virtual space (and only 512MB of lowmem), while arm, x86, and powerpc are configurable but usually go with 3GB of user virtual space.

I suppose this bit should be added to slightly reduce the chance of exhausting the address space:

arch/arm/Kconfig +1 -0
@@ -300,6 +300,7 @@ config ARCH_MMAP_RND_BITS_MIN
 config ARCH_MMAP_RND_BITS_MAX
        default 14 if PAGE_OFFSET=0x40000000
        default 15 if PAGE_OFFSET=0x80000000
+       default 15 if PAGE_OFFSET=0xB0000000
        default 16
 
 #

With that added:

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

#3 lore raw

arch/arm/Kconfig config ARCH_MMAP_RND_BITS_MIN · line 304

Quoted 10 lines · Arnd Bergmann

On Tue, Nov 3, 2020 at 11:56 PM Ard Biesheuvel <[email protected]> wrote:

arch/arm/Kconfig +1 -0
@@ -300,6 +300,7 @@ config ARCH_MMAP_RND_BITS_MIN
 config ARCH_MMAP_RND_BITS_MAX
        default 14 if PAGE_OFFSET=0x40000000
        default 15 if PAGE_OFFSET=0x80000000
+       default 15 if PAGE_OFFSET=0xB0000000
        default 16

Sorry I mixed up the numbers, that should have been 0x70000000, not 0xB0000000.

Arnd

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

#4 lore raw
In reply to Christian Melki
Quoted 10 lines · Christian Melki

This allows 2GB systems to have their RAM entirely mapped as low memory. Needed to avoid CONFIG_HIGHMEM for the last 256M.

Definitely not an uncommon configuration in the industry. Following the discussions about deprecating CONFIG_HIGHMEM down the line, this is probably a nice addition.

Tested on a Kontron i.MX6 Quad board equipped with 2G RAM.

This is neat!

Quoted 3 lines

default PHYS_OFFSET if !MMU
default 0x40000000 if VMSPLIT_1G
+ default 0x70000000 if VMSPLIT_2G_OPT

If you apply this to linux-next it will unfortunately not work with the KASan address sanitizer.

Right below the PHYS_OFFSET is now this:

config KASAN_SHADOW_OFFSET

        hex
        depends on KASAN
        default 0x1f000000 if PAGE_OFFSET=0x40000000
        default 0x5f000000 if PAGE_OFFSET=0x80000000
        default 0x9f000000 if PAGE_OFFSET=0xC0000000
        default 0x8f000000 if PAGE_OFFSET=0xB0000000
        default 0xffffffff

So this needs to be updated for your new page offset.

commit c12366ba441da2f6f2b915410aca2b5b39c16514
"ARM: 9015/2: Define the virtual space of KASan's shadow region" explains in detail how these KASAN_SHADOW_OFFSETs
are selected so that you can add that at the same time.

Then you can test the VMSPLIT_2G_OPT system with
KASan to make sure it also works.

Yours,
Linus Walleij

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