From 58b70f4a59655ff67305468607aff6e535eb9155 Mon Sep 17 00:00:00 2001 From: Vincent Donnefort Date: Thu, 24 Apr 2025 09:30:59 +0100 Subject: [PATCH] ANDROID: KVM: arm64: Exposes fixblock_map to pKVM modules fixblock_map() is a PMD-size version of fixmap_map(). It is intended to allow the mapping of large pages. Contrary to fixmap_map() it is not per-CPU but shared. Bug: 357781595 Bug: 411362768 Change-Id: I6ae6fe407fd7340bba879009bb8a7f1cf2eea50e Signed-off-by: Vincent Donnefort --- arch/arm64/include/asm/kvm_pkvm_module.h | 10 ++++++++++ arch/arm64/kvm/hyp/nvhe/modules.c | 2 ++ 2 files changed, 12 insertions(+) diff --git a/arch/arm64/include/asm/kvm_pkvm_module.h b/arch/arm64/include/asm/kvm_pkvm_module.h index 1da077a911ff..fb088625fba4 100644 --- a/arch/arm64/include/asm/kvm_pkvm_module.h +++ b/arch/arm64/include/asm/kvm_pkvm_module.h @@ -51,6 +51,14 @@ enum pkvm_psci_notification { * new mapping is visible. * @fixmap_unmap: Unmap a page from the hypervisor fixmap. This * call is required between each @fixmap_map(). + * @fixblock_map: Map a PMD-size large page into a CPU-shared + * fixmap. This can be used to replace and speed-up + * a set of @fixmap_map. @fixblock_unmap must be + * called between each mappings to do cache + * maintenance and ensure the new mapping is visible. + * @fixblock_unmap: Unmap a PMD-size large page from the hypervisor + * fixmap. This call is required between each + * @fixblock_map. * @linear_map_early: Map a large portion of memory into the * hypervisor linear VA space. This is intended to * be used only for module bootstrap and must be @@ -197,6 +205,8 @@ struct pkvm_module_ops { void (*putx64)(u64 x); void *(*fixmap_map)(phys_addr_t phys); void (*fixmap_unmap)(void); + void *(*fixblock_map)(phys_addr_t phys); + void (*fixblock_unmap)(void); void *(*linear_map_early)(phys_addr_t phys, size_t size, enum kvm_pgtable_prot prot); void (*linear_unmap_early)(void *addr, size_t size); void (*flush_dcache_to_poc)(void *addr, size_t size); diff --git a/arch/arm64/kvm/hyp/nvhe/modules.c b/arch/arm64/kvm/hyp/nvhe/modules.c index 7d5ec6ba1f95..1148c9ba926c 100644 --- a/arch/arm64/kvm/hyp/nvhe/modules.c +++ b/arch/arm64/kvm/hyp/nvhe/modules.c @@ -216,6 +216,8 @@ const struct pkvm_module_ops module_ops = { .putx64 = hyp_putx64, .fixmap_map = hyp_fixmap_map, .fixmap_unmap = hyp_fixmap_unmap, + .fixblock_map = hyp_fixblock_map, + .fixblock_unmap = hyp_fixblock_unmap, .linear_map_early = __pkvm_linear_map_early, .linear_unmap_early = __pkvm_linear_unmap_early, .flush_dcache_to_poc = __kvm_flush_dcache_to_poc,