ANDROID: Revert "KVM: arm64: Expose topup_hyp_memcache() to the rest of KVM"
The upcoming hypervisor heap allocator will use hyp_memcache to carry over memory from host to hyp and vice versa. We then need a topup function which can handle any mc, not only the VCPUs. This reverts commit 8593e2099934a970725de292a05ee6ebdde94f0e. Bug: 357781595 Bug: 273748186 Change-Id: Id55e45ab52a99fed16a2862509b302d696e322af Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
This commit is contained in:
committed by
Keir Fraser
parent
9d8af4215d
commit
48e3029344
@@ -139,7 +139,7 @@ static inline void __free_hyp_memcache(struct kvm_hyp_memcache *mc,
|
||||
}
|
||||
|
||||
void free_hyp_memcache(struct kvm_hyp_memcache *mc);
|
||||
int topup_hyp_memcache(struct kvm_vcpu *vcpu);
|
||||
int topup_hyp_memcache(struct kvm_hyp_memcache *mc, unsigned long min_pages);
|
||||
|
||||
struct kvm_vmid {
|
||||
atomic64_t id;
|
||||
|
||||
@@ -378,7 +378,9 @@ int kvm_smccc_call_handler(struct kvm_vcpu *vcpu)
|
||||
kvm_ptp_get_time(vcpu, val);
|
||||
break;
|
||||
case ARM_SMCCC_VENDOR_HYP_KVM_MMIO_GUARD_MAP_FUNC_ID:
|
||||
if (kvm_vm_is_protected(vcpu->kvm) && !topup_hyp_memcache(vcpu))
|
||||
if (kvm_vm_is_protected(vcpu->kvm) &&
|
||||
!topup_hyp_memcache(&vcpu->arch.pkvm_memcache,
|
||||
kvm_mmu_cache_min_pages(&vcpu->kvm->arch.mmu)))
|
||||
val[0] = SMCCC_RET_SUCCESS;
|
||||
break;
|
||||
case ARM_SMCCC_VENDOR_HYP_KVM_MEM_RELINQUISH_FUNC_ID:
|
||||
|
||||
@@ -1193,14 +1193,12 @@ void free_hyp_memcache(struct kvm_hyp_memcache *mc)
|
||||
kvm_host_va, NULL);
|
||||
}
|
||||
|
||||
int topup_hyp_memcache(struct kvm_vcpu *vcpu)
|
||||
int topup_hyp_memcache(struct kvm_hyp_memcache *mc, unsigned long min_pages)
|
||||
{
|
||||
if (!is_protected_kvm_enabled())
|
||||
return 0;
|
||||
|
||||
return __topup_hyp_memcache(&vcpu->arch.pkvm_memcache,
|
||||
kvm_mmu_cache_min_pages(&vcpu->kvm->arch.mmu),
|
||||
hyp_mc_alloc_fn,
|
||||
return __topup_hyp_memcache(mc, min_pages, hyp_mc_alloc_fn,
|
||||
kvm_host_pa, NULL);
|
||||
}
|
||||
|
||||
@@ -1632,17 +1630,19 @@ static int pkvm_relax_perms(struct kvm *kvm, u64 pfn, u64 gfn,
|
||||
static int pkvm_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
|
||||
struct kvm_memory_slot *memslot)
|
||||
{
|
||||
struct kvm_hyp_memcache *hyp_memcache = &vcpu->arch.pkvm_memcache;
|
||||
struct mm_struct *mm = current->mm;
|
||||
unsigned int flags = FOLL_HWPOISON | FOLL_LONGTERM | FOLL_WRITE;
|
||||
struct kvm_pinned_page *ppage;
|
||||
struct kvm *kvm = vcpu->kvm;
|
||||
struct kvm_s2_mmu *mmu = &kvm->arch.mmu;
|
||||
struct page *page;
|
||||
gfn_t gfn = fault_ipa >> PAGE_SHIFT;
|
||||
unsigned long hva = gfn_to_hva_memslot_prot(memslot, gfn, NULL);
|
||||
u64 pfn;
|
||||
int ret;
|
||||
|
||||
ret = topup_hyp_memcache(vcpu);
|
||||
ret = topup_hyp_memcache(hyp_memcache, kvm_mmu_cache_min_pages(mmu));
|
||||
if (ret)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user