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] Re: Making pages writable again in paging_log_dirty mode

To: "Tim Deegan" <Tim.Deegan@xxxxxxxxxx>
Subject: Re: [Xen-devel] Re: Making pages writable again in paging_log_dirty mode
From: "Mike Sun" <msun@xxxxxxxxxx>
Date: Sat, 3 Jan 2009 20:43:14 -0500
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Sat, 03 Jan 2009 17:43:58 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=8pBqsAPFOMhkkD6f8I6kdOrjaWCS8oHFrO8UuyZBMqA=; b=w+JuPA0/JTODqG7KHHQmlS0FbEOypGrihJa/mylpb3TvRi/a2Bsn1qsBb1wiX02xMF p5wKKNefQtEz7AQd5ELc5IrTi2qSOiOzm2G9ny98X/eqrO97MU6qxELEUBkQIDw1f7fR Uxbp30XSGw1rCwd98gRrnmig/EnAEwG26WGzY=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=LFrv7NXYsDrnu0Cqt6sSEiK1L9FB9ZDZU07BTlzBRjSgDuO0OBg2iL291LBpCc7ccn 8broWDmNW8bcifchAeZFiEtz3RYGZ/lRsNtiANBsDJA85L+vDXbecUmcGKzms0jjQxQ1 ecUXgHG01FE4dOXGhWG7BwalnvzbUAY/Slapc=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20090102172058.GC12729@xxxxxxxxxxxxxxxxxxxxx>
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: <e4e579070812191254k6bc57cf7hfb60e900c1a3c0aa@xxxxxxxxxxxxxx> <e4e579070812191308q77c3a398p6baa246cff5f7ab2@xxxxxxxxxxxxxx> <e4e579070812191359t1bd3a8cand9bb01cd62da9696@xxxxxxxxxxxxxx> <20090102100725.GB12729@xxxxxxxxxxxxxxxxxxxxx> <e4e579070901020850n1b897c1aob521bf28d125b420@xxxxxxxxxxxxxx> <20090102172058.GC12729@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
> That's the opposite problem.  The shadow code needs to remove all the
> writeable mappings of a page (because the guest is using it as a
> pagetable) and finds that after removing all writeable shadow PTEs that
> map the page, the typecount has not reached zero.  So:
>  - there is some other special reason for the frame to have a
>   typecount.  Or,
>  - somehow you've removed a writeable shadow entry without decrementing
>   the type count. That shouldn't be a problem because we know that
>   actions by dom0 (p2m changes, for example) cause writeable shadow
>   PTEs to be torn down (via shadow_put_page_from_l1e) correctly.  Or,
>  - you've accidentally called get_page_and_type() once too often,
>   creating two typecounts for only one shadow PTE.

Thanks Tim.  It make sense that I may accidentally calling
get_page_and_type() once too often. I modified the condition in which
I manually call an extra get_page_and_type() when trying to make PTEs
writable from dom0, but now I get this error condition:

(XEN) sh error: sh_remove_shadows(): can't find all shadows of mfn
02673 (shadow_flags=00000008)

I think I'm accounting for the page type refcounts correctly... but
I'm probably wrong.  Here's the code that's trying to add writable
mappings back:

            SHADOW_FOREACH_L1E(sl1mfn, sl1e, 0, done_l1,
            {
                flags_l1 = shadow_l1e_get_flags(*sl1e);
                if ((flags_l1 & _PAGE_PRESENT) && !(flags_l1 & _PAGE_RW))
                {
                    mfn = shadow_l1e_get_mfn(*sl1e);
                    pfn = mfn_to_gfn(v->domain, mfn);
                    log_dirty_lock(v->domain);
                    if (mfn_valid(mfn) && VALID_M2P(pfn) &&
                        sh_mfn_is_dirty(v->domain, mfn))
                    {
                        /* hack: because of the external mapping condition
                         * ref count not incremented when this is called from
                         * hypercall originating from dom0, need to do it
                         * manually
                         */
                        struct page_info *page = mfn_to_page(mfn);
                        if (((page->u.inuse.type_info & PGT_type_mask)
                                == PGT_writable_page)
                            && ((page->u.inuse.type_info & PGT_count_mask) == 0)
                            && get_page_type(page, PGT_writable_page))
                        {
                            shadow_l1e_t rw_sl1e =
                                shadow_l1e_add_flags(*sl1e, _PAGE_RW);
                            shadow_set_l1e(v, sl1e, rw_sl1e, sl1mfn);
                            cow.made_rw_count++;
                        }
                    }
                    log_dirty_unlock(v->domain);
                }
            });

Any ideas?

Thanks,
Mike

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