From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Aneesh Kumar K.V" Date: Mon, 03 Nov 2014 06:11:43 +0000 Subject: Re: [PATCH 1/5] KVM: PPC: Book3S HV: Fix computation of tlbie operand Message-Id: <87d294hlio.fsf@linux.vnet.ibm.com> List-Id: References: <1414990320-6378-1-git-send-email-paulus@samba.org> <1414990320-6378-2-git-send-email-paulus@samba.org> In-Reply-To: <1414990320-6378-2-git-send-email-paulus@samba.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Paul Mackerras , Alexander Graf , kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, Paul Mackerras Paul Mackerras writes: > The B (segment size) field in the RB operand for the tlbie > instruction is two bits, which we get from the top two bits of > the first doubleword of the HPT entry to be invalidated. These > bits go in bits 8 and 9 of the RB operand (bits 54 and 55 in IBM > bit numbering). > > The compute_tlbie_rb() function gets these bits as v >> (62 - 8), > which is not correct as it will bring in the top 10 bits, not > just the top two. These extra bits could corrupt the AP, AVAL > and L fields in the RB value. To fix this we shift right 62 bits > and then shift left 8 bits, so we only get the two bits of the > B field. Good catch. > > The first doubleword of the HPT entry is under the control of the > guest kernel. In fact, Linux guests will always put zeroes in bits > 54 -- 61 (IBM bits 2 -- 9), but we should not rely on guests doing > this. > > Cc: Aneesh Kumar K.V > Signed-off-by: Paul Mackerras Reviewed-by: Aneesh Kumar K.V > --- > arch/powerpc/include/asm/kvm_book3s_64.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h > index 0aa8179..a37f1a4 100644 > --- a/arch/powerpc/include/asm/kvm_book3s_64.h > +++ b/arch/powerpc/include/asm/kvm_book3s_64.h > @@ -148,7 +148,7 @@ static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r, > /* This covers 14..54 bits of va*/ > rb = (v & ~0x7fUL) << 16; /* AVA field */ > > - rb |= v >> (62 - 8); /* B field */ > + rb |= (v >> HPTE_V_SSIZE_SHIFT) << 8; /* B field */ > /* > * AVA in v had cleared lower 23 bits. We need to derive > * that from pteg index > -- > 2.1.1 > > -- > To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Aneesh Kumar K.V" Subject: Re: [PATCH 1/5] KVM: PPC: Book3S HV: Fix computation of tlbie operand Date: Mon, 03 Nov 2014 11:29:43 +0530 Message-ID: <87d294hlio.fsf@linux.vnet.ibm.com> References: <1414990320-6378-1-git-send-email-paulus@samba.org> <1414990320-6378-2-git-send-email-paulus@samba.org> Mime-Version: 1.0 Content-Type: text/plain Cc: kvm@vger.kernel.org, Paul Mackerras To: Paul Mackerras , Alexander Graf , kvm-ppc@vger.kernel.org Return-path: In-Reply-To: <1414990320-6378-2-git-send-email-paulus@samba.org> Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Paul Mackerras writes: > The B (segment size) field in the RB operand for the tlbie > instruction is two bits, which we get from the top two bits of > the first doubleword of the HPT entry to be invalidated. These > bits go in bits 8 and 9 of the RB operand (bits 54 and 55 in IBM > bit numbering). > > The compute_tlbie_rb() function gets these bits as v >> (62 - 8), > which is not correct as it will bring in the top 10 bits, not > just the top two. These extra bits could corrupt the AP, AVAL > and L fields in the RB value. To fix this we shift right 62 bits > and then shift left 8 bits, so we only get the two bits of the > B field. Good catch. > > The first doubleword of the HPT entry is under the control of the > guest kernel. In fact, Linux guests will always put zeroes in bits > 54 -- 61 (IBM bits 2 -- 9), but we should not rely on guests doing > this. > > Cc: Aneesh Kumar K.V > Signed-off-by: Paul Mackerras Reviewed-by: Aneesh Kumar K.V > --- > arch/powerpc/include/asm/kvm_book3s_64.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h > index 0aa8179..a37f1a4 100644 > --- a/arch/powerpc/include/asm/kvm_book3s_64.h > +++ b/arch/powerpc/include/asm/kvm_book3s_64.h > @@ -148,7 +148,7 @@ static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r, > /* This covers 14..54 bits of va*/ > rb = (v & ~0x7fUL) << 16; /* AVA field */ > > - rb |= v >> (62 - 8); /* B field */ > + rb |= (v >> HPTE_V_SSIZE_SHIFT) << 8; /* B field */ > /* > * AVA in v had cleared lower 23 bits. We need to derive > * that from pteg index > -- > 2.1.1 > > -- > To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html