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=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 2C36EFA3728 for ; Wed, 16 Oct 2019 20:01:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DD3C921A49 for ; Wed, 16 Oct 2019 20:01:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="Xa0aYLt9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD3C921A49 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 18A4C8E001A; Wed, 16 Oct 2019 16:01:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 114138E000C; Wed, 16 Oct 2019 16:01:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF5CE8E001A; Wed, 16 Oct 2019 16:01:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id C73978E000C for ; Wed, 16 Oct 2019 16:01:11 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 81C3D184A82C3 for ; Wed, 16 Oct 2019 20:01:11 +0000 (UTC) X-FDA: 76050716742.02.tub01_a5acfe97c139 X-HE-Tag: tub01_a5acfe97c139 X-Filterd-Recvd-Size: 7605 Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Oct 2019 20:01:11 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id p10so23976914qkg.8 for ; Wed, 16 Oct 2019 13:01:10 -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=EkJ2n3u+MavwQwkZo1EWpv98Wdy6XKHkdOkUGe9PK3g=; b=Xa0aYLt9LaMmHhTg5HWXYkhK4Ue0oTxEya9uvjF+xNS2UIkW5Fsn8jKLdX/Z7V0p5B m+Hz2iki7BKDg00FNOvZOR7q5GkkXtmABLVSh0HT1FDBj4I2lAlSHHI2UOf922ghxaeQ c2nJYF/JZ/bD8qI7kFHv4HgH4WF4M51eaqXFEySNuL7xHZ1j5jr/zsORc+GWsUincyyP AqZn13kCAU/KP2lOo8aYFxPZTTOVfAW6FHSWudKtIxum86Av18pWyG7tAUaqnyHxB3+i /uC9R3m/4rIpECG6CXV+Bitg150NRKhJ/AbewCk1aHetaGgu+UY0HUnNHJwrCURKaKwu BooA== 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=EkJ2n3u+MavwQwkZo1EWpv98Wdy6XKHkdOkUGe9PK3g=; b=CRBrQiBGt9drWb7vmChOe6VZmlT4h+rBRLtDtHORxxGMd0owMYZbaZlKYfr1rebuTl T/A/00zzBGvW5jjnLu/HSXmVgZaQZFvnI7Pm2YtG8UOViqKt0U5agxTTHuaBPo4WAXf0 k+pL7oxrpftVM+zTN45acRTBqgsZ1RfXh341Vh9c+YP/ylcNZokvzKJGfAPS/18L5jh+ lBXJge8WE7E2Soe3dx0U3qahsa7QTYRjia5wpGjDo6HMcEzJ5X0AOk7xwf0Lvu7abQRX whSQVvIA9ZCEbd/oPJHCW8oQ+xL7WGQ4Afrw0CH+s6r+0+EqmFelD72J9klxuFqNvBxE y9xg== X-Gm-Message-State: APjAAAXWdyTGsPZH76m0gcuPEY8DNDB6nQYLrts3ahJTesIbYmOtOduP X2u2U29TCxh1K336ETNVb4eDZ86h8SQ= X-Google-Smtp-Source: APXvYqzB53L+GX2u0+ltlyrZ8qCWIjXjRiiKZH1InwMU/QOJx5m4IaTXo0Tlba/wud/QDWsoFUjs5w== X-Received: by 2002:a37:9a46:: with SMTP id c67mr4646976qke.52.1571256070370; Wed, 16 Oct 2019 13:01:10 -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 c204sm13342030qkb.90.2019.10.16.13.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 13:01:09 -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, marc.zyngier@arm.com, james.morse@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, bhsharma@redhat.com, linux-mm@kvack.org, mark.rutland@arm.com, steve.capper@arm.com, rfontana@redhat.com, tglx@linutronix.de Subject: [PATCH v7 21/25] arm64: kexec: offset for relocation function Date: Wed, 16 Oct 2019 16:00:30 -0400 Message-Id: <20191016200034.1342308-22-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016200034.1342308-1-pasha.tatashin@soleen.com> References: <20191016200034.1342308-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: Soon, relocation function will share the same page with EL2 vectors. Add offset within this page to arm64_relocate_new_kernel, and also the total size of relocation code which will include both the function and the EL2 vectors. Signed-off-by: Pavel Tatashin --- arch/arm64/include/asm/kexec.h | 7 +++++++ arch/arm64/kernel/machine_kexec.c | 13 ++++--------- arch/arm64/kernel/relocate_kernel.S | 13 ++++++++----- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexe= c.h index 189dce24f4cb..8cad34e7a9d9 100644 --- a/arch/arm64/include/asm/kexec.h +++ b/arch/arm64/include/asm/kexec.h @@ -90,6 +90,13 @@ static inline void crash_prepare_suspend(void) {} static inline void crash_post_resume(void) {} #endif =20 +#if defined(CONFIG_KEXEC_CORE) +/* The beginning and size of relcation code to stage 2 kernel */ +extern const unsigned long kexec_relocate_code_size; +extern const unsigned char kexec_relocate_code_start[]; +extern const unsigned long kexec_kern_reloc_offset; +#endif + /* * kern_reloc_arg is passed to kernel relocation function as an argument= . * head kimage->head, allows to traverse through relocation segments. diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machin= e_kexec.c index 5f1211f3aeef..5e7b1f6569c4 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -23,10 +23,6 @@ =20 #include "cpu-reset.h" =20 -/* Global variables for the arm64_relocate_new_kernel routine. */ -extern const unsigned char arm64_relocate_new_kernel[]; -extern const unsigned long arm64_relocate_new_kernel_size; - /** * kexec_image_info - For debugging output. */ @@ -82,9 +78,8 @@ int machine_kexec_post_load(struct kimage *kimage) if (!kern_reloc_arg) return -ENOMEM; =20 - memcpy(reloc_code, arm64_relocate_new_kernel, - arm64_relocate_new_kernel_size); - kimage->arch.kern_reloc =3D __pa(reloc_code); + memcpy(reloc_code, kexec_relocate_code_start, kexec_relocate_code_size)= ; + kimage->arch.kern_reloc =3D __pa(reloc_code) + kexec_kern_reloc_offset; kimage->arch.kern_reloc_arg =3D __pa(kern_reloc_arg); kern_reloc_arg->head =3D kimage->head; kern_reloc_arg->entry_addr =3D kimage->start; @@ -190,7 +185,7 @@ void machine_kexec(struct kimage *kimage) "Some CPUs may be stale, kdump will be unreliable.\n"); =20 /* Flush the reboot_code_buffer in preparation for its execution. */ - __flush_dcache_area(reboot_code_buffer, arm64_relocate_new_kernel_size)= ; + __flush_dcache_area(reboot_code_buffer, kexec_relocate_code_size); =20 /* * Although we've killed off the secondary CPUs, we don't update @@ -199,7 +194,7 @@ void machine_kexec(struct kimage *kimage) * the offline CPUs. Therefore, we must use the __* variant here. */ __flush_icache_range((uintptr_t)reboot_code_buffer, - arm64_relocate_new_kernel_size); + kexec_relocate_code_size); =20 /* Flush the kimage list and its buffers. */ kexec_list_flush(kimage); diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relo= cate_kernel.S index 22ccdcb106d3..3c05220a79ab 100644 --- a/arch/arm64/kernel/relocate_kernel.S +++ b/arch/arm64/kernel/relocate_kernel.S @@ -14,6 +14,8 @@ #include #include =20 +GLOBAL(kexec_relocate_code_start) + /* * arm64_relocate_new_kernel - Put a 2nd stage image in place and boot i= t. * @@ -86,13 +88,14 @@ ENTRY(arm64_relocate_new_kernel) .ltorg END(arm64_relocate_new_kernel) =20 -.Lcopy_end: +.Lkexec_relocate_code_end: .org KEXEC_CONTROL_PAGE_SIZE .align 3 /* To keep the 64-bit values below naturally aligned. */ /* - * arm64_relocate_new_kernel_size - Number of bytes to copy to the + * kexec_relocate_code_size - Number of bytes to copy to the * control_code_page. */ -.globl arm64_relocate_new_kernel_size -arm64_relocate_new_kernel_size: - .quad .Lcopy_end - arm64_relocate_new_kernel +GLOBAL(kexec_relocate_code_size) + .quad .Lkexec_relocate_code_end - kexec_relocate_code_start +GLOBAL(kexec_kern_reloc_offset) + .quad arm64_relocate_new_kernel - kexec_relocate_code_start --=20 2.23.0