From patchwork Mon Mar 30 14:38:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pratyush Anand X-Patchwork-Id: 6121951 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B52049F2EC for ; Mon, 30 Mar 2015 14:41:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC0FE20381 for ; Mon, 30 Mar 2015 14:41:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 913E8202B4 for ; Mon, 30 Mar 2015 14:41:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YcaqD-0007Nd-21; Mon, 30 Mar 2015 14:39:01 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ycaq5-0007F5-Nj; Mon, 30 Mar 2015 14:38:54 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 81851A0CDD; Mon, 30 Mar 2015 14:38:32 +0000 (UTC) Received: from localhost.localdomain (vpn-58-70.rdu2.redhat.com [10.10.58.70]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2UEcSmd003530; Mon, 30 Mar 2015 10:38:29 -0400 Message-ID: <55195FE3.5090409@redhat.com> Date: Mon, 30 Mar 2015 20:08:27 +0530 From: Pratyush Anand User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Geoff Levand Subject: Re: arm64 kexec hang References: <1427477015.27739.30.camel@infradead.org> <5515C799.8010600@redhat.com> <551940F5.9050102@redhat.com> In-Reply-To: <551940F5.9050102@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150330_073853_870425_03614457 X-CRM114-Status: GOOD ( 17.34 ) X-Spam-Score: -5.0 (-----) Cc: Kyle McMartin , Takahiro Akashi , kexec@lists.infradead.org, Vivek Goyal , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Monday 30 March 2015 05:56 PM, Pratyush Anand wrote: > Hi Geoff, > > On Saturday 28 March 2015 02:41 AM, Pratyush Anand wrote: >> Hi Geoff, >> >> On Friday 27 March 2015 10:53 PM, Geoff Levand wrote: >>> Hi Pratyush, >>> >>> On Wed, 2015-03-25 at 15:55 +0530, Pratyush Anand wrote: >>>> So with following changes kexec load seems to complete without any >>>> error. However, kexec reboot does not work yet, Nothing after bye >>>> message :( (1st kernel booted with maxcpus=1) >>> >>> 'Bye!' doesn't mean much, other than the first kernel has >>> almost shutdown. I recommend for debugging you either define >>> ARM64_DEBUG_PORT for the kexec-tools build, or have a suitable >>> earlyprintk= on the kernel command line. See the read_sink() >>> routine in kexec-arm64.c. >>> >> > > Problem seems to be related to compilation of purgatory code. > > For example see here: > > 70 0000000000000120 : > 71 120: a9bf7bfd stp x29, x30, [sp,#-16]! > 72 124: 910003fd mov x29, sp > 73 128: 58000100 ldr x0, 148 > 74 12c: 94000000 bl 544 > > > So, when it executes instruction at address 0x128 in above code, it does > not contain correct address of data where "I'm in purgatory" is located. > It seems that code has been compiled as 32 bit. > > PC: 0x400415012c , PSTATE: 0x400003c9 > (gdb) monitor reg x0 > x0 (/64): 0x00000000041568F8 > (gdb) monitor mdw 0x00000000041568F8 4 > 0x41568f8: fffefffe fffefffe fffefffe fffefffe : ................ > > The buffer location passed to printf is not correct. > > Similarly, even if ARM64_DEBUG_PORT is programmed with correct UART TX > register, arm64_sink is not modified correctly when elf_rel_set_symbol > is called. > > So correct data is at 0x00000040041568F8 and not 0x00000000041568F8 > > (gdb) monitor mdw 0x00000040041568F8 4 > 0x40041568f8: 206d2749 70206e69 61677275 79726f74 : I'm in purgatory > > > should n't the pc relative instruction like adrp be generated instead of > ldr. > > What does -mcmodel=large cflag do? May be it is causing to generate such > instruction. > Following changes allows purgatory to execute. switch(r_type) { @@ -1026,7 +1026,7 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type, break; } - dbgprintf("%s: %s %x->%x\n", __func__, type, data, *location); + dbgprintf("%s: %s %lx->%lx\n", __func__, type, data, *location); } So I get following and then nothing.. [ 162.087569] Bye! I'm in purgatory purgatory: kernel_entry: 0000004000280000 purg Hopefully, I will be able to debug it further.will come back. ~Pratyush diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c index 8df66f5c8273..4365bb4087ad 100644 --- a/kexec/arch/arm64/kexec-arm64.c +++ b/kexec/arch/arm64/kexec-arm64.c @@ -993,8 +993,8 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type, # define R_AARCH64_CALL26 283 #endif - uint32_t *location = (uint32_t *)ptr; - uint32_t data = *location; + uint64_t *location = (uint64_t *)ptr; + uint64_t data = *location; const char *type = NULL;