mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-23 06:40:49 +00:00
LV2/Loader: Fix kernel regions addresses
This commit is contained in:
parent
7a0185dbcc
commit
1843a27c2a
@ -1860,16 +1860,31 @@ bool ppu_load_exec(const ppu_exec_object& elf, bool virtual_load, const std::str
|
|||||||
else if (already_loaded)
|
else if (already_loaded)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if (!vm::falloc(addr, size, vm::main))
|
else if (![&]() -> bool
|
||||||
{
|
{
|
||||||
ppu_loader.error("vm::falloc(vm::main) failed (addr=0x%x, memsz=0x%x)", addr, size); // TODO
|
// 1M pages if it is RSX shared
|
||||||
|
const u32 area_flags = (_seg.flags >> 28) ? vm::page_size_1m : vm::page_size_64k;
|
||||||
|
const u32 alloc_at = std::max<u32>(addr & -0x10000000, 0x10000);
|
||||||
|
|
||||||
if (!vm::falloc(addr, size))
|
const auto area = vm::reserve_map(vm::any, std::max<u32>(addr & -0x10000000, 0x10000), 0x10000000, area_flags);
|
||||||
|
|
||||||
|
if (!area)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (area->addr != alloc_at || (area->flags & 0xf00) != area_flags)
|
||||||
|
{
|
||||||
|
ppu_loader.error("Failed to allocate memory at 0x%x - conflicting memory area exists: area->addr=0x%x, area->flags=0x%x", addr, area->addr, area->flags);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return area->falloc(addr, size);
|
||||||
|
}())
|
||||||
{
|
{
|
||||||
ppu_loader.error("ppu_load_exec(): vm::falloc() failed (addr=0x%x, memsz=0x%x)", addr, size);
|
ppu_loader.error("ppu_load_exec(): vm::falloc() failed (addr=0x%x, memsz=0x%x)", addr, size);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Store only LOAD segments (TODO)
|
// Store only LOAD segments (TODO)
|
||||||
_main.segs.emplace_back(_seg);
|
_main.segs.emplace_back(_seg);
|
||||||
|
@ -85,6 +85,12 @@ struct sys_memory_address_table
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<vm::block_t> reserve_map(u32 alloc_size, u32 align)
|
||||||
|
{
|
||||||
|
return vm::reserve_map(align == 0x10000 ? vm::user64k : vm::user1m, 0, align == 0x10000 ? 0x20000000 : utils::align(alloc_size, 0x10000000)
|
||||||
|
, align == 0x10000 ? (vm::page_size_64k | vm::bf0_0x1) : (vm::page_size_1m | vm::bf0_0x1));
|
||||||
|
}
|
||||||
|
|
||||||
// Todo: fix order of error checks
|
// Todo: fix order of error checks
|
||||||
|
|
||||||
error_code sys_memory_allocate(cpu_thread& cpu, u32 size, u64 flags, vm::ptr<u32> alloc_addr)
|
error_code sys_memory_allocate(cpu_thread& cpu, u32 size, u64 flags, vm::ptr<u32> alloc_addr)
|
||||||
@ -123,7 +129,7 @@ error_code sys_memory_allocate(cpu_thread& cpu, u32 size, u64 flags, vm::ptr<u32
|
|||||||
return CELL_ENOMEM;
|
return CELL_ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto area = vm::reserve_map(align == 0x10000 ? vm::user64k : vm::user1m, 0, utils::align(size, 0x10000000), 0x401))
|
if (const auto area = reserve_map(size, align))
|
||||||
{
|
{
|
||||||
if (const u32 addr = area->alloc(size, nullptr, align))
|
if (const u32 addr = area->alloc(size, nullptr, align))
|
||||||
{
|
{
|
||||||
@ -197,7 +203,7 @@ error_code sys_memory_allocate_from_container(cpu_thread& cpu, u32 size, u32 cid
|
|||||||
return ct.ret;
|
return ct.ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto area = vm::reserve_map(align == 0x10000 ? vm::user64k : vm::user1m, 0, utils::align(size, 0x10000000), 0x401))
|
if (const auto area = reserve_map(size, align))
|
||||||
{
|
{
|
||||||
if (const u32 addr = area->alloc(size))
|
if (const u32 addr = area->alloc(size))
|
||||||
{
|
{
|
||||||
|
@ -1803,12 +1803,12 @@ namespace vm
|
|||||||
{
|
{
|
||||||
const u32 max = (0xC0000000 - size) & (0 - align);
|
const u32 max = (0xC0000000 - size) & (0 - align);
|
||||||
|
|
||||||
if (size > 0xC0000000 - 0x20000000 || max < 0x20000000)
|
if (size > 0xC0000000 - 0x10000000 || max < 0x10000000)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 addr = utils::align<u32>(0x20000000, align);; addr += align)
|
for (u32 addr = utils::align<u32>(0x10000000, align);; addr += align)
|
||||||
{
|
{
|
||||||
if (_test_map(addr, size))
|
if (_test_map(addr, size))
|
||||||
{
|
{
|
||||||
@ -2131,8 +2131,8 @@ namespace vm
|
|||||||
|
|
||||||
g_locations =
|
g_locations =
|
||||||
{
|
{
|
||||||
std::make_shared<block_t>(0x00010000, 0x1FFF0000, page_size_64k | preallocated), // main
|
std::make_shared<block_t>(0x00010000, 0x0FFF0000, page_size_64k | preallocated), // main
|
||||||
std::make_shared<block_t>(0x20000000, 0x10000000, page_size_64k | bf0_0x1), // user 64k pages
|
nullptr, // user 64k pages
|
||||||
nullptr, // user 1m pages
|
nullptr, // user 1m pages
|
||||||
nullptr, // rsx context
|
nullptr, // rsx context
|
||||||
std::make_shared<block_t>(0xC0000000, 0x10000000, page_size_64k | preallocated), // video
|
std::make_shared<block_t>(0xC0000000, 0x10000000, page_size_64k | preallocated), // video
|
||||||
|
Loading…
x
Reference in New Issue
Block a user