hva_to_pfn and memory leak
Hello, guys!
I have written paravirtual interface for GPA->HPA translation inside guest. I build GPA->HPA translation table in guest virtual memory.
To do this, I need to translate userspace virtual address from memslot to host physical address. I use hva_to_pfn for it. It works fine, but linux doesn't free the guest memory after guest power off. After testing I have found that cause of memory leak is hva_to_pfg call. You can find my code at http://pastebin.com/0zBV2aPN.
Do I translate hva to hpa in the right way?
I do this patch for RHEL Linux Kernel 2.6.32-279.5.2.el6 because I use CentOS 6.3.
Thanks!
Vladimir.
22.11.2012, 18:13, "Koshelev Vladimir" <[email protected]>:
> Hello, guys!
>
> I have written paravirtual interface for GPA->HPA translation inside guest. I build GPA->HPA translation table in guest virtual memory.
> To do this, I need to translate userspace virtual address from memslot to host physical address. I use hva_to_pfn for it. It works fine, but linux doesn't free the guest > memory after guest power off. After testing I have found that cause of memory leak is hva_to_pfg call. You can find my code at http://pastebin.com/0zBV2aPN.
> Do I translate hva to hpa in the right way?
>
> I do this patch for RHEL Linux Kernel 2.6.32-279.5.2.el6 because I use CentOS 6.3.
>
> Thanks!
>
> Vladimir.
Fixed.
I have found that kvm_release_pfn_clean is necessary for this case. Before that I thought hva_to_pfn just translates(doesn't map) the HVA, but it is not true.