From 786fb04d2005577fc17c5851e6d651054a1b80c4 Mon Sep 17 00:00:00 2001 From: Mary Date: Sun, 28 Nov 2021 13:01:17 +0100 Subject: [PATCH] kernel: Add support for CFI (#2839) Add basic support for the CFI value being passed in X18 since 11.0.0 by the official kernel. We do not implement any random generator atm in the kernel and as such the KSystemControl.GenerateRandom function is stubbed --- Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs | 6 ++++++ Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs | 1 + 2 files changed, 7 insertions(+) diff --git a/Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs b/Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs index 630baacfc2..881421424f 100644 --- a/Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs +++ b/Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs @@ -58,6 +58,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Common return DramMemoryMap.DramBase + GetDramSize(size); } + public static ulong GenerateRandom() + { + // TODO + return 0; + } + public static ulong GetDramSize(MemorySize size) { return size switch diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs index 396a79bae9..646292487d 100644 --- a/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs +++ b/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs @@ -187,6 +187,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading if (is64Bits) { + Context.SetX(18, KSystemControl.GenerateRandom() | 1); Context.SetX(31, stackTop); } else