mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-13 22:23:45 +00:00
parent
67fc1ec42b
commit
ad1f38a780
@ -64,14 +64,22 @@ enum {
|
||||
};
|
||||
|
||||
typedef Genode::Bit_allocator<HANDY_PAGES> Page_ids;
|
||||
typedef Genode::Bit_allocator<MAX_CHUNK_IDS> Chunk_ids;
|
||||
typedef Genode::Bit_array<PAGES_SUPERPAGE> Free_ids;
|
||||
typedef Genode::Bit_array<PAGES_SUPERPAGE> Free_ids;
|
||||
|
||||
class Chunk_ids: public Genode::Bit_allocator<MAX_CHUNK_IDS>
|
||||
{
|
||||
public:
|
||||
|
||||
void reserve(Genode::addr_t bit_start, size_t const num) {
|
||||
_reserve(bit_start, num); };
|
||||
};
|
||||
|
||||
static Page_ids page_ids;
|
||||
static Chunk_ids chunk_ids;
|
||||
|
||||
|
||||
static Sub_rm_connection &vm_memory(Genode::addr_t vm_size = 0)
|
||||
|
||||
static Sub_rm_connection &vm_memory(Genode::uint64_t vm_size = 0)
|
||||
{
|
||||
/* memory used by the VM in any order as the VMM asks for allocations */
|
||||
static Sub_rm_connection vm_memory(genode_env(), vm_size);
|
||||
@ -113,6 +121,12 @@ static Sub_rm_connection &vm_memory(Genode::addr_t vm_size = 0)
|
||||
memory = fli.page();
|
||||
}
|
||||
|
||||
/* reserve chunkids which are special or unused */
|
||||
chunk_ids.reserve(0, CHUNKID_START);
|
||||
addr_t const unused_id = CHUNKID_START + vm_size / GMM_CHUNK_SIZE;
|
||||
addr_t const unused_count = MAX_CHUNK_IDS - unused_id - 1;
|
||||
chunk_ids.reserve(unused_id, unused_count);
|
||||
|
||||
return vm_memory;
|
||||
}
|
||||
|
||||
@ -156,7 +170,7 @@ HRESULT genode_setup_machine(ComObjPtr<Machine> machine)
|
||||
HRESULT ret = genode_check_memory_config(machine);
|
||||
|
||||
if (ret == VINF_SUCCESS)
|
||||
vm_memory(memory_vbox * 1024 * 1024 + (CHUNKID_START + 1) * GMM_CHUNK_SIZE);
|
||||
vm_memory(1024ULL * 1024 * memory_vbox + (CHUNKID_START + 1) * GMM_CHUNK_SIZE);
|
||||
|
||||
return ret;
|
||||
};
|
||||
@ -307,17 +321,6 @@ int SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned uOperation,
|
||||
GVMMCREATEVMREQ &req = reinterpret_cast<GVMMCREATEVMREQ &>(*pReqHdr);
|
||||
SUPR3QueryHWACCLonGenodeSupport(reinterpret_cast<VM *>(req.pVMR3));
|
||||
|
||||
/* reserve lower chunk ids */
|
||||
try {
|
||||
for (unsigned i = 0; i < CHUNKID_START; i++) {
|
||||
unsigned chunkid = chunk_ids.alloc();
|
||||
AssertMsg(chunkid == i, ("chunkid %u != %u i\n", chunkid, i));
|
||||
}
|
||||
} catch (...) {
|
||||
Genode::error(__func__," ", __LINE__, " allocation failed");
|
||||
throw;
|
||||
}
|
||||
|
||||
return VINF_SUCCESS;
|
||||
}
|
||||
case VMMR0_DO_GVMM_REGISTER_VMCPU:
|
||||
@ -443,7 +446,7 @@ int SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned uOperation,
|
||||
Assert(req->idChunkUnmap == NIL_GMM_CHUNKID);
|
||||
Assert(req->idChunkMap != NIL_GMM_CHUNKID);
|
||||
|
||||
Genode::addr_t local_addr_offset = req->idChunkMap << GMM_CHUNK_SHIFT;
|
||||
Genode::addr_t local_addr_offset = (uintptr_t)req->idChunkMap << GMM_CHUNK_SHIFT;
|
||||
Genode::addr_t to = vm_memory().local_addr(local_addr_offset);
|
||||
|
||||
req->pvR3 = reinterpret_cast<RTR3PTR>(to);
|
||||
@ -501,7 +504,7 @@ int SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned uOperation,
|
||||
AssertMsgReturn(pVM->pgm.s.aHandyPages[iFirst + iPage].idSharedPage == NIL_GMM_PAGEID, ("#%#x: %#x\n", iFirst + iPage, pVM->pgm.s.aHandyPages[iFirst + iPage].idSharedPage), VERR_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
unsigned chunkid = 0;
|
||||
Genode::uint64_t chunkid = 0;
|
||||
|
||||
try {
|
||||
chunkid = chunk_ids.alloc();
|
||||
@ -576,7 +579,7 @@ int SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned uOperation,
|
||||
Assert(pVM->pgm.s.cLargeHandyPages == 0);
|
||||
|
||||
try {
|
||||
unsigned chunkid = chunk_ids.alloc();
|
||||
Genode::uint64_t chunkid = chunk_ids.alloc();
|
||||
|
||||
pVM->pgm.s.aLargeHandyPage[0].idPage = (chunkid << GMM_CHUNKID_SHIFT);
|
||||
pVM->pgm.s.aLargeHandyPage[0].HCPhysGCPhys = vm_memory().local_addr(chunkid << GMM_CHUNK_SHIFT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user