Re: KVM: MMU: add KVM_ZAP_GFN ioctl

Avi Kivity
2008-03-23T08:50:18Z

Marcelo Tosatti wrote:
> On Fri, Mar 21, 2008 at 12:42:14PM +0100, Andrea Arcangeli wrote:
>
>> On Thu, Mar 20, 2008 at 02:09:15PM +0200, Avi Kivity wrote:
>>
>>> Marcelo Tosatti wrote:
>>>
>>>> Add an ioctl to zap all mappings to a given gfn. This allows userspace
>>>> remove the QEMU process mappings and the page without causing
>>>> inconsistency.
>>>>
>>>>
>>>>
>>> I'm thinking of comitting rmap_nuke() to kvm.git, and the rest to the
>>> external module, since this is only needed on kernels without mmu notifiers.
>>>
>>> Andrea, is rmap_nuke() suitable for the mmu notifiers pte clear callback?
>>>
>> There's the usual smp race condition. The tlb must be flushed before
>> the final put_page in rmap_remove. And it can't be safe to call this
>> ioctl before sys_munmap(), so this would be the final put_page.
>>
>> My kvm_unmap_hva takes care of that.
>>
>
> This is not the final put_page().
>
>

I think it may be, when this is used as an mmu notifier callback.

btw, when we nuke an spte, don't we lose dirty bit information? That
doesn't matter with madvise(), but it does when removing a pte for other
reasons, say swapping. Don't we need to clear the spte with cmpxchg(),
to make sure the dirty bit is what we think it is?

--
error compiling committee.c: too many arguments to function