mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-02 19:27:31 +01:00
kern: enforce maximum secure region size
This commit is contained in:
parent
de6d8d4ab4
commit
262a066c8c
@ -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 New Issue
Block a user