x86: avoid leaking PKRU and BND* between vCPU-s
authorJan Beulich <jbeulich@suse.com>
Tue, 20 Jun 2017 12:24:03 +0000 (13:24 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Thu, 7 Sep 2017 18:17:58 +0000 (19:17 +0100)
commit5d63ffffd90721c34eb2129ed4a87aa1d4afa60f
tree52e8b718118dd6e72677d214c35e16460f3298fd
parent30a119930b2f26199be3bc95e7cece0b8b6dfcc8
x86: avoid leaking PKRU and BND* between vCPU-s

PKRU is explicitly "XSAVE-managed but not XSAVE-enabled", so guests
might access the register (via {RD,WR}PKRU) without setting XCR0.PKRU.
Force context switching as well as migrating the register as soon as
CR4.PKE is being set the first time.

For MPX (BND<n>, BNDCFGU, and BNDSTATUS) the situation is less clear,
and the SDM has not entirely consistent information for that case.
While experimentally the instructions don't change register state as
long as the two XCR0 bits aren't both 1, be on the safe side and enable
both if BNDCFGS.EN is being set the first time.

This is XSA-220.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Gbp-Pq: Name x86-avoid-leaking-pkru-and-bnd-between-v
xen/arch/x86/hvm/hvm.c