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: 12044163 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=-17.0 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=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 9D580C433E0 for ; Mon, 25 Jan 2021 19:24:39 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 5F58121D79 for ; Mon, 25 Jan 2021 19:24:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F58121D79 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=merlin.20170209; 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=7Pq5jkX25TbzueftKKl+uOz9L9QLGUOQeVZ4dgXxFnQ=; b=Tn2Bl7nyUl7to0wPxBtS5Th1r+ jTiE78KPoM+4BeNFVPvlkO5hb+ywaOLGqzWW2Tf/+iHc/zv96WszXWnbm0xkc5qV5RQjD0zBxOdE3 pOQA2CZ564Fc/jQ0EzrF3mGEzxkAlYM7FBZ9iUZENdqbSsraudKO3M4iQ/X+Wsh0MPiALD6p0ObP1 dRdFB9mKk2OijuJ7wXkl8aWxyXlX/zoetRNGMn/WoyxOubylPZsIjH2jt9HdkQFEdSWa1zP5OiT4I 8Q2UTmmZxCS9cb2wpixlnjg8zKfHLSgtKwz5KAUFGGsSDLv36xDO9EmNXWNIhLXUhbEGogf3GmMsg iUOeKeZg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l47Rr-0008NT-37; Mon, 25 Jan 2021 19:22:51 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l47Oq-0007BS-EI for linux-arm-kernel@lists.infradead.org; Mon, 25 Jan 2021 19:20:07 +0000 Received: by mail-qt1-x832.google.com with SMTP id e17so10529433qto.3 for ; Mon, 25 Jan 2021 11:19:43 -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=mDEgTzeX3SDh6dqORIoJi1yki22/Wv06gXhBAsKK+ZEHoN66bliKQ+xmZrs1zWwQTQ FIeXGNeNU5CCtnH3ywgSE8YvVgG2SiF29YEGVoZbUFk0r+1uZ+8mPq+TjHXVxRVvnTls N8F36tZFS9tfoIYeHKPdv2Oo6dy5BFc+jPqeGlkIHmCaneS2PqTVDGSjlkJKS/EcOUu3 3SFPlzpXKWGJwX3JuBIZoR4TOQ9L/7zbJafyain6OFuQ2vlyFQ/cXkUsZZhQmi6g6J5n G6OTa0tHS+lS324MFFblYq5mPIB6BsXss0koGUxP9ra1M8skw+CKmpp4lg0lv11oj7zC 7wIA== X-Gm-Message-State: AOAM5308L/BhtjALLmU7ZeotjOZ+2WJM+zx1aSy+mlDr1QQivq2Z7xVs UqGZ5YhJFg2wB6AoJzcSKbTnyQ== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210125_141944_556979_86CF5519 X-CRM114-Status: GOOD ( 14.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 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 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