sysdeps/managarm: Use VM_REMAP to unmap memory
@@ -372,7 +372,39 @@ int sys_vm_remap(void *pointer, size_t size, size_t new_size, void **window) {
}
int sys_vm_unmap(void *pointer, size_t size) {
- HEL_CHECK(helUnmapMemory(kHelNullHandle, pointer, (size + 0xFFF) & ~size_t(0xFFF)));
+ HelAction actions[3];
+ globalQueue.trim();
+
+ managarm::posix::CntRequest<MemoryAllocator> req(getAllocator());
+ req.set_request_type(managarm::posix::CntReqType::VM_UNMAP);
+ req.set_address(reinterpret_cast<uintptr_t>(pointer));
+ req.set_size(size);
+
+ frigg::String<MemoryAllocator> ser(getAllocator());
+ req.SerializeToString(&ser);
+ actions[0].type = kHelActionOffer;
+ actions[0].flags = kHelItemAncillary;
+ actions[1].type = kHelActionSendFromBuffer;
+ actions[1].flags = kHelItemChain;
+ actions[1].buffer = ser.data();
+ actions[1].length = ser.size();
+ actions[2].type = kHelActionRecvInline;
+ actions[2].flags = 0;
+ HEL_CHECK(helSubmitAsync(kHelThisThread, actions, 3,
+ globalQueue.getQueue(), 0, 0));
+
+ auto element = globalQueue.dequeueSingle();
+ auto offer = parseSimple(element);
+ auto send_req = parseSimple(element);
+ auto recv_resp = parseInline(element);
+
+ HEL_CHECK(offer->error);
+ HEL_CHECK(send_req->error);
+ HEL_CHECK(recv_resp->error);
+
+ managarm::posix::SvrResponse<MemoryAllocator> resp(getAllocator());
+ resp.ParseFromArray(recv_resp->data, recv_resp->length);
+ __ensure(resp.error() == managarm::posix::Errors::SUCCESS);
return 0;
}
