This patch cleanups rmap_write_protect() as follows: 1. The BUG_ON(!spte)'s right after while(spte) have been there unchanged for a long time. Since we don't see any special reason why we do this double check, we remove these BUG_ON's. 2. In the case of Y and Z are single-bit-set masks, Y: PT_PAGE_SIZE_MASK (1ULL << 7) Z: PT_PRESENT_MASK (1ULL << 0) checking the following two conditions (X & Z) (X & (Y|Z)) == (Y|Z) is logically equivalent to checking (X & Z) (X & Y) meaning that X has the both bits represented by Y and Z set. Considering the nature of these bit masks, the condition that these masks are single-bit-set will not change. So this patch replaces the second check to simpler one to make what we are checking clearer. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@xxxxxxxxxxxxx> --- arch/x86/kvm/mmu.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 56da796..df8c09d 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -740,7 +740,6 @@ static int rmap_write_protect(struct kvm *kvm, u64 gfn) spte = rmap_next(kvm, rmapp, NULL); while (spte) { - BUG_ON(!spte); BUG_ON(!(*spte & PT_PRESENT_MASK)); rmap_printk("rmap_write_protect: spte %p %llx\n", spte, *spte); if (is_writable_pte(*spte)) { @@ -763,9 +762,8 @@ static int rmap_write_protect(struct kvm *kvm, u64 gfn) rmapp = gfn_to_rmap(kvm, gfn, i); spte = rmap_next(kvm, rmapp, NULL); while (spte) { - BUG_ON(!spte); BUG_ON(!(*spte & PT_PRESENT_MASK)); - BUG_ON((*spte & (PT_PAGE_SIZE_MASK|PT_PRESENT_MASK)) != (PT_PAGE_SIZE_MASK|PT_PRESENT_MASK)); + BUG_ON(!(*spte & PT_PAGE_SIZE_MASK)); pgprintk("rmap_write_protect(large): spte %p %llx %lld\n", spte, *spte, gfn); if (is_writable_pte(*spte)) { drop_spte(kvm, spte, -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html