On Tuesday 01 Jun 2021 at 15:38:22 (+0100), Marc Zyngier wrote: > On Thu, 27 May 2021 13:51:30 +0100, > Quentin Perret <qperret@xxxxxxxxxx> wrote: > > +/* > > + * Pages that are available for allocation are tracked in free-lists, so we use > > + * the pages themselves to store the list nodes to avoid wasting space. As the > > + * allocator always returns zeroed pages (which are zeroed on the hyp_put_page() > > + * path to optimize allocation speed), we also need to clean-up the list node in > > + * each page when we take it out of the list. > > + */ > > +static inline void page_remove_from_list(struct hyp_page *p) > > +{ > > + struct list_head *node = (struct list_head *)hyp_page_to_virt(p); > > Nit: How about changing hyp_page_to_virt() so that it returns a > convenient 'void *', and get rid of the ugly casts? It should already return void *, but I kind of liked the explicit cast here for documentation purpose. We're turning a 'random' piece of unused memory into a typed object, so that felt like a useful annotation. Happy to get rid of it though. > > + > > + __list_del_entry(node); > > + memset(node, 0, sizeof(*node)); > > +} > > + > > +static inline void page_add_to_list(struct hyp_page *p, struct list_head *head) > > +{ > > + struct list_head *node = (struct list_head *)hyp_page_to_virt(p); > > + > > + INIT_LIST_HEAD(node); > > + list_add_tail(node, head); > > +} > > + > > +static inline struct hyp_page *node_to_page(struct list_head *node) > > +{ > > + return (struct hyp_page *)hyp_virt_to_page(node); > > Why is this cast necessary? If I'm not mistaken, hyp_vmemmap is > already cast as a 'struct hyp_page *', so hyp_virt_to_page() should > return the same type. Right, that one is totally unnecessary, I'll remove. Cheers, Quentin _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm