Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1929972rdb; Tue, 5 Sep 2023 09:05:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgGf2hwPYUw5Nkk7gTMp42ISPjnJ+tMSyjPRKC/TX6hWhc6FnXT3uF+RwIq6U4S977d/ke X-Received: by 2002:a17:907:a052:b0:9a1:edb0:2a7f with SMTP id gz18-20020a170907a05200b009a1edb02a7fmr234324ejc.6.1693929953943; Tue, 05 Sep 2023 09:05:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693929953; cv=none; d=google.com; s=arc-20160816; b=REfQg7G071z6fIJguV+Veb02zHvdDcHqTJYZ4JoHIIXi04HPSGXJD8bJtMPtwOPygh zmIgfzhmQ3hMoYY0cAAwmzRMnclLOI9cDMJcB7UiEUDFRUUAe2K3ogOBXcXsV/NvsIN5 OZGfITZfSxoLgdjfrty70w4ONhESHA0SonDl213pHs37ab0WB0YiTpf8Fl2BzA9RM6zM pD2gibuzQmRXAQvn8hcoMgPrSp5wpinREraaelQSYZwHFhTcXl7oSbdEUeozEOUxHlq1 ZkjO69C4LFQTqaYbpUKC6eBa+aL1ZCB1ssHRia0CAuCM0aL62eCRJvZgEyQkFgGrjCuk lNzg== 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=VLpJ0By+uggcIhJYmSWnMBNXU1HDxm7Xj4Itea5Fi6Q=; fh=Ca9OyyX+uG/bg0Z/e/G3khtvcViS1P7RwYYOW867td0=; b=q89zw1RVGZcXcsZbberjv7BH9Z/C0axDmBGnvkZrw35NA5YivYclmfI3MW1salzxNc xEy6+Wm+JqK/iPXCgiqTNIPv89y6FnZVuIG+JVzWsT7O9BvwJFTGfRGktubW54zW/sHH M6QQDcFE5CNdn1ySNgfYUjtznToODJNyNJ3y9NbeDaf0BXBst1a2vM5xOZfnTJ6QNVGZ BHzPQS90jqe7xW8ST8YsGeru1f4QZGHMDgOhh0eDYUsMYhtZ8YUGMNA778AOI/8myhsT /5KC0C2k/dINqDgL5Qlz54aXLDok4W+30DZynPRYBneljUppkcxxB2qXCzmRryV/1Hna zPcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XT26yiNU; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k9-20020a170906578900b00978884c2f47si7632153ejq.867.2023.09.05.09.05.48; Tue, 05 Sep 2023 09:05:53 -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=@chromium.org header.s=google header.b=XT26yiNU; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229717AbjIALzU (ORCPT + 10 others); Fri, 1 Sep 2023 07:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231515AbjIALzT (ORCPT ); Fri, 1 Sep 2023 07:55:19 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4836291 for ; Fri, 1 Sep 2023 04:55:15 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-522bd411679so2493318a12.0 for ; Fri, 01 Sep 2023 04:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693569314; x=1694174114; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=VLpJ0By+uggcIhJYmSWnMBNXU1HDxm7Xj4Itea5Fi6Q=; b=XT26yiNUmcFvQj8YcXLhMidXN4oNoaX6SSnEWtUjNJfrzrb2+i9EEByaCpadNzOObX CkLnOTxpKWyAvn4V5saH71L5avAd5f4f2cpXa1CUax6yW69vo/1Sq6Ya/0uyoy4n+9VZ J6a14gZPhokGn53ToZg9a6jsHjtTXdN9N6W2A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693569314; x=1694174114; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VLpJ0By+uggcIhJYmSWnMBNXU1HDxm7Xj4Itea5Fi6Q=; b=TLJwgY97XCTpRCfol6R6lrtM9bW6GYzmvv4o9hKc31Xn3zYLD8S//IKqsrVRpSze8j 2GE529zRcd6dqolYIxu/20fNxi/tcq9savwkE6vBeMO3WUEI6TKj0rlYaoCZk6KRIvfy ekBNzfffT+L0L1Luqx5HKCbCMkohO4PzKTWJeze2O06aHPIFkSG+BMeoBKQspIVZ20NB 5r8R6s8c22reFyQvVdMl1eD92s+mLwrBm8O2m+J7oB+Dy57J0UID3c1cdktxu3fN+NDP nIws87g7P6JPRVWlLuwVC6oojIcRNEFU4aG7Co+9sCtkIohAr+OomNhYoXxyHmuScztF +XnQ== X-Gm-Message-State: AOJu0YwmPkx8tOUbbVkApafvSVf1HjbZPEe++n0/GPOS2tLuSnW3MwPa 6PTbf3+89gUuyvDwyIigBv1BCbpFS069skCnUsoF1Q== X-Received: by 2002:a05:6402:389:b0:523:47b0:9077 with SMTP id o9-20020a056402038900b0052347b09077mr1729490edv.38.1693569313494; Fri, 01 Sep 2023 04:55:13 -0700 (PDT) MIME-Version: 1.0 References: <20230822203446.4111742-1-sjg@chromium.org> In-Reply-To: From: Simon Glass Date: Fri, 1 Sep 2023 05:54:55 -0600 Message-ID: Subject: Re: [PATCH v3 1/2] schemas: Add a schema for memory map To: Ard Biesheuvel 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=-9.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_SPF_WL autolearn=no 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 Hi Ard, On Fri, 1 Sept 2023 at 04:48, Ard Biesheuvel wrote: > > On Fri, 1 Sept 2023 at 03:12, Simon Glass wrote: > > > > Hi Ard, > > > > On Thu, 31 Aug 2023 at 16:39, Ard Biesheuvel wrote: > > > > > > On Fri, 1 Sept 2023 at 00:17, Simon Glass wrote: > > > > > > > > Hi Ard, > > > > > > > > On Thu, 31 Aug 2023 at 15:48, Ard Biesheuvel wrote: > > > > > > > > > > On Thu, 31 Aug 2023 at 21:03, Simon Glass wrote: > > > > > > > > > > > > Hi Ard, > > > > > > > > > > > > On Thu, 31 Aug 2023 at 06:28, Ard Biesheuvel wrote: > > > > > > > > > > > > > > On Wed, 30 Aug 2023 at 23:11, Simon Glass wrote: > > > > > > > > > > > > > > > > Hi Ard, > > > > > > > > > > > > > > > > On Tue, 29 Aug 2023 at 15:32, Ard Biesheuvel wrote: > > > > > > > > > > > > > > > > > > On Tue, 29 Aug 2023 at 21:18, Simon Glass wrote: > > > > > > > > > > > > > > > > > > > > Hi Ard, > > > > > > > > > > > > > > > > > > > > On Thu, 24 Aug 2023 at 03:10, Ard Biesheuvel wrote: > > > > > > > ... > > > > > > > > > > > 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. > > > > > > > > > > > > > > > > > > > > Bear in mind that one or both sides of this interface may be UEFI. > > > > > > > > > > There is no boot-services link between the two parts that I have > > > > > > > > > > outlined. > > > > > > > > > > > > > > > > > > > > > > > > > > > > I don't understand what this means. > > > > > > > > > > > > > > > > > > UEFI specifies how one component invokes another, and it is not based > > > > > > > > > on a DT binding. If the second component calls UEFI boot or runtime > > > > > > > > > services, it should be invoked in this manner. If it doesn't, then it > > > > > > > > > doesn't care about these memory reservations (and the OS will not be > > > > > > > > > booted via UEFI either) > > > > > > > > > > > > > > > > > > So I feel I am missing something here. Perhaps a practical example > > > > > > > > > would be helpful? > > > > > > > > > > > > > > > > Let's say we want to support these combinations: > > > > > > > > > > > > > > > > Platform Init -> Payload > > > > > > > > -------------------------------- > > > > > > > > U-Boot -> Tianocore > > > > > > > > coreboot -> U-Boot > > > > > > > > Tianocore -> U-Boot > > > > > > > > Tianocore -> Tianocore > > > > > > > > U-Boot -> U-Boot > > > > > > > > > > > > > > > > Some of the above things have UEFI interfaces, some don't. But in the > > > > > > > > case of Tianocore -> Tianocore we want things to work as if it were > > > > > > > > Tianocore -> (its own handoff mechanism) Tiancore. > > > > > > > > > > > > > > > > > > > > > > If Tianocore is the payload, it is either implemented as a EFI app, in > > > > > > > which case it has access to EFI services, or it is not, in which case > > > > > > > it doesn't care about UEFI semantics of the existing reserved regions, > > > > > > > and it only needs to know which regions exist and which of those are > > > > > > > reserved. > > > > > > > > > > > > > > And I think the same applies to all other rows in your table: either > > > > > > > the existence of UEFI needs to be carried forward, which needs to be > > > > > > > done via EFI services, or it doesn't, in which case the UEFI specific > > > > > > > reservations can be dropped, and only reserved and available memory is > > > > > > > relevant. > > > > > > > > > > > > > > > Some Platform Init may create runtime code which needs to accessible later. > > > > > > > > > > > > > > > > > > > > > > But not UEFI runtime code, right? If the payload is not UEFI based, > > > > > > > the OS would never be able to call that runtime code unless it is > > > > > > > described in a different, non-UEFI way. This is fine, but it is not > > > > > > > UEFI so we shouldn't call it UEFI runtime memory. > > > > > > > > > > > > > > > The way I think of it is that we need to generalise the memory map a > > > > > > > > bit. Saying that you must use UEFI boot services to discover it is too > > > > > > > > UEFI-specific. > > > > > > > > > > > > > > > > > > > > > > What I am questioning is why a memory map with UEFI semantics is even > > > > > > > relevant when those boot services do not exist. > > > > > > > > > > > > > > Could you be more specific about why a payload would have to be aware > > > > > > > of the existence of UEFI boot/runtime service regions if it does not > > > > > > > consume the UEFI interfaces of the platform init? And if the payload > > > > > > > exposes UEFI services to the OS, why would it consume a memory map > > > > > > > with UEFI semantics rather than a simple list of memblocks and memory > > > > > > > reservations? > > > > > > > > > > > > It seems like you are thinking of the Payload as grub, or something > > > > > > like that? This is not about grub. If there are EFI boot services to > > > > > > be provided, they are provided by the Payload, not Platform Init. I am > > > > > > not that familiar with Tianocore, but if you are, perhaps think of it > > > > > > as splitting Tianocore into two pieces, one of which inits the silicon > > > > > > and the other which provides the EFI boot services. > > > > > > > > > > > > Again, if you are familiar with Tianocore, it can be built either as a > > > > > > monolithic whole, or as a coreboot Payload. The Payload part of the > > > > > > code is (roughly) the same in each case. But the Platform Init is > > > > > > different[1] > > > > > > > > > > > > > > > > I co-maintain OVMF [including the ARM port that I created from > > > > > scratch] as well as the ARM architecture support in Tianocore, along > > > > > with a couple of platform ports for ARM boards, some of which could by > > > > > now be characterized as 'historical' (AMD Seattle, Socionext SynQuacer > > > > > and Raspberry Pi 3/4). So I think I have a pretty good handle on how > > > > > Tianocore based firmware is put together. > > > > > > > > > > Tianocore as a payload will expose boot services to the OS, and will > > > > > provide the OS with a memory map using the UEFI APIs. But you still > > > > > haven't explained why the memory description this Tianocore inherits > > > > > from the Platform Init would include any UEFI boot or runtime service > > > > > regions, or any of the other memory regions with UEFI semantics. > > > > > TIanocore just needs to know a) where memory lives b) which parts of > > > > > it are already in use (as far as the memory map is concerned), and the > > > > > existing bindings suffice for this purpose. > > > > > > > > > > In short, the memory regions with UEFI semantics are created by the > > > > > boot phase that actually exposes UEFI to the OS, in which case the > > > > > boot services can be used to obtain the memory map. If the consumer is > > > > > not UEFI based, there is no reason to bother it with descriptions of > > > > > memory regions that have no significance to it. > > > > > > > > But aren't you assuming that the Payload knows how to handle the > > > > hardware and can implement the runtime services? What if (for example) > > > > powering off the device is hardware-specific and only Platform Init > > > > knows how? > > > > > > > > > > If the payload relies on the platform init for anything, it can use > > > whichever interface those components manage to agree on. > > > > > > If this interface is UEFI, the payload can use UEFI to obtain the memory map. > > > > I think you are still getting mixed up with grub. Platform Init does > > not necessarily provide EFI boot services, even for Tianocore. It is > > the Payload which provides those services. In other words, the second > > half of Tianocore does not use EFI boot services to talk to the first > > half. > > > > I might be misunderstanding your examples, as they are somewhat vague > and hypothetical. > > Drawing from my experience working on Tianocore, allow me to give a > few examples myself: > - ArmVirtQemu (ARM port of OVMF) receives information about system RAM > via memory nodes in the device tree, using device_type=memory, from > QEMU, which fulfills the role of platform init in this case. > ArmVirtQemu currently doesn't consume the /reserved-memory node as > QEMU does not populate it, but that would be the appropriate place to > document RAM regions that Tianocore must treat as reserved; > - DeveloperBox [0] (based on Socionext SynQuacer) receives a platform > specific struct with memory regions and reservations in a patch of > SRAM that the early Tianocore code uses for stack and heap. Note that > system RAM is not available yet at this point (as it is being > discovered via this mechanism) and SRAM is quite tight, so DT is not > an option here; > - The Tianocore port for Raspberry Pi 4 [1] receives RAM information > from the VideoCore firmware by calling the mailbox interface. This > covers both available memory and reserved memory (for the GPU). The > statically allocated TF-A code and data regions that reside in > non-secure DRAM on this platform are reserved implicitly due to the > fact that they are part of the same firmware image, which knows not to > step on itself. > > In none of these cases, I see a need for the binding that you propose. > Platfom Init -> Payload handover is highly platform specific, so > adding another generic DT binding for an as yet unidentified use case > seems seems premature at the very least. I am working with the Tiancocore people and volunteered to submit this binding on their behalf. I did try suggesting it was not needed, but it seems that it is. > > [0] https://github.com/tianocore/edk2-platforms/tree/master/Platform/Socionext/DeveloperBox > [1] https://github.com/tianocore/edk2-platforms/tree/master/Platform/RaspberryPi/RPi4 > > > > > > > If this interface is not UEFI, the UEFI memory map is irrelevant, and > > > existing DT bindings are available that can describe this information. > > > > Can you please point me to those? > > > > The /memory node is documented in the DT specification. The > /reserved-memory node is documented here: > > Documentation/devicetree/bindings/reserved-memory/reserved-memory.yaml OK, so I think we have reached a conclusion here. > > > > > > > > On another track, would it help if we just dropped all mention of > > > > UEFI? The binding does not mention it. > > > > > > > > > > Your binding has > > > > > > + usage: > > > + $ref: /schemas/types.yaml#/definitions/string > > > + description: | > > > + Describes the usage of the memory region, e.g.: > > > + > > > + "acpi-reclaim", "acpi-nvs", "bootcode", "bootdata", "bootdata", > > > + "runtime-code", "runtime-data". > > > + > > > + See enum EFI_MEMORY_TYPE in "Unified Extensible Firmware Interface > > > + (UEFI) Specification" for all the types. For now there are not > > > + listed here. > > > > > > Every type listed is derived from a definition in the UEFI spec, which > > > is specifically mentioned as the source. > > > > Yes, but please see the v4 or v5 patch version, where that has > > changed. I sent v4 two days ago. I am worried that you are still > > responding to something that I revised in response to your original > > comments? > > > > No, I haven't looked at those yet. Maybe the uboot community is > different, but in the Linux community, we tend to finish discussing vN > of a series before sendindg out vN+1. This prevents the kind of > parallel track discussions that seem to be taking place here. Also, it > is highly appreciated when an author takes all feedback into account > (or at least acknowledges it) in a vN+1 submission, which is difficult > to do before the discussion around vN has concluded. OK. I tend to react to feedback and try to rework my patches accordingly. > > ... > > > > > > But if the Platform Init wants to reserve some system RAM for runtime > > > code (e.g., for its PSCI implementation on ARM), it can add it to the > > > /reserved-memory node, where both the payload and the OS will be able > > > to find it if needed. > > > > OK good. So with my binding that would be 'runtime-code@...'. I am > > still not sure what the problem is here. > > > > The problem is that you are not using /reserved-memory to describe a > memory reservation but something new that all DT consumers need to be > taught about, or they might step on memory that turns out to be > reserved. The DT ecosystem is large and heterogeneous, and any tool or > boot stage in existence is at the risk of stepping on this memory > inadvertently, whereas /reserved-memory already provides the means to > reserve it and document its nature. > > > > > > > > I'm just not sure that Platform Init and Payload are as completely > > > > independent as you seem to be suggesting. Once we get into the > > > > Payload, the only things we know are what Platform Init told us. > > > > > > > > > > They are not independent, and that is not at all what I am claiming. > > > > > > What I am objecting to is framing the platform init<->payload memory > > > handover in terms of UEFI memory types, which may conflict with well > > > established DT bindings that already serve the same purpose. The only > > > difference between /reserved-memory and this binding seems to be the > > > collection of UEFI memory types, which don't belong there in the first > > > place. > > > > OK, so please help me get this resolved. > > > > I have already indicated how this should be resolved in my opinion, > which is by using the /reserved-memory node to describe memory > reservations, and not this binding. OK, that is the direction I took from Rob's email a week ago. Let's continue any discussion on the v5 series. Regards, Simon