[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240618094011.19247-1-jinglin.wen@shingroup.cn>
Date: Tue, 18 Jun 2024 17:40:11 +0800
From: Jinglin Wen <jinglin.wen@...ngroup.cn>
To: segher@...nel.crashing.org
Cc: mpe@...erman.id.au,
npiggin@...il.com,
christophe.leroy@...roup.eu,
naveen.n.rao@...ux.ibm.com,
masahiroy@...nel.org,
linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] powerpc: Fixed duplicate copying in the early boot.
Hi Segher Boessenkool,
Segher Boessenkool <segher@...nel.crashing.org> writes:
> Hi!
>
> On Mon, Jun 17, 2024 at 10:35:09AM +0800, Jinglin Wen wrote:
> > + cmplwi cr0,r4,0 /* runtime base addr is zero */
>
> Just write
> cmpwi r4,0
>
> cr0 is the default, also implicit in many other instructions, please
> don't clutter the source code. All the extra stuff makes you miss the
> things that do matter!
>
> The "l" is unnecessary, you only care about equality here after all.
>
> Should it not be cmpdi here, though?
>
>
> Segher
Thank you very much for your suggestion. I will use cmpd directly from now on.
The specific code is as follows:
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 4690c219bfa4..751181dfb897 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -647,8 +647,9 @@ __after_prom_start:
* Note: This process overwrites the OF exception vectors.
*/
LOAD_REG_IMMEDIATE(r3, PAGE_OFFSET)
- mr. r4,r26 /* In some cases the loader may */
- beq 9f /* have already put us at zero */
+ mr r4,r26 /* Load the virtual source address into r4 */
+ cmpd r3,r4 /* Check if source == dest */
+ beq 9f /* If so skip the copy */
li r6,0x100 /* Start offset, the first 0x100 */
/* bytes were copied earlier. */
Thanks,
Jinglin Wen
Powered by blists - more mailing lists