> 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
 |