From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA732C4332D for ; Wed, 23 Dec 2020 02:33:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86FC2221F0 for ; Wed, 23 Dec 2020 02:33:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730590AbgLWCcz (ORCPT ); Tue, 22 Dec 2020 21:32:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:54022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728868AbgLWCZQ (ORCPT ); Tue, 22 Dec 2020 21:25:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 56D922333D; Wed, 23 Dec 2020 02:25:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690301; bh=q486Ccf37EISGzSH2d4Tt5pJpsZ9Y1IrmDAlGJlUEaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=atIL0AdnFa/2z8ewEG0zPBwZGVqtGPC6YJYpMPDAvVXTU/Pb5PGaAbDApaC/fLeno H3CXbg2eofBEWS9ILnpZI9d/RB4NNeDbwf5PRaPQkbBbbiI5YRTJoa4diLh5yE6hw9 mRihWJqbCEEz7YOVUwTXGu0ZenG2PhSxZbDby+6L6CQUBNxiVljWDjzrO6NqkyS6I6 zYv5ysf2efgnNwa1bBeE7rJRtrxziduGDc5qVCbCtGioaNdmwPfM80u4i+NC9bEVcD oWgkxSpcMPukiz6Dhhw/pb960/BC6hfMJ1T1d/cx1VaPpn6rbEaDK82Viy/5Urunuy BX6kTyzgjHppg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jinyang He , Thomas Bogendoerfer , Sasha Levin , linux-mips@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 36/48] MIPS: KASLR: Avoid endless loop in sync_icache if synci_step is zero Date: Tue, 22 Dec 2020 21:24:04 -0500 Message-Id: <20201223022417.2794032-36-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022417.2794032-1-sashal@kernel.org> References: <20201223022417.2794032-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jinyang He [ Upstream commit c0aac3a51cb6364bed367ee3e1a96ed414f386b4 ] 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 Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- 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 1958910b75c07..f759aae1e1f3d 100644 --- a/arch/mips/kernel/relocate.c +++ b/arch/mips/kernel/relocate.c @@ -52,7 +52,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.27.0