WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Memory mapping

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-devel] Memory mapping
From: Frederic Beck <frederic.beck@xxxxxxxx>
Date: Wed, 18 Feb 2009 15:35:47 +0100
Delivery-date: Wed, 18 Feb 2009 06:36:06 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20090216175824.4daf3c44@xxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: INRIA-LORIA
References: <20090216175824.4daf3c44@xxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Well, first of all, i did a wrong copy and paste when i mapped the
code, the mask i apply is 0xFFFFE000.

I checked the control registers, cr0 and cr3 to ensure that paging is
used, i just have to understand now how it is implemented.

Digging right now in several file, prom mm.c to page.h, paging.h to
understand how i can walk through the memory.

Any hint or pointer to documentation would be helpful

Thanks
Fred

Le Mon, 16 Feb 2009 17:58:24 +0100,
Frederic Beck <frederic.beck@xxxxxxxx> a écrit :

> Hello
> 
> I managed to do what i wanted with my module (finally gave up on the
> syscall and did everything in the module init), and i foudn the
> offsets i was looking for. I later found out that what i've done was
> already available via XenAccess (tools/linux-offset-finder).
> 
> I have the following offsets:
> linux_name = 0x225;
> linux_tasks = 0xd0;
> linux_mm = 0xe8;
> linux_pid = 0x10c;
> linux_pgd = 0x24;
> linux_addr = 0x84;
> 
> After disabling fast system calls handling, i modified  do_guest_trap
> in xen/arch/x86/traps.c. I get the user regs to have access to the CPU
> registers EAX, EIP and ESP (info i wanna log via the tracing). I take
> the ESP and apply the mask 0xFFFFF000 to get the base address of the
> thread_info struct.
> 
> user_regs = guest_cpu_user_regs();
> base_addr = (user_regs->esp & 0xFFFFF000);
> 
> Then the first 4 bytes after this base_addr are on a regular system a
> pointer to a task_struct where the PId of the current task is stored,
> which i wanna get. On a regular OS (i tested on Dom0 or DomU) I can
> find easily the PID and print it out. I would like to do the same in
> the hypervisor. 
> 
> I tried to map the same code without modification, but i begin reading
> memory addresses that do not exist and the hypervisor crashes when i
> create my DomU. So far, i'm not very surprised, as there must be some
> virtual memory handling that i'm missing.
> 
> However, i do not understand well how i can do the mapping. how do i
> map this kernel address in the hypervisor to read the right memory
> address ?
> 
> I guess that this mapping will be different for HVM and PV domains ?
> Is there a function that dynamically detects what kind of domain the
> guest is ?
> 
> Moreover, i found out in XenAccess that the right formula to get the
> PID would be 
> memcpy(&pid, memory + offset + PID_OFFSET - TASKS_OFFSET,4);
> I guess that memory is the base adress of the virtual stack. How can i
> find that value ? in that case the base_addr i calculated earlier
> would be the offset ?
> 
> Thanks for the help!
> 
> Regards
> Fred
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>