From 5cd596e53c0ebee22bb5f644a0ba4f1252dad6b1 Mon Sep 17 00:00:00 2001 From: Kostas Missos Date: Tue, 12 Feb 2019 00:36:24 +0200 Subject: [PATCH] Add SVC generic patches First patch allows same process on svcControlCodeMemory --- bootloader/hos/hos.c | 2 ++ bootloader/hos/pkg2.c | 2 ++ bootloader/hos/pkg2.h | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index 028afae..db93fa8 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -487,6 +487,8 @@ int hos_launch(ini_sec_t *cfg) for (u32 j = 0; j < kernel_patchset[i].val; j++) *(vu32 *)(ctxt.kernel + kernel_patchset[i].off + (j << 2)) = temp[j]; } + else if (kernel_patchset[i].id < SVC_VERIFY_DS) + *(vu32 *)(ctxt.kernel + kernel_patchset[i].off) = kernel_patchset[i].val; } } } diff --git a/bootloader/hos/pkg2.c b/bootloader/hos/pkg2.c index 724fa52..528a0ea 100644 --- a/bootloader/hos/pkg2.c +++ b/bootloader/hos/pkg2.c @@ -219,6 +219,7 @@ KERNEL_PATCHSET_DEF(_kernel_4_patchset, ); KERNEL_PATCHSET_DEF(_kernel_5_patchset, + { SVC_GENERIC, 0x38C2C, _NOP(), NULL }, // Allow same process on svcControlCodeMemory. { SVC_VERIFY_DS, 0x45E6C, _NOP(), NULL }, // Disable SVC verifications { DEBUG_MODE_EN, 0x5513C, _MOVZX(8, 1, 0), NULL }, // Enable Debug Patch // Atmosphère kernel patches. @@ -233,6 +234,7 @@ KERNEL_PATCHSET_DEF(_kernel_5_patchset, ); KERNEL_PATCHSET_DEF(_kernel_6_patchset, + { SVC_GENERIC, 0x3A8CC, _NOP(), NULL }, // Allow same process on svcControlCodeMemory. { SVC_VERIFY_DS, 0x47EA0, _NOP(), NULL }, // Disable SVC verifications { DEBUG_MODE_EN, 0x57548, _MOVZX(8, 1, 0), NULL }, // Enable Debug Patch // Atmosphère kernel patches. diff --git a/bootloader/hos/pkg2.h b/bootloader/hos/pkg2.h index 92d90bf..d1eae64 100644 --- a/bootloader/hos/pkg2.h +++ b/bootloader/hos/pkg2.h @@ -44,8 +44,10 @@ typedef struct _kernel_patch_t enum { - // Generic instruction patches - SVC_VERIFY_DS = 0x10, // 0x0-0xF are RESERVED. + // Always applied. + SVC_GENERIC = 0, + // Generic instruction patches. + SVC_VERIFY_DS = 0x10, DEBUG_MODE_EN, ATM_GEN_PATCH, // >4 bytes patches. Value is a pointer of a u32 array.