lkml.org 
[lkml]   [2021]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v3 06/32] KVM: arm64: Factor memory allocation out of pgtable.c
On Tue, Mar 02, 2021 at 02:59:36PM +0000, Quentin Perret wrote:
> In preparation for enabling the creation of page-tables at EL2, factor
> all memory allocation out of the page-table code, hence making it
> re-usable with any compatible memory allocator.
>
> No functional changes intended.
>
> Signed-off-by: Quentin Perret <qperret@google.com>
> ---
> arch/arm64/include/asm/kvm_pgtable.h | 41 +++++++++++-
> arch/arm64/kvm/hyp/pgtable.c | 98 +++++++++++++++++-----------
> arch/arm64/kvm/mmu.c | 66 ++++++++++++++++++-
> 3 files changed, 163 insertions(+), 42 deletions(-)

Just a few nits:

> diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h
> index 8886d43cfb11..3c306f90f7da 100644
> --- a/arch/arm64/include/asm/kvm_pgtable.h
> +++ b/arch/arm64/include/asm/kvm_pgtable.h
> @@ -13,17 +13,50 @@
>
> typedef u64 kvm_pte_t;
>
> +/**
> + * struct kvm_pgtable_mm_ops - Memory management callbacks.
> + * @zalloc_page: Allocate a single zeroed memory page. The @arg parameter
> + * can be used by the walker to pass a memcache. The
> + * initial refcount of the page is 1.
> + * @zalloc_pages_exact: Allocate an exact number of zeroed memory pages. The
> + * @size parameter is in bytes, it is automatically rounded
> + * to PAGE_SIZE and the resulting allocation is physically
> + * contiguous.

It's not clear to me whether "it is automatically rounded to PAGE_SIZE"
means that the caller or the callee does the rounding. If it's the caller,
maybe it would be better to pass the number of pages as an 'npages' argument
instead of the size in bytes?

> + * @free_pages_exact: Free an exact number of memory pages, to free memory
> + * allocated with zalloc_pages_exact.

"Free an exact number of memory pages previously allocated by
zalloc_pages_exact()"


> + * @get_page: Increment the refcount on a page.
> + * @put_page: Decrement the refcount on a page. When the refcount
> + * reaches 0 the page is automatically freed.
> + * @page_count: Return the refcount of a page.
> + * @phys_to_virt: Convert a physical address into a virtual address as
> + * accessible in the current context.

s/as accessible/mapped/

With those changes:

Acked-by: Will Deacon <will@kernel.org>

Will

\
 
 \ /
  Last update: 2021-03-04 15:09    [W:0.480 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site