|
From: Avi K. <av...@qu...> - 2008-04-30 12:57:06
|
Muli Ben-Yehuda wrote:
>> @@ -544,19 +545,35 @@ pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn)
>> npages = get_user_pages(current, current->mm, addr, 1, 1, 1, page,
>> NULL);
>>
>> - if (npages != 1) {
>> - get_page(bad_page);
>> - return page_to_pfn(bad_page);
>> - }
>> + if (unlikely(npages != 1)) {
>> + struct vm_area_struct *vma;
>>
>> - return page_to_pfn(page[0]);
>> + vma = find_vma(current->mm, addr);
>> + if (vma == NULL || addr >= vma->vm_start ||
>> + !(vma->vm_flags & VM_PFNMAP)) {
>>
>
> Isn't the check for addr backwards here? For the VMA we would like to
> to find, vma->vm_start <= addr < vma->vm_end.
>
>
The code is not trying to find a vma for the address, but a vma for the
address which also has VM_PFNMAP set. The cases for vma not found, or
vma found, but not VM_PFNMAP, are folded together.
--
Any sufficiently difficult bug is indistinguishable from a feature.
|