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.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 E019EC433B4 for ; Mon, 3 May 2021 18:59:18 +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 4D0CE611C0 for ; Mon, 3 May 2021 18:59:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D0CE611C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=LaxXVmRIl5Mkmoe0xT931FNfUb0T8SawdPGhuDCC6ZM=; b=GPpI/xzqreMVUtHNMILjj0amD h1A9kcLCY23GhRSToifWgglm7AE2uanbAQQmn2U67CZfMX3c4102Szp4d6yqIvuUoAm8mPB9Q7OZA XdzSoFMDrg1sMOw48CHHDhC9LMaWAneeczNAAqzMOc6/VrwRYsC4Dl32IcgEkUxPXf8WZwfO4RGRQ e1EL2QZAiH8E3WhuIUPjDz8w3WUV8U6wZrvTf0x3v6l9wg0QCxnlcSYIdJTvPucIHNRM9Yv0HRooQ pKtBjfFz0Mys9BgTKYC/VB8AWMAkeP6pEQE/YYanCsXhekxAu9s/6D0R6Q+WqW4hMCwspcAii8lVm KBu0fujAA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lddkS-00EfCk-TB; Mon, 03 May 2021 18:56:53 +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 1lddkI-00EfAw-Da; Mon, 03 May 2021 18:56:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=xN1vIdSdlI8AjiOUn9JP97vsEZYoJQw35+/JZhnBaQ8=; b=frdFdqqzovnTMJz8yh0Cfg6S7Z xACdCMNVgyq2YZU4CAsQcKh5CkHLZEW6JZTyTccgx5P+eNJl70q9jVWZx+BXLFeVQSI9KbXt/LUah 31Q7rDyQeI7kprITKSWZ9qGPZg2hbThbpKz0IR3NpJCvDXaBALZ0IK4E4riP6Y858ULgt+CZROoJl OrAqVigHgdU5rD42zQVy4a7qkeHLqWCRUMkj1blkYSAr3W46KZBQj4fq+lq+lwsUWV834vvFzrNfk el8ZbmIW1TAutn72CYzTdrx1pctlw4XJpQY11QNLL49IqIv6WsL5v2T+XiNaVCqlylySjVSurfixj n5qwmjTw==; Received: from mail-pl1-f178.google.com ([209.85.214.178]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lddkF-003PvQ-D0; Mon, 03 May 2021 18:56:40 +0000 Received: by mail-pl1-f178.google.com with SMTP id y1so3346659plg.11; Mon, 03 May 2021 11:56:38 -0700 (PDT) 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:references :mime-version:content-disposition:in-reply-to; bh=xN1vIdSdlI8AjiOUn9JP97vsEZYoJQw35+/JZhnBaQ8=; b=L17iPJuBDDJC/4ZVWEMQBcQs6X/UgBCIASLH2U9OmBfSpNTP0IHKvIajbYHzqmimf1 tOfS4+6RzJ7b6PMAXwdTorlAh0/6jDJcbGj2aiCxFV2T/NVcTTPRE1w5kyr7sQyXlv29 DScm13402Qbr1bUTkWIIsrDX/DDtn03xrYKWmubvg1fw3RZBorgXAgTe9GR6z2HIpyw9 fyaiyMaF9kciphViW8k886dnUf4FYJT9jhULorjBnZaAozT27Cg/0d3UTMOjSrpLEa1r c4+rtuHmR35aPxjQyeRE2kr1ps6yEAFFdIZLtM3lcgRmws8bHyTaubFeaG17XzubbHPM N8cQ== X-Gm-Message-State: AOAM532nWK/HIayc6SjFMZeWiTHiegQjvYZlnpJUA72zF7EeMUIYr9r+ GdapMyp6TkokWGQsJWjW1kE= X-Google-Smtp-Source: ABdhPJzpE6dKHGIg9l83NU43eQCArINnQQS5VmcVPnP33/R/FT2AGR213vV7B3JYoJHavMby64GPIQ== X-Received: by 2002:a17:902:8ec1:b029:e9:998d:91f3 with SMTP id x1-20020a1709028ec1b02900e9998d91f3mr21766492plo.59.1620068197546; Mon, 03 May 2021 11:56:37 -0700 (PDT) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id e8sm9539433pfv.177.2021.05.03.11.56.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 11:56:37 -0700 (PDT) Date: Mon, 3 May 2021 11:56:36 -0700 From: Moritz Fischer To: Marc Zyngier Cc: 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 , Bhupesh Sharma , AKASHI Takahiro , kernel-team@android.com Subject: Re: [PATCH 1/2] firmware/efi: Tell memblock about EFI reservations Message-ID: References: <20210429133533.1750721-1-maz@kernel.org> <20210429133533.1750721-2-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210429133533.1750721-2-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210503_115639_467024_048EEA73 X-CRM114-Status: GOOD ( 26.81 ) 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 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; > + } > + } > + > 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; > } > > 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel