Hi all, I am trying to understand write page table handler for PV guests. I got the core of ptwr_do_page_fault is x86_emulate() which will emulate the write operation in Xen. But why after that Xen calls put_page() to free the page mapped to the PTE ? The code snapshot is as follows: int ptwr_do_page_fault(struct vcpu *v, unsigned long addr, struct cpu_user_regs *regs) { struct domain *d = v->domain; struct page_info *page; l1_pgentry_t pte; struct ptwr_emulate_ctxt ptwr_ctxt; int rc; /* Attempt to read the PTE that maps the VA being accessed. */ guest_get_eff_l1e(v, addr, &pte); ...... page = l1e_get_page(pte); ...... rc = x86_emulate(&ptwr_ctxt.ctxt, &ptwr_emulate_ops); page_unlock(page); put_page(page); ...... } Thanks a lot, -- Xinxin _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
On Mon, 2012-10-15 at 07:43 +0100, Xinxin Jin wrote:> Hi all, > I am trying to understand write page table handler for PV guests. I > got the core of ptwr_do_page_fault is x86_emulate() which will emulate > the write operation in Xen. But why after that Xen calls put_page() > to free the page mapped to the PTE ? The code snapshot is as follows:The put_page balances the get_page inside get_page_from_pagenr which is in the code you trimmed out below. Ian.
Hmmm, put_page() release the page, but seems get_page_from_pagenr() does not allocate a page ? Thanks ! On Mon, Oct 15, 2012 at 1:00 AM, Ian Campbell <Ian.Campbell@citrix.com>wrote:> On Mon, 2012-10-15 at 07:43 +0100, Xinxin Jin wrote: > > Hi all, > > I am trying to understand write page table handler for PV guests. I > > got the core of ptwr_do_page_fault is x86_emulate() which will emulate > > the write operation in Xen. But why after that Xen calls put_page() > > to free the page mapped to the PTE ? The code snapshot is as follows: > > The put_page balances the get_page inside get_page_from_pagenr which is > in the code you trimmed out below. > > Ian. > > > >-- Xinxin _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Please don''t top post. On Mon, 2012-10-15 at 09:13 +0100, Xinxin Jin wrote:> Hmmm, put_page() release the page, but seems get_page_from_pagenr() > does not allocate a page ? Thanks !It''s implementing reference counting. Ian.