From patchwork Wed Jun 9 00:44:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12308487 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.9 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,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 CF13AC4743D for ; Wed, 9 Jun 2021 00:49:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 8F497610A5 for ; Wed, 9 Jun 2021 00:49:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F497610A5 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=bombadil.20210309; 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=j3JNL8gKEAsXvkjLu7lFKC+grC/beK0+cA4JebFvT6I=; b=spp9TgKvbHc3dE Mj4Y7HTLhl5rXdIQUEc3+GHgmMa3LVrII6orhKhDo8EiSgL8lCgGtkxupl1H8OlBAASjCVwydJH+l /pKa2zVBkw5bQoteBV78D5IeqJPKdIyDmyMHhI4IKqNL5Nx9hq1fa8bNUXLu/q8PhD+oMD6CRNxCO IaF1HDcDP1rjaEiFG5A40OKgfWDWqINKRNacYKG/ZVOzgnJPgsYD5GIlXj0CVnc2rXSUJtDses7Ef C2Eb4CGcyRMB7dBwNik8JWZUz20BXjK2NGETA/6H2fbiV+1C+NbsDKUUtN13Yp1g+z/+DO9VF6KwC 6OKNj3VVzT4Nm6PLdBJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqmLM-00AvS6-O7; Wed, 09 Jun 2021 00:45:16 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqmKd-00Av6p-DX for linux-arm-kernel@lists.infradead.org; Wed, 09 Jun 2021 00:44:32 +0000 Received: by mail-qk1-x734.google.com with SMTP id d196so17025961qkg.12 for ; Tue, 08 Jun 2021 17:44:31 -0700 (PDT) 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=GQ5BgIaJviFIJ4FCU2ORrVnn57SMRpQ9H71Ow8Vj6m4=; b=Y7E3HUKBWsfN3xCB81SMmwmoPU+UXzi7iX+gQK3HhBmGGLkxpTawLrk0L9WbhmKQcD PH5qlwzeky/C+Se+XOhgLii5iyYIw5w/4Eu+6fTt7CT0z2pngUyDoX/2/zRg9hoYxd4c geMyJmmU7GUUUTJcXBr556Gauh36IKBJ8XpAZeYrRUkn4R6mDaADzFE2koFCW2tbY9LH +1mFKAebl8I/Zh1RiYzMWGa/+8MmuwHqL055hGUjSzSqf3vu7CbQF3qYVbTXJfkgjpr/ V79O61DQjzqNgeE0YVPXFc3CCfVA8dK1PJ93zuKermcSdgc4S4GA+r5dgwtJQLDak4kQ KfLg== 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=GQ5BgIaJviFIJ4FCU2ORrVnn57SMRpQ9H71Ow8Vj6m4=; b=c31SyhgZ7ISgnapaXZfxr0LTEcs1h8fILZ0q8zkZJzWAUV35g4SFMxZWZ5rJLKCbz0 WN+5QSTFwWIPdh95ySX3cLkhfVDbuxvJV5AvDqW7C5Q2wHYSa4Ir4BMDXpXTEsl2H/Ot 3H9A4jPtWbr1oT91pl6u4D0uiknaXi2wduSBYLzRihpEoXWaPkLNi1kSPVKWEyP3m9N2 6GK/g8PTJ8yDIsvoBYE52hEM4A469msPwvOiUsEF3Kd7Sl9BHbt1Bd+5z0/sU/MEP2OH sHkLBY9O0WBxZAWNk11UJb/45WzEhERM7Ht/9IU+0dEAC6EQ9G6V7/iwO8+6E530EG1W sAdQ== X-Gm-Message-State: AOAM530N10thKmgWgOCdwTmRRsQKz07I61j7xxBvxuWbE7NwYrLmS7Yc /2yLMgqO0GqH40BriieFzLbKGg== X-Google-Smtp-Source: ABdhPJxJHulb7L09eWqLRuz1AoAZSBaTc/m3jSYUkhZOutuErP2+QhJiIPXDPhjGVQPaqZVif1ou/g== X-Received: by 2002:a37:7145:: with SMTP id m66mr24028223qkc.379.1623199470340; Tue, 08 Jun 2021 17:44:30 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id n194sm12869011qka.66.2021.06.08.17.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 17:44:29 -0700 (PDT) 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, kernelfans@gmail.com, akpm@linux-foundation.org, madvenka@linux.microsoft.com Subject: [PATCH v15 06/15] arm64: kexec: Use dcache ops macros instead of open-coding Date: Tue, 8 Jun 2021 20:44:10 -0400 Message-Id: <20210609004419.936873-7-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609004419.936873-1-pasha.tatashin@soleen.com> References: <20210609004419.936873-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-20210608_174431_507851_C5D2F042 X-CRM114-Status: GOOD ( 12.36 ) 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 kexec does dcache maintenance when it re-writes all memory. Our dcache_by_line_op macro depends on reading the sanitized 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. Suggested-by: James Morse 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 8418c1bd8f04..f1367863d995 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -393,10 +393,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 @@ -416,12 +415,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: