Skip to contentSkip to conversation

DomU Kernel Mapping

DISCUSSION Security Initiative Team 3 participants 3 messages Apr 17, 2007 – Apr 18, 2007

lore
Share & tools
lore
#0 lore raw

Where is the code that maps the kernel of a DomU into memory?

i.e, when you do a xm create <config file>
what code is called to actually map the kernel into memory?

Is it a python script or is it re-directed to Dom0 to do?

Thanks.
-Brian

---------------------------------
Ahhh...imagining that irresistible "new car" smell?
Check outnew cars at Yahoo! Autos.

_______________________________________________
Xen-users mailing list
[email protected]
http://lists.xensource.com/xen-users

#1 lore raw
Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Security Initiative Team
Sent: 17 April 2007 18:53
To: [email protected]; [email protected]
Subject: [Xen-users] DomU Kernel Mapping

Quoted 4 lines

Where is the code that maps the kernel of a DomU into memory?

i.e, when you do a xm create <config file>
what code is called to actually map the kernel into memory?

It is in .../tools/libxc/xc_dom_compat.c and .../tools/libxc/xc_hvm_build.c for PV and HVM respectively.

Quoted 2 lines

Is it a python script or is it re-directed to Dom0 to do?

Ehm, you can only do xm create in dom0, so I'm not sure what you mean by this.

xm is written in python, but it calls out to C-functions, which in turn makes hypercalls to the hypervisor to perform for example memory allocation, setting up VCPU(s), creation of the actual domain (empty, to be filled in), starting the domain, etc, etc.

The code for "xm create" is in .../tools/python/xen/xm/create.py.

--
Mats

Quoted 13 lines

Thanks.
-Brian

________________________________

Ahhh...imagining that irresistible "new car" smell? Check out new cars at Yahoo! Autos.
<http://us.rd.yahoo.com/evt=48245/*http://autos.yahoo.com/new_
cars.html;_ylc=X3oDMTE1YW1jcXJ2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGF ncwRzbGsDbmV3LWNhcnM->

#2 lore raw
In reply to Security Initiative Team

As Mats says, the code is in tools/libxc. When you load an ELF binary (such as a Linux kernel), the function xc_dom_elfloader.c::xc_dom_load_elf_kernel() performs the mapping and loading of the kernel.

The following chain of function calls maps the memory into dom0 for loading the kernel:

xc_dom.h::xc_dom_seg_to_ptr() calls
xc_dom_core.c::xc_dom_pfn_to_ptr() calls
xc_dom_boot.c::xc_dom_boot_domU_map() calls
xc_{linux,solaris}.c::xc_map_foreign_ranges() which (for the Linux case) performs an ioctl on the privcmd device, and maps the memory into dom0 user-space using the mmu_update hypercall.

A call to libelf-loader.c::elf_load_binary() copies the kernel into domU.

I should add that I'm currently working on moving this code to a small, trusted domain. The goal would be to remove dom0's ability to map arbitrary memory from other guests.

Hope this helps.

Regards,

Derek Murray.

Quoted 16 lines · Security Initiative Team

Where is the code that maps the kernel of a DomU into memory?

i.e, when you do a xm create <config file>
what code is called to actually map the kernel into memory?

Is it a python script or is it re-directed to Dom0 to do?

Thanks.
-Brian

Ahhh...imagining that irresistible "new car" smell? Check out new cars at Yahoo! Autos.
_______________________________________________
Xen-devel mailing list [email protected]
http://lists.xensource.com/xen-devel