Skip to contentSkip to conversation

Mapping foreign frames from dom0

DISCUSSION Julian Stecklina 2 participants 3 messages Feb 15, 2007 – Feb 21, 2007

lore
Share & tools
lore
#0 lore raw

Hello,

I am hacking on a Mini-OS that is able to run as domain 0 and is able to start a guest (another Mini-OS for now). I was able to get a memory allocated to the guest and am now trying to build its pagetable and after that copy the kernel to the right places. The problem is:

Given a machine frame number from a memory frame of the guest, how do I conceptionally map this into dom0's address space? I followed the code path from xc_map_foreign_range to some obscure pagetable updates in the Linux kernel, but am still unable to make heads or tails of it.

Any help is appreciated.

Regards,
Julian

#1 lore raw
Quoted 8 lines

Hello,

I am hacking on a Mini-OS that is able to run as domain 0 and is able to start a guest (another Mini-OS for now). I was able to get a memory allocated to the guest and am now trying to build its pagetable and after that copy the kernel to the right places. The problem is:

Given a machine frame number from a memory frame of the guest, how do I conceptionally map this into dom0's address space? I followed the code path from xc_map_foreign_range to some obscure pagetable updates in the Linux kernel, but am still unable to make heads or tails of it.

Any help is appreciated.

Foreign mappings are very similar to standard mappings (assuming that the mapping domain is privileged). HYPERVISOR_mmu_update with domid set to the foreign domain will deal with page table update.

Note that you need to find some virtual address for the mapping. This is what demand_map_area is for, have a look at map_frames() in arch/x86/mm.c for more info.

Derek Murray has an implementation of foreign mappings and the whole domain builder for that matter. I'll however not share his code. You better ask him directly when he gets back to Cambridge (at the beginning of the next week). I'm CC-ing him.

Cheers
Gregor

#2 lore raw
Quoted 4 lines · Grzegorz Milos
Quoted 4 lines

Hello,

I am hacking on a Mini-OS that is able to run as domain 0 and is able to start a guest (another Mini-OS for now). I was able to get a memory allocated to the guest and am now trying to build its pagetable and after that copy the kernel to the right places. The problem is:

Quoted 8 lines
Quoted 4 lines

Given a machine frame number from a memory frame of the guest, how do I conceptionally map this into dom0's address space? I followed the code path from xc_map_foreign_range to some obscure pagetable updates in the Linux kernel, but am still unable to make heads or tails of it.

Any help is appreciated.

Foreign mappings are very similar to standard mappings (assuming that the mapping domain is privileged). HYPERVISOR_mmu_update with domid set to the foreign domain will deal with page table update.

Note that you need to find some virtual address for the mapping. This is what demand_map_area is for, have a look at map_frames() in arch/x86/mm.c for more info.

Ah, i was under the false impression that I had to modify the MACHPHYS table, but doing a normal page table update with the foreigndom set, works. Thanks.

Regards,
Julian