summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-12-31 17:10:05 +0100
committerGitHub <noreply@github.com>2018-12-31 17:10:05 +0100
commit09ffa0cb21fa5421934bfa3f69ba9226a345e193 (patch)
treeabe7a8e46dedee288fd91e6de02496169d381a2a /src/core/hle/kernel/svc.cpp
parentMerge pull request #1965 from lioncash/fmt (diff)
parentkernel/svc: Correct misleading error message within CreateThread() (diff)
downloadyuzu-09ffa0cb21fa5421934bfa3f69ba9226a345e193.tar
yuzu-09ffa0cb21fa5421934bfa3f69ba9226a345e193.tar.gz
yuzu-09ffa0cb21fa5421934bfa3f69ba9226a345e193.tar.bz2
yuzu-09ffa0cb21fa5421934bfa3f69ba9226a345e193.tar.lz
yuzu-09ffa0cb21fa5421934bfa3f69ba9226a345e193.tar.xz
yuzu-09ffa0cb21fa5421934bfa3f69ba9226a345e193.tar.zst
yuzu-09ffa0cb21fa5421934bfa3f69ba9226a345e193.zip
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 660e6f577..6588bd3b8 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -715,8 +715,8 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
enum class GetInfoType : u64 {
// 1.0.0+
- AllowedCpuIdBitmask = 0,
- AllowedThreadPrioBitmask = 1,
+ AllowedCPUCoreMask = 0,
+ AllowedThreadPriorityMask = 1,
MapRegionBaseAddr = 2,
MapRegionSize = 3,
HeapRegionBaseAddr = 4,
@@ -747,8 +747,8 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
const auto info_id_type = static_cast<GetInfoType>(info_id);
switch (info_id_type) {
- case GetInfoType::AllowedCpuIdBitmask:
- case GetInfoType::AllowedThreadPrioBitmask:
+ case GetInfoType::AllowedCPUCoreMask:
+ case GetInfoType::AllowedThreadPriorityMask:
case GetInfoType::MapRegionBaseAddr:
case GetInfoType::MapRegionSize:
case GetInfoType::HeapRegionBaseAddr:
@@ -774,12 +774,12 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
}
switch (info_id_type) {
- case GetInfoType::AllowedCpuIdBitmask:
- *result = process->GetAllowedProcessorMask();
+ case GetInfoType::AllowedCPUCoreMask:
+ *result = process->GetCoreMask();
return RESULT_SUCCESS;
- case GetInfoType::AllowedThreadPrioBitmask:
- *result = process->GetAllowedThreadPriorityMask();
+ case GetInfoType::AllowedThreadPriorityMask:
+ *result = process->GetPriorityMask();
return RESULT_SUCCESS;
case GetInfoType::MapRegionBaseAddr:
@@ -1219,12 +1219,6 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V
"threadpriority=0x{:08X}, processorid=0x{:08X} : created handle=0x{:08X}",
entry_point, arg, stack_top, priority, processor_id, *out_handle);
- if (priority > THREADPRIO_LOWEST) {
- LOG_ERROR(Kernel_SVC, "An invalid priority was specified, expected {} but got {}",
- THREADPRIO_LOWEST, priority);
- return ERR_INVALID_THREAD_PRIORITY;
- }
-
auto* const current_process = Core::CurrentProcess();
if (processor_id == THREADPROCESSORID_IDEAL) {
@@ -1233,17 +1227,29 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V
ASSERT(processor_id != THREADPROCESSORID_IDEAL);
}
- switch (processor_id) {
- case THREADPROCESSORID_0:
- case THREADPROCESSORID_1:
- case THREADPROCESSORID_2:
- case THREADPROCESSORID_3:
- break;
- default:
+ if (processor_id < THREADPROCESSORID_0 || processor_id > THREADPROCESSORID_3) {
LOG_ERROR(Kernel_SVC, "Invalid thread processor ID: {}", processor_id);
return ERR_INVALID_PROCESSOR_ID;
}
+ const u64 core_mask = current_process->GetCoreMask();
+ if ((core_mask | (1ULL << processor_id)) != core_mask) {
+ LOG_ERROR(Kernel_SVC, "Invalid thread core specified ({})", processor_id);
+ return ERR_INVALID_PROCESSOR_ID;
+ }
+
+ if (priority > THREADPRIO_LOWEST) {
+ LOG_ERROR(Kernel_SVC,
+ "Invalid thread priority specified ({}). Must be within the range 0-64",
+ priority);
+ return ERR_INVALID_THREAD_PRIORITY;
+ }
+
+ if (((1ULL << priority) & current_process->GetPriorityMask()) == 0) {
+ LOG_ERROR(Kernel_SVC, "Invalid thread priority specified ({})", priority);
+ return ERR_INVALID_THREAD_PRIORITY;
+ }
+
const std::string name = fmt::format("thread-{:X}", entry_point);
auto& kernel = Core::System::GetInstance().Kernel();
CASCADE_RESULT(SharedPtr<Thread> thread,