]> xenbits.xensource.com Git - xen.git/commit
xen/cpu: Distinguish "cpu already in that state" in cpu_{up,down}()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 2 Apr 2019 13:21:56 +0000 (14:21 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 4 Apr 2019 13:32:41 +0000 (14:32 +0100)
commitab0e50c03f01c51c091f232d1a096a90085c2a24
treed1eafe5064523505f4cd5b9fc840f35476ae9b13
parent1a09cb35deaf961776f8fb4acdda95c0e7acfc86
xen/cpu: Distinguish "cpu already in that state" in cpu_{up,down}()

All methods of querying the online state of a CPU are racy without the hotplug
lock held, which can lead to a TOCTOU race trying to online or offline CPUs.

Distinguish this case with -EEXIST rather than -EINVAL, so the caller can take
other actions if necessary.

While adjusting this, rework the code slightly to fold the exit paths, which
results in a minor reduction in compiled code size.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/cpu.c