Skip to contentSkip to conversation

How hypervisor accesses machine address

DISCUSSION LIU Wei 2 participants 2 messages Dec 30, 2009

lore
Share & tools
lore

LIU Wei

author
#0 lore raw

Hi, all

The Definitive Guide to the Xen Hypervisor writes: "The hypervisor already has all of the pages in physical memory mapped into its address space..."

So, I do following experiment. All operations are done in the hypervisor, in a hypercall written by myself:

1. provide a mfn, denoted as maddr, which refers to a machine frame of an running domain.

2. calculate vaddr=__va(maddr) .

3. access this page through vaddr.

But Xen generates a fatal page fault and the whole system hangs. Since I'm not very familiar with memory management issue, I don't know how to let the hypervisor access arbitary machine address. Did I use wrong macro/function? Or did I misunderstand the book? Any one can give me a hint?

Thanks in advanced.

Wei LIU

#1 lore raw
Quoted 6 lines · LIU Wei

So, I do following experiment. All operations are done in the hypervisor, in a hypercall written by myself:

1. provide a mfn, denoted as maddr, which refers to a machine frame of an running domain.

First of all, an mfn is not the same as a maddr. An mfn represents a range of maddrs, in the range mfn<<PAGE_SHIFT to (mfn<<PAGE_SHIFT)+PAGE_SIZE-1. Basically you need to shift an mfn left by PAGE_SHIFT before passing to __va().

Quoted 1 line

2. calculate vaddr=__va(maddr) .

Secondly, only 64-bit hypervisor has all memory mapped all the time. If you are running a 32-bit hypervisor then you have to use map_domain_page()/unmap_domain_page() interfaces to dynamically map/unmap arbitrary memory pages.

-- Keir

Quoted 1 line

3. access this page through vaddr.