ANDROID: KVM: arm64: Expose get_leaf to pKVM modules

Expose an API allowing to query the host stage-2 page-table to module.

Bug: 264070847
Change-Id: Ifbb2c9c8f8899778b9bf1f7df1dae81acba2af6d
Signed-off-by: Quentin Perret <qperret@google.com>
This commit is contained in:
Quentin Perret
2023-01-06 18:03:29 +00:00
parent 63ad198da8
commit 272cf01f5e
4 changed files with 14 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ struct pkvm_module_ops {
void (*flush_dcache_to_poc)(void *addr, size_t size);
int (*register_host_perm_fault_handler)(int (*cb)(struct kvm_cpu_context *ctxt, u64 esr, u64 addr));
int (*protect_host_page)(u64 pfn, enum kvm_pgtable_prot prot);
int (*host_stage2_get_leaf)(phys_addr_t phys, kvm_pte_t *ptep, u32 *level);
int (*register_host_smc_handler)(bool (*cb)(struct kvm_cpu_context *));
int (*register_default_trap_handler)(bool (*cb)(struct kvm_cpu_context *));
int (*register_illegal_abt_notifier)(void (*cb)(struct kvm_cpu_context *));

View File

@@ -99,6 +99,7 @@ int hyp_pin_shared_mem(void *from, void *to);
void hyp_unpin_shared_mem(void *from, void *to);
void reclaim_guest_pages(struct pkvm_hyp_vm *vm, struct kvm_hyp_memcache *mc);
int hyp_protect_host_page(u64 pfn, enum kvm_pgtable_prot prot);
int host_stage2_get_leaf(phys_addr_t phys, kvm_pte_t *ptep, u32 *level);
int refill_memcache(struct kvm_hyp_memcache *mc, unsigned long min_pages,
struct kvm_hyp_memcache *host_mc);

View File

@@ -2234,3 +2234,14 @@ int host_stage2_protect_pages_locked(phys_addr_t addr, u64 size)
return ret;
}
int host_stage2_get_leaf(phys_addr_t phys, kvm_pte_t *ptep, u32 *level)
{
int ret;
host_lock_component();
ret = kvm_pgtable_get_leaf(&host_mmu.pgt, phys, ptep, level);
host_unlock_component();
return ret;
}

View File

@@ -69,6 +69,7 @@ const struct pkvm_module_ops module_ops = {
.flush_dcache_to_poc = __kvm_flush_dcache_to_poc,
.register_host_perm_fault_handler = hyp_register_host_perm_fault_handler,
.protect_host_page = hyp_protect_host_page,
.host_stage2_get_leaf = host_stage2_get_leaf,
.register_host_smc_handler = __pkvm_register_host_smc_handler,
.register_default_trap_handler = __pkvm_register_default_trap_handler,
.register_illegal_abt_notifier = __pkvm_register_illegal_abt_notifier,