linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] MIPS: KASLR: Avoid endless loop in sync_icache when synci_step is zero
@ 2020-12-04  1:11 Jinyang He
  2020-12-07 10:32 ` Thomas Bogendoerfer
  0 siblings, 1 reply; 2+ messages in thread
From: Jinyang He @ 2020-12-04  1:11 UTC (permalink / raw)
  To: Thomas Bogendoerfer; +Cc: linux-mips, linux-kernel

Avoid endless loop if synci_step was zero read by rdhwr instruction.

Most platforms do not need to do synci instruction operations when
synci_step is 0. But for example, the synci implementation on Loongson64
platform has some changes. On the one hand, it ensures that the memory
access instructions have been completed. On the other hand, it guarantees
that all prefetch instructions need to be fetched again. And its address
information is useless. Thus, only one synci operation is required when
synci_step is 0 on Loongson64 platform. I guess that some other platforms
have similar implementations on synci, so add judgment conditions in
`while` to ensure that at least all platforms perform synci operations
once. For those platforms that do not need synci, they just do one more
operation similar to nop.

Signed-off-by: Jinyang He <hejinyang@loongson.cn>
---
 arch/mips/kernel/relocate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c
index 57bdd276..47aeb33 100644
--- a/arch/mips/kernel/relocate.c
+++ b/arch/mips/kernel/relocate.c
@@ -64,7 +64,7 @@ static void __init sync_icache(void *kbase, unsigned long kernel_length)
 			: "r" (kbase));
 
 		kbase += step;
-	} while (kbase < kend);
+	} while (step && kbase < kend);
 
 	/* Completion barrier */
 	__sync();
-- 
2.1.0


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

* Re: [PATCH v2] MIPS: KASLR: Avoid endless loop in sync_icache when synci_step is zero
  2020-12-04  1:11 [PATCH v2] MIPS: KASLR: Avoid endless loop in sync_icache when synci_step is zero Jinyang He
@ 2020-12-07 10:32 ` Thomas Bogendoerfer
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Bogendoerfer @ 2020-12-07 10:32 UTC (permalink / raw)
  To: Jinyang He; +Cc: linux-mips, linux-kernel

On Fri, Dec 04, 2020 at 09:11:46AM +0800, Jinyang He wrote:
> Avoid endless loop if synci_step was zero read by rdhwr instruction.
> 
> Most platforms do not need to do synci instruction operations when
> synci_step is 0. But for example, the synci implementation on Loongson64
> platform has some changes. On the one hand, it ensures that the memory
> access instructions have been completed. On the other hand, it guarantees
> that all prefetch instructions need to be fetched again. And its address
> information is useless. Thus, only one synci operation is required when
> synci_step is 0 on Loongson64 platform. I guess that some other platforms
> have similar implementations on synci, so add judgment conditions in
> `while` to ensure that at least all platforms perform synci operations
> once. For those platforms that do not need synci, they just do one more
> operation similar to nop.
> 
> Signed-off-by: Jinyang He <hejinyang@loongson.cn>
> ---
>  arch/mips/kernel/relocate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

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

end of thread, other threads:[~2020-12-07 10:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04  1:11 [PATCH v2] MIPS: KASLR: Avoid endless loop in sync_icache when synci_step is zero Jinyang He
2020-12-07 10:32 ` Thomas Bogendoerfer

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).