Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5457755pxu; Tue, 22 Dec 2020 18:39:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJynMfhTRbUlFWjC/VuWZ2jBuHXDAZDmhbuML0kU5IW8Dns49X8CF7asOGJ1vo5qEt0/XipJ X-Received: by 2002:a05:6402:14c5:: with SMTP id f5mr22569750edx.232.1608691159375; Tue, 22 Dec 2020 18:39:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608691159; cv=none; d=google.com; s=arc-20160816; b=tw+ALjydbsF8UgX1X24Yii+HGP4DA8QPSmpb8xDbyQQTeWVMKmbUOT/0dpgZuwIjXm 9Wa4t0f9hkdn+PYkoe0Zgz3gk+J5Brfi7zu7yAbkgWff7TeNo4KESt4cBk9JDSpH++bO eFdRcvVNrzITDAMQZmVcNsL0PSUQNQFrOdiLfHMRRaRkjJTsukpE7uVJ1qalc1OJjOnC LfXN9BVrJygeBmkZJ91Mwmu8avJlzbhtT2sBLqoesANrJKe4g3e8XCNsZJgyoMIJaPnC 3UKkfNAP0FNxnYfTiUyhR4VhkuvNQzQ0I5iMP/toH0MksT8vJ32f6P3vNqh/8H/4sop4 QLCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=miCLNbA3ZKz2EXwvdQhFlu7jrSKCh885Ns4Kg7oh/5o=; b=AwjXRiKXzWkY76PEi690kNIGthFyEtXudJ6Nj2ONnFX6iGCdavjK6p1NdSY600L3EJ 9EY8kpIq1KRoT38kmsVP7mYNAc9mrPtXQaKufDHBbuu1ib6wkFw17sm9fmuRXScCO0DY lai1QHVnX3FkJx6piPi1oufwnTaZDDWaPW1yzph20QipvaQEaMBHlt9aHkXWviYgQIpr iwMz/wdEpwvMASTavyFjBu7ve9z1njcedIkRXA5U6f+0ACFypjuwQgtky+YMlROefnA1 prblB7TTPvsSwqSErjKBU6fSezQ8kpt0AUhd+Y61BY3YEf+kXOKg+RMkJiz4o+aKMxIJ X6Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SDPw9gIp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e13si6775585edr.407.2020.12.22.18.38.57; Tue, 22 Dec 2020 18:39:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SDPw9gIp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730109AbgLWCYS (ORCPT + 99 others); Tue, 22 Dec 2020 21:24:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:50890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730144AbgLWCYK (ORCPT ); Tue, 22 Dec 2020 21:24:10 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 14FBE22202; Wed, 23 Dec 2020 02:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690234; bh=PZkgTS62SlZ9oyrHhbnmA49Yyl+63TAaiWIp/xvU5dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SDPw9gIp45xnVFDZz0DCuV1BInzW7voCa20QfNQWq/+FKqOXQYy4Hfw6KvuTmEcWi OBjuT2Fi5MOEuA/PEJ11+qXJC3DZpIETF7w8geR4GNmOUQ5UXzh/Xxn5iJZdS8Bglk A8+4RqBZbbth4fLubqqphnu843fNml4fWet4tNXyDGivUaI9LdyijkDly5XCyYFrcv oaAmXUl8vTHpgi0Fd6HzZJnyqYMBCVO6yMv6aySGEUORM/VtSVULgc58mK/zto9mvc 4+IPwPXBm8WCTTpgj9FNSiUYmmEByThu4ZWZlX/lI175zvguDZZM8pDJOWwe2RACJu b+S9Qt1f2sF1A== 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.14 49/66] MIPS: KASLR: Avoid endless loop in sync_icache if synci_step is zero Date: Tue, 22 Dec 2020 21:22:35 -0500 Message-Id: <20201223022253.2793452-49-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-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 cbf4cc0b0b6cf..5639c2d5cf0e4 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.27.0