mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-05 15:56:49 +00:00
Fix vm::falloc() for misaligned args (#9764)
Force addr/size alignment.
This commit is contained in:
parent
f009d36811
commit
5b044a93c1
@ -1236,15 +1236,23 @@ namespace vm
|
||||
// Determine minimal alignment
|
||||
const u32 min_page_size = flags & 0x100 ? 0x1000 : 0x10000;
|
||||
|
||||
// Take address misalignment into account
|
||||
const u32 size0 = orig_size + addr % min_page_size;
|
||||
|
||||
// Align to minimal page size
|
||||
const u32 size = utils::align(orig_size, min_page_size);
|
||||
const u32 size = utils::align(size0, min_page_size);
|
||||
|
||||
// return if addr or size is invalid
|
||||
if (!size || addr < this->addr || orig_size > size || addr + u64{size} > this->addr + u64{this->size} || flags & 0x10)
|
||||
// If shared memory is provided, addr/size must be aligned
|
||||
if (!size || addr < this->addr || orig_size > size0 || orig_size > size ||
|
||||
(addr - addr % min_page_size) + u64{size} > this->addr + u64{this->size} || (src && (orig_size | addr) % min_page_size) || flags & 0x10)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Force aligned address
|
||||
addr -= addr % min_page_size;
|
||||
|
||||
u8 pflags = flags & 0x1000 ? 0 : page_readable | page_writable;
|
||||
|
||||
if ((flags & SYS_MEMORY_PAGE_SIZE_64K) == SYS_MEMORY_PAGE_SIZE_64K)
|
||||
|
Loading…
Reference in New Issue
Block a user