mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
kern: enforce maximum secure region size
This commit is contained in:
parent
8ef6c49d30
commit
ef1b67b87b
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 SecureAlignment = 128_KB;
|
||||||
|
|
||||||
|
constexpr size_t SecureSizeMax = util::AlignDown(512_MB - 1, SecureAlignment);
|
||||||
|
|
||||||
/* Global variables for panic. */
|
/* Global variables for panic. */
|
||||||
constinit bool g_call_smc_on_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) {
|
bool SetSecureRegion(KPhysicalAddress phys_addr, size_t size) {
|
||||||
|
/* Ensure size is valid. */
|
||||||
|
if (size > SecureSizeMax) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Ensure address and size are aligned. */
|
/* Ensure address and size are aligned. */
|
||||||
if (!util::IsAligned(GetInteger(phys_addr), SecureAlignment)) {
|
if (!util::IsAligned(GetInteger(phys_addr), SecureAlignment)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue