Patch kernel11 to remove checks on core2/3 thread creation
This stubs checks in SvcCreateThread and SvcSetProcessIdealProcessor that applied when creating threads on core2 and core3. This allows non-sysmodules to create threads on core3. Please note, core2 access was already being automatically granted to 3dsx apps for a long time (this is controlled through a kernel flag), and other apps that needed it had that flag too. This commit thus changes nothing for all these applications. Do not create threads on core3 unless you know exactly what you're doing. On N3DS, gsp (GPU sysmodule) depends on qtm (head-tracking sysmodule) which runs many threads at very high priority on core3. Running code that needs the GPU (including printf) on core3 can thus result in thread starvation / deadlock. If you just need an extra application core, just use core2 as it is intended for that exact purpose and is by default completely idle. Closes #1668
This commit is contained in:
parent
71cf677b00
commit
fcd08d6614
@ -1,7 +1,7 @@
|
||||
%rename link old_link
|
||||
|
||||
*link:
|
||||
%(old_link) -T %:getenv(TOPDIR /linker.ld) --nmagic --gc-sections
|
||||
%(old_link) -T %:getenv(TOPDIR /linker.ld) --nmagic --gc-sections --no-warn-rwx-segments
|
||||
|
||||
*startfile:
|
||||
crti%O%s crtbegin%O%s
|
||||
|
@ -1,7 +1,7 @@
|
||||
%rename link old_link
|
||||
|
||||
*link:
|
||||
%(old_link) -T %:getenv(TOPDIR /linker.ld) --nmagic --gc-sections
|
||||
%(old_link) -T %:getenv(TOPDIR /linker.ld) --nmagic --gc-sections --no-warn-rwx-segments
|
||||
|
||||
*startfile:
|
||||
crti%O%s crtbegin%O%s
|
||||
|
@ -271,6 +271,23 @@ u32 patchKernel11(u8 *pos, u32 size, u32 baseK11VA, u32 *arm11SvcTable, u32 *arm
|
||||
off[-5] = 0xE51FF004;
|
||||
off[-4] = K11EXT_VA + 0x2C;
|
||||
|
||||
if (ISN3DS)
|
||||
{
|
||||
// Patch SvcSetProcessIdealProcessor and SvcCreate thread to always allow
|
||||
// for core2 and core3 to be used. Normally, processes with the 0x2000 kernel flag
|
||||
// have access to core2, and BASE processes have access to both core2 and core3.
|
||||
// We're patching the if (memory region == BASE) check to be always true.
|
||||
off = (u32 *)pos;
|
||||
for (u32 i = 0; i < 2 && (u8 *)off < pos + size; i++)
|
||||
{
|
||||
// cmp r2, #0x300; beq...
|
||||
for (; (off[0] != 0xE3520C03 || off[1] != 0x0A000003) && (u8 *)off < pos + size; off++);
|
||||
if ((u8 *)off > pos + size)
|
||||
return 1;
|
||||
off[1] = 0xEA000003;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -581,7 +598,7 @@ u32 patchP9AMTicketWrapperZeroKeyIV(u8 *pos, u32 size, u32 firmVersion)
|
||||
//Beyond limit
|
||||
if(opjumpdistance < -0x1fffff || opjumpdistance > 0x1fffff) return 1;
|
||||
|
||||
//r0 and r1 for old call are already correct for this one
|
||||
//r0 and r1 for old call are already correct for this one
|
||||
//BLX __rt_memclr
|
||||
u32 op = (0xE800F000U | (((u32)opjumpdistance & 0x7FF) << 16) | (((u32)opjumpdistance >> 11) & 0x3FF) | (((u32)opjumpdistance >> 21) & 0x400)) & ~(1<<16);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
%rename link old_link
|
||||
|
||||
*link:
|
||||
%(old_link) -T %:getenv(TOPDIR /linker.ld) --nmagic --gc-sections
|
||||
%(old_link) -T %:getenv(TOPDIR /linker.ld) --nmagic --gc-sections --no-warn-rwx-segments
|
||||
|
||||
*startfile:
|
||||
crti%O%s crtbegin%O%s
|
||||
|
Loading…
x
Reference in New Issue
Block a user