]> xenbits.xensource.com Git - xen.git/commit
xen/sched: Introduce domain_vcpu() helper
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 24 Jul 2014 10:06:39 +0000 (11:06 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 24 Jan 2019 18:08:43 +0000 (18:08 +0000)
commit9e92acf1b752dfdfb294234b32d1fa9f55bfdc0f
tree6aafb7f22a3df433a7b7c947066372b215f0352e
parente3b418ac491919127211b4d3c692d431061d7c09
xen/sched: Introduce domain_vcpu() helper

The progression of multi-vcpu support in Xen (originally a single pointer,
then an embedded d->vcpu[] array, then a dynamically allocated array) has
resulted in a large quantity of ad-hoc code for looking a vcpu up by id, and a
large number of ways that the toolstack can cause Xen to trip over a NULL
pointer.  Some of this has been addressed in Xen 4.12, and work is ongoing.

Another property of looking a vcpu up by id is that it is frequently done in
unprivileged hypercall context, making it an attractive target for speculative
sidechannel attacks.

Introduce a helper to do the lookup correctly, and without speculative
interference.  For performance reasons, it is useful not to have an smp_rmb()
in this helper on ARM, and luckily this is safe to do, because of the
serialisation offered by the global domlist lock.

As a minor change noticed when checking the safety of this construct, sanity
check during boot that idle->max_vcpus is a suitable upper bound for
idle->vcpu[].

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/schedule.c
xen/include/xen/sched.h