kern: support 2-pool layout on 2.x-4.x instead of modern 4-pool layout

This commit is contained in:
Michael Scire 2020-08-25 18:10:58 -07:00 committed by SciresM
parent ce95af89ef
commit e8ffbe630f
7 changed files with 204 additions and 92 deletions

View file

@ -168,6 +168,17 @@ namespace ams::pm::resource {
}
}
bool IsKTraceEnabled() {
if (!svc::IsKernelMesosphere()) {
return false;
}
u64 value = 0;
R_ABORT_UNLESS(svc::GetInfo(std::addressof(value), svc::InfoType_MesosphereMeta, INVALID_HANDLE, svc::MesosphereMetaInfo_IsKTraceEnabled));
return value != 0;
}
}
/* Resource API. */
@ -265,6 +276,14 @@ namespace ams::pm::resource {
g_memory_resource_limits[i][ResourceLimitGroup_System] += extra_memory_size;
g_memory_resource_limits[i][src_group] -= extra_memory_size;
}
/* If KTrace is enabled, account for that by subtracting the memory from the applet pool. */
if (IsKTraceEnabled()) {
constexpr size_t KTraceBufferSize = 16_MB;
for (size_t i = 0; i < spl::MemoryArrangement_Count; i++) {
g_memory_resource_limits[i][ResourceLimitGroup_Applet] -= KTraceBufferSize;
}
}
}
/* Actually set resource limits. */