From nobody Thu Dec 18 05:02:03 2025 Received: from bg1.exmail.qq.com (bg1.exmail.qq.com [114.132.124.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09A77E57E; Thu, 20 Jun 2024 02:49:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.132.124.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718851753; cv=none; b=VqKN6ss/9TFTPMGR8BaFImHY9TX7E+/pAeR7MSs7kfUkKnqlzray/iB9qJ5vN/wuSYIALVFljURpBFWUk+byL2jfhjYj7DRPTB6iQEaiLeOsHFG4oYhTeUVBCGNyrc3Nv+DcxkiChe/b4rMYmuhrLFweO21udPsSl23wzbRF/2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718851753; c=relaxed/simple; bh=Y/rDw2bzCXwt+Sd6tTdo6KTXR1kTgawHQy3Q4jGSmAQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pSlzxCOrJ4dYga5gkNb2QUlNqdtWRqKDllA1OyW9/UXgAKGxrcLQJkn0BxWc6QygtEMg2SF4rXy94yhc3j16q6Io6WCBin/F2IdnFJ2JFwodoQd7UE42HmnM1sDxNlWnkA7OaBx31fa/ivmqMaucE6WYCkdFDsg7cBrWpTXuxNU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shingroup.cn; spf=pass smtp.mailfrom=shingroup.cn; arc=none smtp.client-ip=114.132.124.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shingroup.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shingroup.cn X-QQ-mid: bizesmtp89t1718851638tsf77eb2 X-QQ-Originating-IP: Cnxcf0yE6w+MsvywbXobZi1OIKdeiMnOlWen8+fPLAs= Received: from HX01040082.powercore.com.cn ( [14.19.141.254]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 20 Jun 2024 10:47:16 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 16810093544147674005 From: Jinglin Wen To: mpe@ellerman.id.au Cc: npiggin@gmail.com, christophe.leroy@csgroup.eu, naveen.n.rao@linux.ibm.com, masahiroy@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Jinglin Wen , stable@vger.kernel.org Subject: [PATCH v2] powerpc: Fix unnecessary copy to 0 when kernel is booted at address 0. Date: Thu, 20 Jun 2024 10:41:50 +0800 Message-Id: <20240620024150.14857-1-jinglin.wen@shingroup.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240617023509.5674-1-jinglin.wen@shingroup.cn> References: <20240617023509.5674-1-jinglin.wen@shingroup.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-2 Content-Type: text/plain; charset="utf-8" According to the code logic, when the kernel is loaded to address 0, no copying operation should be performed, but it is currently being done. This patch fixes the issue where the kernel code was incorrectly duplicated to address 0 when booting from address 0. Fixes: b270bebd34e3 ("powerpc/64s: Run at the kernel virtual address earlie= r in boot") Signed-off-by: Jinglin Wen Suggested-by: Michael Ellerman Cc: --- v2: - According to 87le336c6k.fsf@mail.lhotse, improve this patch. v1: - 20240617023509.5674-1-jinglin.wen@shingroup.cn arch/powerpc/kernel/head_64.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S index 4690c219bfa4..63432a33ec49 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 */ + cmpld r3,r4 /* Check if source =3D=3D dest */ + beq 9f /* If so skip the copy */ li r6,0x100 /* Start offset, the first 0x100 */ /* bytes were copied earlier. */ =20 --=20 2.25.1