Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp346539pxu; Fri, 4 Dec 2020 04:58:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEie17taqYYEjW5js0SWJTm4PF4J+DwfcZ+5kpYOSZyTjSaAseo+EDHspv5MYuhJlH4Mpg X-Received: by 2002:a50:f089:: with SMTP id v9mr7525768edl.353.1607086720991; Fri, 04 Dec 2020 04:58:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607086720; cv=none; d=google.com; s=arc-20160816; b=aqulDSPgaNcQuofkcbJz9cqZliLDWiNrvbx7KvgIOEteWsNAzOiMeXb/70/4yBhTg8 7w7oNABTF0/JFoeg5H7gopdwKiwBV398B9NMEGE7qglJ4LxDDel4+t/QEAKTQRHuIfvA IrmzHgXAL4IPp0rpy+2/zby7nTyP7IGV1jiA8gy/4Cmy1BdnIOl5g7lnKZgkRTtlQNnR AEZKFkCLBPA0snEV8sy0u1yOYzrQzITKHsfS85FtMfU9dESwApvBem5lv4fyHtfwcnGZ 6cwOx2946peZ2BxntK68YF6yS4/VLzo3QvOoMOLKXS5H5xCdcUx0/ydiRcywH86ns0lh dsyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Qd6m/yTYJi2pZQObPtt84PWp7bmdF05U4SiDlMvXUEw=; b=Tt72xcrb4ppAfcBwjxguVvEoJ3SN1lWrdWL2C81eOtfThtTKMDPDUHypRHvLNrkP4u rgXGUEA9r3iltZo0M+cgiyMxE/vUizr49GoUpFGB83Cq45uodxd0mQCeasnZG+uyUM+Z O+o9j+cSXSUqrG3G6ysRSjyHVZ0tFS//bFFB8klT9k+7M05Fl5akacRJO22agtULvwIM LDVccIqlUfztjyMj0Fo5deEzhDqNhZCxCyYHN4sbdZXR5m/UlZqTZDGJuJdrhRJKvGmJ k8f6Ot3OWCnTcPhxqv+clmgIXiw8HpG+GJ+cgT0wjX4TeOk8mLfvMgGUJFySNHKrkaU1 Gb0A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq4si1352865ejc.14.2020.12.04.04.58.17; Fri, 04 Dec 2020 04:58:40 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387477AbgLDMzH (ORCPT + 99 others); Fri, 4 Dec 2020 07:55:07 -0500 Received: from elvis.franken.de ([193.175.24.41]:48216 "EHLO elvis.franken.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730173AbgLDMzH (ORCPT ); Fri, 4 Dec 2020 07:55:07 -0500 Received: from uucp (helo=alpha) by elvis.franken.de with local-bsmtp (Exim 3.36 #1) id 1klAbR-0005vN-00; Fri, 04 Dec 2020 13:54:25 +0100 Received: by alpha.franken.de (Postfix, from userid 1000) id 2AE1CC02E5; Fri, 4 Dec 2020 13:14:56 +0100 (CET) Date: Fri, 4 Dec 2020 13:14:56 +0100 From: Thomas Bogendoerfer To: Jiaxun Yang Cc: Jinyang He , 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 Message-ID: <20201204121456.GA10990@alpha.franken.de> References: <1606878005-11427-1-git-send-email-hejinyang@loongson.cn> <20201202103943.GA9065@alpha.franken.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 03, 2020 at 12:02:10PM +0800, Jiaxun Yang wrote: > > > 在 2020/12/2 下午6:39, Thomas Bogendoerfer 写道: > > 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 ? > > I thought that's because legacy flush requires much more cares. that's true. It shouldn't be that hard, but probably has to wait until someone needs it. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]