[RFC PATCH 12/45] KVM: arm64: pkvm: Unify pkvm_pkvm_teardown_donated_memory()

Jean-Philippe Brucker jean-philippe at linaro.org
Tue Jan 23 11:49:31 PST 2024


Hi Seb,

On Mon, Jan 15, 2024 at 02:33:50PM +0000, Sebastian Ene wrote:
> >  int __pkvm_teardown_vm(pkvm_handle_t handle)
> >  {
> >  	size_t vm_size, last_ran_size;
> > @@ -813,19 +802,18 @@ int __pkvm_teardown_vm(pkvm_handle_t handle)
> >  		vcpu_mc = &hyp_vcpu->vcpu.arch.pkvm_memcache;
> >  		while (vcpu_mc->nr_pages) {
> >  			addr = pop_hyp_memcache(vcpu_mc, hyp_phys_to_virt);
> > -			push_hyp_memcache(mc, addr, hyp_virt_to_phys);
> > -			unmap_donated_memory_noclear(addr, PAGE_SIZE);
> > +			pkvm_teardown_donated_memory(mc, addr, 0);
> 
> Here we probably need to pass PAGE_SIZE as an argument instead of "0"
> to make sure that we clear out the content of the page before tearing it
> down.

But since it's replacing unmap_donated_memory_noclear(), would that be a
change of behavior?  That would be a separate patch because this one is
just trying to refactor things.

Thanks,
Jean

> 
> >  		}
> >  
> > -		teardown_donated_memory(mc, hyp_vcpu, sizeof(*hyp_vcpu));
> > +		pkvm_teardown_donated_memory(mc, hyp_vcpu, sizeof(*hyp_vcpu));
> >  	}
> >  
> >  	last_ran_size = pkvm_get_last_ran_size();
> > -	teardown_donated_memory(mc, hyp_vm->kvm.arch.mmu.last_vcpu_ran,
> > -				last_ran_size);
> > +	pkvm_teardown_donated_memory(mc, hyp_vm->kvm.arch.mmu.last_vcpu_ran,
> > +				     last_ran_size);
> >  
> >  	vm_size = pkvm_get_hyp_vm_size(hyp_vm->kvm.created_vcpus);
> > -	teardown_donated_memory(mc, hyp_vm, vm_size);
> > +	pkvm_teardown_donated_memory(mc, hyp_vm, vm_size);
> >  	hyp_unpin_shared_mem(host_kvm, host_kvm + 1);
> >  	return 0;
> >  
> > -- 
> > 2.39.0
> >
> 
> Thanks,
> Seb



More information about the linux-arm-kernel mailing list