|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH RESEND v5 4/6] xen/arm: Implement virtual-linear page table for guest p2m mapping in live migration
> > > +{
> > > + int i;
> > > + dsb();
> > > + for ( i = d->arch.dirty.second_lvl_start;
> > > + i < d->arch.dirty.second_lvl_end;
> > > + ++i )
> > > + {
> > > + int k = i % LPAE_ENTRIES;
> > > + int l = i / LPAE_ENTRIES;
> > > +
> > > + if ( xen_second[i].bits != d->arch.dirty.second_lvl[l][k].bits )
> > > + {
> > > + __write_pte(&xen_second[i], d->arch.dirty.second_lvl[l][k]);
> > > + __flush_xen_data_tlb_range_va(i << SECOND_SHIFT,
> > > + 1 << SECOND_SHIFT);
> > > + }
> > > + }
> > > + dsb();
> > > + isb();
> > > +}
> > > +
> > > +/* setting up the xen page table for vlpt mapping for domain d */ int
> > > +prepare_vlpt(struct domain *d) {
> > > + int xen_second_linear_base;
> > > + int gp2m_start_index, gp2m_end_index;
> > > + struct p2m_domain *p2m = &d->arch.p2m;
> > > + struct page_info *second_lvl_page;
> > > + paddr_t gma_start = 0;
> > > + paddr_t gma_end = 0;
> > > + lpae_t *first[2];
> > > + int i;
> > > + uint64_t required, avail = VIRT_LIN_P2M_END - VIRT_LIN_P2M_START;
> > > +
> > > + get_gma_start_end(d, &gma_start, &gma_end);
> > > + required = (gma_end - gma_start) >> LPAE_SHIFT;
> > > +
> > > +
> > > + if ( required > avail )
> >
> > avail is the number of bytes of virtual address space in the linear p2m
> > area.
> >
> > required is the number of pages which the guest has. Does this comparison
> > correctly account for each page being represented by an 8-byte lpae_t
> > entry?
>
> Yes, it does. See, LPAE_SHIFT only shifts 9 bits. Shifting PAGE_SHIFT (12
> bits)
> gives the number of pages (every bit), and 9-bit shift gives the required
> memory for storing third-level PTE. Since this one-shifting of LPAE_SHIFT
> is confusing enough, we can make it explicit by using something like
> required = ((gma_end - gma_start) >> PAGE_SHIFT ) * (sizeof lpae_t).
I think this is clearer than requiring the reader to have to think about
the effect of shift by N-M and the reasons for it, thanks. The
alternative would be a comment explaining what is going on.
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |