* [PATCH] powerpc/mm: Fix hash computation function
@ 2013-01-30 5:40 Aneesh Kumar K.V
2013-01-30 7:23 ` Mike Qiu
2013-02-04 3:29 ` Michael Ellerman
0 siblings, 2 replies; 4+ messages in thread
From: Aneesh Kumar K.V @ 2013-01-30 5:40 UTC (permalink / raw)
To: benh, paulus; +Cc: Mike Qiu, linuxppc-dev, Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
The ASM version of hash computation function was truncating the upper bit.
Make the ASM version similar to hpt_hash function. Remove masking vsid bits.
Without this patch, we observed hang during bootup due to not satisfying page
fault request correctly. The fault handler used wrong hash values to update
the HPTE. Hence we kept looping with page fault.
hash_page(ea=000001003e260008, access=203, trap=300 ip=3fff91787134 dsisr 42000000
The computed value of hash 000000000f22f390
update: avpnv=4003e46054003e00, hash=000000000722f390, f=80000006, psize: 2 ...
Reported-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
arch/powerpc/mm/hash_low_64.S | 62 +++++++++++++++++++++++------------------
1 file changed, 35 insertions(+), 27 deletions(-)
diff --git a/arch/powerpc/mm/hash_low_64.S b/arch/powerpc/mm/hash_low_64.S
index 5658508..7443481 100644
--- a/arch/powerpc/mm/hash_low_64.S
+++ b/arch/powerpc/mm/hash_low_64.S
@@ -115,11 +115,13 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
sldi r29,r5,SID_SHIFT - VPN_SHIFT
rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT - VPN_SHIFT)
or r29,r28,r29
-
- /* Calculate hash value for primary slot and store it in r28 */
- rldicl r5,r5,0,25 /* vsid & 0x0000007fffffffff */
- rldicl r0,r3,64-12,48 /* (ea >> 12) & 0xffff */
- xor r28,r5,r0
+ /*
+ * Calculate hash value for primary slot and store it in r28
+ * r3 = va, r5 = vsid
+ * r0 = (va >> 12) & ((1ul << (28 - 12)) -1)
+ */
+ rldicl r0,r3,64-12,48
+ xor r28,r5,r0 /* hash */
b 4f
3: /* Calc vpn and put it in r29 */
@@ -130,11 +132,12 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
/*
* calculate hash value for primary slot and
* store it in r28 for 1T segment
+ * r3 = va, r5 = vsid
*/
- rldic r28,r5,25,25 /* (vsid << 25) & 0x7fffffffff */
- clrldi r5,r5,40 /* vsid & 0xffffff */
- rldicl r0,r3,64-12,36 /* (ea >> 12) & 0xfffffff */
- xor r28,r28,r5
+ sldi r28,r5,25 /* vsid << 25 */
+ /* r0 = (va >> 12) & ((1ul << (40 - 12)) -1) */
+ rldicl r0,r3,64-12,36
+ xor r28,r28,r5 /* vsid ^ ( vsid << 25) */
xor r28,r28,r0 /* hash */
/* Convert linux PTE bits into HW equivalents */
@@ -407,11 +410,13 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
*/
rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT - VPN_SHIFT)
or r29,r28,r29
-
- /* Calculate hash value for primary slot and store it in r28 */
- rldicl r5,r5,0,25 /* vsid & 0x0000007fffffffff */
- rldicl r0,r3,64-12,48 /* (ea >> 12) & 0xffff */
- xor r28,r5,r0
+ /*
+ * Calculate hash value for primary slot and store it in r28
+ * r3 = va, r5 = vsid
+ * r0 = (va >> 12) & ((1ul << (28 - 12)) -1)
+ */
+ rldicl r0,r3,64-12,48
+ xor r28,r5,r0 /* hash */
b 4f
3: /* Calc vpn and put it in r29 */
@@ -426,11 +431,12 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
/*
* Calculate hash value for primary slot and
* store it in r28 for 1T segment
+ * r3 = va, r5 = vsid
*/
- rldic r28,r5,25,25 /* (vsid << 25) & 0x7fffffffff */
- clrldi r5,r5,40 /* vsid & 0xffffff */
- rldicl r0,r3,64-12,36 /* (ea >> 12) & 0xfffffff */
- xor r28,r28,r5
+ sldi r28,r5,25 /* vsid << 25 */
+ /* r0 = (va >> 12) & ((1ul << (40 - 12)) -1) */
+ rldicl r0,r3,64-12,36
+ xor r28,r28,r5 /* vsid ^ ( vsid << 25) */
xor r28,r28,r0 /* hash */
/* Convert linux PTE bits into HW equivalents */
@@ -752,25 +758,27 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT - VPN_SHIFT)
or r29,r28,r29
- /* Calculate hash value for primary slot and store it in r28 */
- rldicl r5,r5,0,25 /* vsid & 0x0000007fffffffff */
- rldicl r0,r3,64-16,52 /* (ea >> 16) & 0xfff */
- xor r28,r5,r0
+ /* Calculate hash value for primary slot and store it in r28
+ * r3 = va, r5 = vsid
+ * r0 = (va >> 16) & ((1ul << (28 - 16)) -1)
+ */
+ rldicl r0,r3,64-16,52
+ xor r28,r5,r0 /* hash */
b 4f
3: /* Calc vpn and put it in r29 */
sldi r29,r5,SID_SHIFT_1T - VPN_SHIFT
rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT_1T - VPN_SHIFT)
or r29,r28,r29
-
/*
* calculate hash value for primary slot and
* store it in r28 for 1T segment
+ * r3 = va, r5 = vsid
*/
- rldic r28,r5,25,25 /* (vsid << 25) & 0x7fffffffff */
- clrldi r5,r5,40 /* vsid & 0xffffff */
- rldicl r0,r3,64-16,40 /* (ea >> 16) & 0xffffff */
- xor r28,r28,r5
+ sldi r28,r5,25 /* vsid << 25 */
+ /* r0 = (va >> 16) & ((1ul << (40 - 16)) -1) */
+ rldicl r0,r3,64-16,40
+ xor r28,r28,r5 /* vsid ^ ( vsid << 25) */
xor r28,r28,r0 /* hash */
/* Convert linux PTE bits into HW equivalents */
--
1.7.10
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc/mm: Fix hash computation function
2013-01-30 5:40 [PATCH] powerpc/mm: Fix hash computation function Aneesh Kumar K.V
@ 2013-01-30 7:23 ` Mike Qiu
2013-02-04 3:29 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Mike Qiu @ 2013-01-30 7:23 UTC (permalink / raw)
To: linuxppc-dev; +Cc: paulus, Aneesh Kumar K.V
With the fix, the machine can boot up successfully
Tested-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
于 2013/1/30 13:40, Aneesh Kumar K.V 写道:
> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>
> The ASM version of hash computation function was truncating the upper bit.
> Make the ASM version similar to hpt_hash function. Remove masking vsid bits.
> Without this patch, we observed hang during bootup due to not satisfying page
> fault request correctly. The fault handler used wrong hash values to update
> the HPTE. Hence we kept looping with page fault.
>
> hash_page(ea=000001003e260008, access=203, trap=300 ip=3fff91787134 dsisr 42000000
> The computed value of hash 000000000f22f390
> update: avpnv=4003e46054003e00, hash=000000000722f390, f=80000006, psize: 2 ...
>
> Reported-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
> arch/powerpc/mm/hash_low_64.S | 62 +++++++++++++++++++++++------------------
> 1 file changed, 35 insertions(+), 27 deletions(-)
>
> diff --git a/arch/powerpc/mm/hash_low_64.S b/arch/powerpc/mm/hash_low_64.S
> index 5658508..7443481 100644
> --- a/arch/powerpc/mm/hash_low_64.S
> +++ b/arch/powerpc/mm/hash_low_64.S
> @@ -115,11 +115,13 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
> sldi r29,r5,SID_SHIFT - VPN_SHIFT
> rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT - VPN_SHIFT)
> or r29,r28,r29
> -
> - /* Calculate hash value for primary slot and store it in r28 */
> - rldicl r5,r5,0,25 /* vsid & 0x0000007fffffffff */
> - rldicl r0,r3,64-12,48 /* (ea >> 12) & 0xffff */
> - xor r28,r5,r0
> + /*
> + * Calculate hash value for primary slot and store it in r28
> + * r3 = va, r5 = vsid
> + * r0 = (va >> 12) & ((1ul << (28 - 12)) -1)
> + */
> + rldicl r0,r3,64-12,48
> + xor r28,r5,r0 /* hash */
> b 4f
>
> 3: /* Calc vpn and put it in r29 */
> @@ -130,11 +132,12 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
> /*
> * calculate hash value for primary slot and
> * store it in r28 for 1T segment
> + * r3 = va, r5 = vsid
> */
> - rldic r28,r5,25,25 /* (vsid << 25) & 0x7fffffffff */
> - clrldi r5,r5,40 /* vsid & 0xffffff */
> - rldicl r0,r3,64-12,36 /* (ea >> 12) & 0xfffffff */
> - xor r28,r28,r5
> + sldi r28,r5,25 /* vsid << 25 */
> + /* r0 = (va >> 12) & ((1ul << (40 - 12)) -1) */
> + rldicl r0,r3,64-12,36
> + xor r28,r28,r5 /* vsid ^ ( vsid << 25) */
> xor r28,r28,r0 /* hash */
>
> /* Convert linux PTE bits into HW equivalents */
> @@ -407,11 +410,13 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
> */
> rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT - VPN_SHIFT)
> or r29,r28,r29
> -
> - /* Calculate hash value for primary slot and store it in r28 */
> - rldicl r5,r5,0,25 /* vsid & 0x0000007fffffffff */
> - rldicl r0,r3,64-12,48 /* (ea >> 12) & 0xffff */
> - xor r28,r5,r0
> + /*
> + * Calculate hash value for primary slot and store it in r28
> + * r3 = va, r5 = vsid
> + * r0 = (va >> 12) & ((1ul << (28 - 12)) -1)
> + */
> + rldicl r0,r3,64-12,48
> + xor r28,r5,r0 /* hash */
> b 4f
>
> 3: /* Calc vpn and put it in r29 */
> @@ -426,11 +431,12 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
> /*
> * Calculate hash value for primary slot and
> * store it in r28 for 1T segment
> + * r3 = va, r5 = vsid
> */
> - rldic r28,r5,25,25 /* (vsid << 25) & 0x7fffffffff */
> - clrldi r5,r5,40 /* vsid & 0xffffff */
> - rldicl r0,r3,64-12,36 /* (ea >> 12) & 0xfffffff */
> - xor r28,r28,r5
> + sldi r28,r5,25 /* vsid << 25 */
> + /* r0 = (va >> 12) & ((1ul << (40 - 12)) -1) */
> + rldicl r0,r3,64-12,36
> + xor r28,r28,r5 /* vsid ^ ( vsid << 25) */
> xor r28,r28,r0 /* hash */
>
> /* Convert linux PTE bits into HW equivalents */
> @@ -752,25 +758,27 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
> rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT - VPN_SHIFT)
> or r29,r28,r29
>
> - /* Calculate hash value for primary slot and store it in r28 */
> - rldicl r5,r5,0,25 /* vsid & 0x0000007fffffffff */
> - rldicl r0,r3,64-16,52 /* (ea >> 16) & 0xfff */
> - xor r28,r5,r0
> + /* Calculate hash value for primary slot and store it in r28
> + * r3 = va, r5 = vsid
> + * r0 = (va >> 16) & ((1ul << (28 - 16)) -1)
> + */
> + rldicl r0,r3,64-16,52
> + xor r28,r5,r0 /* hash */
> b 4f
>
> 3: /* Calc vpn and put it in r29 */
> sldi r29,r5,SID_SHIFT_1T - VPN_SHIFT
> rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT_1T - VPN_SHIFT)
> or r29,r28,r29
> -
> /*
> * calculate hash value for primary slot and
> * store it in r28 for 1T segment
> + * r3 = va, r5 = vsid
> */
> - rldic r28,r5,25,25 /* (vsid << 25) & 0x7fffffffff */
> - clrldi r5,r5,40 /* vsid & 0xffffff */
> - rldicl r0,r3,64-16,40 /* (ea >> 16) & 0xffffff */
> - xor r28,r28,r5
> + sldi r28,r5,25 /* vsid << 25 */
> + /* r0 = (va >> 16) & ((1ul << (40 - 16)) -1) */
> + rldicl r0,r3,64-16,40
> + xor r28,r28,r5 /* vsid ^ ( vsid << 25) */
> xor r28,r28,r0 /* hash */
>
> /* Convert linux PTE bits into HW equivalents */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc/mm: Fix hash computation function
2013-01-30 5:40 [PATCH] powerpc/mm: Fix hash computation function Aneesh Kumar K.V
2013-01-30 7:23 ` Mike Qiu
@ 2013-02-04 3:29 ` Michael Ellerman
2013-02-04 4:24 ` Benjamin Herrenschmidt
1 sibling, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2013-02-04 3:29 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: Mike Qiu, paulus, linuxppc-dev
On Wed, 2013-01-30 at 11:10 +0530, Aneesh Kumar K.V wrote:
> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>
> The ASM version of hash computation function was truncating the upper bit.
> Make the ASM version similar to hpt_hash function. Remove masking vsid bits.
> Without this patch, we observed hang during bootup due to not satisfying page
> fault request correctly.
Which commit(s) introduced the bug?
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc/mm: Fix hash computation function
2013-02-04 3:29 ` Michael Ellerman
@ 2013-02-04 4:24 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2013-02-04 4:24 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Mike Qiu, linuxppc-dev, paulus, Aneesh Kumar K.V
On Mon, 2013-02-04 at 14:29 +1100, Michael Ellerman wrote:
> On Wed, 2013-01-30 at 11:10 +0530, Aneesh Kumar K.V wrote:
> > From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
> >
> > The ASM version of hash computation function was truncating the upper bit.
> > Make the ASM version similar to hpt_hash function. Remove masking vsid bits.
> > Without this patch, we observed hang during bootup due to not satisfying page
> > fault request correctly.
>
> Which commit(s) introduced the bug?
The bug has been there for ever (well, as far back as git goes without
digging the old monster repo) so may as well date from my original port
of the C hashing code to asm.
However it wasn't per-se a bug until Aneesh 64T support was added in 3.7
since we didn't use the top vsid bits that are masked.
I've merged the patch. My only worry is whether there might have been a
reason for the masking in the first place, ie, do we ever carry VSIDs
with bad bits at the top... though the hash mask should take care of
that in any case (well I hope...)
Cheers,
Ben.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-04 4:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-30 5:40 [PATCH] powerpc/mm: Fix hash computation function Aneesh Kumar K.V
2013-01-30 7:23 ` Mike Qiu
2013-02-04 3:29 ` Michael Ellerman
2013-02-04 4:24 ` Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).