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=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 2A453C38A24 for ; Thu, 7 May 2020 16:22:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D84932053B for ; Thu, 7 May 2020 16:22:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D84932053B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 88D28900007; Thu, 7 May 2020 12:22:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86492900002; Thu, 7 May 2020 12:22:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7793D900007; Thu, 7 May 2020 12:22:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0025.hostedemail.com [216.40.44.25]) by kanga.kvack.org (Postfix) with ESMTP id 5D620900002 for ; Thu, 7 May 2020 12:22:35 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 241A711929 for ; Thu, 7 May 2020 16:22:35 +0000 (UTC) X-FDA: 76790441070.18.store21_50b84bd809e28 X-HE-Tag: store21_50b84bd809e28 X-Filterd-Recvd-Size: 4435 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 May 2020 16:22:34 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CB8011FB; Thu, 7 May 2020 09:22:33 -0700 (PDT) Received: from [192.168.0.14] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 64DEE3F71F; Thu, 7 May 2020 09:22:31 -0700 (PDT) Subject: Re: [PATCH v9 14/18] arm64: kexec: offset for relocation function To: Pavel Tatashin References: <20200326032420.27220-1-pasha.tatashin@soleen.com> <20200326032420.27220-15-pasha.tatashin@soleen.com> From: James Morse Cc: 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, 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, selindag@gmail.com Message-ID: <2c23b35d-d4b7-904c-9516-5f317dd963c7@arm.com> Date: Thu, 7 May 2020 17:22:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200326032420.27220-15-pasha.tatashin@soleen.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit 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: Hi Pavel, On 26/03/2020 03:24, Pavel Tatashin wrote: > Soon, relocation function will share the same page with EL2 vectors. The EL2 vectors would only be executed with the MMU off, so they don't need to be mapped anywhere in particular. (this is something hibernate probably does sloppily). > 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. See arch/arm64/kernel/vmlinux.lds.S and sections.h for an example of how the idmap, hibernate and the non-KVM hyp code do this. If we're going to change this, I'd prefer it be the same as the other users... > diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h > index 990185744148..d944c2e289b2 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 This makes these things visible globally ... but drops the arm64_ prefix! > diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relocate_kernel.S > index 22ccdcb106d3..aa9f2b2cd77c 100644 > --- a/arch/arm64/kernel/relocate_kernel.S > +++ b/arch/arm64/kernel/relocate_kernel.S > @@ -14,6 +14,9 @@ > #include > #include > > +.globl kexec_relocate_code_start > +kexec_relocate_code_start: Which of the fancy new asm-annotations should this be? > @@ -86,13 +89,16 @@ 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 > +.globl kexec_relocate_code_size > +kexec_relocate_code_size: > + .quad .Lkexec_relocate_code_end - kexec_relocate_code_start > +.globl kexec_kern_reloc_offset > +kexec_kern_reloc_offset: > + .quad arm64_relocate_new_kernel - kexec_relocate_code_start > Can't we calculate this from the start/end markers? These variables held in assembly generated code is pretty manky. Thanks, James