From: Hou Wenlong <houwenlong.hwl@xxxxxxxxxxxx> PVM needs to reserve a contiguous and aligned kernel virtual area for the guest kernel. Therefor, add a helper to achieve this. It is a temporary method currently, and a better method is needed in the future. Suggested-by: Lai Jiangshan <jiangshan.ljs@xxxxxxxxxxxx> Signed-off-by: Hou Wenlong <houwenlong.hwl@xxxxxxxxxxxx> Signed-off-by: Lai Jiangshan <jiangshan.ljs@xxxxxxxxxxxx> --- include/linux/vmalloc.h | 2 ++ mm/vmalloc.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index c720be70c8dd..1821494b51d6 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -204,6 +204,8 @@ static inline size_t get_vm_area_size(const struct vm_struct *area) } extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags); +extern struct vm_struct *get_vm_area_align(unsigned long size, unsigned long align, + unsigned long flags); extern struct vm_struct *get_vm_area_caller(unsigned long size, unsigned long flags, const void *caller); extern struct vm_struct *__get_vm_area_caller(unsigned long size, diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d12a17fc0c17..6e4b95f24bd8 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2642,6 +2642,16 @@ struct vm_struct *get_vm_area(unsigned long size, unsigned long flags) __builtin_return_address(0)); } +struct vm_struct *get_vm_area_align(unsigned long size, unsigned long align, + unsigned long flags) +{ + return __get_vm_area_node(size, align, PAGE_SHIFT, flags, + VMALLOC_START, VMALLOC_END, + NUMA_NO_NODE, GFP_KERNEL, + __builtin_return_address(0)); +} +EXPORT_SYMBOL_GPL(get_vm_area_align); + struct vm_struct *get_vm_area_caller(unsigned long size, unsigned long flags, const void *caller) { -- 2.19.1.6.gb485710b