From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Roedel Subject: Re: Always false condition in rmap_add Date: Thu, 11 Nov 2010 22:09:32 +0100 Message-ID: <20101111210931.GF5193@8bytes.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org To: Prasad Joshi Return-path: Received: from 8bytes.org ([88.198.83.132]:45399 "EHLO 8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756913Ab0KKVJd (ORCPT ); Thu, 11 Nov 2010 16:09:33 -0500 Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Nov 11, 2010 at 06:38:47PM +0000, Prasad Joshi wrote: > Hello All, >=20 > I have question on code of rmap_add >=20 > Here is the code of the function >=20 > =A0613 static int rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gf= n) > =A0614 { >=20 > 624=A0=A0=A0=A0 rmapp =3D gfn_to_rmap(vcpu->kvm, gfn, sp->role.level)= ; > =A0625=A0=A0=A0=A0 if (!*rmapp) { > =A0626=A0=A0=A0=A0=A0=A0=A0=A0 rmap_printk("rmap_add: %p %llx 0->1\n"= , spte, *spte); > =A0627=A0=A0=A0=A0=A0=A0=A0=A0 *rmapp =3D (unsigned long)spte; > =A0628=A0=A0=A0=A0 } else if (!(*rmapp & 1)) { > =A0629=A0=A0=A0=A0=A0=A0=A0=A0 rmap_printk("rmap_add: %p %llx 1->many= \n", spte, *spte); > =A0630=A0=A0=A0=A0=A0=A0=A0=A0 desc =3D mmu_alloc_rmap_desc(vcpu); > =A0631=A0=A0=A0=A0=A0=A0=A0=A0 desc->sptes[0] =3D (u64 *)*rmapp; > =A0632=A0=A0=A0=A0=A0=A0=A0=A0 desc->sptes[1] =3D spte; > =A0633=A0=A0=A0=A0=A0=A0=A0=A0 *rmapp =3D (unsigned long)desc | 1; > =A0634=A0=A0=A0=A0=A0=A0=A0=A0 ++count; > =A0635=A0=A0=A0=A0 } else { >=20 > The line 628 checks whether the last bit of the rmapp is 1. > If it is one then line 633 assigns a new value to rmapp with and sets > the last bit to 1. No, line 628 checks if the last bit is not 1, so the check works. Joerg