From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e28smtp08.in.ibm.com (e28smtp08.in.ibm.com [122.248.162.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e28smtp08.in.ibm.com", Issuer "GeoTrust SSL CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 06D082C02F3 for ; Tue, 5 Mar 2013 05:11:09 +1100 (EST) Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 4 Mar 2013 23:37:10 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 0EE62E004A for ; Mon, 4 Mar 2013 23:42:14 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r24IAx4M27721980 for ; Mon, 4 Mar 2013 23:40:59 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r24IB1jP000924 for ; Tue, 5 Mar 2013 05:11:02 +1100 From: "Aneesh Kumar K.V" To: Paul Mackerras Subject: Re: [PATCH -V1 09/24] powerpc: Decode the pte-lp-encoding bits correctly. In-Reply-To: <87vc971iwd.fsf@linux.vnet.ibm.com> References: <1361865914-13911-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> <1361865914-13911-10-git-send-email-aneesh.kumar@linux.vnet.ibm.com> <20130304054848.GE27523@drongo> <87vc971iwd.fsf@linux.vnet.ibm.com> Date: Mon, 04 Mar 2013 23:41:01 +0530 Message-ID: <87txor828a.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , "Aneesh Kumar K.V" writes: > Paul Mackerras writes: > >> On Tue, Feb 26, 2013 at 01:34:59PM +0530, Aneesh Kumar K.V wrote: >>> From: "Aneesh Kumar K.V" >>>=20 >>> +static inline int hpte_actual_psize(struct hash_pte *hptep, int psize) >>> +{ >>> + unsigned int mask; >>> + int i, penc, shift; >>> + /* Look at the 8 bit LP value */ >>> + unsigned int lp =3D (hptep->r >> LP_SHIFT) & ((1 << LP_BITS) - 1); >>> + >>> + penc =3D 0; >>> + for (i =3D 0; i < MMU_PAGE_COUNT; i++) { >>> + /* valid entries have a shift value */ >>> + if (!mmu_psize_defs[i].shift) >>> + continue; >>> + >>> + /* encoding bits per actual page size */ >>> + shift =3D mmu_psize_defs[i].shift - 11; >>> + if (shift > 9) >>> + shift =3D 9; >>> + mask =3D (1 << shift) - 1; >>> + if ((lp & mask) =3D=3D mmu_psize_defs[psize].penc[i]) >>> + return i; >>> + } >>> + return -1; >>> +} >> >> This doesn't look right to me. First, it's not clear what the 11 and >> 9 refer to, and I think the 9 should be LP_BITS (i.e. 8). Secondly, >> the mask for the comparison needs to depend on the actual page size >> not the base page size. > > How about the below. I am yet to test this in user space.=20 I needed to special case 4K case. This seems to work fine with the test. static inline int hpte_actual_psize(struct hash_pte *hptep, int psize) { unsigned int mask; int i, penc, shift; /* Look at the 8 bit LP value */ unsigned int lp =3D (hptep->r >> LP_SHIFT) & ((1 << LP_BITS) - 1); /* First check if it is large page */ if (!(hptep->v & HPTE_V_LARGE)) return MMU_PAGE_4K; penc =3D 0; for (i =3D 1; i < MMU_PAGE_COUNT; i++) { /* valid entries have a shift value */ if (!mmu_psize_defs[i].shift) continue; /* * encoding bits per actual page size * PTE LP actual page size * rrrr rrrz =E2=89=A58KB * rrrr rrzz =E2=89=A516KB * rrrr rzzz =E2=89=A532KB * rrrr zzzz =E2=89=A564KB * ....... */ shift =3D mmu_psize_defs[i].shift - mmu_psize_defs[MMU_PAGE_4K].shift; if (shift > LP_BITS) shift =3D LP_BITS; mask =3D (1 << shift) - 1; if ((lp & mask) =3D=3D mmu_psize_defs[psize].penc[i]) return i; } return -1; }