xen/arm: sched: Ensure the vCPU context is seen before vcpu_pause() returns
authorJulien Grall <jgrall@amazon.com>
Tue, 22 Sep 2020 19:31:04 +0000 (20:31 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 6 Nov 2020 01:49:26 +0000 (17:49 -0800)
commitd131310e60828a15f1354f0d73a89f42b64fe810
tree244cd96ae42aaa96e64ec7b500bc9f3bc3576ff4
parent7d2b21fd36c2a47799eed71c67bae7faa1ec4272
xen/arm: sched: Ensure the vCPU context is seen before vcpu_pause() returns

Some callers of vcpu_pause() will expect to access the latest vcpu
context when the function returns (see XENDOMCTL_{set,get}vcpucontext}.

However, the latest vCPU context can only be observed after
v->is_running has been observed to be false.

As there is no memory barrier instruction generated, a processor could
try to speculatively access the vCPU context before it was observed.

To prevent the corruption of the vCPU context, we need to insert a
memory barrier instruction after v->is_running is observed and before
the context is accessed. This barrier is added in sync_vcpu_execstate()
as it seems to be the place where we expect the synchronization to
happen.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
(cherry picked from commit f6790389613cd54775ece6575013a679572b46b3)
xen/arch/arm/domain.c