Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp209420rdb; Thu, 24 Aug 2023 04:04:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWfHcaIz1wWEpoNgTjP5zcWL5bgHtTrFOLE5+c/6tyVT+ikg/2NaMi0snMzzEzcW5fpSvw X-Received: by 2002:a17:906:32d3:b0:9a1:af6f:e373 with SMTP id k19-20020a17090632d300b009a1af6fe373mr6249908ejk.42.1692875069366; Thu, 24 Aug 2023 04:04:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692875069; cv=none; d=google.com; s=arc-20160816; b=zu2WOWdhsdC/SAEMpN41a9hDkWbWDMtMeWwYY7impS061oLlDjuiQGqoZIAycUK54Q 8mENjFHZQC0aGG8NdDAWHa+luLWK0HGiaqt3bpGSUfctdousIyhATPV8WNpwrEswnrUU R47pvbHMwPigQaeDIA5Pzke5vv8/EtLFYywT0msz0qZJqhVk3ftxHlCq8xx/e2BGEVVK Y4e9nJRt2fUlRwro2I5i5GAU05MKEq1kK5eVqjtkmaLZcGrcMYjxULcnLg/95m1P4A36 QmixD2OtmJXYqqB5u0AI37Jzhfzgy+VXM6Mpa0VMCqiyk9EvFH+pTlqDrbRMxHjFVaX3 pOkw== 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=CvOi81xVN7dLP6TeL6VVcyglyQNPDBw8wk5Sg4PnCr0=; fh=x+pkgqsmNbQ+ZF7WQMSDOwVMFXzET87KYIfpDGvdgtU=; b=iZilI0hJM5a14gdwPBk+pukerOME/dxheHVvRiGDgNWjQSiSywZIGUozGMJy88yGIX 7wRzto/Kb+JxZmVpQLsZe/UKkGNz9fmaalnnv8k5SO/OnnUZcSMzRfxPMcXG1OKPthVO HnjTfZanDlpfzj1XkYXJH6Bswm0taJsgm1llohCOdDEF+JGK6wEs+NPt0prp4EJw6XgQ 3MgCU8QgnMTe4vSkZ8f+URcXw2h72UU5MvEby/rUHsIw9ojatPwDRsJCNsuukhRErRNi /Jx9ZlbgJn9EjpGQCjpLK1r7KeaAAMdl7qpjtAxjPTVEXlKMeFc+GyTp1PawYAOIi5nu O3Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UaCn6ZVe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a17090679c700b0099b42c9082bsi10656539ejo.508.2023.08.24.04.03.58; Thu, 24 Aug 2023 04:04:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UaCn6ZVe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S236119AbjHXJKd (ORCPT + 99 others); Thu, 24 Aug 2023 05:10:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235115AbjHXJKU (ORCPT ); Thu, 24 Aug 2023 05:10:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBAE710FA; Thu, 24 Aug 2023 02:10:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 707C566868; Thu, 24 Aug 2023 09:10:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD22FC433CC; Thu, 24 Aug 2023 09:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692868216; bh=7M2xqO1AKiy66zJXRZ//i4wSn+wQl5CkWQs5eGyEols=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=UaCn6ZVe225sX5NaZDcDs9oSE1RypLFGbrd8IvEqX4ijSeAmZ3YzLv8gd6qDnummg /puBieqcwhAOmigju3arMX+WbVhSc4LDyRHBbP0gNmiyyC7PrBwbD00OKN9C0P7KS/ 9jqBwNUBLvwfKT6JWK5dQNDp7w4k9EiDq062stg9C2K/Acxy0uFEfq+geEWBkOtvUm uTZOGlyET1LWblPQDHjvi7HWVLKiBfZ/zk/lWUDUYdmIH8Rj6l9vgLHp9HpkpKREm1 SuDKv2dc7jNF1S9WJEuw2SL/qIiyxQc3ZylVWFortxNwHyAwPjzjC/BODaAgtPr0CS BiB5qCY5rXIKg== Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-4fe8c16c1b4so10007586e87.2; Thu, 24 Aug 2023 02:10:16 -0700 (PDT) X-Gm-Message-State: AOJu0YzBQjvfjskzy+ei6I7l3x8C9QHkqPpEZRcli6RBX1Hx+33Gd2qB gDX3wziFxF7gACVbLNlDo8J8FDHlHemfO/dsJgg= X-Received: by 2002:a05:6512:2208:b0:4ff:74e2:4268 with SMTP id h8-20020a056512220800b004ff74e24268mr13170713lfu.56.1692868214708; Thu, 24 Aug 2023 02:10:14 -0700 (PDT) MIME-Version: 1.0 References: <20230822203446.4111742-1-sjg@chromium.org> In-Reply-To: From: Ard Biesheuvel Date: Thu, 24 Aug 2023 11:10:03 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/2] schemas: Add a schema for memory map To: Simon Glass Cc: Mark Rutland , devicetree@vger.kernel.org, Rob Herring , Chiu Chasel , U-Boot Mailing List , Gua Guo , linux-acpi@vger.kernel.org, lkml , Yunhui Cui , ron minnich , Tom Rini , Lean Sheng Tan Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 23 Aug 2023 at 22:04, Simon Glass wrote: > > Hi, > > On Wed, 23 Aug 2023 at 08:24, Ard Biesheuvel wrote: > > > > On Wed, 23 Aug 2023 at 10:59, Mark Rutland wrote: > > > > > > On Tue, Aug 22, 2023 at 02:34:42PM -0600, Simon Glass wrote: > > > > The Devicetree specification skips over handling of a logical view of > > > > the memory map, pointing users to the UEFI specification. > > > > > > > > It is common to split firmware into 'Platform Init', which does the > > > > initial hardware setup and a "Payload" which selects the OS to be booted. > > > > Thus an handover interface is required between these two pieces. > > > > > > > > Where UEFI boot-time services are not available, but UEFI firmware is > > > > present on either side of this interface, information about memory usage > > > > and attributes must be presented to the "Payload" in some form. > > > > Not quite. > > > > This seems to be intended for consumption by Linux booting in ACPI > > mode, but not via UEFI, right? > > Actually, this is for consumption by firmware. The goal is to allow > edk2 to boot into U-Boot and vice versa, i.e. provide some > interoperability between firmware projects. I will use the "Platform > Init" and "Payload" terminology here too. > OK. It was the cc to linux-acpi@ and the authors of the ACPI/SMBIOS-without-UEFI patches that threw me off here. If we are talking about an internal interface for firmware components, I'd be inclined to treat this as an implementation detail, as long as the OS is not expected to consume these DT nodes. However, I struggle to see the point of framing this information as a 'UEFI memory map'. Neither EDK2 nor u-boot consume this information natively, and there is already prior art in both projects to consume nodes following the existing bindings for device_type=memory and the /reserved-memory node. UEFI runtime memory is generally useless without UEFI runtime services, and UEFI boot services memory is just free memory. There is also an overlap with the handover between secure and non-secure firmware on arm64, which is also DT based, and communicates available memory as well as RAM regions that are reserved for firmware use. In summary, I don't see why a non-UEFI payload would care about UEFI semantics for pre-existing memory reservations, or vice versa. Note that EDK2 will manage its own memory map, and expose it via UEFI boot services and not via DT. ... > > There is no intent to implement the UEFI spec, here. It is simply that > some payloads (EDK2) are used to having this information. > > Imagine splitting EDK2 into two parts, one of which does platform init > and the other which (the payload) boots the OS. The payload wants > information from Platform Init and it needs to be in a devicetree, > since that is what we have chosen for this interface. So to some > extent this is unrelated to whether you have EFI boot services. We > just need to be able to pass the information across the interface. > Note that the user can (without recompilation, etc.) replace the > second part with U-Boot (for example) and it must still work. > OK, so device tree makes sense for this. This is how I implemented the EDK2 port that targets QEMU/mach-virt - it consumes the DT to discover the UART, RTC,, memory, PCI host bridge, etc. But I don't see a use case for a UEFI memory map here. > > > > > > > > Today Linux does that by passing: > > > > > > /chosen/linux,uefi-mmap-start > > > /chosen/linux,uefi-mmap-size > > > /chosen/linux,uefi-mmap-desc-size > > > /chosen/linux,uefi-mmap-desc-ver > > > > > > ... or /chosen/xen,* variants of those. > > > > > > Can't we document / genericise that? > > That seems to me to be the fields from the EFI memory-map call, but > where is the actual content? I looked in the kernel but it seems to be > an internal interface (between the stub and the kernel)? > > > > > > > > Given the ACPI angle, promoting this to external ABI would introduce a > > DT dependency to ACPI boot. So we'll at least have to be very clear > > about which takes precedence, or maybe disregard everything except the > > /chosen node when doing ACPI boot? > > > > This also argues for not creating an ordinary binding for this (i.e., > > describing it as part of the platform topology), but putting it under > > /chosen as a Linux-only boot tweak. > > > > > Pointing to that rather than re-encoding it in DT means that it stays in-sync > > > with the EFI spec and we won't back ourselves into a corner where we cannot > > > encode something due to a structural difference. I don't think it's a good idea > > > to try to re-encode it, or we're just setting ourselves up for futher pain. > > > > > > > What I would prefer is to formalize pseudo-EFI boot and define the > > bare required minimum (system table + memory map + config tables) in > > an arch-agnostic manner. That way, the only thing that needs to be > > passed via DT/boot_params/etc is the (pseudo-)EFI system table > > address, and everything else (SMBIOS, ACPI as well as the EFI memory > > map and even the initrd) can be passed via config tables as usual, all > > of which is already supported in (mostly) generic kernel code. > > > > Here I believe you are talking about booting the kernel in EFI mode, > but that is not the intent of this patch. This is all about things > happening in firmware. Now, if the payload (second) part of the > firmware decides it wants to offer EFI boot services and boot the > kernel via the EFI stub, then it may very well pack this information > (with a few changes) into a system table and make it available to the > kernel stub. But by then this FDT binding is irrelevant, since it has > served its purpose (which, to reiterate, is to facilitate information > passage from platform init to 'payload'). > Indeed. As long as this binding is never consumed by the OS, I don't have any objections to it - I just fail to see the point.