diff --git a/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp b/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp index 4c83687c4..a92e6477a 100644 --- a/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp @@ -210,7 +210,8 @@ namespace ams::ldr { MetaFlag_AddressSpaceTypeShift = 1, MetaFlag_AddressSpaceTypeMask = (7 << MetaFlag_AddressSpaceTypeShift), - MetaFlag_OptimizeMemoryAllocation = (1 << 4), + MetaFlag_OptimizeMemoryAllocation = (1 << 4), + MetaFlag_DisableDeviceAddressSpaceMerge = (1 << 5), }; enum AddressSpaceType { diff --git a/stratosphere/loader/source/ldr_meta.cpp b/stratosphere/loader/source/ldr_meta.cpp index 10d9077c9..ef6e32b78 100644 --- a/stratosphere/loader/source/ldr_meta.cpp +++ b/stratosphere/loader/source/ldr_meta.cpp @@ -55,11 +55,20 @@ namespace ams::ldr { R_UNLESS(npdm->magic == Npdm::Magic, ResultInvalidMeta()); /* Validate flags. */ - u32 mask = ~0x1F; - if (hos::GetVersion() < hos::Version_7_0_0) { - /* 7.0.0 added 0x10 as a valid bit to NPDM flags, so before that we only check 0xF. */ + u32 mask; + if (hos::GetVersion() >= hos::Version_11_0_0) { + /* 11.0.0 added bit 5 = "DisableDeviceAddressSpaceMerge". */ + mask = ~0x3F; + } else if (hos::GetVersion() >= hos::Version_7_0_0) { + /* 7.0.0 added bit 4 = "UseOptimizedMemory" */ + mask = ~0x1F; + } else { mask = ~0xF; } + + /* We set the "DisableDeviceAddressSpaceMerge" bit on all versions, so be permissive with it. */ + mask &= ~0x20; + R_UNLESS(!(npdm->flags & mask), ResultInvalidMeta()); /* Validate Acid extents. */ diff --git a/stratosphere/loader/source/ldr_process_creation.cpp b/stratosphere/loader/source/ldr_process_creation.cpp index f1163d36a..2ca46a53d 100644 --- a/stratosphere/loader/source/ldr_process_creation.cpp +++ b/stratosphere/loader/source/ldr_process_creation.cpp @@ -326,6 +326,13 @@ namespace ams::ldr { } } + /* 11.0.0+ Set Disable DAS merge. */ + if (hos::GetVersion() >= hos::Version_11_0_0 || svc::IsKernelMesosphere()) { + if (meta_flags & Npdm::MetaFlag_DisableDeviceAddressSpaceMerge) { + flags |= svc::CreateProcessFlag_DisableDeviceAddressSpaceMerge; + } + } + *out = flags; return ResultSuccess(); }