linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Jinyang He <hejinyang@loongson.cn>
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MIPS: KASLR: Fix sync_icache() trapped in loop when synci_step is zero
Date: Wed, 2 Dec 2020 11:39:43 +0100	[thread overview]
Message-ID: <20201202103943.GA9065@alpha.franken.de> (raw)
In-Reply-To: <1606878005-11427-1-git-send-email-hejinyang@loongson.cn>

On Wed, Dec 02, 2020 at 11:00:05AM +0800, Jinyang He wrote:
> Reading synci_step by using rdhwr instruction may return zero if no cache
> need be synchronized. On the one hand, to make sure all load operation and
> store operation finished we do __sync() for every platform. On the other
> hand, some platform need operate synci one time although step is zero.

Should this be someting like: Avoid endless loop, if no synci is needed ?

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

why not do a

	if (step == 0)
		return;

before entering the loop ? According to MIPS32PRA no synci is needed,
if stepi value is zero.

Thomas.

PS: Does anybody know a reason, why this code doesn't use an old fashioned
dache/icache flushing, which might be slower but would work also on
legecy cores ?

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

  reply	other threads:[~2020-12-02 10:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  3:00 [PATCH] MIPS: KASLR: Fix sync_icache() trapped in loop when synci_step is zero Jinyang He
2020-12-02 10:39 ` Thomas Bogendoerfer [this message]
2020-12-03  3:29   ` Jinyang He
2020-12-08  6:46     ` Maciej W. Rozycki
2020-12-03  4:02   ` Jiaxun Yang
2020-12-04 12:14     ` Thomas Bogendoerfer
2020-12-07 15:35   ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201202103943.GA9065@alpha.franken.de \
    --to=tsbogend@alpha.franken.de \
    --cc=hejinyang@loongson.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).