Received: by 10.223.185.116 with SMTP id b49csp6917971wrg; Wed, 28 Feb 2018 18:51:24 -0800 (PST) X-Google-Smtp-Source: AG47ELvXgJwFaJ/TaPU9UZ9b/QP6Fs4TJ/d//jtx2eGO0NYbpsAWa3CwpvlhdxxITr5gdPh3JFjp X-Received: by 2002:a17:902:b40e:: with SMTP id x14-v6mr71017plr.442.1519872684613; Wed, 28 Feb 2018 18:51:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519872684; cv=none; d=google.com; s=arc-20160816; b=BbAwSpiKlaOKQB1RBFdWF6pxoqsQ60xQej8ZMJ4o0uo7BJpEWpRjWBr+aW8i3yhHMs 7fLDwkwKAr12LonSDq8VqxYjh/HZFOYIvSwjFBwOdRVr9XyDFcQQTlADakyAqS/g0uor kVMRgyxrIGukUCXG0mXee12giNoL8xSSIaVNfdcxjpU9e0qWJBxIUL5sfxDKW9gSROuW UVnsvBS+1EQjFaAC/VoadQqMYFwO8SpvSg1lE/a7t4IGu9SyI98WM4ywJBsrU42f1SYv b5IfNHsOuABTdfG2nNTRn5McudcQMfqpJxCJUn2m5HsJ4WU14lBdOgiOFlod3QC6jkyb 7drQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=am8Zv3vGtBzBKPPB2sbGurBFHQsu63O8uNrogWYKEAE=; b=B/H8PwZR65+82ZBdlnjA4itxI0LOxi6lTDEW3XH49qcqU+J7WBn2D1lNv9tCPD+Rlz jelAvl+f5uqJ96PGQ7JQelRvExWe+sIod1/lZDdS1qGSukka7DviFL7MOKfeHF5XFh6w cza2HTqUvq8zGDTdtf3EKuG+fGiUMjiHbG7XR3tHUo6cyWh4ZF7hFwas0S3JaQUSB13h sgcLPvYQbYD/6CkgRc+xd2ttfLR+o6iqp+NFhuKpumOszkWQwe5DaPVRCOoq/BLa36Ns jSdTayKAh9wcjIW+vXbKxp9gi5KXwQJCEX4cIdjJxt6O6cd6MBxSGywnKnAJib9Dxf+a CrAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fbXWx75w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si1830610pgg.286.2018.02.28.18.51.10; Wed, 28 Feb 2018 18:51:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fbXWx75w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965565AbeCACuV (ORCPT + 99 others); Wed, 28 Feb 2018 21:50:21 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:40974 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965554AbeCACuS (ORCPT ); Wed, 28 Feb 2018 21:50:18 -0500 Received: by mail-pf0-f194.google.com with SMTP id f80so1866724pfa.8 for ; Wed, 28 Feb 2018 18:50:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=am8Zv3vGtBzBKPPB2sbGurBFHQsu63O8uNrogWYKEAE=; b=fbXWx75wu/eek+mmfdMuhOyAcevErEpdT/eSE++FZrnq6ccxo8puNd4F0LJPycAfXv SmOUkwHjEPyRXIKZ7boZdBdmBL8LkxZUqgYY80iVOpG9veRM2sH0LB4HqTpk3bIYneo3 ZjniDdj/cDrPf16JjViQLaMc80x8/njzbh+Iw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=am8Zv3vGtBzBKPPB2sbGurBFHQsu63O8uNrogWYKEAE=; b=hwGT30oA2rhtdIhGiec7ced1RrG5qV8fV6Jdg8wx8XD170vm8iHH4mcTpsptjVT3Wv MP3XR9Q3EtT8REwEWzvz9k9ocmU4nkvyO82m1DIFtp8WNmpusIjawyB4JOlmD4Dcc+cj BOPI6caOkfAUAPqDbx0fJTntofGJS1gLOLQRdxVL2jd2PGG90tQ/z5zIg8MRRGBSAi+/ C+RopkI0Z1TfmihEf1UFkSyX+nHMrRUamJfo/nRdd/D62SLX8/gzcDBXUKxebCoA87I9 Zq3A17jpiCZAxnRviycwfO1CHzrlLgUOzLb7zsQPQAIQviLw9V4cfeiQ7TWdxyWmRmDt TfYg== X-Gm-Message-State: APf1xPDIMKdZPPJ9asxFLxPmCgWmvno6N09BapMg9/0wofQ6dBDBo1dm +VDvmzIqKWnEweReyfg2WpyMyQ== X-Received: by 10.167.128.194 with SMTP id a2mr339278pfn.186.1519872617671; Wed, 28 Feb 2018 18:50:17 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id f7sm4253290pgq.66.2018.02.28.18.50.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 18:50:17 -0800 (PST) Date: Thu, 1 Mar 2018 11:50:28 +0900 From: AKASHI Takahiro To: Jeffrey Hugo Cc: Tyler Baicar , ard.biesheuvel@linaro.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, sgoel@codeaurora.org, timur@codeaurora.org Subject: Re: [PATCH 0/2] ESRT fixes for relocatable kexec'd kernel Message-ID: <20180301025026.GK6019@linaro.org> Mail-Followup-To: AKASHI Takahiro , Jeffrey Hugo , Tyler Baicar , ard.biesheuvel@linaro.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, sgoel@codeaurora.org, timur@codeaurora.org References: <1519414953-5478-1-git-send-email-tbaicar@codeaurora.org> <20180228061901.GJ6019@linaro.org> <1f03865f-2d22-8ba1-a276-a6b49d7c14de@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1f03865f-2d22-8ba1-a276-a6b49d7c14de@codeaurora.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Feb 28, 2018 at 08:39:42AM -0700, Jeffrey Hugo wrote: > On 2/27/2018 11:19 PM, AKASHI Takahiro wrote: > >Tyler, > > > ># I missed catching your patch as its subject doesn't contain arm64. > > > >On Fri, Feb 23, 2018 at 12:42:31PM -0700, Tyler Baicar wrote: > >>Currently on arm64 ESRT memory does not appear to be properly blocked off. > >>Upon successful initialization, ESRT prints out the memory region that it > >>exists in like: > >> > >>esrt: Reserving ESRT space from 0x000000000a4c1c18 to 0x000000000a4c1cf0. > >> > >>But then by dumping /proc/iomem this region appears as part of System RAM > >>rather than being reserved: > >> > >>08f10000-0deeffff : System RAM > >> > >>This causes issues when trying to kexec if the kernel is relocatable. When > >>kexec tries to execute, this memory can be selected to relocate the kernel to > >>which then overwrites all the ESRT information. Then when the kexec'd kernel > >>tries to initialize ESRT, it doesn't recognize the ESRT version number and > >>just returns from efi_esrt_init(). > > > >I'm not sure what is the root cause of your problem. > >Do you have good confidence that the kernel (2nd kernel image in this case?) > >really overwrite ESRT region? > > According to my debug, yes. > Using JTAG, I was able to determine that the ESRT memory region was getting > overwritten by the secondary kernel in > kernel/arch/arm64/kernel/relocate_kernel.S - specifically the "copy_page" > line of arm64_relocate_new_kernel() > > >To my best knowledge, kexec is carefully designed not to do such a thing > >as it allocates a temporary buffer for kernel image and copies it to the > >final destination at the very end of the 1st kernel. > > > >My guess is that kexec, or rather kexec-tools, tries to load the kernel image > >at 0x8f80000 (or 0x9080000?, not sure) in your case. It may or may not be > >overlapped with ESRT. > >(Try "-d" option when executing kexec command for confirmation.) > > With -d, I see > > get_memory_ranges_iomem_cb: 0000000009611000 - 000000000e5fffff : System RAM > > That overlaps the ESRT reservation - > [ 0.000000] esrt: Reserving ESRT space from 0x000000000b708718 to > 0x000000000b7087f0 > > > > >Are you using initrd with kexec? > > Yes To make the things clear, can you show me, if possible, the followings: * dmesg * /proc/iomem * the output from "kexec -d", particularly the last part like kexec_load: entry = 0x411d7660 flags = 0xb70000 nr_segments = 3 segment[0].buf = 0xffff86613010 segment[0].bufsz = 0x10e9b48 segment[0].mem = 0x40080000 segment[0].memsz = 0x1156000 segment[1].buf = 0xffff86211010 segment[1].bufsz = 0x20e segment[1].mem = 0x411d6000 segment[1].memsz = 0x1000 segment[2].buf = 0x5045420 segment[2].bufsz = 0x31b8 segment[2].mem = 0x411d7000 segment[2].memsz = 0x4000 Thanks, -Takahiro AKASHI > > > >Thanks, > >-Takahiro AKASHI > > > > > >>This causes an early ioremap leak because > >>the memory allocated for 'va' is never unmapped. So first fix that error > >>case to properly unmap 'va' before returning. > >> > >>This still leaves ESRT unable to initialize in the kexec'd kernel, so now > >>mark the ESRT memory block as nomap so that this memory is not treated as > >>System RAM. With this change I'm able to see that the ESRT data is not > >>overwritten when running a kexec'd kernel. > >> > >>Tyler Baicar (2): > >> efi/esrt: fix unsupported version initialization failure > >> efi/esrt: mark ESRT memory region as nomap > >> > >> drivers/firmware/efi/esrt.c | 10 +++++++++- > >> 1 file changed, 9 insertions(+), 1 deletion(-) > >> > >>-- > >>Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. > >>Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, > >>a Linux Foundation Collaborative Project. > >> > >-- > >To unsubscribe from this list: send the line "unsubscribe linux-efi" in > >the body of a message to majordomo@vger.kernel.org > >More majordomo info at http://vger.kernel.org/majordomo-info.html > > > > > -- > Jeffrey Hugo > Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, > Inc. > Qualcomm Technologies, Inc. is a member of the > Code Aurora Forum, a Linux Foundation Collaborative Project.