From 8589984a269c18465a00bea2f0a7904800d7c872 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Thu, 10 Apr 2025 03:18:00 +0200 Subject: [PATCH 1/2] bootstrap: force alignement to make possible to build nacl_helper_bootstrap with a different page size --- src/trusted/service_runtime/linux/nacl_bootstrap.x | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/trusted/service_runtime/linux/nacl_bootstrap.x b/src/trusted/service_runtime/linux/nacl_bootstrap.x index b49a2a3044..aee560729c 100644 --- a/src/trusted/service_runtime/linux/nacl_bootstrap.x +++ b/src/trusted/service_runtime/linux/nacl_bootstrap.x @@ -107,9 +107,9 @@ SECTIONS { * It just maps it from the file, i.e. way off the end of the file, * which is perfect for reserving the address space. */ - . = ALIGN(CONSTANT(COMMONPAGESIZE)); + . = ALIGN(CONSTANT(MAXPAGESIZE)); RESERVE_START = .; - .reserve : { + .reserve : ALIGN(CONSTANT(MAXPAGESIZE)) { . += (RESERVE_TOP > RESERVE_START) ? (RESERVE_TOP - RESERVE_START) : 0; } :reserve From de2b9ca69328f848a20d87a696cb9cae8236a5c5 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Thu, 10 Apr 2025 03:18:00 +0200 Subject: [PATCH 2/2] scons: build arm sel_ldr and nacl_helper_bootstrap with 64K page size Build arm sel_ldr and nacl_helper_bootstrap with 64K page size alignment. Makes it compatible with 16k page size kernels. SCons plumbing. --- SConstruct | 6 +++++- src/trusted/service_runtime/build.scons | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 6dc544d18a..703103df71 100755 --- a/SConstruct +++ b/SConstruct @@ -2688,6 +2688,8 @@ def MakeGenericLinuxEnv(platform=None): LINK = '$CXX', ) + linux_env.SetDefault(MAX_PAGE_SIZE='0x1000') + # Prepend so we can disable warnings via Append linux_env.Prepend( CPPDEFINES = [['_POSIX_C_SOURCE', '199506'], @@ -2710,6 +2712,7 @@ def MakeGenericLinuxEnv(platform=None): LINKFLAGS = ['-m64'] + sysroot_flags, ) elif linux_env.Bit('build_arm'): + linux_env.Replace(MAX_PAGE_SIZE='0x10000') SetUpLinuxEnvArm(linux_env) elif linux_env.Bit('build_mips32'): SetUpLinuxEnvMips(linux_env) @@ -2735,7 +2738,8 @@ def MakeGenericLinuxEnv(platform=None): linux_env.Prepend(SHLINKFLAGS=['$COMMON_LINKFLAGS']) linux_env.Prepend(COMMON_LINKFLAGS=['-Wl,-z,relro', '-Wl,-z,now', - '-Wl,-z,noexecstack']) + '-Wl,-z,noexecstack', + '-Wl,-z,max-page-size=${MAX_PAGE_SIZE}']) linux_env.Prepend(LINKFLAGS=['-pie']) # The ARM toolchain has a linker that doesn't handle the code its # compiler generates under -fPIE. diff --git a/src/trusted/service_runtime/build.scons b/src/trusted/service_runtime/build.scons index 33aa2e0ebd..f01e1c4acc 100644 --- a/src/trusted/service_runtime/build.scons +++ b/src/trusted/service_runtime/build.scons @@ -427,7 +427,7 @@ if (env.Bit('linux') and not env.Bit('built_elsewhere')): 'nacl_bootstrap_raw', [bootstrap_obj], ("env CXX='${CXX}' ${PYTHON} %s %s " + - '-m %s --build-id -static -z max-page-size=0x1000 ' + + '-m %s --build-id -static -z max-page-size=${MAX_PAGE_SIZE} ' + '--defsym RESERVE_TOP=%s --script %s -o ${TARGET} ${SOURCES}') % (bootstrap_env.File('linux/ld_bfd.py'), compiler_override, ld_emul, reserve_top, bootstrap_env.File('linux/nacl_bootstrap.x')),