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][PATCH] unshadow the page table page which are used as da

To: "Xin, Xiaohui" <xiaohui.xin@xxxxxxxxx>
Subject: Re: [Xen-devel][PATCH] unshadow the page table page which are used as data page
From: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
Date: Wed, 5 Dec 2007 10:10:16 +0000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, "Kay, Allen M" <allen.m.kay@xxxxxxxxx>
Delivery-date: Wed, 05 Dec 2007 02:11:12 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <9A1462408D6D394C8A7A812E98F00A4D0251FEBC@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <9A1462408D6D394C8A7A812E98F00A4D0251FEBC@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.13 (2006-08-11)
Hi,

At 10:48 +0800 on 05 Dec (1196851700), Xin, Xiaohui wrote:
> The patch will check if the data guest writes to the page table contains
> valid mfn or not, if not, we believe it is a data page now and then
> unshadow the page.

Good plan, thanks.

> +static inline void
> +check_for_data_page_unshadow(struct vcpu *v, void *addr,mfn_t mfn)
> +{
> +    gfn_t gfn;
> +    p2m_type_t p2m_type;
> +
> +#if SHADOW_OPTIMIZATIONS & SHOPT_EARLY_UNSHADOW
> +    if ( mfn_to_page(mfn)->shadow_flags & SHF_L2_32 )
> +    {
> +        gfn = _gfn((paddr_t)(((*(u32*)addr) & (PADDR_MASK&PAGE_MASK))) >>
> +                 PAGE_SHIFT);

Shouldn't you also check for the _PAGE_PRESENT bit?  Otherwise I think
normal shadow performance could be hurt.

> +        if ( gfn_to_mfn(v->domain, gfn, &p2m_type) == INVALID_MFN )
> +            sh_remove_shadows(v, mfn, 1, 0);
> +    }
> +    else if (mfn_to_page(mfn)->shadow_flags &
> +                (SHF_L4_64|SHF_L2_PAE|SHF_L2H_PAE))

Why not SHF_L3_64, SHF_l2_64 and SHF_L2H_64?

> +    {
> +        gfn = _gfn((paddr_t)(((*(u64*)addr) & (PADDR_MASK&PAGE_MASK))) >>
> +                 PAGE_SHIFT);
> +        if ( gfn_to_mfn(v->domain, gfn, &p2m_type) == INVALID_MFN )
> +            sh_remove_shadows(v, mfn, 1, 0);
> +    }
> +#endif
> +}
>  
>  int
>  sh_x86_emulate_write(struct vcpu *v, unsigned long vaddr, void *src,
> @@ -4068,7 +4092,8 @@ sh_x86_emulate_write(struct vcpu *v, uns
>          check_for_early_unshadow(v, mfn);
>      else
>          reset_early_unshadow(v);
> -    
> +
> +    check_for_data_page_unshadow(v, addr, mfn);
>      paging_mark_dirty(v->domain, mfn_x(mfn));

This, and its equivalent in sh_x86_emulate_cmpxchg, need to be gated on
bytes() being greater than the size of the read you'll be doing in
check_for_data_page_unshadow() or you'll get #PF when a guest writes to
the top word of a page.

Cheers,

Tim.

-- 
Tim Deegan <Tim.Deegan@xxxxxxxxxx>
Principal Software Engineer, Citrix Systems.
[Company #5334508: XenSource UK Ltd, reg'd c/o EC2Y 5EB, UK.]

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