From 1d5f66be56d401f52943e278d5f2b18cf2ab866c Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 25 Oct 2021 17:34:47 -0700 Subject: [PATCH] kern: implement 13.1.0 kernel changes --- .../libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp | 4 ++++ .../include/mesosphere/kern_k_scheduler_lock.hpp | 3 +++ libraries/libvapours/include/vapours/svc/svc_version.hpp | 2 +- mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s | 3 ++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp index 353824372..f8c39552b 100644 --- a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp +++ b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp @@ -52,6 +52,10 @@ namespace ams::kern::arch::arm64::cpu { __asm__ __volatile__("dmb sy" ::: "memory"); } + ALWAYS_INLINE void DataMemoryBarrierInnerShareable() { + __asm__ __volatile__("dmb ish" ::: "memory"); + } + ALWAYS_INLINE void InstructionMemoryBarrier() { __asm__ __volatile__("isb" ::: "memory"); } diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_scheduler_lock.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_scheduler_lock.hpp index 10896f4fc..e12ac1184 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_scheduler_lock.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_scheduler_lock.hpp @@ -74,6 +74,9 @@ namespace ams::kern { /* Release an instance of the lock. */ if ((--m_lock_count) == 0) { + /* Perform a memory barrier here. */ + cpu::DataMemoryBarrierInnerShareable(); + /* We're no longer going to hold the lock. Take note of what cores need scheduling. */ const u64 cores_needing_scheduling = SchedulerType::UpdateHighestPriorityThreads(); diff --git a/libraries/libvapours/include/vapours/svc/svc_version.hpp b/libraries/libvapours/include/vapours/svc/svc_version.hpp index 01b99ef7d..a80879fec 100644 --- a/libraries/libvapours/include/vapours/svc/svc_version.hpp +++ b/libraries/libvapours/include/vapours/svc/svc_version.hpp @@ -58,7 +58,7 @@ namespace ams::svc { /* This is the highest SVC version supported by Atmosphere, to be updated on new kernel releases. */ /* NOTE: Official kernel versions have SVC major = SDK major + 4, SVC minor = SDK minor. */ constexpr inline u32 SupportedKernelMajorVersion = ConvertToSvcMajorVersion(13); - constexpr inline u32 SupportedKernelMinorVersion = ConvertToSvcMinorVersion( 3); + constexpr inline u32 SupportedKernelMinorVersion = ConvertToSvcMinorVersion( 4); constexpr inline u32 SupportedKernelVersion = EncodeKernelVersion(SupportedKernelMajorVersion, SupportedKernelMinorVersion); diff --git a/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s b/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s index 19200e3ab..b8c96c2ec 100644 --- a/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s +++ b/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s @@ -126,7 +126,8 @@ _ZN3ams4kern10KScheduler12ScheduleImplEv: cmp x7, x18 b.ne 1f - /* If they're the same, then we can just return as there's nothing to do. */ + /* If they're the same, then we can just issue a memory barrier and return. */ + dmb ish ret 0: /* The interrupt task thread is runnable. */