Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp33326pxj; Wed, 9 Jun 2021 15:41:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMVhJeBhMgJJDOVoMSVsPK8fA+86J0lpysanP4VYuHk1fP51jrxmfCiWfT9oUguz2bzFLC X-Received: by 2002:a17:906:7f8d:: with SMTP id f13mr1828482ejr.272.1623278490724; Wed, 09 Jun 2021 15:41:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278490; cv=none; d=google.com; s=arc-20160816; b=oiPYMHkFbu8sx+ZcdXGHVe/NXUIGxjZ3ylo0GLCotx2i09GVcIno6yCcw9brdoZrzC 57c8Xo8CEcuCGMaSK9QWBeM03CaIaLydiuBTFATO1Gqjj73Fd1ofAa+FwW7zh5650BQm ZxY+vAu9StXwh0CA7eM7hXCi05GLghou7j8nYLDp2o5y51FpCNK+k9gQftfZs/6W/Bq+ WRtO1RMIzGGCX+18iZeknBuAk0PgD/IVxGL0+o3IOGoM7KIeMKq50+uZmxaEt77r2l+s c+xX1+6gNcA4vujYtr49vfRFG19fXpv7MKelZSbyzEr0cQcJq2dK23rj5aAZkeW+uQZB vOHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=y9rdhpixbvXKHcp1SoNHlksJfvedlhffce9YZeswBsw=; b=BjM+NpV0wgjBkEBZyZ9Ruwhr106s52EfqaW2tDvUpowXkEA8KGN/SDDwjF7gfOJAkV 97coPWSRuD1jN5Eme9P+FGTP3bQsDkyeV4fW8h33/RJ6TodsNW5j6ftYSQN5LxlZNhaA yjPPvAh1gWGN/nilLq+4O5EDEzDJYQUbJ6jEd1KOU3OFmgrC7m748i+VWjUrznCIiNrz sM98jenPHakA1tAFEAPBb4wpI4m0BavgUDc41GdL4oWVHh3BXUtgPvJNravVA3HfiNQJ wXLF/3M0KJTRqJc0LIZ4TJKbnH/sWEpdL+wmPoxj8hjdNXvaj4UczJR7krZy2hd+Cc5F +jMg== ARC-Authentication-Results: i=1; mx.google.com; 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 c11si724009edt.322.2021.06.09.15.41.07; Wed, 09 Jun 2021 15:41:30 -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; 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 S229937AbhFIWmE (ORCPT + 99 others); Wed, 9 Jun 2021 18:42:04 -0400 Received: from mail-pj1-f49.google.com ([209.85.216.49]:37659 "EHLO mail-pj1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbhFIWmD (ORCPT ); Wed, 9 Jun 2021 18:42:03 -0400 Received: by mail-pj1-f49.google.com with SMTP id 22-20020a17090a0c16b0290164a5354ad0so2543582pjs.2 for ; Wed, 09 Jun 2021 15:39:58 -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=y9rdhpixbvXKHcp1SoNHlksJfvedlhffce9YZeswBsw=; b=MtTK0KJ8yAYcF4quExqWPudXFZ1/i0Klpp5YhRzZFZ+l9NbCP0UAESHDbGtK3L9X5w stFYBP3eg1zk5pBuP3f6pKtHD2tJieDyUbmwP5VEozD5qyWYNLQ2jEp62ocTeGDMRWeO /39wR9tAKk8kBPFhE2RlWGybvH1w/JbIC8Hbi07QFKprTZy3IOqnUfu4DS313FN4pBtz e0SRNtR5sLPmrUMinlZ2C8XXHNBvL0N51huEeaMPB9JKDBERJ4IHzLJ2VJItdnmPfeYE aRe2K7IDdFBBDoZi+ruh+qf3QxkNmIYYo2XyH9+SEqez+g4y0haKF3/Mst9SUUgN9Kfw l1jQ== X-Gm-Message-State: AOAM530t4wFUBnApFj8ooMg4z/5o310IkcjE2RyAjByY8jpv3n0EFXQu KjayaZx47KdO3dx1JCjIckk= X-Received: by 2002:a17:90a:31c4:: with SMTP id j4mr13156394pjf.105.1623278398559; Wed, 09 Jun 2021 15:39:58 -0700 (PDT) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id r19sm470332pfh.152.2021.06.09.15.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:39:58 -0700 (PDT) Date: Wed, 9 Jun 2021 15:39:57 -0700 From: Moritz Fischer To: James Morse Cc: Marc Zyngier , kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , Ard Biesheuvel , Mark Rutland , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , Eric Biederman , Bhupesh SHARMA , AKASHI Takahiro , Dave Young , Andrew Morton , Moritz Fischer , kernel-team@android.com Subject: Re: [PATCH v2 0/5] arm64: Make kexec_file_load honor iomem reservations Message-ID: References: <20210531095720.77469-1-maz@kernel.org> <41ac1e4b-3779-4cb2-5b64-d638521e67c1@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41ac1e4b-3779-4cb2-5b64-d638521e67c1@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi James, Marc On Fri, Jun 04, 2021 at 05:20:38PM +0100, James Morse wrote: > Hi Marc, > > On 31/05/2021 10:57, Marc Zyngier wrote: > > This series is a complete departure from the approach I initially sent > > almost a month ago[0]. Instead of trying to teach EFI, ACPI and other > > subsystem to use memblock, I've decided to stick with the iomem > > resource tree and use that exclusively for arm64. > > > This means that my current approach is (despite what I initially > > replied to both Dave and Catalin) to provide an arm64-specific > > implementation of arch_kexec_locate_mem_hole() which walks the > > resource tree and excludes ranges of RAM that have been registered for > > any odd purpose. This is exactly what the userspace implementation > > does, and I don't really see a good reason to diverge from it. > > Because in the ideal world we'd have only 'is it reserved' list to check against. > Memblock has been extended before. The resource-list is overly stringy, and I'm not sure > we can shove everything in the resource list. > > Kexec already has problems on arm64 with memory hotplug. Fixing this for regular kexec in > /proc/iomem was rejected, and memblock's memblock_is_hotpluggable() is broken because > free_low_memory_core_early() does this: > | memblock_clear_hotplug(0, -1) > > Once that has been unpicked its clear kexec_file_load() can use > memblock_is_hotpluggable(). (its on the todo list, well, jira) > > > I'd prefer to keep kexec using memblock because it _shouldn't_ change after boot. Having > an "I want to reserve this and make it persistent over kexec" call that can happen at any > time can't work if the kexec image has already been loaded. > Practically, once user-space has started, you can't have new things you want to reserve > over kexec. > > > I don't see how the ACPI tables can escape short of a firmware bug. Could someone with an > affected platform boot with efi=debug and post the EFI memory map and the 'ACPI: FOO > 0xphysicaladdress' stuff at the top of the boot log? > > > efi_mem_reserve_persistent() has one caller for the GIC ITS stuff. > > For the ITS, the reservations look like they are behind irqchip_init(), which is well > before the arch_initcall() that updates the resource tree from memblock. Your v1's first > patch should be sufficient. > > > > Again, this allows my Synquacer board to reliably use kexec_file_load > > with as little as 256M, something that would always fail before as it > > would overwrite most of the reserved tables. > > > > Although this series still targets 5.14, the initial patch is a > > -stable candidate, and disables non-kdump uses of kexec_file_load. I > > have limited it to 5.10, as earlier kernels will require a different, > > probably more invasive approach. > > > > Catalin, Ard: although this series has changed a bit compared to v1, > > I've kept your AB/RB tags. Should anything seem odd, please let me > > know and I'll drop them. > > > Thanks, > > James > > > [0] I'm pretty sure this is enough. (Not tested) > diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c > index 4b7ee3fa9224..3ed45153ce7f 100644 > --- a/drivers/firmware/efi/efi.c > +++ b/drivers/firmware/efi/efi.c > @@ -893,7 +893,7 @@ static int __init efi_memreserve_map_root(void) > return 0; > } > > -static int efi_mem_reserve_iomem(phys_addr_t addr, u64 size) > +static int __efi_mem_reserve_iomem(phys_addr_t addr, u64 size) > { > struct resource *res, *parent; > > @@ -911,6 +911,16 @@ static int efi_mem_reserve_iomem(phys_addr_t addr, u64 size) > return parent ? request_resource(parent, res) : 0; > } > > +static int efi_mem_reserve_iomem(phys_addr_t addr, u64 size) > +{ > + int err = __efi_mem_reserve_iomem(addr, size); > + > + if(IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK) && !err) > + memblock_reserve(addr, size); > + > + return err; > +} > + > int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size) > { > struct linux_efi_memreserve *rsv; Sorry for the long radio silence. Just got around to testing this. I can confirm that the above change James proposed does work on the platform that the issue was first observed on. Cheers, Moritz