target/i386: Added consistency checks for CR3

All MBZ in CR3 must be zero (APM2 15.5)
Added checks in both helper_vmrun and helper_write_crN.
When EFER.LMA is zero the upper 32 bits needs to be zeroed.

Signed-off-by: Lara Lazier <laramglazier@gmail.com>
Message-Id: <20210723112740.45962-1-laramglazier@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Lara Lazier 2021-07-23 13:27:40 +02:00 committed by Paolo Bonzini
parent 917ddc27d8
commit 3407259b20
2 changed files with 14 additions and 3 deletions

View file

@ -96,6 +96,13 @@ void helper_write_crN(CPUX86State *env, int reg, target_ulong t0)
cpu_x86_update_cr0(env, t0);
break;
case 3:
if ((env->efer & MSR_EFER_LMA) &&
(t0 & ((~0UL) << env_archcpu(env)->phys_bits))) {
cpu_vmexit(env, SVM_EXIT_ERR, 0, GETPC());
}
if (!(env->efer & MSR_EFER_LMA)) {
t0 &= 0xffffffffUL;
}
cpu_x86_update_cr3(env, t0);
break;
case 4: