[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v3 1/6] domain: introduce alloc/free_shared_info() helpers...
On Thu, 2020-03-05 at 12:44 +0000, pdurrant@xxxxxxxx wrote: > From: Paul Durrant <pdurrant@xxxxxxxxxx> > > ... and save the MFN. > > This patch modifies the 'shared_info' field of struct domain to be > a structure comprising an MFN and a virtual address. Allocations are > still done from xenheap, so the virtual address still equates to > virt_to_mfn() called on the MFN but subsequent patch will change > this. > Hence the need to save the MFN. > > NOTE: Whist defining the new helpers, virt_to_mfn() in > common/domain.c > is made type safe. > The definition of nmi_reason() in asm-x86/shared.h is also re- > flowed to avoid overly long lines. > > Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx> > Reviewed-by: Julien Grall <julien@xxxxxxx> > ... > > +int alloc_shared_info(struct domain *d, unsigned int memflags) > +{ > + if ( (d->shared_info.virt = alloc_xenheap_pages(0, memflags)) == > NULL ) > + return -ENOMEM; > + > + d->shared_info.mfn = virt_to_mfn(d->shared_info.virt); > + > + clear_page(d->shared_info.virt); > + share_xen_page_with_guest(mfn_to_page(d->shared_info.mfn), d, > SHARE_rw); > + > + return 0; > +} > + > +void free_shared_info(struct domain *d) > +{ > + if ( !d->shared_info.virt ) > + return; > + > + free_xenheap_page(d->shared_info.virt); > + d->shared_info.virt = NULL; > +} > + I was going to say that free_xenheap_page() can deal with NULL so we do not have to return on NULL. But then I found that the final patch needs to unmap it which cannot deal with NULL anyway, so I no longer have a strong opinion to do clean-ups here. Other than that, Reviewed-by: Hongyan Xia <hongyxia@xxxxxxxxxx> Hongyan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |