[PATCH v5 3/8] arm64: hyperv: Add memory alloc/free functions for Hyper-V size pages
Marc Zyngier
maz at kernel.org
Thu Nov 7 14:19:49 UTC 2019
On 2019-10-03 20:12, Michael Kelley wrote:
> Add ARM64-specific code to allocate memory with HV_HYP_PAGE_SIZE
> size and alignment. These are for use when pages need to be shared
> with Hyper-V. Separate functions are needed as the page size used
> by Hyper-V may not be the same as the guest page size. Free
> operations are rarely done, so no attempt is made to combine
> freed pages into larger chunks.
>
> This code is built only when CONFIG_HYPERV is enabled.
>
> Signed-off-by: Michael Kelley <mikelley at microsoft.com>
> ---
> arch/arm64/hyperv/hv_init.c | 68
> ++++++++++++++++++++++++++++++++++++++++++
> include/asm-generic/mshyperv.h | 5 ++++
> 2 files changed, 73 insertions(+)
>
> diff --git a/arch/arm64/hyperv/hv_init.c
> b/arch/arm64/hyperv/hv_init.c
> index 6808bc8..9c294f6 100644
> --- a/arch/arm64/hyperv/hv_init.c
> +++ b/arch/arm64/hyperv/hv_init.c
> @@ -15,10 +15,78 @@
> #include <linux/export.h>
> #include <linux/mm.h>
> #include <linux/hyperv.h>
> +#include <linux/spinlock.h>
> +#include <linux/list.h>
> +#include <linux/string.h>
> #include <asm-generic/bug.h>
> #include <asm/hyperv-tlfs.h>
> #include <asm/mshyperv.h>
>
> +
> +/*
> + * 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)?
M.
--
Jazz is not dead. It just smells funny...
More information about the devel
mailing list