1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 04:32:35 +01:00

ppu: Stack size allocation improvements

This commit is contained in:
Eladash 2019-07-27 07:51:29 +03:00 committed by Ivan
parent 3ce18fd960
commit cbcd06d1dc
3 changed files with 4 additions and 4 deletions

View File

@ -1544,7 +1544,7 @@ void ppu_load_exec(const ppu_exec_object& elf)
case 0x70: primary_stacksize = 1024 * 1024; break; // SYS_PROCESS_PRIMARY_STACK_SIZE_1M
default:
{
primary_stacksize = sz >= 4096 ? ::align(std::min<u32>(sz, 0x100000), 4096) : 0x4000;
primary_stacksize = ::align<u32>(std::clamp<u32>(sz, 0x10000, 0x100000), 4096);
break;
}
}

View File

@ -307,7 +307,7 @@ error_code _sys_ppu_thread_create(vm::ptr<u64> thread_id, vm::ptr<ppu_thread_par
}
// Compute actual stack size and allocate
const u32 stack_size = _stacksz >= 4096 ? ::align(std::min<u32>(_stacksz, 0x100000), 4096) : 0x4000;
const u32 stack_size = ::align<u32>(std::max<u32>(_stacksz, 4096), 4096);
const vm::addr_t stack_base{vm::alloc(stack_size, vm::stack, 4096)};

View File

@ -709,7 +709,7 @@ namespace vm
}
// Return if size is invalid
if (!orig_size || !size || size > this->size)
if (!orig_size || !size || orig_size > size || size > this->size)
{
return 0;
}
@ -764,7 +764,7 @@ namespace vm
const u32 size = ::align(orig_size, min_page_size);
// return if addr or size is invalid
if (!size || addr < this->addr || addr + u64{size} > this->addr + u64{this->size} || flags & 0x10)
if (!size || addr < this->addr || orig_size > size || addr + u64{size} > this->addr + u64{this->size} || flags & 0x10)
{
return 0;
}