diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp index f31d95972..04035e30d 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp @@ -51,7 +51,7 @@ namespace ams::kern::arch::arm64 { cpu::InstructionMemoryBarrier(); } - uintptr_t SetupStackForUserModeThreadStarter(KVirtualAddress pc, KVirtualAddress k_sp, KVirtualAddress u_sp, uintptr_t arg, bool is_64_bit) { + uintptr_t SetupStackForUserModeThreadStarter(KVirtualAddress pc, KVirtualAddress k_sp, KVirtualAddress u_sp, uintptr_t arg, const bool is_64_bit) { /* NOTE: Stack layout on entry looks like following: */ /* SP */ /* | */ @@ -76,6 +76,11 @@ namespace ams::kern::arch::arm64 { MESOSPHERE_LOG("Creating User 32-Thread, %016lx\n", GetInteger(pc)); } + /* Set CFI-value. */ + if (is_64_bit) { + ctx->x[18] = KSystemControl::GenerateRandomU64() | 1; + } + /* Set stack pointer. */ if (is_64_bit) { ctx->sp = GetInteger(u_sp);