[PATCH v5 3/8] arm64: hyperv: Add memory alloc/free functions for Hyper-V size pages

Michael Kelley mikelley at microsoft.com
Fri Nov 8 19:00:24 UTC 2019

From: Marc Zyngier <maz at kernel.org>  Sent: Thursday, November 7, 2019 6:20 AM
> > +/*
> > + * Functions for allocating and freeing memory with size and
> > + * alignment HV_HYP_PAGE_SIZE. These functions are needed because
> > + * the guest page size may not be the same as the Hyper-V page
> > + * size. And while kalloc() could allocate the memory, it does not
> > + * guarantee the required alignment. So a separate small memory
> > + * allocator is needed.  The free function is rarely used, so it
> > + * does not try to combine freed pages into larger chunks.
> Is this still needed now that kmalloc has alignment guarantees
> (see 59bb47985c1d)?

The new kmalloc alignment guarantee is good news, and at least
for now would allow these implementations to collapse to just
kmalloc/kzalloc/kfree calls.  My inclination is to keep the function calls
as wrappers, since ISA neutral Hyper-V drivers are starting to use
them, and future work on memory encryption in virtual environments
may require special handling of pages like these that are shared
between the host and guest.  But they probably can be moved into
the ISA neutral Hyper-V drivers instead of per arch.


More information about the devel mailing list