nx-hbloader icon indicating copy to clipboard operation
nx-hbloader copied to clipboard

Add some non-zero SystemResourceSize to NPDM

Open DCNick3 opened this issue 4 years ago • 8 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"
     },

DCNick3 avatar Nov 01 '20 09:11 DCNick3

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.

fincs avatar Nov 01 '20 11:11 fincs

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

DCNick3 avatar Nov 01 '20 11:11 DCNick3

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.

fincs avatar Nov 01 '20 11:11 fincs

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).

DCNick3 avatar Nov 01 '20 12:11 DCNick3

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!).

fincs avatar Nov 01 '20 12:11 fincs

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..

DCNick3 avatar Nov 01 '20 12:11 DCNick3

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.

SciresM avatar Nov 01 '20 12:11 SciresM

(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).

SciresM avatar Nov 01 '20 12:11 SciresM