From e423aef0335f60b6ecf225a799869df8ca2406df Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 17 Jun 2021 12:49:25 -0700 Subject: [PATCH] kern: ensure InitArguments do not cross page boundaries --- .../mesosphere/arch/arm64/init/kern_k_init_arguments.hpp | 5 +++-- .../include/mesosphere/init/kern_init_arguments_select.hpp | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/libmesosphere/include/mesosphere/arch/arm64/init/kern_k_init_arguments.hpp b/libraries/libmesosphere/include/mesosphere/arch/arm64/init/kern_k_init_arguments.hpp index 204f34a7d..c167e735b 100644 --- a/libraries/libmesosphere/include/mesosphere/arch/arm64/init/kern_k_init_arguments.hpp +++ b/libraries/libmesosphere/include/mesosphere/arch/arm64/init/kern_k_init_arguments.hpp @@ -18,7 +18,7 @@ namespace ams::kern::init { - struct KInitArguments { + struct alignas(util::CeilingPowerOfTwo(INIT_ARGUMENTS_SIZE)) KInitArguments { u64 ttbr0; u64 ttbr1; u64 tcr; @@ -32,7 +32,8 @@ namespace ams::kern::init { u64 setup_function; u64 exception_stack; }; - static_assert(sizeof(KInitArguments) == INIT_ARGUMENTS_SIZE); + static_assert(alignof(KInitArguments) == util::CeilingPowerOfTwo(INIT_ARGUMENTS_SIZE)); + static_assert(sizeof(KInitArguments) == std::max(INIT_ARGUMENTS_SIZE, util::CeilingPowerOfTwo(INIT_ARGUMENTS_SIZE))); static_assert(__builtin_offsetof(KInitArguments, ttbr0) == INIT_ARGUMENTS_TTBR0); static_assert(__builtin_offsetof(KInitArguments, ttbr1) == INIT_ARGUMENTS_TTBR1); diff --git a/libraries/libmesosphere/include/mesosphere/init/kern_init_arguments_select.hpp b/libraries/libmesosphere/include/mesosphere/init/kern_init_arguments_select.hpp index f6df949b8..b249592e1 100644 --- a/libraries/libmesosphere/include/mesosphere/init/kern_init_arguments_select.hpp +++ b/libraries/libmesosphere/include/mesosphere/init/kern_init_arguments_select.hpp @@ -24,6 +24,8 @@ namespace ams::kern::init { + static_assert(util::IsPowerOfTwo(alignof(KInitArguments)) && util::IsPowerOfTwo(sizeof(KInitArguments))); + KPhysicalAddress GetInitArgumentsAddress(s32 core_id); }