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

[Xen-devel] Writing a not present shadow entry


  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • From: Cutter 409 <cutter409@xxxxxxxxx>
  • Date: Thu, 9 Dec 2010 14:26:43 -0500
  • Delivery-date: Thu, 09 Dec 2010 11:27:57 -0800
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=DnilYY8h6iXpwrQW2ofWsb+SfwxEnNblWzRsjIxAkSTikfpuyppmHjQWbWvgOZGZxU dM+7FVtJUzXjG8HVP/Yn9rdDRyGLLcil7LsPt61XcC5VtVCp+SdJW7ueCnfFIE8k9Ct0 fnuuJXeib9m1/exCXFI0qJj/O9G6fLKEkpHQg=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

Hello,

I'm trying to do something similar to what Ether does, using Xen 3.4.2
My function to write a not present shadow entry doesn't seem to work. I never catch a page fault for an address that I've marked not present.

The function in question should take a virtual address and write a shadow entry for it, marking it either present or not present.
If it's not present I should be able to detect when the guest accesses it.

static int sh_set_present(struct vcpu *v, unsigned long vaddr, int present, int need_lock) {
    shadow_l1e_t sl1e;
    walk_t gw;
    shadow_l1e_t *ptr_sl1e;

    gfn_t gfn = _gfn(0);
    mfn_t gmfn, sl1mfn = _mfn(0);
    p2m_type_t p2mt;

    int result = 0;

    if(need_lock)
        shadow_lock(v->domain);

    // Returns 0 for success
    if(unlikely(sh_walk_guest_tables(v, vaddr, &gw, p2mt) != 0)) {
        printk("Unable to walk guest tables\n")    ;
        goto done;
    }

    /* What mfn is the guest trying to access? */
    gfn = guest_l1e_get_gfn(gw.l1e);
    gmfn = gfn_to_mfn_guest(v->domain, gfn, &p2mt);


    // Create the shadow entry
    ptr_sl1e = shadow_get_and_create_l1e(v, &gw, &sl1mfn, ft_demand_read);

    // Calculate the shadow entry
    l1e_propagate_from_guest(v, gw.l1e, gmfn, &sl1e, ft_demand_read, p2mt);

    if (present) {
        sl1e = shadow_l1e_add_flags(sl1e, _PAGE_PRESENT);
    } else {
        // I don't think we should have to do this part..
        sl1e = shadow_l1e_remove_flags(sl1e, _PAGE_PRESENT);
    }

    // Write the shadow entry
    printk("shadow_set_l1e: %X\n", shadow_set_l1e(v, ptr_sl1e, sl1e, sl1mfn));

/*    printk("Set %lX as", vaddr);
    if(!present)
        printk(" NOT");
    printk(" present\n");*/

    result = 1;

done:
    if(need_lock)
        shadow_unlock(v->domain);

    return result;
}

I do have ept disabled. Can anyone give me any ideas about what could be wrong, or how to go about debugging this? I'm not extremely familiar with the shadow page table.

Thanks!
_______________________________________________
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®.