loader: correct GetCapabilityId allowal

This commit is contained in:
Michael Scire 2020-12-17 04:10:25 -08:00
parent f7e83a72a9
commit b8471bcd4e
2 changed files with 8 additions and 5 deletions

View file

@ -507,6 +507,11 @@
return R_SUCCEEDED(::ams::svc::GetInfo(std::addressof(dummy), ::ams::svc::InfoType_MesosphereMeta, ::ams::svc::InvalidHandle, ::ams::svc::MesosphereMetaInfo_KernelVersion)); 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 #endif

View file

@ -419,11 +419,9 @@ namespace ams::ldr::caps {
switch (GetCapabilityId(cur_cap)) { switch (GetCapabilityId(cur_cap)) {
case CapabilityId::MapRegion: case CapabilityId::MapRegion:
{ {
/* MapRegion was added in 8.0.0+. */ /* MapRegion was added in 8.0.0+, and is only allowed under kernels which have the relevant mappings. */
/* To prevent kernel error, we should reject the descriptor on lower firmwares. */ /* However, we allow it under all firmwares on mesosphere, to facilitate KTrace usage by hbl. */
/* NOTE: We also allow it on any firmware under mesosphere, as an extension. */ if (!svc::IsKTraceEnabled()) {
const bool is_allowed = (hos::GetVersion() >= hos::Version_8_0_0 || svc::IsKernelMesosphere());
if (!is_allowed) {
caps[i] = EmptyCapability; caps[i] = EmptyCapability;
} }
} }