From patchwork Wed Mar 3 00:22:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12113859 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 4184BC433E0 for ; Wed, 3 Mar 2021 16:44:23 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D470F64EBB for ; Wed, 3 Mar 2021 16:44:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D470F64EBB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=79Glskrpq9wLpPHrIrocDP7p5BHgF+r7llzQIidIOFA=; b=KmpzUbMa/YI29ssTuBxav39LH tGIFTv3troClHoWsc+1qx7roKAVGQrbXaFlX9+/6Vxs2olgvEe5V1f7LBQvcDT7u7i0ZA/uNmY4iT us56cz/RzaLyXUQsxlGl+NYBVs63xu9TOohdb9InTBbXZti/keqligUhYK07WxyDOysU0qrgLAlva 7ZgIqpISLWi3kj7rClj0lCBhvBFlFJ0TUjWNm05PzwMvx+qN0BXPLXDhU/kYXHcm0mqnriOVHYbOV lz9QFiXBfRSS2TN28gSzJlhWClYi/GXS1QmnxzaLzhPQ8xEnEppyGH2YRbyHqm8ARckwAlxK0zv4A S9ffef5aw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHUZN-005e5N-Js; Wed, 03 Mar 2021 16:41:54 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHSqZ-005EGf-1k for linux-arm-kernel@desiato.infradead.org; Wed, 03 Mar 2021 14:51:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=d9prc1UZUFN5dwsf86cy1HbKMQhioOGgsdfiYkk/1yQ=; b=HDVvT0PqJTTMLrcqcuF84fWmLl TUyqEzl7/mBWvIC8oK08wXc7y45dIjCQ88s7aMAVwW2yeOfkIlt6KgzuTuwfJn8UyO42UrwgQ/Uaf 3n1sdpKR7+iKSS3VYKAMaXf5rS+VOcD8CRHwdY9tSnnV4MLsyhnxmQvKuhYOGLeW/rjoPDoHRGAFU geX72fNI5QkyfMeuP909hvJors+ZOITa8V1WbtQcSYGISw0FzA96IUWMs8Z/qjIIGQwZRx1xliw3h JPYXtLL+8566V0zcQ79mC+w2MpvRJRBZ9AVpEH4xA8OUN+ORYbymvc3UH9z4tUi6XogpQ753TWl6H uBiVpazw==; Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHFIv-000jcb-ES for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 00:23:54 +0000 Received: by mail-qk1-x72f.google.com with SMTP id s7so12234008qkg.4 for ; Tue, 02 Mar 2021 16:23: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=JeF+27Vrg+LgE6kwgLwyGRARpvexae362RU0k6Iroi7voNFC4s6auY72sMrFNuQ2+l eHiS7bnOVmP/FpD6MTO/pJIg8xpLR1hUUegmFA8W7AhL2C5BCygdAbAww3Ni5udWssa8 QYw6j/QBrndckQwqcAGzPOuEfv+/9N7sT/+q6yDFBbTM/+VVMt6YYFFeE8o61J8X81Ov iwSV3CIgovadiYLAT4DXxwaWjD5N3xtH7FHxdBFkkPJS99FPvAoX3jAvTuni8r2etlz0 GsZGviqJk4P+zudN1i3a7kre6PPqohvfvfBEGW8Xc8cDfPbMel38iifrsDYRQpeZsStF 7x7g== X-Gm-Message-State: AOAM5323tujIO2YbajqnqiSGLU6VEkySWy2lh+RCNia2e5yymNnSiN9l gbo4Pkr3Mosl0WfdBEvJoUCslw== X-Google-Smtp-Source: ABdhPJzrhYCjfrgecXKXC5DvGpsZHuFJheu6IGy3c5MWfmYc4aXycDNvYiyhxoSY+nCVc07vrEcfIw== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210303_002354_693593_38587E91 X-CRM114-Status: GOOD ( 11.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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: