mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
ANDROID: KVM: arm64: move kvm_shadow_destroy to pkvm.c for symmetry with create_el2_shadow
Better to have the creation and teardown code in the same file to understand what's happening. Simplifies subsequent patches. Bug: 220830416 Signed-off-by: Fuad Tabba <tabba@google.com> Change-Id: I07bc8a9e254753f000c4faffffcf52a0d8f3a831
This commit is contained in:
committed by
Quentin Perret
parent
ab9f8c8200
commit
aaf5614200
@@ -22,6 +22,7 @@
|
||||
int kvm_arm_vm_ioctl_pkvm(struct kvm *kvm, struct kvm_enable_cap *cap);
|
||||
int kvm_init_pvm(struct kvm *kvm, unsigned long type);
|
||||
int create_el2_shadow(struct kvm *kvm);
|
||||
void kvm_shadow_destroy(struct kvm *kvm);
|
||||
|
||||
/*
|
||||
* Definitions for features to be allowed or restricted for guest virtual
|
||||
|
||||
@@ -195,31 +195,6 @@ vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
|
||||
return VM_FAULT_SIGBUS;
|
||||
}
|
||||
|
||||
void free_hyp_memcache(struct kvm_hyp_memcache *mc);
|
||||
static void kvm_shadow_destroy(struct kvm *kvm)
|
||||
{
|
||||
struct kvm_pinned_page *ppage, *tmp;
|
||||
struct mm_struct *mm = current->mm;
|
||||
struct list_head *ppages;
|
||||
|
||||
if (kvm->arch.pkvm.shadow_handle)
|
||||
WARN_ON(kvm_call_hyp_nvhe(__pkvm_teardown_shadow, kvm));
|
||||
|
||||
free_hyp_memcache(&kvm->arch.pkvm.teardown_mc);
|
||||
|
||||
ppages = &kvm->arch.pkvm.pinned_pages;
|
||||
list_for_each_entry_safe(ppage, tmp, ppages, link) {
|
||||
WARN_ON(kvm_call_hyp_nvhe(__pkvm_host_reclaim_page,
|
||||
page_to_pfn(ppage->page)));
|
||||
cond_resched();
|
||||
|
||||
account_locked_vm(mm, 1, false);
|
||||
unpin_user_pages_dirty_lock(&ppage->page, 1, true);
|
||||
list_del(&ppage->link);
|
||||
kfree(ppage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* kvm_arch_destroy_vm - destroy the VM data structure
|
||||
* @kvm: pointer to the KVM struct
|
||||
|
||||
@@ -196,6 +196,30 @@ int create_el2_shadow(struct kvm *kvm)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void kvm_shadow_destroy(struct kvm *kvm)
|
||||
{
|
||||
struct kvm_pinned_page *ppage, *tmp;
|
||||
struct mm_struct *mm = current->mm;
|
||||
struct list_head *ppages;
|
||||
|
||||
if (kvm->arch.pkvm.shadow_handle)
|
||||
WARN_ON(kvm_call_hyp_nvhe(__pkvm_teardown_shadow, kvm));
|
||||
|
||||
free_hyp_memcache(&kvm->arch.pkvm.teardown_mc);
|
||||
|
||||
ppages = &kvm->arch.pkvm.pinned_pages;
|
||||
list_for_each_entry_safe(ppage, tmp, ppages, link) {
|
||||
WARN_ON(kvm_call_hyp_nvhe(__pkvm_host_reclaim_page,
|
||||
page_to_pfn(ppage->page)));
|
||||
cond_resched();
|
||||
|
||||
account_locked_vm(mm, 1, false);
|
||||
unpin_user_pages_dirty_lock(&ppage->page, 1, true);
|
||||
list_del(&ppage->link);
|
||||
kfree(ppage);
|
||||
}
|
||||
}
|
||||
|
||||
static int __init pkvm_firmware_rmem_err(struct reserved_mem *rmem,
|
||||
const char *reason)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user