switchbrew / nx-hbloader

Host process for loading Switch homebrew NROs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add some non-zero SystemResourceSize to NPDM

DCNick3 opened this issue · comments

As for now, all homebrew apps are ran with SystemResourceSize = 0. This prevents from doing anything useful with svcMapPhysicalMemory, as it uses this limit. I propose increasing it to maximum value - 0x1FE00000 to suit all (possible) homebrew.

This should be as simple as:

--- a/hbl.json
+++ b/hbl.json
@@ -11,6 +11,7 @@
     "is_64_bit": true,
     "address_space_type": 1,
     "is_retail": true,
+    "system_resource_size": "0x1FE00000",
     "filesystem_access": {
         "permissions": "0xFFFFFFFFFFFFFFFF"
     },
commented

Support for new-style heap allocation is under consideration, however there are still problems we need to solve, such as the fact that it is not available on kernels older than 3.0.

it is not available on kernels older than 3.0.

Wouldn't stable release of mesosphere lift this problem? I heard SciresM talk about it providing newer SVCs on low firmware versions

commented

Yes it does. However we cannot have hbloader unconditionally use it regardless of system version, because it would break compatibility with the official kernel on old system versions. We've also not taken a decision yet on whether we'd require mesosphère to run on older system versions.

Makes sense.

But, as far as I can understand SystemResourceSize NPDM field was simply reserved before 3.0.0. I guess whether adding it would be a breaking change depends on the way it was "reserved": either ignored (just fine) or forced to be zero (would be problematic).

commented

I mean the fact that we'd have to remove usage of svcSetHeapSize in favor of dynamically resizing heap using PhysicalMemory SVCs. Currently it is using the old approach of reserving all the memory (leaving nothing left for potential PhysicalMemory users!).

Oh, yeah, now I see the problem. Maybe something hybrid would work: use the novel API when available and svcSetHeapSize as a fallback. But this would probably be a maintenance pain..

The actual field isn't an issue, as the field in CreateProcessParameter is only set on 3.0.0+ (https://github.com/Atmosphere-NX/Atmosphere/blob/master/stratosphere/loader/source/ldr_process_creation.cpp#L340), and even then 1.0.0/2.0.0 kernels simply do not access the field inside svc::CreateProcessParameter (it was reserved/padding previously).

But yeah, it requires actual hbl design logic thought/changes, as finc has described.

(But also, yeah, if you want to use physical memory on < 3.0.0 this will require ams.loader changes. I guess I should think about that once mesosphere is stable).