From patchwork Thu Sep 30 14:31:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12528547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94A09C433EF for ; Thu, 30 Sep 2021 14:37:13 +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 5B79B61269 for ; Thu, 30 Sep 2021 14:37:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5B79B61269 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=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=kGNAKM0pCivALP3Hsm3ry+oQj0dccRkZOYQ06UuTuDQ=; b=yIG5Nl4uZWpIGW DkycSX7afr7cWFVFmK/FkONJl2G6GlkFU7rz1GLY+TOonzEyMT+MyGGC76AE88+gywtDsztTcUNTR 0ks5cWmQDWlNaM81Bkw/9r6zF70HldSoIP9QGBGtz2PrWm2NE9CSw0OF5jcIbK7f1k3r+2/lwrCt/ EHgD/nJDr1xnxZWkLkij3ywM5xLDlY5CQ0PoE+Ea4/dQDipohd7c4BNU54B6y4Dk8fasXAU06q7IJ m8piySu4XufgNRKm16OoglASz+4JkhyxF6djkcloA6pcMyfRzP7u33cNvp0osMDmTx3td0pvysEYR C5FEnEluuw1CDSCyRuBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVx8Y-00Eihw-FC; Thu, 30 Sep 2021 14:34:14 +0000 Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVx5n-00EhQk-Jd for linux-arm-kernel@lists.infradead.org; Thu, 30 Sep 2021 14:31:27 +0000 Received: by mail-qk1-x731.google.com with SMTP id i132so5999752qke.1 for ; Thu, 30 Sep 2021 07:31:22 -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=UIkM47FXs5P7Z/Da3Mn+8DCMex1zjJveQjNKvVhGh4k=; b=HAsc0xpvY/J7ECsq2WRyYU/gr+1qYLJdXXgcW7LBuP6Ck7/Ze+a0P8y/kFcZ9s4sBG CwKWrt/wRlgYhSyE8RDbsVvBXDwWX3j3zpgu3zaWiQbEL57hwBFqnzhPBbq/ZXYEa9X6 OTV8mpwqGNCSOvXYIvWJjjiVqAb255gIiz0u656noA+ql4bIpfbuLR/FvM+oxIDWJYxC Ovp2KOoR3zDAdTJ8kp0W1Doa1VICEloK8cfOUhjbl9VsuR0lbeMoG8zNTtpiVfDxuEAD XQQHdoPSdene+TR0RbeUo3xCYIjqnjPoTuNAvD4reELA4S2ULq+Z1lbpIp9kkqH0jtVV hnXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UIkM47FXs5P7Z/Da3Mn+8DCMex1zjJveQjNKvVhGh4k=; b=uCqGXD3wLPqEsLc+sv4Dd04xVSCuGSG6ajS+kh/X03YekzrHNIoj8SG0AoET3fHoyt JwwBDNLb5CPyPnwG1nCA4coK1Jd7QOb2wb5mGiSOkbUPMTXsdoKOqpb1KtWK9VAU/qju pKRAWakNebjKGKdgRwy7G1A6o98LIGgwGe+ghfRaK93xnBdPj31Bq08la2i6ofxJbYIB 33Zuo2KeQsMHygaxnQ6YJhi7TXVckjPhN0LNM5KZPsAb/Y4253szXYPOvIJZ5buvoLSZ 9k0DGU6qcrG9rEXt0Pgdap6zeCNEWmQ6iPj76trq3yQ+iNPiURHZ1bjc5QH5I0sL0YvZ vRog== X-Gm-Message-State: AOAM5311e35F7kTYMqaoG7MFu6AApSxZMN7C8BduXe2FW5Jt9h1tp9X/ +1gCZJcc2dGTduUa1i63D5Rcmg== X-Google-Smtp-Source: ABdhPJz+yokIGfxLu3ulCxnz5lUdNKG81GcyHkZE4+G8gOjEmo4IXXWq+pXgLlUabAlOLSxioSB5Qg== X-Received: by 2002:a37:993:: with SMTP id 141mr4982102qkj.488.1633012281915; Thu, 30 Sep 2021 07:31:21 -0700 (PDT) Received: from soleen.c.googlers.com.com (189.216.85.34.bc.googleusercontent.com. [34.85.216.189]) by smtp.gmail.com with ESMTPSA id l195sm1528731qke.98.2021.09.30.07.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 07:31:21 -0700 (PDT) From: Pasha Tatashin To: pasha.tatashin@soleen.com, 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, kernelfans@gmail.com, akpm@linux-foundation.org Subject: [PATCH v18 06/15] arm64: kexec: Use dcache ops macros instead of open-coding Date: Thu, 30 Sep 2021 14:31:04 +0000 Message-Id: <20210930143113.1502553-7-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog In-Reply-To: <20210930143113.1502553-1-pasha.tatashin@soleen.com> References: <20210930143113.1502553-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-20210930_073123_706121_31052AFE X-CRM114-Status: GOOD ( 13.86 ) 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: Pasha Tatashin Acked-by: Catalin Marinas --- arch/arm64/include/asm/assembler.h | 30 ++++++++++++++++++++++------- arch/arm64/kernel/relocate_kernel.S | 13 +++---------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index bfa58409a4d4..d5281f75a58d 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -405,19 +405,19 @@ alternative_endif /* * Macro to perform a data cache maintenance for the interval - * [start, end) + * [start, end) with dcache line size explicitly provided. * * op: operation passed to dc instruction * domain: domain used in dsb instruciton * start: starting virtual address of the region * end: end virtual address of the region + * linesz: dcache line size * fixup: optional label to branch to on user fault - * Corrupts: start, end, tmp1, tmp2 + * Corrupts: start, end, tmp */ - .macro dcache_by_line_op op, domain, start, end, tmp1, tmp2, fixup - dcache_line_size \tmp1, \tmp2 - sub \tmp2, \tmp1, #1 - bic \start, \start, \tmp2 + .macro dcache_by_myline_op op, domain, start, end, linesz, tmp, fixup + sub \tmp, \linesz, #1 + bic \start, \start, \tmp .Ldcache_op\@: .ifc \op, cvau __dcache_op_workaround_clean_cache \op, \start @@ -436,7 +436,7 @@ alternative_endif .endif .endif .endif - add \start, \start, \tmp1 + add \start, \start, \linesz cmp \start, \end b.lo .Ldcache_op\@ dsb \domain @@ -444,6 +444,22 @@ alternative_endif _cond_extable .Ldcache_op\@, \fixup .endm +/* + * Macro to perform a data cache maintenance for the interval + * [start, end) + * + * op: operation passed to dc instruction + * domain: domain used in dsb instruciton + * start: starting virtual address of the region + * end: end virtual address of the region + * fixup: optional label to branch to on user fault + * Corrupts: start, end, tmp1, tmp2 + */ + .macro dcache_by_line_op op, domain, start, end, tmp1, tmp2, fixup + dcache_line_size \tmp1, \tmp2 + dcache_by_myline_op \op, \domain, \start, \end, \tmp1, \tmp2, \fixup + .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..8c43779e8cc6 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 + add x1, x2, #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: