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=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 5A719C433ED for ; Thu, 13 May 2021 03:23:16 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B0496610F7 for ; Thu, 13 May 2021 03:23:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0496610F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TRVoBtDsXwaxL7sjCTx6qjvn2uSOqRG1wo0hvbAyDGk=; b=p5UQWhKlR9HbxjX+cazi/sSHF GtxDJN1Bpd+Su9RxcSOHxiVR3fQRY64g2+TfTVrlSzyIMcf3Kopc7pgstn826wy1GBikhuS/vJFPS GoM7+a/xh5vZf70FaeuUc3IR5XZHiMK395wPsNDIJf5JQBhqs297l2YE56SCE8Xn4JO/1ZoGdDsMA 1EPpKkQAGeUOcPMXrmMMtEKHiuwC7JnNWYU0rtaDiI+RPqNqOY/tCAJM1xkKaFTRJh/POQOIaZixN dqt043UhmstPi2sa+xfOTNL4xhHD5wm+lp9N2q7ykeDaKUCL0cqKqfAYDy/WZfNgOSqfccBb2KjI1 VXpPHupag==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lh1u0-004b20-2K; Thu, 13 May 2021 03:20:44 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lh1tw-004b1K-EO for linux-arm-kernel@desiato.infradead.org; Thu, 13 May 2021 03:20:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:In-Reply-To:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0pJ41TIHkZuyVQ7X/aOhCGRwv+o8xnsER6uiPAfs/lI=; b=i2LeOZbWWIJNC1Zmej6iqZhmS4 RzsFweQ6GLj4W11BPO4DciHE9NxIANxBV58/Dw5JXdCliRicC25/z006gOTW/vqHjDevBDcSvQaOx kvs6TxH13H8bHPVB+fcXygCfKjwXRvuYEB1rLUx5ry79oAKzQQdM4b7bfh9u9hcwqhBsGaKwsK1ZM CoNCu0gVSLHLeoF5S6Q47Jtl2C+6WVFZUc7og1hm98SUExGuO5z0yFREWx9wuc6K/10ErjoPW6lzp QRYa+sMDMmUgtUzJoRb2su1uZBRl6782GDShYdfB24HpKSxkhG458/h4Z9Ubi6szqXWTziSHnAYMD wPG7rM/A==; Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lh1ts-00Ayyf-Ob for linux-arm-kernel@lists.infradead.org; Thu, 13 May 2021 03:20:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620876035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0pJ41TIHkZuyVQ7X/aOhCGRwv+o8xnsER6uiPAfs/lI=; b=FLoUxoY4aAaFh78+7vkk+j0BANNGJzUZxUrXRx8XQOD1kXf+6zChcP6rP5yd2AUrrATfJl zefhmJ0AU4cUWf+PukYfhduGpmUxX047bfqIBEjAFThg1gxHG3VjTz9+kM7m/En/e1RIu3 WpqXYSqUlmT8JHu4VFiUF1DdPI2SXXc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-GzWBFrtZPkCcsAU3A1jknw-1; Wed, 12 May 2021 23:20:32 -0400 X-MC-Unique: GzWBFrtZPkCcsAU3A1jknw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8C3F88049CB; Thu, 13 May 2021 03:20:30 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-207.pek2.redhat.com [10.72.12.207]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC1F81A26A; Thu, 13 May 2021 03:20:24 +0000 (UTC) Date: Thu, 13 May 2021 11:20:21 +0800 From: Dave Young To: Moritz Fischer Cc: Marc Zyngier , kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Ard Biesheuvel , Mark Rutland , James Morse , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , Eric Biederman , AKASHI Takahiro , kernel-team@android.com Subject: Re: [PATCH 1/2] firmware/efi: Tell memblock about EFI reservations Message-ID: <20210513031958.GD45898@dhcp-128-65.nay.redhat.com> References: <20210429133533.1750721-1-maz@kernel.org> <20210429133533.1750721-2-maz@kernel.org> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dyoung@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210512_202036_908047_86F22596 X-CRM114-Status: GOOD ( 32.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 05/03/21 at 11:56am, Moritz Fischer wrote: > Marc, > > On Thu, Apr 29, 2021 at 02:35:32PM +0100, Marc Zyngier wrote: > > kexec_load_file() relies on the memblock infrastructure to avoid > > stamping over regions of memory that are essential to the survival > > of the system. > > > > However, nobody seems to agree how to flag these regions as reserved, > > and (for example) EFI only publishes its reservations in /proc/iomem > > for the benefit of the traditional, userspace based kexec tool. > > > > On arm64 platforms with GICv3, this can result in the payload being > > placed at the location of the LPI tables. Shock, horror! > > > > Let's augment the EFI reservation code with a memblock_reserve() call, > > protecting our dear tables from the secondary kernel invasion. > > > > At some point, someone will have to go and figure out a way to unify > > these multiple reservation trees, because sprinkling random reservation > > calls is only a temporary workaround. > > > > Feel free to add (and/or): > > Reported-by: Moritz Fischer > Tested-by: Moritz Fischer > > Signed-off-by: Marc Zyngier > > --- > > drivers/firmware/efi/efi.c | 23 ++++++++++++++++++++++- > > 1 file changed, 22 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c > > index 4b7ee3fa9224..026b02f5f7d8 100644 > > --- a/drivers/firmware/efi/efi.c > > +++ b/drivers/firmware/efi/efi.c > > @@ -896,11 +896,25 @@ static int __init efi_memreserve_map_root(void) > > static int efi_mem_reserve_iomem(phys_addr_t addr, u64 size) > > { > > struct resource *res, *parent; > > + int ret; > > > > res = kzalloc(sizeof(struct resource), GFP_ATOMIC); > > if (!res) > > return -ENOMEM; > > > > + /* > > + * Given that efi_mem_reserve_iomem() can be called at any > > + * time, only call memblock_reserve() if the architecture > > + * keeps the infrastructure around. > > + */ > > + if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) { > > + ret = memblock_reserve(addr, size); > > + if (ret) { > > + kfree(res); > > + return ret; > > + } > > + } > > + If you go with memblock, it would be better to handle it separately from the iomem? > > res->name = "reserved"; > > res->flags = IORESOURCE_MEM; > > res->start = addr; > > @@ -908,7 +922,14 @@ static int efi_mem_reserve_iomem(phys_addr_t addr, u64 size) > > > > /* we expect a conflict with a 'System RAM' region */ > > parent = request_resource_conflict(&iomem_resource, res); > > - return parent ? request_resource(parent, res) : 0; > > + ret = parent ? request_resource(parent, res) : 0; > > + if (ret) { > > + kfree(res); > > + if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) > > + memblock_free(addr, size); > > + } > > + > > + return ret; It looks odd to free memblock when reqeust resource fails, they are not relavant? > > } > > > > int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size) > > -- > > 2.29.2 > > > > > > _______________________________________________ > > linux-arm-kernel mailing list > > linux-arm-kernel@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > > Thanks, > Moritz > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec > > Thanks Dave _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel