[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] How to map machine address and pseudo-physical address?



Hello evrybody,

  I need to parse data structures supplied by the BIOS in machine memory.
I'd like to know how I can do it in dom0? 

  I though about mapping part of memory machine in dom0 but I have the
following problem. I take the example of code taken from Linux in
arch/i386/kernel/summit.c to get the pointer to the EBDA at physical @
0x40E:

...
    unsigned long           ptr;

    /* The pointer to the EBDA is stored in the word @ phys 
       0x40E(40:0E)*/
    ptr = *(unsigned short *)phys_to_virt(0x40Eul);
    ptr = (unsigned long)phys_to_virt(ptr << 4);
...

On a linux kernel, ptr==0xffff810000099000
If I run the same code inside dom0, I get ptr==0xffff880000000000

  It's normal because under dom0 the 0X40E corresponds to the pseudo
physical address and not to the machine address. So the idea (maybe it's
not the good one, it's a try :) is to map the machine address 0x40E to
pseudo physical address 0x40E and then, I should read the correct
pointer value from dom0. Thus in Xen I add a new 'case' in the
function arch/x86/plateform_hypercall.c:do_platform_op() that is:

....
    case XENPF_set_ebda_ptr:
    {
       unsigned long ebda_ptr = op->u.set_ebda_ptr.val;
       unsigned long ptr;
        
        /* the ptr value is used to see if the mapping is working */
        /* The pointer to the EBDA is stored in the word @ maddr
           0x40E(40:0E) */
        ptr = *(unsigned short*)maddr_to_virt(ebda_ptr); 
        ptr = (unsigned long)maddr_to_virt(ptr << 4);
        printk(KERN_INFO "TESTGuill: ptr = 0x%lx \n", ptr);            
        set_gpfn_from_mfn(ebda_ptr, ebda_ptr);
    }       
    break;
....

  I also add needed structure. Now, before reading ptr in dom0, I make an
hypercall to map machine address 0x40E (value passed in
op->u.set_ebda_ptr.val) and I can see in the boot messages the
following:

(XEN) TESTGuill: ptr = 0xffff830000099000
TESTGuill: ptr = 0xffff880000000000

  I expected to see the same value under Xen and under dom0. The value
0xffff830000099000 read under Xen seems OK because it corresponds to 1:1
direct mapping of all physical memory so 0x99000 is the right value.

 So the question is: Is machine memory mapped in dom0? if not, can I map
parts of it?


Regards,
Guillaume 

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.