All of lore.kernel.org
 help / color / mirror / Atom feed
* [sparc64] Question about loop interations in trampoline_64.S
@ 2013-08-17  0:52 Kirill Tkhai
  2013-08-21 19:30 ` David Miller
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kirill Tkhai @ 2013-08-17  0:52 UTC (permalink / raw)
  To: sparclinux

Hi!

%l5 iterates from 0 to %l6, where %l6 is (num_kernel_image_mappings + 1).

The loop is equal to:

for (l5 = 0; l5 < num_kernel_image_mappings + 1; l5++).

Is there no error? Looks like we don't have to lock 4MB page, which  number
is num_kernel_image_mappings. Or prom call has any side effect?

Regards,
Kirill

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [sparc64] Question about loop interations in trampoline_64.S
  2013-08-17  0:52 [sparc64] Question about loop interations in trampoline_64.S Kirill Tkhai
@ 2013-08-21 19:30 ` David Miller
  2013-08-22 11:49 ` Kirill Tkhai
  2013-08-22 23:40 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-08-21 19:30 UTC (permalink / raw)
  To: sparclinux

From: Kirill Tkhai <tkhai@yandex.ru>
Date: Sat, 17 Aug 2013 04:52:22 +0400

> %l5 iterates from 0 to %l6, where %l6 is (num_kernel_image_mappings + 1).
> 
> The loop is equal to:
> 
> for (l5 = 0; l5 < num_kernel_image_mappings + 1; l5++).
> 
> Is there no error? Looks like we don't have to lock 4MB page, which  number
> is num_kernel_image_mappings. Or prom call has any side effect?

That definitely looks like an off-by-one error, could you test the
following obvious fix?

diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
index e0b1e13..ad4bde3 100644
--- a/arch/sparc/kernel/trampoline_64.S
+++ b/arch/sparc/kernel/trampoline_64.S
@@ -129,7 +129,6 @@ startup_continue:
 	clr		%l5
 	sethi		%hi(num_kernel_image_mappings), %l6
 	lduw		[%l6 + %lo(num_kernel_image_mappings)], %l6
-	add		%l6, 1, %l6
 
 	mov		15, %l7
 	BRANCH_IF_ANY_CHEETAH(g1,g5,2f)
@@ -222,7 +221,6 @@ niagara_lock_tlb:
 	clr		%l5
 	sethi		%hi(num_kernel_image_mappings), %l6
 	lduw		[%l6 + %lo(num_kernel_image_mappings)], %l6
-	add		%l6, 1, %l6
 
 1:
 	mov		HV_FAST_MMU_MAP_PERM_ADDR, %o5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [sparc64] Question about loop interations in trampoline_64.S
  2013-08-17  0:52 [sparc64] Question about loop interations in trampoline_64.S Kirill Tkhai
  2013-08-21 19:30 ` David Miller
@ 2013-08-22 11:49 ` Kirill Tkhai
  2013-08-22 23:40 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Kirill Tkhai @ 2013-08-22 11:49 UTC (permalink / raw)
  To: sparclinux

21.08.2013, 23:30, "David Miller" <davem@davemloft.net>:
> From: Kirill Tkhai <tkhai@yandex.ru>
> Date: Sat, 17 Aug 2013 04:52:22 +0400
>
>> š%l5 iterates from 0 to %l6, where %l6 is (num_kernel_image_mappings + 1).
>>
>> šThe loop is equal to:
>>
>> šfor (l5 = 0; l5 < num_kernel_image_mappings + 1; l5++).
>>
>> šIs there no error? Looks like we don't have to lock 4MB page, which šnumber
>> šis num_kernel_image_mappings. Or prom call has any side effect?
>
> That definitely looks like an off-by-one error, could you test the
> following obvious fix?

This had worked for me, but I doubted about all of TLB types...

So, now I confirm the patch.

> diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
> index e0b1e13..ad4bde3 100644
> --- a/arch/sparc/kernel/trampoline_64.S
> +++ b/arch/sparc/kernel/trampoline_64.S
> @@ -129,7 +129,6 @@ startup_continue:
> šššššššššclr %l5
> šššššššššsethi %hi(num_kernel_image_mappings), %l6
> šššššššššlduw [%l6 + %lo(num_kernel_image_mappings)], %l6
> - add %l6, 1, %l6
>
> šššššššššmov 15, %l7
> šššššššššBRANCH_IF_ANY_CHEETAH(g1,g5,2f)
> @@ -222,7 +221,6 @@ niagara_lock_tlb:
> šššššššššclr %l5
> šššššššššsethi %hi(num_kernel_image_mappings), %l6
> šššššššššlduw [%l6 + %lo(num_kernel_image_mappings)], %l6
> - add %l6, 1, %l6
>
> š1:
> šššššššššmov HV_FAST_MMU_MAP_PERM_ADDR, %o5

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [sparc64] Question about loop interations in trampoline_64.S
  2013-08-17  0:52 [sparc64] Question about loop interations in trampoline_64.S Kirill Tkhai
  2013-08-21 19:30 ` David Miller
  2013-08-22 11:49 ` Kirill Tkhai
@ 2013-08-22 23:40 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-08-22 23:40 UTC (permalink / raw)
  To: sparclinux

From: Kirill Tkhai <tkhai@yandex.ru>
Date: Thu, 22 Aug 2013 15:49:13 +0400

> 21.08.2013, 23:30, "David Miller" <davem@davemloft.net>:
>> From: Kirill Tkhai <tkhai@yandex.ru>
>> Date: Sat, 17 Aug 2013 04:52:22 +0400
>>
>>>  %l5 iterates from 0 to %l6, where %l6 is (num_kernel_image_mappings + 1).
>>>
>>>  The loop is equal to:
>>>
>>>  for (l5 = 0; l5 < num_kernel_image_mappings + 1; l5++).
>>>
>>>  Is there no error? Looks like we don't have to lock 4MB page, which  number
>>>  is num_kernel_image_mappings. Or prom call has any side effect?
>>
>> That definitely looks like an off-by-one error, could you test the
>> following obvious fix?
> 
> This had worked for me, but I doubted about all of TLB types...
> 
> So, now I confirm the patch.

Thanks for testing, I gave it a quick test too, commited as follows
and queued up for -stable.

--------------------
[PATCH] sparc64: Fix off by one in trampoline TLB mapping installation loop.

Reported-by: Kirill Tkhai <tkhai@yandex.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 arch/sparc/kernel/trampoline_64.S | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
index e0b1e13..ad4bde3 100644
--- a/arch/sparc/kernel/trampoline_64.S
+++ b/arch/sparc/kernel/trampoline_64.S
@@ -129,7 +129,6 @@ startup_continue:
 	clr		%l5
 	sethi		%hi(num_kernel_image_mappings), %l6
 	lduw		[%l6 + %lo(num_kernel_image_mappings)], %l6
-	add		%l6, 1, %l6
 
 	mov		15, %l7
 	BRANCH_IF_ANY_CHEETAH(g1,g5,2f)
@@ -222,7 +221,6 @@ niagara_lock_tlb:
 	clr		%l5
 	sethi		%hi(num_kernel_image_mappings), %l6
 	lduw		[%l6 + %lo(num_kernel_image_mappings)], %l6
-	add		%l6, 1, %l6
 
 1:
 	mov		HV_FAST_MMU_MAP_PERM_ADDR, %o5
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-22 23:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-17  0:52 [sparc64] Question about loop interations in trampoline_64.S Kirill Tkhai
2013-08-21 19:30 ` David Miller
2013-08-22 11:49 ` Kirill Tkhai
2013-08-22 23:40 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.