hv: add check to invalid CR8 writting from guest

According to SDM, inject #GP(0) if guest tries to write reserved
bit of CR8.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Yin Fengwei 2018-07-27 16:49:12 +08:00 committed by lijinxia
parent 13a50c929d
commit dec24a9f9f
1 changed files with 9 additions and 0 deletions

View File

@ -281,6 +281,15 @@ int cr_access_vmexit_handler(struct vcpu *vcpu)
break;
case 0x08U:
/* mov to cr8 */
/* According to SDM 6.15 "Exception and interrupt Reference":
*
* set reserved bit in CR8 causes GP to guest
*/
if (*regptr & ~0xFUL) {
pr_dbg("Invalid cr8 write operation from guest");
vcpu_inject_gp(vcpu, 0U);
break;
}
vlapic_set_cr8(vcpu->arch_vcpu.vlapic, *regptr);
break;
case 0x18U: