mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
KVM: selftests: Add arch hook to force page tables to be naturally aligned
Add an arch hook to communicate to the core physical page allocator that page table allocations need to be naturally aligned. The hook will be used for upcoming PowerPC support, which has MMU tables that are larger than the guest base page size and need to be naturally aligned. Bury the hook in the physical page allocator to avoid having to plumb a rarely used param into the main APIs. Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Tested-by: Itaru Kitayama <itaru.kitayama@fujitsu.com> Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Tested-by: Itaru Kitayam <itaru.kitayama@fujitsu.com> Link: https://patch.msgid.link/20260902164123.2546762-21-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
6c28a0d7cf
commit
1e59e5a3bd
|
|
@ -1052,6 +1052,8 @@ void kvm_gsi_routing_write(struct kvm_vm *vm, struct kvm_irq_routing *routing);
|
|||
|
||||
const char *exit_reason_str(unsigned int exit_reason);
|
||||
|
||||
bool kvm_arch_needs_naturally_aligned_page_tables(void);
|
||||
|
||||
gpa_t ____vm_phy_pages_alloc(struct kvm_vm *vm, size_t nr_pages, gpa_t min_gpa,
|
||||
u32 memslot, bool protected, bool naturally_aligned);
|
||||
gpa_t __vm_phy_pages_alloc(struct kvm_vm *vm, size_t nr_pages,
|
||||
|
|
|
|||
|
|
@ -2085,10 +2085,16 @@ gpa_t ____vm_phy_pages_alloc(struct kvm_vm *vm, size_t nr_pages, gpa_t min_gpa,
|
|||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
__weak bool kvm_arch_needs_naturally_aligned_page_tables(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
gpa_t __vm_phy_pages_alloc(struct kvm_vm *vm, size_t nr_pages,
|
||||
enum kvm_mem_region_type type, bool protected)
|
||||
{
|
||||
struct userspace_mem_region *region = vm_get_mem_region(vm, type);
|
||||
bool naturally_aligned = false;
|
||||
gpa_t min_gpa;
|
||||
|
||||
TEST_ASSERT(region, "No region for type '%u', memslot '%u'",
|
||||
|
|
@ -2110,6 +2116,7 @@ gpa_t __vm_phy_pages_alloc(struct kvm_vm *vm, size_t nr_pages,
|
|||
break;
|
||||
case MEM_REGION_PT:
|
||||
min_gpa = KVM_GUEST_PAGE_TABLE_MIN_PADDR;
|
||||
naturally_aligned = kvm_arch_needs_naturally_aligned_page_tables();
|
||||
break;
|
||||
case MEM_REGION_TEST_EXTRA:
|
||||
min_gpa = region->region.guest_phys_addr;
|
||||
|
|
@ -2120,7 +2127,7 @@ gpa_t __vm_phy_pages_alloc(struct kvm_vm *vm, size_t nr_pages,
|
|||
}
|
||||
|
||||
return ____vm_phy_pages_alloc(vm, nr_pages, min_gpa, vm->memslots[type],
|
||||
protected, false);
|
||||
protected, naturally_aligned);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user