From patchwork Wed Dec 4 15:59:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11273207 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76206109A for ; Wed, 4 Dec 2019 16:00:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3525520865 for ; Wed, 4 Dec 2019 16:00:48 +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="cu+p4RqK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3525520865 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 D1A8E6B0B75; Wed, 4 Dec 2019 11:00:13 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CCBAB6B0B76; Wed, 4 Dec 2019 11:00:13 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBBE06B0B77; Wed, 4 Dec 2019 11:00:13 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id A7AFC6B0B75 for ; Wed, 4 Dec 2019 11:00:13 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 7341F82D5A81 for ; Wed, 4 Dec 2019 16:00:13 +0000 (UTC) X-FDA: 76227920706.24.laugh93_1efa01c97054d X-Spam-Summary: 2,0,0,7c4ec09e8e067b32,d41d8cd98f00b204,pasha.tatashin@soleen.com,: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::mark.rutland@arm.com:steve.capper@arm.com:rfontana@redhat.com:tglx@linutronix.de,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1381:1431:1437:1500:1515:1535:1544:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:2895:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:4118:4321:4605:5007:6261:6653:6737:7875:8603:8634:9010:9592:10004:11026:11473:11657:11658:11914:12043:12048:12295:12297:12438:12517:12519:12555:12895:13161:13229:13894:14096:14181:14394:14721:21063:21080:21222:21325:21444:21451:21627:30012:30034:30054:3007 0:30079: X-HE-Tag: laugh93_1efa01c97054d X-Filterd-Recvd-Size: 7600 Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Dec 2019 16:00:12 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id d124so356252qke.6 for ; Wed, 04 Dec 2019 08:00:12 -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=SvTPGoWzcPkObV2Ws85OzWUy+7CYa3mnpkPEsJWZNzE=; b=cu+p4RqK3Zmx7hWnQSABCZglBgezn5eGQzuTkON/BGZNxKpEU1LoNRODi9ekiA+9ku /ZobcizQIRPhtU0+snmXbaF2M5yZuiN5PFlBdWDIJm0AGn5BWV5LQDz9CJt6/0Lity+v xisJmjhNGiX136oinbjNKH1rvVjN2c7Z/Q35xKU3qcr3ajjy4dgHBBdtaWrOSBhz12kM 0SYxeCJnYQrKHjEAHJP+56wX8ja0DAATSwJnv7/BmALDrdxSnUR3j8/KTYpW6LeaZchE LqLej/VDgFvtbMsFSBcXgG/inm+Uf4Q2j9eK03s8vaFMKhFYmUBAqGeceb6c2l7XmwVw s/wA== 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=SvTPGoWzcPkObV2Ws85OzWUy+7CYa3mnpkPEsJWZNzE=; b=rxjS9w+fTe7RH7b8t0WbufNU6AWYaiWzypeVPdvcy08McaQ1quxVxeGpPWxXZi7wQJ GlQ/6z35/dzzEi89jh/ymfcm8HYK7F3bDGqQZl6AdKrEwNhiXiK9kfYCt58TKmbupzc1 XgHHdcDhe68u74QmFK3XmJ8lwkNRPOlIP28HBbrZA8KoaskOJVvai7Z42zgIExnQaKjl S7/9k9s/uJ+p883oCaTjdPWSBqeQ3Rkc73kkWEMpAZeOGqF6DcdllCX2qy51KE4REhV1 bXXsACDf9rziTcfSt3NJKn7STGCbtzOuZtV+H6dlzmx5jGCzGbqNA7mbfaHv3/U+i3V7 op9A== X-Gm-Message-State: APjAAAW96O2xwpVvCNK2SwXhbT7obgGiE6mNN+P8npLnWOongPwjSYTx kmmIzzM84Y3VfDVmb4EiPSd49Q== X-Google-Smtp-Source: APXvYqwJu5ElHhYW15zTS5aeaMgKbUmMET7cn1hc9pUfr6v0add/5xWuzNZp92mrLeWlXbSulQ5WUw== X-Received: by 2002:a37:9fce:: with SMTP id i197mr3504897qke.466.1575475212067; Wed, 04 Dec 2019 08:00:12 -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 w21sm4177585qth.17.2019.12.04.08.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 08:00:11 -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, 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 v8 21/25] arm64: kexec: offset for relocation function Date: Wed, 4 Dec 2019 10:59:34 -0500 Message-Id: <20191204155938.2279686-22-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204155938.2279686-1-pasha.tatashin@soleen.com> References: <20191204155938.2279686-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: 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/kexec.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 +#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/machine_kexec.c index 5f1211f3aeef..5e7b1f6569c4 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -23,10 +23,6 @@ #include "cpu-reset.h" -/* 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; - memcpy(reloc_code, arm64_relocate_new_kernel, - arm64_relocate_new_kernel_size); - kimage->arch.kern_reloc = __pa(reloc_code); + memcpy(reloc_code, kexec_relocate_code_start, kexec_relocate_code_size); + kimage->arch.kern_reloc = __pa(reloc_code) + kexec_kern_reloc_offset; kimage->arch.kern_reloc_arg = __pa(kern_reloc_arg); kern_reloc_arg->head = kimage->head; kern_reloc_arg->entry_addr = kimage->start; @@ -190,7 +185,7 @@ void machine_kexec(struct kimage *kimage) "Some CPUs may be stale, kdump will be unreliable.\n"); /* 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); /* * 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); /* Flush the kimage list and its buffers. */ kexec_list_flush(kimage); diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relocate_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 +GLOBAL(kexec_relocate_code_start) + /* * arm64_relocate_new_kernel - Put a 2nd stage image in place and boot it. * @@ -86,13 +88,14 @@ ENTRY(arm64_relocate_new_kernel) .ltorg END(arm64_relocate_new_kernel) -.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