diff --git a/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp b/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp index 49d894692..1a5cc7e04 100644 --- a/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp +++ b/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp @@ -507,6 +507,11 @@ return R_SUCCEEDED(::ams::svc::GetInfo(std::addressof(dummy), ::ams::svc::InfoType_MesosphereMeta, ::ams::svc::InvalidHandle, ::ams::svc::MesosphereMetaInfo_KernelVersion)); } + ALWAYS_INLINE bool IsKTraceEnabled() { + uint64_t value = 0; + return R_SUCCEEDED(::ams::svc::GetInfo(std::addressof(value), ::ams::svc::InfoType_MesosphereMeta, ::ams::svc::InvalidHandle, ::ams::svc::MesosphereMetaInfo_IsKTraceEnabled)) && value != 0; + } + } #endif \ No newline at end of file diff --git a/stratosphere/loader/source/ldr_capabilities.cpp b/stratosphere/loader/source/ldr_capabilities.cpp index 6b0600a8c..e24dcbc21 100644 --- a/stratosphere/loader/source/ldr_capabilities.cpp +++ b/stratosphere/loader/source/ldr_capabilities.cpp @@ -419,11 +419,9 @@ namespace ams::ldr::caps { switch (GetCapabilityId(cur_cap)) { case CapabilityId::MapRegion: { - /* MapRegion was added in 8.0.0+. */ - /* To prevent kernel error, we should reject the descriptor on lower firmwares. */ - /* NOTE: We also allow it on any firmware under mesosphere, as an extension. */ - const bool is_allowed = (hos::GetVersion() >= hos::Version_8_0_0 || svc::IsKernelMesosphere()); - if (!is_allowed) { + /* MapRegion was added in 8.0.0+, and is only allowed under kernels which have the relevant mappings. */ + /* However, we allow it under all firmwares on mesosphere, to facilitate KTrace usage by hbl. */ + if (!svc::IsKTraceEnabled()) { caps[i] = EmptyCapability; } }