Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3679942pxv; Mon, 26 Jul 2021 09:15:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypyekmQIRgXOBAxOP4xaL1OVHr1U8OTXv/ZJgClCjdF6Dp6hMFx9xTuNdeefbt7UyOEzLq X-Received: by 2002:aa7:d703:: with SMTP id t3mr22360647edq.50.1627316116370; Mon, 26 Jul 2021 09:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627316116; cv=none; d=google.com; s=arc-20160816; b=qB/9kRvzODYSa6yVXVVxJ89Kg1yjQGu9/nRAK9v2b8iEWQDPqxTwU6xv7Thwa95c8A PibW865dPmKKftKs+/cajI6wzD70tSxD9YYV6hQXw7OCqiIeVH/wGAsQgjT1kdqQV5yn +iMwSc6/gqzv5yBCnaQqTOtzd4b83xhsVVdf9RgcdtNzaNJyC5eMwngc4+uPGRR+nRcV 6P8hcfqsSM8ARSV9VgK0EIvchP/twXemCXFqPyaIfGTZHPnpq3eyz1ZVDv/7B+0yhkWm 01nAZJjxqPKQQgXdTdoId9bp9C3vXjoVp/ZjNsY5B3smrTDZDzpCpEopLPTC+IQEVEeG kxYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VsBhsxbHUfSbPV3x+L8KlRRGRQMIqj/wrYcXIO2ZT0w=; b=AhmZr0ySz4Y5qW4xciNJJW68UXpF/TBbh9oQh2ex/7811dfHrYOsXaEMXAUN1L76nI S/ujnIlea2LMq/MBBpcNSeVAdDbu0RPkz+cR8odmLfZMEm8rvoc9DzMUsXm3VW5mHdKl MnQXXFuPnUctw8PSSnkrhMqBKhrPfM00e8TVIvOqXtmxIQrkEQPn3UmmMlA5sCUGxWtr c9k8qwQ3NZFoJqv1JrZ2oCb7+s+QjSbuJygXrgnIAsRnIhQrbSI7nZYN7gx9UkmXHrdN n9WkMYUG1kY0OtXvIttJCJIY8YvR03+PjXVX20k/7V6Hex3brU0IFwCHwalxS61pVuE3 yjYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qQIfDryI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l27si286226eja.265.2021.07.26.09.14.46; Mon, 26 Jul 2021 09:15:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qQIfDryI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233768AbhGZPci (ORCPT + 99 others); Mon, 26 Jul 2021 11:32:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:59020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236483AbhGZPSX (ORCPT ); Mon, 26 Jul 2021 11:18:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5EB8860F38; Mon, 26 Jul 2021 15:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315131; bh=lzQKPoo8QqXewdWrppWK3ujm6LJ1rxUUg35ItxCMLk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qQIfDryIELRiHvjfzZ+XAYpEjn+F9k0/cylEe4mXJaCXIDW0wcBhofj38wJOsIGZP JLLeg4Y8mFy/MKRSjyz/D2yjo8QZCBc8EsowuzCmuB34BTc4NzUHTIvSC++k0RQvNi VaFZb0drMqeoZJHEeeadiHxw5psI4IMeQlADOdEE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moritz Fischer , Marc Zyngier , Ard Biesheuvel , James Morse , Catalin Marinas , Will Deacon Subject: [PATCH 5.4 088/108] firmware/efi: Tell memblock about EFI iomem reservations Date: Mon, 26 Jul 2021 17:39:29 +0200 Message-Id: <20210726153834.498521607@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit 2bab693a608bdf614b9fcd44083c5100f34b9f77 upstream. 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. Reported-by: Moritz Fischer Tested-by: Moritz Fischer Signed-off-by: Marc Zyngier Cc: stable@vger.kernel.org Cc: Ard Biesheuvel Cc: James Morse Cc: Catalin Marinas Cc: Will Deacon Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/efi.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -975,6 +975,7 @@ static int __init efi_memreserve_map_roo 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) @@ -987,7 +988,17 @@ static int efi_mem_reserve_iomem(phys_ad /* 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; + + /* + * 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); + + return ret; } int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size)