Message ID | 20090515131943.GT9835@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Joerg Roedel wrote: > Subject: [PATCH] kvm/mmu: fix reserved bit checking on 4kb pte level > > The reserved bits checking code looks at bit 7 of the pte to determine > if it has to use the mask for a large pte or a normal pde. This does not > work on 4kb pte level because bit 7 is used there for PAT. Account this > in the checking function. > > > static bool is_rsvd_bits_set(struct kvm_vcpu *vcpu, u64 gpte, int level) > { > - int bit7; > + int bit7 = 0; > + > + if (level != PT_PAGE_TABLE_LEVEL) > + bit7 = (gpte >> 7) & 1; > > - bit7 = (gpte >> 7) & 1; > return (gpte & vcpu->arch.mmu.rsvd_bits_mask[bit7][level-1]) != 0; > } > > If we make rsvd_bits_mask[1][0] == rsvd_bits_mask[0][0], we don't need the extra check. That's why it is named bit7 and not pse (need to make sure bit 7 is not reserved in this case).
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 479e748..8d9552e 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2124,9 +2124,11 @@ static void paging_free(struct kvm_vcpu *vcpu) static bool is_rsvd_bits_set(struct kvm_vcpu *vcpu, u64 gpte, int level) { - int bit7; + int bit7 = 0; + + if (level != PT_PAGE_TABLE_LEVEL) + bit7 = (gpte >> 7) & 1; - bit7 = (gpte >> 7) & 1; return (gpte & vcpu->arch.mmu.rsvd_bits_mask[bit7][level-1]) != 0; }