Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1246721pxv; Fri, 16 Jul 2021 05:13:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxed45NeDU5sYnB+U8Ci0cUuuJIBql/XFxLgGIQUIdLzwJmRinRZFs9QlHkX3LRQnfc2jRu X-Received: by 2002:aa7:ccc1:: with SMTP id y1mr14162186edt.321.1626437590058; Fri, 16 Jul 2021 05:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626437590; cv=none; d=google.com; s=arc-20160816; b=Eo/Gfw5Nh9zuFbR5IOCRwMkG9N771SNq+5A0otq+xOIl608swlwavcZ7oi3L0+gJIn zcVryIy3/hc5Au2Lk34S1qjWd8VjCfMpGcMpEDH2IvEYN+xAr+IaTjNC1XFpRm+W8zWc pz9AOeyJUktlmS/r2VNL0rsejVwoC5qGSn9H0EO3f1Cinz0unEzxORil9BruYdK2Wv2V 9HeMtYNruORn6o7mgy0TVaqctcQPSYcGrK2cpIcxj7lMsqm4eLzwgHIaajN3Cxd9wHd2 7e9nkB2WoTQ5Z2VWAEpVZO3OibBHC6H0RZmBDNfMwlezPvYvYRfaKznPn4JAmCfrXbcD 3Awg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ms8U12gcsIgcJS2U33P+xzGrlcLuh2pLvycQ1z2Lywo=; b=LP+uf83zfmnYCTzasa3DkAdbBWKgFCCfzXs1L3MqiAl38R3fm4EKwJmr5D4BRYElh0 14PMzSIYH4+76Fpdiu/026yV8E7aQOsf/CdbyJkV2l4ULgv8HFR367moZbEBdcVDHjU4 VrHXKL0TqIZCUjtTRDC0mt255p/1eZ/fsWLr5thRfJWlPr0wIqlqLdcCOrCjuFzItKYZ JNaLLiZyMiVbOiUlwzAC+FeAt/JQufApGy9ltA8RIqywM8hUcEEEOof166ghmfHEKU6F 2WbLSbLCeps+Gw/edzVxeCfHXi2UoU6C5KqjjLY2ceSJ6Fpr0olmTQuvrcx2GE4uXNEp 9eew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Orphy0+G; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h20si10700252ejt.70.2021.07.16.05.12.44; Fri, 16 Jul 2021 05:13:10 -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=@kernel.org header.s=k20201202 header.b=Orphy0+G; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232524AbhGPMNW (ORCPT + 99 others); Fri, 16 Jul 2021 08:13:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:36800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232085AbhGPMNU (ORCPT ); Fri, 16 Jul 2021 08:13:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 24EEA6128B; Fri, 16 Jul 2021 12:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626437426; bh=Oi9M1FnUn5e6PKKsPa8PI7WcOoFC+K32ceOQ98rLJCs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Orphy0+GFAEfcVZy9yZqB5p7ky4hLZ0YYs6o9KF+a4klC91YHgFeioM8sIF50dNDG babGnhsvAaKe+6IyFJG/4iFr9v8gRVTSAQNImLrYepIYEMKDbGOgQl74Y4ZB7+lBX8 6XSS1N3N/AI3AdQsgk6YgRVAs0gWxRT0ExVivCvg9w+wfHK1Q6TsJ7jqfSuRouJMGE BvzkXR9Z+amZdh7ob+IRZwn155Oecv4ZZtlTkt2VDNDg6Two0ci5yZHXxzYNsUF/Zf j+jGlftTvI1r6VELV1KgJ2eY+HjQ4JAMppiqqpGOZL/dc5IQ5zHj0C9zwx7VX1L0dj C0TgmpaLF2TlA== Received: by mail-oi1-f182.google.com with SMTP id t25so10588785oiw.13; Fri, 16 Jul 2021 05:10:26 -0700 (PDT) X-Gm-Message-State: AOAM533n644O0UYns/2A5z2NVCoREO9tIylSeKby+xssGCMHiIxX3DgW t/uwlcnjOSUd5Ria26MLIre4+s04OcB+RveUmSQ= X-Received: by 2002:aca:4c49:: with SMTP id z70mr7521680oia.174.1626437425519; Fri, 16 Jul 2021 05:10:25 -0700 (PDT) MIME-Version: 1.0 References: <20210713184326.570923-1-maz@kernel.org> In-Reply-To: <20210713184326.570923-1-maz@kernel.org> From: Ard Biesheuvel Date: Fri, 16 Jul 2021 14:10:14 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] firmware/efi: Tell memblock about EFI iomem reservations To: Marc Zyngier Cc: Linux ARM , Linux Kernel Mailing List , wnliu@google.com, Moritz Fischer , "# 3.4.x" , James Morse , Catalin Marinas , Will Deacon Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 13 Jul 2021 at 20:43, 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. > > 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 Thanks, I'll queue this as a fix. > --- > drivers/firmware/efi/efi.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c > index 4b7ee3fa9224..847f33ffc4ae 100644 > --- a/drivers/firmware/efi/efi.c > +++ b/drivers/firmware/efi/efi.c > @@ -896,6 +896,7 @@ 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) > @@ -908,7 +909,17 @@ 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; > + > + /* > + * 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) > -- > 2.30.2 >