x86/HVM: refine SMEP/SMAP tests in HVM_CR4_GUEST_RESERVED_BITS()
authorJan Beulich <jbeulich@suse.com>
Tue, 10 Jun 2014 11:12:05 +0000 (13:12 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 10 Jun 2014 11:12:05 +0000 (13:12 +0200)
commit584287380baf81e5acdd9dc7dfc7ffccd1e9a856
tree062c8ad52bee9d6e5b1d04a99f8ecd3809ed6e58
parentf08cb2b2eaa0e53880b26728523b0c5198c5b695
x86/HVM: refine SMEP/SMAP tests in HVM_CR4_GUEST_RESERVED_BITS()

Andrew validly points out that the use of the macro on the restore path
can't rely on the CPUID bits for the guest already being in place (as
their setting by the tool stack in turn requires the other restore
operations already having taken place). And even worse, using
hvm_cpuid() is invalid here because that function assumes to be used in
the context of the vCPU in question.

Reverting to the behavior prior to the change from checking
cpu_has_sm?p to hvm_vcpu_has_sm?p() would break the other (non-restore)
use of the macro. So let's revert to the prior behavior only for the
restore path, by adding a respective second parameter to the macro.

Obviously the two cpu_has_* uses in the macro should really also be
converted to hvm_cpuid() based checks at least for the non-restore
path.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: David Vrabel <david.vrabel@citrix.com>
xen/arch/x86/hvm/hvm.c
xen/include/asm-x86/hvm/hvm.h