From patchwork Mon Jan 25 19:19:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12044127 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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 7319AC433DB for ; Mon, 25 Jan 2021 19:19:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F2D4F21744 for ; Mon, 25 Jan 2021 19:19:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2D4F21744 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BA7948D0026; Mon, 25 Jan 2021 14:19:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B59668D0023; Mon, 25 Jan 2021 14:19:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6D408D0026; Mon, 25 Jan 2021 14:19:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0254.hostedemail.com [216.40.44.254]) by kanga.kvack.org (Postfix) with ESMTP id 9040A8D0023 for ; Mon, 25 Jan 2021 14:19:44 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9EAE3181AEF0B for ; Mon, 25 Jan 2021 19:19:43 +0000 (UTC) X-FDA: 77745261846.16.nut24_1d0e19727588 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 75855100E690C for ; Mon, 25 Jan 2021 19:19:43 +0000 (UTC) X-HE-Tag: nut24_1d0e19727588 X-Filterd-Recvd-Size: 6807 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Mon, 25 Jan 2021 19:19:42 +0000 (UTC) Received: by mail-qt1-f172.google.com with SMTP id t17so10543358qtq.2 for ; Mon, 25 Jan 2021 11:19:42 -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=fYtwEkSD1g4zgc3mwZlXud5vJEM5wBsBl27BfuiCCGo=; b=U2AIVAJVNsrZwMQGm3jBTprnYlMZE2r0f07KZ/zh8a2HtVegm5Vrw9+CSVp/lI7Olr b3BHv9VX9zYpOGGmLuvOmzIVhSJR0S+/r/mkSAONsXUZHdQBInsFN0VBlaumZAGrgg/F s4k2BJaAFHTTlqUf+cDOFIXSAPXmQj1K0VWS9M4Dhs8r6V23ddNJ1CPgIA5l3dp1IaPX 9gBIB7dFsc7RCkiDRTBhE9rOUkOsra1PlaC4eXs98zEiGF268+JK7j0dEP/u53Tvk+FU fIy+tzeA6q2grkIIzOJ3NToRGJ3bHoTlX+Ix/f+DR7XKJX/ZM7gvINzw0/dtPHUm1kYk PTgA== 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=fYtwEkSD1g4zgc3mwZlXud5vJEM5wBsBl27BfuiCCGo=; b=l5WjAJJDJ5qywtqlGoV/WEFSTfxkESAA9iZmyuanVaod0HJYMhDxJiStmfYmPpX3On CrvN/CgBeUOrHSy2Z/0Yn+Ny/Zi8F/Dfeqnumz6HFSLExWqOFsh2cXawEIJHd1N4S1kE rMbkd3w1peGAeOx7fk6iFGUqGS3fZFTKwnKfZ5HkP+32eNlFflhg4w5HJMzRtvaLqTZ4 EkVA0v0NfdOTjRlFzJE8q7lVt61eM9wATfDR2VTz/ELS/Wgda9kQoSlfxHxQGd2gNMvM ry/tsitXZkGHNF5v3xxiTEeUNBsqobtkX7rfJcPWufrQh+A5du4eHX3ZnvT75GcVkNha RQKw== X-Gm-Message-State: AOAM530A2+I3TRshnSznpZt9prNZBYge9AB/A4mIZxVeIObWMeHCnqWC fWeg1fVLW4YXr4HKdCvlQBUDFQ== X-Google-Smtp-Source: ABdhPJyI8k+86XaV/8c2jn/BKReyE9eDvlppb7XnDOdVY2z1s16lwW29T78nGb4fSsM7KDSok6C8eQ== X-Received: by 2002:ac8:a82:: with SMTP id d2mr1908195qti.343.1611602382398; Mon, 25 Jan 2021 11:19:42 -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 s6sm9047638qtx.63.2021.01.25.11.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 11:19:41 -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 v10 11/18] arm64: kexec: arm64_relocate_new_kernel clean-ups and optimizations Date: Mon, 25 Jan 2021 14:19:16 -0500 Message-Id: <20210125191923.1060122-12-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210125191923.1060122-1-pasha.tatashin@soleen.com> References: <20210125191923.1060122-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In preparation to bigger changes to arm64_relocate_new_kernel that would enable this function to do MMU backed memory copy, do few clean-ups and optimizations. These include: 1. Call raw_dcache_line_size() only when relocation is actually going to happen. i.e. kdump type kexec, does not need it. 2. copy_page(dest, src, tmps...) increments dest and src by PAGE_SIZE, so no need to store dest prior to calling copy_page and increment it after. Also, src is not used after a copy, not need to copy either. 3. For consistency use comment on the same line with instruction when it describes the instruction itself. 4. Some comment corrections Signed-off-by: Pavel Tatashin --- arch/arm64/kernel/relocate_kernel.S | 36 +++++++---------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relocate_kernel.S index 84eec95ec06c..462ffbc37071 100644 --- a/arch/arm64/kernel/relocate_kernel.S +++ b/arch/arm64/kernel/relocate_kernel.S @@ -17,28 +17,24 @@ /* * arm64_relocate_new_kernel - Put a 2nd stage image in place and boot it. * - * The memory that the old kernel occupies may be overwritten when coping the + * The memory that the old kernel occupies may be overwritten when copying the * new image to its final location. To assure that the * arm64_relocate_new_kernel routine which does that copy is not overwritten, * all code and data needed by arm64_relocate_new_kernel must be between the * symbols arm64_relocate_new_kernel and arm64_relocate_new_kernel_end. The * machine_kexec() routine will copy arm64_relocate_new_kernel to the kexec - * control_code_page, a special page which has been set up to be preserved - * during the copy operation. + * safe memory that has been set up to be preserved during the copy operation. */ SYM_CODE_START(arm64_relocate_new_kernel) - /* Setup the list loop variables. */ mov x18, x2 /* x18 = dtb address */ mov x17, x1 /* x17 = kimage_start */ mov x16, x0 /* x16 = kimage_head */ - raw_dcache_line_size x15, x0 /* x15 = dcache line size */ mov x14, xzr /* x14 = entry ptr */ mov x13, xzr /* x13 = copy dest */ - /* Check if the new image needs relocation. */ tbnz x16, IND_DONE_BIT, .Ldone - + raw_dcache_line_size x15, x0 /* x15 = dcache line size */ .Lloop: and x12, x16, PAGE_MASK /* x12 = addr */ @@ -57,34 +53,18 @@ SYM_CODE_START(arm64_relocate_new_kernel) b.lo 2b dsb sy - mov x20, x13 - mov x21, x12 - copy_page x20, x21, x0, x1, x2, x3, x4, x5, x6, x7 - - /* dest += PAGE_SIZE */ - add x13, x13, PAGE_SIZE + copy_page x13, x12, x0, x1, x2, x3, x4, x5, x6, x7 b .Lnext - .Ltest_indirection: tbz x16, IND_INDIRECTION_BIT, .Ltest_destination - - /* ptr = addr */ - mov x14, x12 + mov x14, x12 /* ptr = addr */ b .Lnext - .Ltest_destination: tbz x16, IND_DESTINATION_BIT, .Lnext - - /* dest = addr */ - mov x13, x12 - + mov x13, x12 /* dest = addr */ .Lnext: - /* entry = *ptr++ */ - ldr x16, [x14], #8 - - /* while (!(entry & DONE)) */ - tbz x16, IND_DONE_BIT, .Lloop - + ldr x16, [x14], #8 /* entry = *ptr++ */ + tbz x16, IND_DONE_BIT, .Lloop /* while (!(entry & DONE)) */ .Ldone: /* wait for writes from copy_page to finish */ dsb nsh