On 05/02/2025 08:16, Ilias Apalodimas wrote:
Hi!
This is v1 of [0].

This is an attempt to map the U-Boot binary properly, but leave the
area we load binaries unaffected and RWX.

There's a few changes since the RFC
- Fixed the alignment of meminfo command when printing regions
- 'meminfo' now prints arch specific attributes e.g PXN, UXN etc for arm
   instead of RW, RO, RX
- Since we don't set the permissions of EFI runtime services yet and keep
   them as RWX, I removed the linker alignment changes which makes patch #3
   easier to review. It's worth noting that qemu-arm sbsa was crashing with
   the efi services page aligned. This is probably due to a mismatch of
   memory, since the crash is only reproducible with QEMU instances that
   have < 2 GB of RAM. I'll fix that along with the efi runtime services
- Defined memory attribute changes properly with an enum for RW, RO, RX
   instead of the hardcoded '1,2,3' I had on the RFC
- Enabling mappings is now under a Kconfig (CONFIG_MMU_PGPROT), since
   peope reported crashes when testing this, which are orthogonal to this
   patch. We still have places in U-Boot where we define and later write
   const variables. This will lead to a crash now as const variables are
   properly managed and places in RO memory
- Split patches to be easier to review
- Added a patch updating 'meminfo'
- Picked up acked-by tags from Jerome

patch #1 adds printing capabilities for page mappings in 'meminfo'
patch #2 adds documention in 'meminfo' command
patch #3 prepares linker scripts, aligns sections in page boundaries etc
patch #4 prepares an internal function to change the PTEs
patch #5 adds function definitions & stubs for all archs
patch #6 wires up the changes in U-Boot after it relocates

[0] 
https://lore.kernel.org/u-boot/20250130072100.27297-1-ilias.apalodi...@linaro.org/

Ilias Apalodimas (6):
   meminfo: add memory details for armv8
   doc: update meminfo with arch specific information
   arm: Prepare linker scripts for memory permissions
   arm64: mmu_change_region_attr() add an option not to break PTEs
   treewide: Add a function to change page permissions
   arm64: Enable RW, RX and RO mappings for the relocated binary

  arch/arc/lib/cache.c                    |  2 +
  arch/arm/cpu/arm926ejs/cache.c          |  2 +
  arch/arm/cpu/armv7/cache_v7.c           |  1 +
  arch/arm/cpu/armv7m/cache.c             |  2 +
  arch/arm/cpu/armv8/cache_v8.c           | 54 +++++++++++++++++--
  arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 10 ++--
  arch/arm/cpu/armv8/u-boot.lds           | 29 +++++-----
  arch/arm/include/asm/armv8/mmu.h        |  2 +
  arch/arm/include/asm/system.h           | 11 +++-
  arch/arm/lib/cache.c                    |  2 +
  arch/arm/mach-snapdragon/board.c        |  2 +-
  arch/m68k/lib/cache.c                   |  2 +
  arch/nios2/lib/cache.c                  |  2 +
  arch/powerpc/lib/cache.c                |  2 +
  arch/riscv/lib/cache.c                  |  2 +
  arch/sh/cpu/sh4/cache.c                 |  2 +
  arch/xtensa/lib/cache.c                 |  2 +
  cmd/meminfo.c                           |  5 ++
  common/Kconfig                          | 13 +++++
  common/board_r.c                        | 20 +++++++
  doc/usage/cmd/meminfo.rst               | 71 ++++++++++++++++++-------
  include/asm-generic/sections.h          |  2 +
  include/cpu_func.h                      | 16 ++++++
  23 files changed, 215 insertions(+), 41 deletions(-)

--
2.47.2


Tested-by: Neil Armstrong <neil.armstr...@linaro.org> # on AML-S905X-CC
Tested-by: Neil Armstrong <neil.armstr...@linaro.org> # on AML-S805X-AC
Tested-by: Neil Armstrong <neil.armstr...@linaro.org> # on BananaPi-M5
Tested-by: Neil Armstrong <neil.armstr...@linaro.org> # on BananaPi-M2S
Tested-by: Neil Armstrong <neil.armstr...@linaro.org> # on SM8550-QRD
Tested-by: Neil Armstrong <neil.armstr...@linaro.org> # on SM8550-HDK
Tested-by: Neil Armstrong <neil.armstr...@linaro.org> # on SM8650-QRD
Tested-by: Neil Armstrong <neil.armstr...@linaro.org> # on SM8650-HDK

I ran this patchset on all of those board and ran meminfo to check the 
permissions,
no issues nor crash observed.

Thanks,
Neil

Reply via email to