mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-09-03 17:51:23 +00:00

With the introduction of stage-2 huge mappings in the pKVM hypervisor, guest pages CMO is needed for PMD_SIZE size. Fixmap only supports PAGE_SIZE and iterating over the huge-page is time consuming (mostly due to TLBI on hyp_fixmap_unmap) which is a problem for EL2 latency. Introduce a shared PMD_SIZE fixmap (hyp_fixblock_map/hyp_fixblock_unmap) to improve guest page CMOs when stage-2 huge mappings are installed. On a Pixel6, the iterative solution resulted in a latency of ~700us, while the PMD_SIZE fixmap reduces it to ~100us. Because of the horrendous private range allocation that would be necessary, this is disabled for 64KiB pages systems. Suggested-by: Quentin Perret <qperret@google.com> Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Quentin Perret <qperret@google.com> Link: https://lore.kernel.org/r/20250521124834.1070650-11-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
35 lines
1.1 KiB
C
35 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#ifndef __KVM_HYP_MM_H
|
|
#define __KVM_HYP_MM_H
|
|
|
|
#include <asm/kvm_pgtable.h>
|
|
#include <asm/spectre.h>
|
|
#include <linux/memblock.h>
|
|
#include <linux/types.h>
|
|
|
|
#include <nvhe/memory.h>
|
|
#include <nvhe/spinlock.h>
|
|
|
|
extern struct kvm_pgtable pkvm_pgtable;
|
|
extern hyp_spinlock_t pkvm_pgd_lock;
|
|
|
|
int hyp_create_fixmap(void);
|
|
void *hyp_fixmap_map(phys_addr_t phys);
|
|
void hyp_fixmap_unmap(void);
|
|
void *hyp_fixblock_map(phys_addr_t phys, size_t *size);
|
|
void hyp_fixblock_unmap(void);
|
|
|
|
int hyp_create_idmap(u32 hyp_va_bits);
|
|
int hyp_map_vectors(void);
|
|
int hyp_back_vmemmap(phys_addr_t back);
|
|
int pkvm_cpu_set_vector(enum arm64_hyp_spectre_vector slot);
|
|
int pkvm_create_mappings(void *from, void *to, enum kvm_pgtable_prot prot);
|
|
int pkvm_create_mappings_locked(void *from, void *to, enum kvm_pgtable_prot prot);
|
|
int __pkvm_create_private_mapping(phys_addr_t phys, size_t size,
|
|
enum kvm_pgtable_prot prot,
|
|
unsigned long *haddr);
|
|
int pkvm_create_stack(phys_addr_t phys, unsigned long *haddr);
|
|
int pkvm_alloc_private_va_range(size_t size, unsigned long *haddr);
|
|
|
|
#endif /* __KVM_HYP_MM_H */
|