Avi, thanks for your review.+ if (is_rsvd_bits_set(vcpu, gentry, PT_PAGE_TABLE_LEVEL))That only works if the gpte is for the same mode as the current vcpu mmu
+ gentry = 0;
+
mode. In some cases it is too strict (vcpu in pae mode writing a 32-bit
gpte), which is not too bad, in some cases it is too permissive (vcpu in
nonpae mode writing a pae gpte).
Do you mean that the VM has many different mode vcpu? For example, both
nonpae vcpu and pae vcpu are running in one VM? I forgot to consider this
case.
(once upon a time mixed modes were rare, only on OS setup, but withI'm afraid it's still has problem, it will cause access corruption:
nested virt they happen all the time).
1: if nonpae vcpu write pae gpte, it will miss NX bit
2: if pae vcpu write nonpae gpte, it will add NX bit that over gpte's width
How about only update the shadow page which has the same pae set with the written
vcpu? Just like this:
@@ -3000,6 +3000,10 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
while (npte--) {
entry = *spte;
mmu_pte_write_zap_pte(vcpu, sp, spte);
+
+ if (!!is_pae(vcpu) != sp->role.cr4_pae)
+ continue;
+