Skip to content

Commit cf2d228

Browse files
vdonnefortoupton
authored andcommitted
KVM: arm64: Add flags to kvm_hyp_memcache
Add flags to kvm_hyp_memcache and propagate the latter to the allocation and free callbacks. This will later allow to account for memory, based on the memcache configuration. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Acked-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20250313114038.1502357-2-vdonnefort@google.com Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 0ad2507 commit cf2d228

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct kvm_hyp_memcache {
8686
phys_addr_t head;
8787
unsigned long nr_pages;
8888
struct pkvm_mapping *mapping; /* only used from EL1 */
89+
unsigned long flags;
8990
};
9091

9192
static inline void push_hyp_memcache(struct kvm_hyp_memcache *mc,

arch/arm64/kvm/mmu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,12 +1086,12 @@ void kvm_free_stage2_pgd(struct kvm_s2_mmu *mmu)
10861086
}
10871087
}
10881088

1089-
static void hyp_mc_free_fn(void *addr, void *unused)
1089+
static void hyp_mc_free_fn(void *addr, void *mc)
10901090
{
10911091
free_page((unsigned long)addr);
10921092
}
10931093

1094-
static void *hyp_mc_alloc_fn(void *unused)
1094+
static void *hyp_mc_alloc_fn(void *mc)
10951095
{
10961096
return (void *)__get_free_page(GFP_KERNEL_ACCOUNT);
10971097
}
@@ -1102,7 +1102,7 @@ void free_hyp_memcache(struct kvm_hyp_memcache *mc)
11021102
return;
11031103

11041104
kfree(mc->mapping);
1105-
__free_hyp_memcache(mc, hyp_mc_free_fn, kvm_host_va, NULL);
1105+
__free_hyp_memcache(mc, hyp_mc_free_fn, kvm_host_va, mc);
11061106
}
11071107

11081108
int topup_hyp_memcache(struct kvm_hyp_memcache *mc, unsigned long min_pages)
@@ -1117,7 +1117,7 @@ int topup_hyp_memcache(struct kvm_hyp_memcache *mc, unsigned long min_pages)
11171117
}
11181118

11191119
return __topup_hyp_memcache(mc, min_pages, hyp_mc_alloc_fn,
1120-
kvm_host_pa, NULL);
1120+
kvm_host_pa, mc);
11211121
}
11221122

11231123
/**

0 commit comments

Comments
 (0)