diff --git a/stratosphere/sm/Makefile b/stratosphere/sm/Makefile index dd7eb33ad..a0da4da5b 100644 --- a/stratosphere/sm/Makefile +++ b/stratosphere/sm/Makefile @@ -34,7 +34,7 @@ ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE CFLAGS := -g -Wall -O2 -ffunction-sections \ $(ARCH) $(DEFINES) -CFLAGS += $(INCLUDE) -D__SWITCH__ -DSM_ENABLE_SMHAX -DSM_ENABLE_MITM +CFLAGS += $(INCLUDE) -D__SWITCH__ -DSM_ENABLE_SMHAX -DSM_ENABLE_MITM -DSM_MINIMUM_SESSION_LIMIT=8 CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 diff --git a/stratosphere/sm/source/sm_registration.cpp b/stratosphere/sm/source/sm_registration.cpp index b6e4e3169..1a5f49ce4 100644 --- a/stratosphere/sm/source/sm_registration.cpp +++ b/stratosphere/sm/source/sm_registration.cpp @@ -252,6 +252,12 @@ Result Registration::RegisterServiceForPid(u64 pid, u64 service, u64 max_session return 0x815; } +#ifdef SM_MINIMUM_SESSION_LIMIT + if (max_sessions < SM_MINIMUM_SESSION_LIMIT) { + max_sessions = SM_MINIMUM_SESSION_LIMIT; + } +#endif + Registration::Service *free_service = GetFreeService(); if (free_service == NULL) { return 0xA15; @@ -288,6 +294,12 @@ Result Registration::RegisterServiceForSelf(u64 service, u64 max_sessions, bool if (HasService(service)) { return 0x815; } + +#ifdef SM_MINIMUM_SESSION_LIMIT + if (max_sessions < SM_MINIMUM_SESSION_LIMIT) { + max_sessions = SM_MINIMUM_SESSION_LIMIT; + } +#endif Registration::Service *free_service = GetFreeService(); if (free_service == NULL) {