mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-18 16:32:05 +00:00
kern: enforce maximum secure region size
This commit is contained in:
parent
de6d8d4ab4
commit
262a066c8c
1 changed files with 7 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue