Hi Julien

> -----Original Message-----
> From: Julien Grall <jul...@xen.org>
> Sent: Thursday, May 12, 2022 6:54 PM
> To: Penny Zheng <penny.zh...@arm.com>; xen-devel@lists.xenproject.org
> Cc: Wei Chen <wei.c...@arm.com>; Stefano Stabellini
> <sstabell...@kernel.org>; Bertrand Marquis <bertrand.marq...@arm.com>;
> Volodymyr Babchuk <volodymyr_babc...@epam.com>
> Subject: Re: [PATCH v3 5/8] xen/arm: Add additional reference to owner
> domain when the owner is allocated
> 
> 
> 
> On 12/05/2022 10:11, Penny Zheng wrote:
> > @@ -827,6 +858,37 @@ static int __init allocate_shared_memory(struct
> domain *d,
> >           }
> >       }
> >
> > +    /*
> > +     * Get the right amount of references per page, which is the number of
> > +     * borrow domains.
> > +     */
> > +    ret = acquire_nr_borrower_domain(d, pbase, psize, &nr_borrowers);
> > +    if ( ret )
> > +        return ret;
> > +
> > +    /*
> > +     * Instead of let borrower domain get a page ref, we add as many
> > +     * additional reference as the number of borrowers when the owner
> > +     * is allocated, since there is a chance that owner is created
> > +     * after borrower.
> > +     */
> > +    page = mfn_to_page(smfn);
> Where do you check that the range [smfn, smfn + nr_pages] is actual RAM?
> If there are none, then you should use mfn_valid() for each mfn to ensure
> there will be a struct page for it.
>

Actually, before this, in acquire_shared_memory_bank, we will finally call into
acquire_staticmem_pages to acquire [smfn, smfn + nr_pages], and in there, we
will do the check. See xen/common/page_alloc.c:acquire_staticmem_pages:2676
 
> Cheers,
> 
> --
> Julien Grall

Reply via email to