Compare commits

..

8 Commits

Author SHA1 Message Date
Michael Scire
fa0df994ba git subrepo push libraries
subrepo:
  subdir:   "libraries"
  merged:   "f6dac1e6"
upstream:
  origin:   "https://github.com/Atmosphere-NX/Atmosphere-libs"
  branch:   "master"
  commit:   "f6dac1e6"
git-subrepo:
  version:  "0.4.1"
  origin:   "???"
  commit:   "???"
2020-09-17 08:34:48 -07:00
Michael Scire
909a1767a6 ams: bump version to 0.14.4 2020-09-17 08:34:02 -07:00
Michael Scire
dbe59fd041 kern: fix KCodeMemory SVCs when Owner process != Generator process 2020-09-17 08:26:08 -07:00
Michael Scire
9b65daf439 kern: default to release config 2020-09-17 08:26:08 -07:00
Michael Scire
4acdc899f5 kern: generate fatal error on panic 2020-09-17 08:26:08 -07:00
Michael Scire
76957e502d kern: add build-define for logging to iram ringbuffer 2020-09-17 08:26:08 -07:00
Michael Scire
909397233c sm: Fix atmosphere-extension interaction with official JIT sysmodule usage 2020-09-17 08:24:47 -07:00
Michael Scire
211a828730 ro: fix process handle leak when using JitPlugin NROs 2020-09-17 08:17:11 -07:00
10 changed files with 67 additions and 12 deletions

View File

@@ -1,4 +1,12 @@
# Changelog
## 0.14.4
+ Several bugs were fixed involving the official jit sysmodule added in 10.0.0.
+ A Process handle leak was fixed when JitPlugin NRRs were registered with the `ro` sysmodule.
+ This prevented processes using jit from being able to exit, causing a full system freeze.
+ The `sm` atmosphere extension to not unregister services when the server's connection is closed was special-case disabled for `jit:u`.
+ This extension is normally desirable in order to allow more concurrent processes to exist (as only 0x40 sm connections may ever be concurrently open), but official jit sysmodule relies on the behavior.
+ This would cause crashes on attempts to launch a program using jit services more than once per reboot.
+ General system stability improvements to enhance the user's experience.
## 0.14.3
+ Support was added for 10.2.0.
+ General system stability improvements to enhance the user's experience.

View File

@@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/Atmosphere-NX/Atmosphere-libs
branch = master
commit = 48dbf4808f4f2042de8c45e9ec471a8f60d5d621
parent = 47d0d5c6abc1c9957cd05c63b02ee5e712179b80
commit = f6dac1e67793233cc916f317cf517244dd348a5e
parent = 909a1767a6080bab7ea6032c00e1ff4cec993af0
method = merge
cmdver = 0.4.1

View File

@@ -17,7 +17,7 @@
#define ATMOSPHERE_RELEASE_VERSION_MAJOR 0
#define ATMOSPHERE_RELEASE_VERSION_MINOR 14
#define ATMOSPHERE_RELEASE_VERSION_MICRO 3
#define ATMOSPHERE_RELEASE_VERSION_MICRO 4
#define ATMOSPHERE_RELEASE_VERSION ATMOSPHERE_RELEASE_VERSION_MAJOR, ATMOSPHERE_RELEASE_VERSION_MINOR, ATMOSPHERE_RELEASE_VERSION_MICRO

View File

@@ -382,13 +382,13 @@ namespace ams::ro::impl {
}
/* Context utilities. */
Result RegisterProcess(size_t *out_context_id, Handle process_handle, os::ProcessId process_id) {
Result RegisterProcess(size_t *out_context_id, os::ManagedHandle process_handle, os::ProcessId process_id) {
/* Validate process handle. */
{
os::ProcessId handle_pid = os::InvalidProcessId;
/* Validate handle is a valid process handle. */
R_UNLESS(R_SUCCEEDED(os::TryGetProcessId(&handle_pid, process_handle)), ResultInvalidProcess());
R_UNLESS(R_SUCCEEDED(os::TryGetProcessId(&handle_pid, process_handle.Get())), ResultInvalidProcess());
/* Validate process id. */
R_UNLESS(handle_pid == process_id, ResultInvalidProcess());
@@ -397,7 +397,7 @@ namespace ams::ro::impl {
/* Check if a process context already exists. */
R_UNLESS(GetContextByProcessId(process_id) == nullptr, ResultInvalidSession());
*out_context_id = AllocateContext(process_handle, process_id);
*out_context_id = AllocateContext(process_handle.Move(), process_id);
return ResultSuccess();
}
@@ -413,13 +413,13 @@ namespace ams::ro::impl {
}
/* Service implementations. */
Result RegisterModuleInfo(size_t context_id, Handle process_h, u64 nrr_address, u64 nrr_size, NrrKind nrr_kind, bool enforce_nrr_kind) {
Result RegisterModuleInfo(size_t context_id, os::ManagedHandle process_handle, u64 nrr_address, u64 nrr_size, NrrKind nrr_kind, bool enforce_nrr_kind) {
/* Get context. */
ProcessContext *context = GetContextById(context_id);
AMS_ABORT_UNLESS(context != nullptr);
/* Get program id. */
const ncm::ProgramId program_id = context->GetProgramId(process_h);
const ncm::ProgramId program_id = context->GetProgramId(process_handle.Get());
/* Validate address/size. */
R_TRY(ValidateAddressAndNonZeroSize(nrr_address, nrr_size));

View File

@@ -30,12 +30,12 @@ namespace ams::ro::impl {
bool ShouldEaseNroRestriction();
/* Context utilities. */
Result RegisterProcess(size_t *out_context_id, Handle process_handle, os::ProcessId process_id);
Result RegisterProcess(size_t *out_context_id, os::ManagedHandle process_handle, os::ProcessId process_id);
Result ValidateProcess(size_t context_id, os::ProcessId process_id);
void UnregisterProcess(size_t context_id);
/* Service implementations. */
Result RegisterModuleInfo(size_t context_id, Handle process_h, u64 nrr_address, u64 nrr_size, NrrKind nrr_kind, bool enforce_nrr_kind);
Result RegisterModuleInfo(size_t context_id, os::ManagedHandle process_h, u64 nrr_address, u64 nrr_size, NrrKind nrr_kind, bool enforce_nrr_kind);
Result UnregisterModuleInfo(size_t context_id, u64 nrr_address);
Result MapManualLoadModuleMemory(u64 *out_address, size_t context_id, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size);
Result UnmapManualLoadModuleMemory(size_t context_id, u64 nro_address);

View File

@@ -56,12 +56,20 @@ namespace ams::ro {
}
Result RoService::RegisterProcessHandle(const sf::ClientProcessId &client_pid, sf::CopyHandle process_h) {
return impl::RegisterProcess(std::addressof(this->context_id), process_h.GetValue(), client_pid.GetValue());
/* Ensure we manage references to the process handle correctly. */
os::ManagedHandle process_handle(process_h.GetValue());
/* Register the process. */
return impl::RegisterProcess(std::addressof(this->context_id), std::move(process_handle), client_pid.GetValue());
}
Result RoService::RegisterProcessModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h) {
/* Ensure we manage references to the process handle correctly. */
os::ManagedHandle process_handle(process_h.GetValue());
/* Register the module. */
R_TRY(impl::ValidateProcess(this->context_id, client_pid.GetValue()));
return impl::RegisterModuleInfo(this->context_id, process_h.GetValue(), nrr_address, nrr_size, this->nrr_kind, this->nrr_kind == NrrKind_JitPlugin);
return impl::RegisterModuleInfo(this->context_id, std::move(process_handle), nrr_address, nrr_size, this->nrr_kind, this->nrr_kind == NrrKind_JitPlugin);
}
}

View File

@@ -350,6 +350,12 @@ namespace ams::sm::impl {
return service == ServiceName::Encode("fsp-srv");
}
bool ShouldCloseOnClientDisconnect(ServiceName service) {
/* jit sysmodule is closed and relaunched by am for each application which uses it. */
constexpr auto JitU = ServiceName::Encode("jit:u");
return service == JitU;
}
Result GetMitmServiceHandleImpl(Handle *out, ServiceInfo *service_info, const MitmProcessInfo &client_info) {
/* Send command to query if we should mitm. */
bool should_mitm;
@@ -419,6 +425,28 @@ namespace ams::sm::impl {
return ResultSuccess();
}
}
/* Client disconnection callback. */
void OnClientDisconnected(os::ProcessId process_id) {
/* Ensure that the process id is valid. */
if (process_id == os::InvalidProcessId) {
return;
}
/* NOTE: Nintendo unregisters all services a process hosted on client close. */
/* We do not do this as an atmosphere extension, in order to reduce the number */
/* of sessions open at any given time. */
/* However, certain system behavior (jit) relies on this occurring. */
/* As such, we will special case the system components which rely on the behavior. */
for (size_t i = 0; i < ServiceCountMax; i++) {
if (g_service_list[i].name != InvalidServiceName && g_service_list[i].owner_process_id == process_id) {
if (ShouldCloseOnClientDisconnect(g_service_list[i].name)) {
g_service_list[i].Free();
}
}
}
}
/* Process management. */

View File

@@ -19,6 +19,9 @@
namespace ams::sm::impl {
/* Client disconnection callback. */
void OnClientDisconnected(os::ProcessId process_id);
/* Process management. */
Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size);
Result UnregisterProcess(os::ProcessId process_id);

View File

@@ -19,6 +19,12 @@
namespace ams::sm {
UserService::~UserService() {
if (this->has_initialized) {
impl::OnClientDisconnected(this->process_id);
}
}
Result UserService::RegisterClient(const sf::ClientProcessId &client_process_id) {
this->process_id = client_process_id.GetValue();
this->has_initialized = true;

View File

@@ -26,6 +26,8 @@ namespace ams::sm {
bool has_initialized = false;
private:
Result EnsureInitialized();
public:
virtual ~UserService();
public:
/* Official commands. */
Result RegisterClient(const sf::ClientProcessId &client_process_id);