gnttab: split maptrack lock to make it fulfill its purpose again
authorJan Beulich <jbeulich@suse.com>
Mon, 31 Jul 2017 14:17:56 +0000 (15:17 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Thu, 7 Sep 2017 18:17:58 +0000 (19:17 +0100)
commitcd0978ab5a71557a05cfb064c62ed2bd0ffce7d4
treee84a61fe10a565f6a93f26f79734562355c5614f
parent2931be464330f4e78c7bf0aa9b79afb806930907
gnttab: split maptrack lock to make it fulfill its purpose again

The way the lock is currently being used in get_maptrack_handle(), it
protects only the maptrack limit: The function acts on current's list
only, so races on list accesses are impossible even without the lock.

Otoh list access races are possible between __get_maptrack_handle() and
put_maptrack_handle(), due to the invocation of the former for other
than current from steal_maptrack_handle(). Introduce a per-vCPU lock
for list accesses to become race free again. This lock will be
uncontended except when it becomes necessary to take the steal path,
i.e. in the common case there should be no meaningful performance
impact.

When in get_maptrack_handle adds a stolen entry to a fresh, empty,
freelist, we think that there is probably no concurrency.  However,
this is not a fast path and adding the locking there makes the code
clearly correct.

Also, while we are here: the stolen maptrack_entry's tail pointer was
not properly set.  Set it.

This is XSA-228.

Reported-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Gbp-Pq: Name gnttab-split-maptrack-lock-to-make-it-fu
docs/misc/grant-tables.txt
xen/common/grant_table.c
xen/include/xen/grant_table.h
xen/include/xen/sched.h