From mboxrd@z Thu Jan 1 00:00:00 1970 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 58C0FC433ED for ; Thu, 8 Apr 2021 04:10:34 +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 3F71D611BD for ; Thu, 8 Apr 2021 04:10:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F71D611BD 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=L9vS0tAUgnK695+xMNOhNTPthc35T9698qK9uRNN4rs=; b=P/PUXz4hpvAW0JsltLA6oJ0sq iz/milMzLsqcde3W1EU+Q0CLwrWkSclCks8OoXiSr7aCbA5QnpIeGQJ7xFOJqMeMX0EQ+DXhZn7pO aKge80AqISW528YJiXw8Ueop6ovj3hnHIsBTLsIscENQvYJ0Vqfi1h0VQXL8AIepQUei8+25QoFwE QJ4ldyUy/R/MsMMwFn7JeUNb6Fmcg8GQwbcERlmZxQwy8LdPh83VwkRES8Ne0mphHA7w0sI89+xX7 4XLA4R0Gbyw8tbi0mZesYiZPNZl3oSWUksN33ojXLTRSWCeQC6akR2MAnD28amGOs9pJNU2OnKj3e T6HL7au/w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lULyL-006mlX-1N; Thu, 08 Apr 2021 04:08:49 +0000 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lULvR-006lad-Jb for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 04:05:53 +0000 Received: by mail-qt1-x830.google.com with SMTP id c6so476582qtc.1 for ; Wed, 07 Apr 2021 21:05:49 -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=FcIEg/sDUKkdURMCkTF1KW5fxOPpkw674yFxDZdydcg=; b=K1NsbXiptJWAFjDZB69MTcxq+sVd357Lm9DKIwBQhxbGV3HftSKBeUqa23Wmi5KKNU zvjcqW4fvbuFxiDUEdiWh3Mcf9hsDD6xZvknyHE0ctG5bfVF8q4qEwPS0v1jcEKtMcbA 8nKTdc1FLRCDhKH+sT2n8fMhr1u+4HPurVK8/xjKe/Z9Cy3im6HxbQ+zh7vl4AwQ97/T ZODphpRxpUyYHVXtt6c71a1yPBcTrl3qHz4ut24V8AGbtwoYkqrh2tIBNNyfurAIblR4 QypVLYj0CXuJ3SBllkLS4gaJWPnDY2g4n0RpZpXaLWcaMPu4cnP4N2D+arBerwRT+OoS Yx6w== 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=FcIEg/sDUKkdURMCkTF1KW5fxOPpkw674yFxDZdydcg=; b=LF4oIyWuxLLu8HTH0iJqyMV5jvQ0BWWc+wYxi7TbvMzhFO7IeVecXTV5kGrIJXp3fd EqrD6LIg59XOHQMX4RrYFG9mCysPQyLeElNO5aJdiVCJwLtRMog7PF8Bu9hdPvMvKkrU xx8UZNLeU0snoX246CEg6L3/igAIOp2ujXW1NNxLjAYmbqjZtLG5vWyNiSNcLa9bBxs6 jj5pBOsacDb9hUCw/od3j1TGoEDBGKiqVYtJN8gtzHHKsDMI+RkOP5jtk2lEmBGj5i+7 YHGZXh8mdGZP4XWYrJ3AT24lZ56F1EFBZLySDx43QSM5DI5qNxzO+xVyDWkg7knXmO0s 5f4A== X-Gm-Message-State: AOAM532hJbfjxXh42hMaUSsoEYfp5ynJcMOtrh7bH3335BTX2yY7dYHc KB43kiEzuCPcbnSOguMFAeWuGg== X-Google-Smtp-Source: ABdhPJz+49F5sFnvxO3bcbTDIuYVduCfSWrd4A61z5Tt8rvcCW5QOx1alJlSaDZm0kDJxf714A6VuA== X-Received: by 2002:ac8:5313:: with SMTP id t19mr5657090qtn.148.1617854748347; Wed, 07 Apr 2021 21:05:48 -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 207sm18177874qkl.125.2021.04.07.21.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Apr 2021 21:05:47 -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 Subject: [PATCH v13 07/18] arm64: kexec: flush image and lists during kexec load time Date: Thu, 8 Apr 2021 00:05:26 -0400 Message-Id: <20210408040537.2703241-8-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408040537.2703241-1-pasha.tatashin@soleen.com> References: <20210408040537.2703241-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-20210408_050549_995032_650011ED X-CRM114-Status: GOOD ( 15.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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently, during kexec load we are copying relocation function and flushing it. However, we can also flush kexec relocation buffers and if new kernel image is already in place (i.e. crash kernel), we can also flush the new kernel image itself. Signed-off-by: Pavel Tatashin --- arch/arm64/kernel/machine_kexec.c | 49 +++++++++++++++---------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index 90a335c74442..3a034bc25709 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -59,23 +59,6 @@ void machine_kexec_cleanup(struct kimage *kimage) /* Empty routine needed to avoid build errors. */ } -int machine_kexec_post_load(struct kimage *kimage) -{ - void *reloc_code = page_to_virt(kimage->control_code_page); - - memcpy(reloc_code, arm64_relocate_new_kernel, - arm64_relocate_new_kernel_size); - kimage->arch.kern_reloc = __pa(reloc_code); - kexec_image_info(kimage); - - /* Flush the reloc_code in preparation for its execution. */ - __flush_dcache_area(reloc_code, arm64_relocate_new_kernel_size); - flush_icache_range((uintptr_t)reloc_code, (uintptr_t)reloc_code + - arm64_relocate_new_kernel_size); - - return 0; -} - /** * machine_kexec_prepare - Prepare for a kexec reboot. * @@ -152,6 +135,29 @@ static void kexec_segment_flush(const struct kimage *kimage) } } +int machine_kexec_post_load(struct kimage *kimage) +{ + void *reloc_code = page_to_virt(kimage->control_code_page); + + /* If in place flush new kernel image, else flush lists and buffers */ + if (kimage->head & IND_DONE) + kexec_segment_flush(kimage); + else + kexec_list_flush(kimage); + + memcpy(reloc_code, arm64_relocate_new_kernel, + arm64_relocate_new_kernel_size); + kimage->arch.kern_reloc = __pa(reloc_code); + kexec_image_info(kimage); + + /* Flush the reloc_code in preparation for its execution. */ + __flush_dcache_area(reloc_code, arm64_relocate_new_kernel_size); + flush_icache_range((uintptr_t)reloc_code, (uintptr_t)reloc_code + + arm64_relocate_new_kernel_size); + + return 0; +} + /** * machine_kexec - Do the kexec reboot. * @@ -169,13 +175,6 @@ void machine_kexec(struct kimage *kimage) WARN(in_kexec_crash && (stuck_cpus || smp_crash_stop_failed()), "Some CPUs may be stale, kdump will be unreliable.\n"); - /* Flush the kimage list and its buffers. */ - kexec_list_flush(kimage); - - /* Flush the new image if already in place. */ - if ((kimage != kexec_crash_image) && (kimage->head & IND_DONE)) - kexec_segment_flush(kimage); - pr_info("Bye!\n"); local_daif_mask(); @@ -250,8 +249,6 @@ void arch_kexec_protect_crashkres(void) { int i; - kexec_segment_flush(kexec_crash_image); - for (i = 0; i < kexec_crash_image->nr_segments; i++) set_memory_valid( __phys_to_virt(kexec_crash_image->segment[i].mem), -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel