loader: support 11.x DisableDeviceAddressSpaceMerge

This commit is contained in:
Michael Scire 2020-12-01 17:47:48 -08:00 committed by SciresM
parent 3d4ab95ab2
commit 1b164613a6
3 changed files with 21 additions and 4 deletions

View file

@ -210,7 +210,8 @@ namespace ams::ldr {
MetaFlag_AddressSpaceTypeShift = 1, MetaFlag_AddressSpaceTypeShift = 1,
MetaFlag_AddressSpaceTypeMask = (7 << MetaFlag_AddressSpaceTypeShift), MetaFlag_AddressSpaceTypeMask = (7 << MetaFlag_AddressSpaceTypeShift),
MetaFlag_OptimizeMemoryAllocation = (1 << 4), MetaFlag_OptimizeMemoryAllocation = (1 << 4),
MetaFlag_DisableDeviceAddressSpaceMerge = (1 << 5),
}; };
enum AddressSpaceType { enum AddressSpaceType {

View file

@ -55,11 +55,20 @@ namespace ams::ldr {
R_UNLESS(npdm->magic == Npdm::Magic, ResultInvalidMeta()); R_UNLESS(npdm->magic == Npdm::Magic, ResultInvalidMeta());
/* Validate flags. */ /* Validate flags. */
u32 mask = ~0x1F; u32 mask;
if (hos::GetVersion() < hos::Version_7_0_0) { if (hos::GetVersion() >= hos::Version_11_0_0) {
/* 7.0.0 added 0x10 as a valid bit to NPDM flags, so before that we only check 0xF. */ /* 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; mask = ~0xF;
} }
/* We set the "DisableDeviceAddressSpaceMerge" bit on all versions, so be permissive with it. */
mask &= ~0x20;
R_UNLESS(!(npdm->flags & mask), ResultInvalidMeta()); R_UNLESS(!(npdm->flags & mask), ResultInvalidMeta());
/* Validate Acid extents. */ /* Validate Acid extents. */

View file

@ -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; *out = flags;
return ResultSuccess(); return ResultSuccess();
} }