Re: KVM swapping with mmu notifiers

Avi Kivity
2008-01-15T14:40:19Z

Andrea Arcangeli wrote:
> On Mon, Jan 14, 2008 at 05:43:58PM +0200, Avi Kivity wrote:
>
>> heavy handed. Maybe it can be fixed in some clever way with rcu or with a
>> rwlock around the memory slot map.
>>
>
> Ok, first the alias looked superflous so I just dropped it (the whole
> point of the alias is to never call get_user_pages in the aliased hva,
> so the notifiers should never trigger in those alias gfn ranges).
>
>

Right, good point.

Note that we can now replace aliases with slots; simply map the same hva
range to two different gpa ranges (using a kvm-private memslot for
backward compat).

> And the code was doing hva->gfn->rmap, while I'm now doing hva->rmap
> directly to avoid two loops over the memslot instead of only one. To
> serialize hva_to_rmapp mmap_sem is taken (in any mode) or the mmu_lock
> is taken, and it's enough to serialize the insertion with the mmu_lock
> and setting userspace_addr to 0 before insertion if the buffer isn't
> allocated by userland. Setting userspace_addr atomically will make the
> memslot visible.
>

Can we do the locking change as a separate patch?

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