* [RFC PATCH 15/73] mm/vmalloc: Add a helper to reserve a contiguous and aligned kernel virtual area [not found] <20240226143630.33643-1-jiangshanlai@gmail.com> @ 2024-02-26 14:35 ` Lai Jiangshan 2024-02-27 14:56 ` Christoph Hellwig 0 siblings, 1 reply; 3+ messages in thread From: Lai Jiangshan @ 2024-02-26 14:35 UTC (permalink / raw) To: linux-kernel Cc: Hou Wenlong, Lai Jiangshan, Linus Torvalds, Peter Zijlstra, Sean Christopherson, Thomas Gleixner, Borislav Petkov, Ingo Molnar, kvm, Paolo Bonzini, x86, Kees Cook, Juergen Gross, Andrew Morton, Uladzislau Rezki, Christoph Hellwig, Lorenzo Stoakes, linux-mm From: Hou Wenlong <houwenlong.hwl@antgroup.com> 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@antgroup.com> Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com> Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com> --- 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH 15/73] mm/vmalloc: Add a helper to reserve a contiguous and aligned kernel virtual area 2024-02-26 14:35 ` [RFC PATCH 15/73] mm/vmalloc: Add a helper to reserve a contiguous and aligned kernel virtual area Lai Jiangshan @ 2024-02-27 14:56 ` Christoph Hellwig 2024-02-27 17:07 ` Lai Jiangshan 0 siblings, 1 reply; 3+ messages in thread From: Christoph Hellwig @ 2024-02-27 14:56 UTC (permalink / raw) To: Lai Jiangshan Cc: linux-kernel, Hou Wenlong, Lai Jiangshan, Linus Torvalds, Peter Zijlstra, Sean Christopherson, Thomas Gleixner, Borislav Petkov, Ingo Molnar, kvm, Paolo Bonzini, x86, Kees Cook, Juergen Gross, Andrew Morton, Uladzislau Rezki, Christoph Hellwig, Lorenzo Stoakes, linux-mm On Mon, Feb 26, 2024 at 10:35:32PM +0800, Lai Jiangshan wrote: > From: Hou Wenlong <houwenlong.hwl@antgroup.com> > > PVM needs to reserve a contiguous and aligned kernel virtual area for Who is "PVM", and why does it need aligned virtual memory space? > +extern struct vm_struct *get_vm_area_align(unsigned long size, unsigned long align, No need for the extern here. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH 15/73] mm/vmalloc: Add a helper to reserve a contiguous and aligned kernel virtual area 2024-02-27 14:56 ` Christoph Hellwig @ 2024-02-27 17:07 ` Lai Jiangshan 0 siblings, 0 replies; 3+ messages in thread From: Lai Jiangshan @ 2024-02-27 17:07 UTC (permalink / raw) To: Christoph Hellwig Cc: linux-kernel, Hou Wenlong, Lai Jiangshan, Linus Torvalds, Peter Zijlstra, Sean Christopherson, Thomas Gleixner, Borislav Petkov, Ingo Molnar, kvm, Paolo Bonzini, x86, Kees Cook, Juergen Gross, Andrew Morton, Uladzislau Rezki, Lorenzo Stoakes, linux-mm Hello On Tue, Feb 27, 2024 at 10:56 PM Christoph Hellwig <hch@infradead.org> wrote: > > On Mon, Feb 26, 2024 at 10:35:32PM +0800, Lai Jiangshan wrote: > > From: Hou Wenlong <houwenlong.hwl@antgroup.com> > > > > PVM needs to reserve a contiguous and aligned kernel virtual area for > > Who is "PVM", and why does it need aligned virtual memory space? PVM stands for Pagetable-based Virtual Machine. It is a new pure software-implemented virtualization solution. The details are in the cover letter: https://lore.kernel.org/lkml/20240226143630.33643-1-jiangshanlai@gmail.com/ I'm sorry for not CC'ing you on the cover letter (I haven't made/found a proper script to generate all cc-recipients for the cover letter.) nor elaborating the reason in the changelog. One of the core designs in PVM is the "Exclusive address space separation", with which in the higher half of the address spaces (where the most significant bits in the addresses are 1s), the address ranges that a PVM guest is allowed are exclusive from the host kernel. So PVM hypervisor has to use get_vm_area_align() to reserve a huge range (normally 16T) with the alignment 512G (PGDIR_SIZE) for all the guests to accommodate the whole guest kernel space. The reserved range cannot be used by the host. The rationale of this core design is also in the cover letter. Thanks Lai > > > +extern struct vm_struct *get_vm_area_align(unsigned long size, unsigned long align, > > No need for the extern here. > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-27 17:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20240226143630.33643-1-jiangshanlai@gmail.com>
2024-02-26 14:35 ` [RFC PATCH 15/73] mm/vmalloc: Add a helper to reserve a contiguous and aligned kernel virtual area Lai Jiangshan
2024-02-27 14:56 ` Christoph Hellwig
2024-02-27 17:07 ` Lai Jiangshan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox