summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZephyron <zephyron@citron-emu.org>2025-01-29 13:17:07 +1000
committerZephyron <zephyron@citron-emu.org>2025-01-29 13:17:07 +1000
commit613099703af39a0ac680a15930d9c2c1e31a9b29 (patch)
tree790157d92184142538e75988e6e2faa0d20fb5e1
parent9a3d4f048985b0d9e77fa07fe305913b8a13fda3 (diff)
kernel/svc: Implement InitialProcessIdRange and improve process exit handling
- Replace stubbed InitialProcessIdRange implementation with proper bounds (1-0x50) - Add handle and info_sub_id validation for InitialProcessIdRange - Replace process exit ASSERT with graceful error handling and logging - Add try-catch block around system.Exit() for safer shutdown - Add atomic header inclusion for binder.h This improves system call reliability by properly implementing process ID range checks and adding safer process exit handling with proper error logging.
-rw-r--r--src/core/hle/kernel/svc/svc_info.cpp12
-rw-r--r--src/core/hle/kernel/svc/svc_process.cpp15
-rw-r--r--src/core/hle/service/nvnflinger/binder.h2
-rw-r--r--vcpkg.json2
4 files changed, 24 insertions, 7 deletions
diff --git a/src/core/hle/kernel/svc/svc_info.cpp b/src/core/hle/kernel/svc/svc_info.cpp
index a66d633f8..26eb1ce92 100644
--- a/src/core/hle/kernel/svc/svc_info.cpp
+++ b/src/core/hle/kernel/svc/svc_info.cpp
@@ -174,9 +174,15 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
R_SUCCEED();
case InfoType::InitialProcessIdRange:
- LOG_WARNING(Kernel_SVC,
- "(STUBBED) Attempted to query privileged process id bounds, returned 0");
- *result = 0;
+ R_UNLESS(handle == 0, ResultInvalidHandle);
+ R_UNLESS(info_sub_id <= 1, ResultInvalidCombination);
+
+ // Return the valid range for initial process IDs
+ if (info_sub_id == 0) {
+ *result = 1; // Minimum initial process ID
+ } else {
+ *result = 0x50; // Maximum initial process ID
+ }
R_SUCCEED();
case InfoType::ThreadTickCount: {
diff --git a/src/core/hle/kernel/svc/svc_process.cpp b/src/core/hle/kernel/svc/svc_process.cpp
index 5c3e8829f..acd1864da 100644
--- a/src/core/hle/kernel/svc/svc_process.cpp
+++ b/src/core/hle/kernel/svc/svc_process.cpp
@@ -12,10 +12,19 @@ void ExitProcess(Core::System& system) {
auto* current_process = GetCurrentProcessPointer(system.Kernel());
LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessId());
- ASSERT_MSG(current_process->GetState() == KProcess::State::Running,
- "Process has already exited");
- system.Exit();
+ // Check if process is in a valid state for exit
+ if (current_process->GetState() != KProcess::State::Running) {
+ LOG_WARNING(Kernel_SVC, "Process {} already exiting or in invalid state", current_process->GetProcessId());
+ return;
+ }
+
+ // Ensure clean shutdown
+ try {
+ system.Exit();
+ } catch (const std::exception& e) {
+ LOG_ERROR(Kernel_SVC, "Error during process exit: {}", e.what());
+ }
}
/// Gets the ID of the specified process or a specified thread's owning process.
diff --git a/src/core/hle/service/nvnflinger/binder.h b/src/core/hle/service/nvnflinger/binder.h
index f9f326e3b..6928a81ec 100644
--- a/src/core/hle/service/nvnflinger/binder.h
+++ b/src/core/hle/service/nvnflinger/binder.h
@@ -1,11 +1,13 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2014 The Android Open Source Project
+// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// Parts of this implementation were based on:
// https://cs.android.com/android/platform/superproject/+/android-5.1.1_r38:frameworks/native/include/binder/IBinder.h
#pragma once
+#include <atomic>
#include <span>
#include "common/common_types.h"
diff --git a/vcpkg.json b/vcpkg.json
index 8fa0de0c2..180232afd 100644
--- a/vcpkg.json
+++ b/vcpkg.json
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "citron",
- "builtin-baseline": "c82f74667287d3dc386bce81e44964370c91a289",
+ "builtin-baseline": "7adc2e4d49e8d0efc07a369079faa6bc3dbb90f3",
"version": "1.0",
"dependencies": [
"boost-algorithm",