Skip to content
Snippets Groups Projects
  1. May 01, 2023
  2. Apr 19, 2023
    • Alexandre Ghiti's avatar
      riscv: Use PUD/P4D/PGD pages for the linear mapping · 3335068f
      Alexandre Ghiti authored
      
      During the early page table creation, we used to set the mapping for
      PAGE_OFFSET to the kernel load address: but the kernel load address is
      always offseted by PMD_SIZE which makes it impossible to use PUD/P4D/PGD
      pages as this physical address is not aligned on PUD/P4D/PGD size (whereas
      PAGE_OFFSET is).
      
      But actually we don't have to establish this mapping (ie set va_pa_offset)
      that early in the boot process because:
      
      - first, setup_vm installs a temporary kernel mapping and among other
        things, discovers the system memory,
      - then, setup_vm_final creates the final kernel mapping and takes
        advantage of the discovered system memory to create the linear
        mapping.
      
      During the first phase, we don't know the start of the system memory and
      then until the second phase is finished, we can't use the linear mapping at
      all and phys_to_virt/virt_to_phys translations must not be used because it
      would result in a different translation from the 'real' one once the final
      mapping is installed.
      
      So here we simply delay the initialization of va_pa_offset to after the
      system memory discovery. But to make sure noone uses the linear mapping
      before, we add some guard in the DEBUG_VIRTUAL config.
      
      Finally we can use PUD/P4D/PGD hugepages when possible, which will result
      in a better TLB utilization.
      
      Note that:
      - this does not apply to rv32 as the kernel mapping lies in the linear
        mapping.
      - we rely on the firmware to protect itself using PMP.
      
      Signed-off-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
      Acked-by: Rob Herring <robh@kernel.org> # DT bits
      Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
      Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
      Tested-by: default avatarAnup Patel <anup@brainfault.org>
      Link: https://lore.kernel.org/r/20230324155421.271544-4-alexghiti@rivosinc.com
      
      
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Unverified
      3335068f
  3. Mar 03, 2023
  4. Mar 02, 2023
  5. Mar 01, 2023
  6. Feb 28, 2023
Loading