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] Writing a not present shadow entry

To: Cutter 409 <cutter409@xxxxxxxxx>
Subject: Re: [Xen-devel] Writing a not present shadow entry
From: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
Date: Thu, 16 Dec 2010 12:35:55 +0000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 16 Dec 2010 04:36:50 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=qtwNQVBIF7kNDobLBtpgCagWs2jG+wMp1UA5BaDLodo=; b=hPwf0AQ0v6NvGdN1XYKqIBobxuqrhnCdAXaBikwc7uXUM9VRqrgdoBHEWSdRMdZyzb vCZbVEZzWDbzIgJy0cAwvrtrRn937R7/RcEAsPjn2VUXfuVZHt8ZoJm8EeF+mNLFUs39 dQhb8IAzmQR+fOtVKsNVF+nsYNJoRCRyJOGRI=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=Zq8bPXSWDvw9gp8cA5aKjGgY0FTXh5nYiuYUF3/N+TS152yK17dDy+ezGuFVI5jqGb RvYSEhGVtUuuqaghJ/7HJ91Ms8osrbbsPN2MjjWFxu05iZQYV0m1+eTNsOxhO4x7urIz 5AjXDhKITXTjmtMMPKiq5WFBbW/uiBMgsE6/M=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <AANLkTi=uOFNH5580Web+HiqEvtkJ+0hSyh+2pr=2QzTG@xxxxxxxxxxxxxx>
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>
References: <AANLkTi=uOFNH5580Web+HiqEvtkJ+0hSyh+2pr=2QzTG@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Are you sure you're looking to "catch" the page fault in the right place?

It's been a long time since I've done anything with the shadow code,
but last time I checked, if the guest walk is valid, the code will
just fix it up in guest_walk (i.e., change your read-only shadow entry
to read-write to match the guest PTE), and after finding nothing else
wrong, just return.  You may do better looking at how either the
logdirty code works.

 -George

On Thu, Dec 9, 2010 at 7:26 PM, Cutter 409 <cutter409@xxxxxxxxx> wrote:
> 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
>
>

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

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