>>> + */
>>> +static int map_p2m_list(struct xc_sr_context *ctx, uint64_t p2m_cr3)
>>> +{
>>> +    xc_interface *xch = ctx->xch;
>>> +    xen_vaddr_t p2m_vaddr, p2m_end, mask, off;
>>> +    xen_pfn_t p2m_mfn, mfn, saved_mfn, max_pfn;
>>> +    uint64_t *ptes;
>>> +    xen_pfn_t *mfns;
>>> +    unsigned fpp, n_pages, level, shift, idx_start, idx_end, idx, 
>>> saved_idx;
>>> +    int rc = -1;
>>> +
>>> +    p2m_mfn = cr3_to_mfn(ctx, p2m_cr3);
>>> +    if ( p2m_mfn == 0 || p2m_mfn > ctx->x86_pv.max_mfn )
>> mfn 0 isn't invalid to use here.  It could, in principle, be available
>> for PV guest use.
> No, the value 0 indicates that the linear p2m info isn't valid. See
> comments in xen/include/public/arch-x86/xen.h

Technically speaking, that is p2m_cr3, rather than p2m_mfn but I suppose
there is a linear mapping between the two.

As this function only gets called with a non-zero p2m_cr3, an
alternative would be assert(p2m_cr3 > 0).

The mfn == 0 comment also applies for reading the ptes in the loop below.

>
>> I believe this allows you drop 'mask' in its entirety.
> Hmm, no. I'd still have to mask possible top 16 '1' bits away.

So you would.  My mistake.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to