diff options
author | Ricardo Koller <ricarkol@google.com> | 2023-04-26 17:23:23 +0000 |
---|---|---|
committer | Oliver Upton <oliver.upton@linux.dev> | 2023-05-16 17:39:18 +0000 |
commit | 2f440b72e852be428540579b5813ba2b8236578d (patch) | |
tree | c4be44262abb5c8da28ca42115b6ae7e885693d4 /arch/arm64/include/asm/kvm_pgtable.h | |
parent | 26f457142d7ee2da20a5b701862230e4961423d9 (diff) | |
download | linux-2f440b72e852be428540579b5813ba2b8236578d.tar.gz linux-2f440b72e852be428540579b5813ba2b8236578d.tar.bz2 linux-2f440b72e852be428540579b5813ba2b8236578d.zip |
KVM: arm64: Add KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE
Add a capability for userspace to specify the eager split chunk size.
The chunk size specifies how many pages to break at a time, using a
single allocation. Bigger the chunk size, more pages need to be
allocated ahead of time.
Suggested-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Ricardo Koller <ricarkol@google.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Link: https://lore.kernel.org/r/20230426172330.1439644-6-ricarkol@google.com
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Diffstat (limited to 'arch/arm64/include/asm/kvm_pgtable.h')
-rw-r--r-- | arch/arm64/include/asm/kvm_pgtable.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index c8e0e7d9303b..cbc6971e2cb4 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -92,6 +92,24 @@ static inline bool kvm_level_supports_block_mapping(u32 level) return level >= KVM_PGTABLE_MIN_BLOCK_LEVEL; } +static inline u32 kvm_supported_block_sizes(void) +{ + u32 level = KVM_PGTABLE_MIN_BLOCK_LEVEL; + u32 r = 0; + + for (; level < KVM_PGTABLE_MAX_LEVELS; level++) + r |= BIT(kvm_granule_shift(level)); + + return r; +} + +static inline bool kvm_is_block_size_supported(u64 size) +{ + bool is_power_of_two = IS_ALIGNED(size, size); + + return is_power_of_two && (size & kvm_supported_block_sizes()); +} + /** * struct kvm_pgtable_mm_ops - Memory management callbacks. * @zalloc_page: Allocate a single zeroed memory page. |