1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-23 02:42:09 +00:00

kern: enforce maximum secure region size

This commit is contained in:
Michael Scire 2022-03-22 14:16:02 -07:00 committed by SciresM
parent 8ef6c49d30
commit ef1b67b87b

View file

@ -23,6 +23,8 @@ namespace ams::kern::board::nintendo::nx {
constexpr size_t SecureAlignment = 128_KB;
constexpr size_t SecureSizeMax = util::AlignDown(512_MB - 1, SecureAlignment);
/* Global variables for panic. */
constinit bool g_call_smc_on_panic;
@ -191,6 +193,11 @@ namespace ams::kern::board::nintendo::nx {
}
bool SetSecureRegion(KPhysicalAddress phys_addr, size_t size) {
/* Ensure size is valid. */
if (size > SecureSizeMax) {
return false;
}
/* Ensure address and size are aligned. */
if (!util::IsAligned(GetInteger(phys_addr), SecureAlignment)) {
return false;