linux/arch/riscv
Alexandre Ghiti d7fbcf40df
riscv: Improve kasan population by using hugepages when possible
The kasan functions that populates the shadow regions used to allocate them
page by page and did not take advantage of hugepages, so fix this by
trying to allocate hugepages of 1GB and fallback to 2MB hugepages or 4K
pages in case it fails.

This reduces the page table memory consumption and improves TLB usage,
as shown below:

Before this patch:

---[ Kasan shadow start ]---
0xffffffc000000000-0xffffffc400000000    0x00000000818ef000        16G PTE     . A . . . . R V
0xffffffc400000000-0xffffffc447fc0000    0x00000002b7f4f000   1179392K PTE     D A . . . W R V
0xffffffc480000000-0xffffffc800000000    0x00000000818ef000        14G PTE     . A . . . . R V
---[ Kasan shadow end ]---

After this patch:

---[ Kasan shadow start ]---
0xffffffc000000000-0xffffffc400000000    0x00000000818ef000        16G PTE     . A . . . . R V
0xffffffc400000000-0xffffffc440000000    0x0000000240000000         1G PGD     D A . . . W R V
0xffffffc440000000-0xffffffc447e00000    0x00000002b7e00000       126M PMD     D A . . . W R V
0xffffffc447e00000-0xffffffc447fc0000    0x00000002b818f000      1792K PTE     D A . . . W R V
0xffffffc480000000-0xffffffc800000000    0x00000000818ef000        14G PTE     . A . . . . R V
---[ Kasan shadow end ]---

Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
2021-02-22 18:54:17 -08:00
..
boot riscv: Add Kendryte KD233 board device tree 2021-02-22 17:51:18 -08:00
configs riscv: Add Canaan Kendryte K210 SD card defconfig 2021-02-22 17:51:21 -08:00
include riscv: Improve kasan definitions 2021-02-22 18:44:53 -08:00
kernel riscv: Disable KSAN_SANITIZE for vDSO 2021-02-22 17:51:23 -08:00
lib riscv: Add support for function error injection 2021-01-14 15:09:09 -08:00
mm riscv: Improve kasan population by using hugepages when possible 2021-02-22 18:54:17 -08:00
net treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
Kbuild riscv: Allow device trees to be built into the kernel 2020-05-18 11:38:05 -07:00
Kconfig riscv/kasan: add KASAN_VMALLOC support 2021-02-18 23:17:59 -08:00
Kconfig.debug RISC-V: Remove EARLY_PRINTK support 2018-12-17 10:23:46 -08:00
Kconfig.socs riscv: Update Canaan Kendryte K210 device tree 2021-02-22 17:51:13 -08:00
Makefile riscv: Enable per-task stack canaries 2021-01-14 15:09:10 -08:00