Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: Introduce two cache maintenance callbacks

To prepare for performing CMOs for guest stage-2 in the fault handlers
in pgtable.c, here introduce two cache maintenance callbacks in struct
kvm_pgtable_mm_ops. We also adjust the comment alignment for the
existing part but make no real content change at all.

Reviewed-by: Fuad Tabba <tabba@google.com>
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
[maz: fixed up comments and renamed callbacks]
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210617105824.31752-2-wangyanan55@huawei.com

authored by

Yanan Wang and committed by
Marc Zyngier
6204004d 8124c8a6

+25 -17
+25 -17
arch/arm64/include/asm/kvm_pgtable.h
··· 27 27 28 28 /** 29 29 * struct kvm_pgtable_mm_ops - Memory management callbacks. 30 - * @zalloc_page: Allocate a single zeroed memory page. The @arg parameter 31 - * can be used by the walker to pass a memcache. The 32 - * initial refcount of the page is 1. 33 - * @zalloc_pages_exact: Allocate an exact number of zeroed memory pages. The 34 - * @size parameter is in bytes, and is rounded-up to the 35 - * next page boundary. The resulting allocation is 36 - * physically contiguous. 37 - * @free_pages_exact: Free an exact number of memory pages previously 38 - * allocated by zalloc_pages_exact. 39 - * @get_page: Increment the refcount on a page. 40 - * @put_page: Decrement the refcount on a page. When the refcount 41 - * reaches 0 the page is automatically freed. 42 - * @page_count: Return the refcount of a page. 43 - * @phys_to_virt: Convert a physical address into a virtual address mapped 44 - * in the current context. 45 - * @virt_to_phys: Convert a virtual address mapped in the current context 46 - * into a physical address. 30 + * @zalloc_page: Allocate a single zeroed memory page. 31 + * The @arg parameter can be used by the walker 32 + * to pass a memcache. The initial refcount of 33 + * the page is 1. 34 + * @zalloc_pages_exact: Allocate an exact number of zeroed memory pages. 35 + * The @size parameter is in bytes, and is rounded 36 + * up to the next page boundary. The resulting 37 + * allocation is physically contiguous. 38 + * @free_pages_exact: Free an exact number of memory pages previously 39 + * allocated by zalloc_pages_exact. 40 + * @get_page: Increment the refcount on a page. 41 + * @put_page: Decrement the refcount on a page. When the 42 + * refcount reaches 0 the page is automatically 43 + * freed. 44 + * @page_count: Return the refcount of a page. 45 + * @phys_to_virt: Convert a physical address into a virtual 46 + * address mapped in the current context. 47 + * @virt_to_phys: Convert a virtual address mapped in the current 48 + * context into a physical address. 49 + * @dcache_clean_inval_poc: Clean and invalidate the data cache to the PoC 50 + * for the specified memory address range. 51 + * @icache_inval_pou: Invalidate the instruction cache to the PoU 52 + * for the specified memory address range. 47 53 */ 48 54 struct kvm_pgtable_mm_ops { 49 55 void* (*zalloc_page)(void *arg); ··· 60 54 int (*page_count)(void *addr); 61 55 void* (*phys_to_virt)(phys_addr_t phys); 62 56 phys_addr_t (*virt_to_phys)(void *addr); 57 + void (*dcache_clean_inval_poc)(void *addr, size_t size); 58 + void (*icache_inval_pou)(void *addr, size_t size); 63 59 }; 64 60 65 61 /**