Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1489005pxb; Thu, 4 Mar 2021 12:40:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxU+A3PpvKyDp+/VE2mpHwwtXriJwgSKDvqjqWAtfcKbJNQVN6g8K7h3MVD9n6SMCH0x1r2 X-Received: by 2002:a17:906:d153:: with SMTP id br19mr6186372ejb.360.1614890446042; Thu, 04 Mar 2021 12:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614890446; cv=none; d=google.com; s=arc-20160816; b=cDkdJ0oWbwNkifPrLMTS/JW3MOIEBn8qP7GWrNp9PSZCgzgKpAp29Txw1RUI+E/Irt MT+4BW5rK7YrIFtc0+UWemfABWEHkQgJfGG4swZZQnWamcfECmuJ4DK0/odYdbU01SIC OgP0eS4K22WXAv6+05/AyTt9giXIaEOFN+JE3n2ZGwjHdTCPbuJN3AXo8Rv6fBbb6PJ2 nu9TyWVX/7A1Ga6Whc9IM5A6UmM7nUcBsaDnGLwp3hGnqekpXS7d9cPgX+srIHvhBG38 WjAuFldSBwSTb7KhRRVUuWd//ylk7Fc1joSjgrBQ7QUPlTsd9CNqI91oHWQWs218h4zi 1fvQ== 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:to:from :dkim-signature; bh=d9prc1UZUFN5dwsf86cy1HbKMQhioOGgsdfiYkk/1yQ=; b=XMxuBqJqzm24Y4GUkxfPduyevsGHybZbEFy0+GQZJyFy/xDzPlzxQmYyGaHNyqS0Y/ Nyq7BD0KSe/h1Nb7619G811RavYocz5LIIsMAAkjhieIb2dx04BpkB3B57Oq2kmSr91X O+WEBcVFdYMkh2D65qtx2YCfujNmtnIlhhmz2gXFLHWzy0kGRPWo5gRcOnm5+tk9IBoa DARrvszrEPE6zsNeBSUcxdZ/B3bM8ycXXOocBU16XknpXeRPBW9KE5mrWWYxnMjWSYED x/vF60j+l0w73ckwWp4XkirjTm5ufnAjb+Z2wKHhvcI9mrgY485cpwnihea77arbm9u2 SW8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=J384aoqF; 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 a20si113494ejg.257.2021.03.04.12.40.21; Thu, 04 Mar 2021 12:40:46 -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=@soleen.com header.s=google header.b=J384aoqF; 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 S1442610AbhCCKvH (ORCPT + 99 others); Wed, 3 Mar 2021 05:51:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237899AbhCCAZu (ORCPT ); Tue, 2 Mar 2021 19:25:50 -0500 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8060DC061225 for ; Tue, 2 Mar 2021 16:22:45 -0800 (PST) Received: by mail-qk1-x72d.google.com with SMTP id l132so21138329qke.7 for ; Tue, 02 Mar 2021 16:22:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=d9prc1UZUFN5dwsf86cy1HbKMQhioOGgsdfiYkk/1yQ=; b=J384aoqFXPkOEjGgXRUpI8bPGle2xZ/d/8Mv1cPGwzPmmCqCRjHEm8PmZPVcr9NZpT Z/KgtFrb4DGavOcxweTEDqhVwUSVb1KHU+Z037e6LKv3ESLtvkWkFGCvdLtPmlCQZTxT RCBUz0Wn/BU+REqHmXxhFqO6OJhLWdMwlbEFdOvgxGxtN5Z2/RSnuvKm9x2xboFy4ck6 ZaSRuztXVrXoPZDDSlAgvE9ZvAUzTrAYXdlp1fhgAD/cLkj2PII4I8mvog8wI+/OCKQF SpzPPSl9SYrpcKF3EJVTlYtPkA5IMuj47TmLjStHmcLs5ptke7rHEW6NWdgao9sd7QOO Z+FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d9prc1UZUFN5dwsf86cy1HbKMQhioOGgsdfiYkk/1yQ=; b=b48sViK7QDLvlQet1ETiewZb/BaBnuXQzEUx1XMZPi/dZodvE51DOuWM4pvs/pdZdw 84fm/7Vjo0HDFwKkd/w54/+3ByRIc7t+yAJUaGAM+MryKFIA4i+XOwVMd4mxiIlAO6OR xpDOhHo/vQoERZC2sgCLbToNM0cvKM3951s8Vrig8tYkBan46yjsgl29UAjQYZD0M5zy shi6bhk23GcBUhvk47jnZ4HiTOZq/cPRJoo/enPMacCNuWG8CDBtu9NnsEoZpfbnnsxl rTb4PixPIEJcDKaZH+Loo99BLtr8KCBWSiiuSrhRyhmDeIN9duDRDlSfAFuXkso/WYBk 8Qog== X-Gm-Message-State: AOAM530Yh35/w/DGalw2qXeNFAe9cXPG061wOSMPsmknCUAHbmmZagr6 UbToUUbWpTdwrBSCFLAkYDKGMw== X-Received: by 2002:a37:a48a:: with SMTP id n132mr13712448qke.359.1614730964775; Tue, 02 Mar 2021 16:22:44 -0800 (PST) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id r3sm16690512qkm.129.2021.03.02.16.22.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 16:22:44 -0800 (PST) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, maz@kernel.org, james.morse@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, linux-mm@kvack.org, mark.rutland@arm.com, steve.capper@arm.com, rfontana@redhat.com, tglx@linutronix.de, selindag@gmail.com, tyhicks@linux.microsoft.com Subject: [PATCH v12 09/17] arm64: kexec: Use dcache ops macros instead of open-coding Date: Tue, 2 Mar 2021 19:22:22 -0500 Message-Id: <20210303002230.1083176-10-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210303002230.1083176-1-pasha.tatashin@soleen.com> References: <20210303002230.1083176-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Morse kexec does dcache maintenance when it re-writes all memory. Our dcache_by_line_op macro depends on reading the sanitised DminLine from memory. Kexec may have overwritten this, so open-codes the sequence. dcache_by_line_op is a whole set of macros, it uses dcache_line_size which uses read_ctr for the sanitsed DminLine. Reading the DminLine is the first thing the dcache_by_line_op does. Rename dcache_by_line_op dcache_by_myline_op and take DminLine as an argument. Kexec can now use the slightly smaller macro. This makes up-coming changes to the dcache maintenance easier on the eye. Code generated by the existing callers is unchanged. Signed-off-by: James Morse [Fixed merging issues] Signed-off-by: Pavel Tatashin --- arch/arm64/include/asm/assembler.h | 12 ++++++++---- arch/arm64/kernel/relocate_kernel.S | 13 +++---------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index ca31594d3d6c..29061b76aab6 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -371,10 +371,9 @@ alternative_else alternative_endif .endm - .macro dcache_by_line_op op, domain, kaddr, size, tmp1, tmp2 - dcache_line_size \tmp1, \tmp2 + .macro dcache_by_myline_op op, domain, kaddr, size, linesz, tmp2 add \size, \kaddr, \size - sub \tmp2, \tmp1, #1 + sub \tmp2, \linesz, #1 bic \kaddr, \kaddr, \tmp2 9998: .ifc \op, cvau @@ -394,12 +393,17 @@ alternative_endif .endif .endif .endif - add \kaddr, \kaddr, \tmp1 + add \kaddr, \kaddr, \linesz cmp \kaddr, \size b.lo 9998b dsb \domain .endm + .macro dcache_by_line_op op, domain, kaddr, size, tmp1, tmp2 + dcache_line_size \tmp1, \tmp2 + dcache_by_myline_op \op, \domain, \kaddr, \size, \tmp1, \tmp2 + .endm + /* * Macro to perform an instruction cache maintenance for the interval * [start, end) diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relocate_kernel.S index 8058fabe0a76..718037bef560 100644 --- a/arch/arm64/kernel/relocate_kernel.S +++ b/arch/arm64/kernel/relocate_kernel.S @@ -41,16 +41,9 @@ SYM_CODE_START(arm64_relocate_new_kernel) tbz x16, IND_SOURCE_BIT, .Ltest_indirection /* Invalidate dest page to PoC. */ - mov x2, x13 - add x20, x2, #PAGE_SIZE - sub x1, x15, #1 - bic x2, x2, x1 -2: dc ivac, x2 - add x2, x2, x15 - cmp x2, x20 - b.lo 2b - dsb sy - + mov x2, x13 + mov x1, #PAGE_SIZE + dcache_by_myline_op ivac, sy, x2, x1, x15, x20 copy_page x13, x12, x1, x2, x3, x4, x5, x6, x7, x8 b .Lnext .Ltest_indirection: -- 2.25.1