Merge pull request #4324 from abhinav29102005/feat/libkernel-memory-pool-commit-type
fix(libkernel): propagate memory type in sceKernelMemoryPoolCommit and batch commit
This commit is contained in:
commit
5a031d49e8
|
|
@ -23,9 +23,9 @@ PoolState& Pool() {
|
|||
|
||||
bool PageAligned(uint64_t v) { return (v & (PS5_PAGE_SIZE - 1)) == 0; }
|
||||
|
||||
int PoolCommit(void* addr, uint64_t len, int prot) {
|
||||
int PoolCommit(void* addr, uint64_t len, int type, int prot) {
|
||||
if (!addr || len == 0 || !PageAligned(reinterpret_cast<uintptr_t>(addr)) || !PageAligned(len)) return SCE_KERNEL_ERROR_EINVAL;
|
||||
const int ret = DoMprotect(addr, static_cast<size_t>(len), prot);
|
||||
const int ret = DoMtypeprotect(addr, static_cast<size_t>(len), type, prot);
|
||||
if (ret == 0) {
|
||||
PoolState& pool = Pool();
|
||||
std::lock_guard<std::mutex> lock(pool.mutex);
|
||||
|
|
@ -67,7 +67,7 @@ int APS5_VABI sceKernelMemoryPoolBatch(const KernelMemoryPoolBatchEntry* entries
|
|||
const KernelMemoryPoolBatchEntry& e = entries[done];
|
||||
ret = Guarded([&] {
|
||||
switch (e.op) {
|
||||
case 1: return PoolCommit(e.commit.addr, e.commit.len, e.commit.prot);
|
||||
case 1: return PoolCommit(e.commit.addr, e.commit.len, e.commit.type, e.commit.prot);
|
||||
case 2: return PoolDecommit(e.decommit.addr, e.decommit.len);
|
||||
case 3: return DoMprotect(e.protect.addr, static_cast<size_t>(e.protect.len), e.protect.prot);
|
||||
case 4: return DoMtypeprotect(e.type_protect.addr, static_cast<size_t>(e.type_protect.len), e.type_protect.type, e.type_protect.prot);
|
||||
|
|
@ -81,9 +81,8 @@ int APS5_VABI sceKernelMemoryPoolBatch(const KernelMemoryPoolBatchEntry* entries
|
|||
}
|
||||
|
||||
int APS5_VABI sceKernelMemoryPoolCommit(void* addr, size_t len, int type, int prot, int flags) {
|
||||
(void)type;
|
||||
(void)flags;
|
||||
return Guarded([&] { return PoolCommit(addr, len, prot); });
|
||||
return Guarded([&] { return PoolCommit(addr, len, type, prot); });
|
||||
}
|
||||
|
||||
int APS5_VABI sceKernelMemoryPoolDecommit(void* addr, size_t len, int flags) {
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ int APS5_VABI sceKernelAvailableDirectMemorySize(std::int64_t, std::int64_t, std
|
|||
int APS5_VABI sceKernelCheckedReleaseDirectMemory(std::int64_t, std::size_t);
|
||||
int APS5_VABI sceKernelReserveVirtualRange(void**, std::size_t, int, std::size_t);
|
||||
int APS5_VABI sceKernelMemoryPoolReserve(void*, std::size_t, std::size_t, int, void**);
|
||||
int APS5_VABI sceKernelMemoryPoolCommit(void*, std::size_t, int, int, int);
|
||||
int APS5_VABI sceKernelOpen(const char*, int, std::uint16_t);
|
||||
int APS5_VABI sceKernelClose(int);
|
||||
std::int64_t APS5_VABI sceKernelRead(int, void*, std::size_t);
|
||||
|
|
@ -478,6 +479,19 @@ static void CheckMtypeprotect() {
|
|||
Require(sceKernelMemoryPoolBatch(&poolEntry, 1, &processed, 0) == 0 && processed == 1);
|
||||
check(1, 3, 1);
|
||||
check(2, 4, 1);
|
||||
Require(sceKernelMemoryPoolCommit(bytes + page * 2, page, 6, 3, 0) == 0);
|
||||
check(2, 6, 3);
|
||||
check(1, 3, 1);
|
||||
KernelMemoryPoolBatchEntry commitEntry{};
|
||||
commitEntry.op = 1;
|
||||
commitEntry.commit.addr = bytes + page * 2;
|
||||
commitEntry.commit.len = page;
|
||||
commitEntry.commit.prot = 1;
|
||||
commitEntry.commit.type = 7;
|
||||
processed = -1;
|
||||
Require(sceKernelMemoryPoolBatch(&commitEntry, 1, &processed, 0) == 0 && processed == 1);
|
||||
check(1, 3, 1);
|
||||
check(2, 7, 1);
|
||||
Require(sceKernelMtypeprotect(bytes, page * 3, 2, 3) == 0);
|
||||
VirtualQueryInfo whole{};
|
||||
Require(sceKernelVirtualQuery(bytes, 0, &whole, sizeof(whole)) == 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue