]> xenbits.xensource.com Git - xen.git/commit
x86/xstate: Use a guests CPUID policy, rather than allowing all features
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 18 Jul 2018 10:56:44 +0000 (11:56 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 19 Jul 2018 18:57:26 +0000 (19:57 +0100)
commit361b835fa00d9f45167c50a60e054ccf22c065d7
tree4a6e8a002cfc6c1a807bf22f318ffdd40f5449b7
parent2e2bd5a29e481d0e7f163a19d663d959e09550fd
x86/xstate: Use a guests CPUID policy, rather than allowing all features

It turns out that Xen has never enforced that a domain remain within the
xstate features advertised in CPUID.

The check of new_bv against xfeature_mask ensures that a domain stays within
the set of features that Xen has enabled in hardware (and therefore isn't a
security problem), but this does means that attempts to level a guest for
migration safety might not be effective if the guest ignores CPUID.

Check the CPUID policy in validate_xstate() (for incoming migration) and in
handle_xsetbv() (for guest XSETBV instructions).  This subsumes the PKRU check
for PV guests in handle_xsetbv() (and also demonstrates that I should have
spotted this problem while reviewing c/s fbf9971241f).

For migration, this is correct despite the current (mis)ordering of data
because d->arch.cpuid is the applicable max policy.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/domctl.c
xen/arch/x86/hvm/hvm.c
xen/arch/x86/xstate.c
xen/include/asm-x86/xstate.h