Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1773065ybk; Mon, 11 May 2020 04:02:16 -0700 (PDT) X-Google-Smtp-Source: APiQypIbgDOdvzZbVdBSdtxi/D6hl//GQCOU5CvaOlBcdiZlQiZzCAqChQxcxq87PtuoLboTSN8h X-Received: by 2002:aa7:c492:: with SMTP id m18mr12704687edq.346.1589194935911; Mon, 11 May 2020 04:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589194935; cv=none; d=google.com; s=arc-20160816; b=asxEldQCCEHnVij9rJuaM6VU3Yb8b3j10Bmec6oUNEQw/wp2gx0VLgzej0Ci7CYC0o UNwjKp4z3lfiK/qJlEB3QTAUQHxSnGLLegcvRleeZj6wMbEjyPUx5A1L3mXg4J2nRCZL 1SULujmX/3Tp9t1eFBrEsFu9BtV8ix9SlS27H141ftKlkdViZEexna8iLcS58fRImXJX EweDXwQCB4rV9TWr6VtBhz9GEzfn1fg/vVIYxZpnQlpr6daQBdCDT5Rl/xLoyDC97Z5m cbcWanpub0vuqyfMyTZTMiYQk6gaQXPOmUadH0og8ztJtW7vEobgCnBwhWj/HxphdxCl 9MSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=c3HrU8T1M8DnyRyLa4V9UXUgSeC2OL6yP+RL8pl8kQM=; b=RZLrNqJnh0KHnkOpjsPQqgjCx72DRtPF0qMFLoEHTHoSl8lPfWuzP/I41aL/qREHN+ 57G8uEazL9lTxSa/LU/IUqtMmLE2wi9tDzf82HIKi/ZoBEVGSqpYLI3HwNewrodLUbgC 51vscbpxaih51c3dwRfdFLEISEOhxb1n+ruPRa6j+AukLj664tEBDd5SiDpaQrAqMImE fGVT0ypGj7SkGCSkb6juVnjVhlcduv/Bqr98AYhV1fkeFRxnAdPJw0vflHVAGnqSwyAC csvx1kjkTIvXeVVyDrKH6G8OBzSMV9WElS5qc9K6ApDJuICu7NEJctz3VZVQ12C6MNZp p+HQ== 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 da11si5782242edb.431.2020.05.11.04.01.52; Mon, 11 May 2020 04:02:15 -0700 (PDT) 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 S1729585AbgEKLA0 (ORCPT + 99 others); Mon, 11 May 2020 07:00:26 -0400 Received: from foss.arm.com ([217.140.110.172]:56316 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729086AbgEKLAZ (ORCPT ); Mon, 11 May 2020 07:00:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4AD751FB; Mon, 11 May 2020 04:00:24 -0700 (PDT) Received: from gaia (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DFC143F305; Mon, 11 May 2020 04:00:20 -0700 (PDT) Date: Mon, 11 May 2020 12:00:14 +0100 From: Catalin Marinas To: Will Deacon Cc: Christoph Hellwig , james.morse@arm.com, Andrew Morton , Arnd Bergmann , Roman Zippel , Jessica Yu , Michal Simek , x86@kernel.org, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, openrisc@lists.librecores.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-um@lists.infradead.org, linux-xtensa@linux-xtensa.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 02/31] arm64: fix the flush_icache_range arguments in machine_kexec Message-ID: <20200511110014.GA19176@gaia> References: <20200510075510.987823-1-hch@lst.de> <20200510075510.987823-3-hch@lst.de> <20200511075115.GA16134@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200511075115.GA16134@willie-the-truck> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 11, 2020 at 08:51:15AM +0100, Will Deacon wrote: > On Sun, May 10, 2020 at 09:54:41AM +0200, Christoph Hellwig wrote: > > The second argument is the end "pointer", not the length. > > > > Signed-off-by: Christoph Hellwig > > --- > > arch/arm64/kernel/machine_kexec.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c > > index 8e9c924423b4e..a0b144cfaea71 100644 > > --- a/arch/arm64/kernel/machine_kexec.c > > +++ b/arch/arm64/kernel/machine_kexec.c > > @@ -177,6 +177,7 @@ void machine_kexec(struct kimage *kimage) > > * the offline CPUs. Therefore, we must use the __* variant here. > > */ > > __flush_icache_range((uintptr_t)reboot_code_buffer, > > + (uintptr_t)reboot_code_buffer + > > arm64_relocate_new_kernel_size); > > Urgh, well spotted. It's annoyingly different from __flush_dcache_area(). > > But now I'm wondering what this code actually does... the loop condition > in invalidate_icache_by_line works with 64-bit arithmetic, so we could > spend a /very/ long time here afaict. I think it goes through the loop only once. The 'b.lo' saves us here. OTOH, there is no I-cache maintenance done. > It's also a bit annoying that we do a bunch of redundant D-cache > maintenance too. Should we use invalidate_icache_range() here instead? Since we have the __flush_dcache_area() above it for cleaning to PoC, we could use invalidate_icache_range() here. We probably didn't have this function at the time, it was added for KVM (commit 4fee94736603cd6). > (and why does that thing need to toggle uaccess)? invalidate_icache_range() doesn't need to, it works on the kernel linear map. __flush_icache_range() doesn't need to either, that's a side-effect of the fall-through implementation. Anyway, I think Christoph's patch needs to go in with a fixes tag: Fixes: d28f6df1305a ("arm64/kexec: Add core kexec support") Cc: # 4.8.x- and we'll change these functions/helpers going forward for arm64. Happy to pick this up via the arm64 for-next/fixes branch. -- Catalin