Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp771282rdb; Fri, 22 Dec 2023 04:49:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/0pkKsVjpjFfFPl4tRtU3froLSyDV9qdY/FIIAaExi5/u9NQTMMAqKq2Wh4DvUoeXPEzR X-Received: by 2002:a17:903:22d0:b0:1d0:6ffd:e2d8 with SMTP id y16-20020a17090322d000b001d06ffde2d8mr1519168plg.114.1703249385781; Fri, 22 Dec 2023 04:49:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703249385; cv=none; d=google.com; s=arc-20160816; b=jGyEfliroyD4LprVUSPjq3dpwvXm067fkET6/8OBOVNMdfZsCkzMHKlMf80UcaZvC8 qEkkBrxi7xJguqSf4rR9gICcJsuBUReWEUd6jxD+x7AbG5nf97ZRJl+gWX5wCr8R9H9V VnBZhi/H7Yzii3aMjbCmyDcdXHlHECJLmsyE4IxnLzTg53wUavgU/FR2Gs1sV3J26PCm 1Dcn7xstOOj4qvuK0e8hs5stwOUtzIZS076URZV0EL4CQH+pZdDQ3uRqJwTwlja5/sQc gPdfFrPPf1jIKszeluLt9PXxZMAa9rpsvmLJvOPOSp7r8enLpyJLM528S71/V6VklR+W QqOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=vhZd7o+l6gcbbg1wnj5wE267NGFT2iGah9zGiFUUeLE=; fh=NyNUHU4Hxmi6jizRBZIQ+W9a7KHXMF/Y7tSAnSRNdOk=; b=bjhURl4wPodtQTE7r8m4Vp+geXjM9YuiEKBQOKIQygrwZx6bRUWBOnikoypkO9yTS9 IAxJ4Bd89yK+aw4yFWkR2XSJVqiYY6Cy9LpOliQqbLOpUYTwYq3XRXu//VQGuRSQivTL nmhHg2X/JDAKZz26vyDp9mHwsdm9uoxFtQ6juC+IHmmvCItSUfbbMsc7f8Q5qF8yl9hP oQJiBaQoRhJYCUvK2If4RUxHGDF3ObG5yhmlWehC1sy6JNqMp/fRy3R3s0bDVgrX5b27 ip5aQwfJ/4tZ6mLZ9hOreBVrkp+zXP+5n4emOpRyjcjGucWEUC0bW7XoK3UXd/wjKQr/ kOVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ly4DFqcI; spf=pass (google.com: domain of linux-kernel+bounces-9726-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9726-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ju10-20020a170903428a00b001cff290413bsi3096382plb.390.2023.12.22.04.49.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 04:49:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9726-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ly4DFqcI; spf=pass (google.com: domain of linux-kernel+bounces-9726-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9726-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6A1092819BE for ; Fri, 22 Dec 2023 12:49:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67B3522314; Fri, 22 Dec 2023 12:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ly4DFqcI" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 969C3224DA; Fri, 22 Dec 2023 12:48:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F7EFC433C7; Fri, 22 Dec 2023 12:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703249290; bh=V72pV+EXR1DLsor55xWUV6GPn2LtZ4+S8rLYXyUkQPM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Ly4DFqcIqG575M4GSPA1U0o94smm+XMk0G4zD/WWsU9CsHBfwE9cRLC/eJ+yIDpKa kRUn51b0erGl0TQVk4OADdDjdz1wiRGyy3W2IhDtCOMsmdij34xTGBGkwVxQi2w2B4 qAFfo8IT/8+ENPD84LreX/2MV0BHMb9iaRTDT+L45LITW0LceaLp9tIWGpioXz6iCj XEaKPK2X9CaG7ltMs+ZYZ5Va9tVhFITOASK/kwV0aDpg04xk4HeroBR22dHesvuGiT AwhBlVD2SiQZCUrKJ9zIER8UFCQzliuEqTWWtnqQxwW4lLH3BFLHLa/f9w+ARPDHuL 5Xwn5L/AxeXyw== Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-50e6a5b5e36so530356e87.3; Fri, 22 Dec 2023 04:48:10 -0800 (PST) X-Gm-Message-State: AOJu0Yw+CsDuQulIcuD5+3Iu6C1hv+4vGgBqTjOqa+pJDbswYvzL/sjA 5n6BXNpEM5mlxaB4jVj81HQgQRDjfxqG9Q0xIBA= X-Received: by 2002:ac2:454e:0:b0:50e:384c:289a with SMTP id j14-20020ac2454e000000b0050e384c289amr643501lfm.78.1703249288530; Fri, 22 Dec 2023 04:48:08 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20230926194242.2732127-1-sjg@chromium.org> <20230926194242.2732127-2-sjg@chromium.org> In-Reply-To: From: Ard Biesheuvel Date: Fri, 22 Dec 2023 13:47:57 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 2/2] schemas: Add some common reserved-memory usages To: "Chiu, Chasel" Cc: Simon Glass , "devicetree@vger.kernel.org" , Mark Rutland , Rob Herring , "Tan, Lean Sheng" , lkml , Dhaval Sharma , "Brune, Maximilian" , Yunhui Cui , "Dong, Guo" , Tom Rini , ron minnich , "Guo, Gua" , "linux-acpi@vger.kernel.org" , U-Boot Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 21 Dec 2023 at 17:50, Chiu, Chasel wrote: > > > Hi Ard, > > Please see my reply below inline and let me know your thoughts. > > Thanks, > Chasel > > > > -----Original Message----- > > From: Ard Biesheuvel > > Sent: Thursday, December 21, 2023 6:31 AM > > To: Chiu, Chasel > > Cc: Simon Glass ; devicetree@vger.kernel.org; Mark Ru= tland > > ; Rob Herring ; Tan, Lean Sheng > > ; lkml ; Dhaval > > Sharma ; Brune, Maximilian > > ; Yunhui Cui ; > > Dong, Guo ; Tom Rini ; ron minn= ich > > ; Guo, Gua ; linux- > > acpi@vger.kernel.org; U-Boot Mailing List > > Subject: Re: [PATCH v7 2/2] schemas: Add some common reserved-memory > > usages > > > > On Tue, 28 Nov 2023 at 21:31, Chiu, Chasel wrot= e: > > > > > > > > > > > > > > > > -----Original Message----- > > > > From: Ard Biesheuvel > > > > Sent: Tuesday, November 28, 2023 10:08 AM > > > > To: Chiu, Chasel > > > > Cc: Simon Glass ; devicetree@vger.kernel.org; Mar= k > > > > Rutland ; Rob Herring ; Tan, > > > > Lean Sheng ; lkml > > > > ; Dhaval Sharma = ; > > > > Brune, Maximilian ; Yunhui Cui > > > > ; Dong, Guo ; Tom Rini > > > > ; ron minnich ; Guo, Gua > > > > ; linux- acpi@vger.kernel.org; U-Boot Mailing > > > > List > > > > Subject: Re: [PATCH v7 2/2] schemas: Add some common reserved-memor= y > > > > usages > > > > > > > > You are referring to a 2000 line patch so it is not 100% clear wher= e to look tbh. > > > > > > > > > > > > On Tue, 21 Nov 2023 at 19:37, Chiu, Chasel = wrote: > > > > > > > > > > > > > > > In PR, UefiPayloadPkg/Library/FdtParserLib/FdtParserLib.c, line > > > > > 268 is for > > > > related example code. > > > > > > > > > > > > > That refers to a 'memory-allocation' node, right? How does that > > > > relate to the 'reserved-memory' node? > > > > > > > > And crucially, how does this clarify in which way "runtime-code" an= d > > > > "runtime- data" reservations are being used? > > > > > > > > Since the very beginning of this discussion, I have been asking > > > > repeatedly for examples that describe the wider context in which th= ese > > reservations are used. > > > > The "runtime" into runtime-code and runtime-data means that these > > > > regions have a special significance to the operating system, not > > > > just to the next bootloader stage. So I want to understand exactly > > > > why it is necessary to describe these regions in a way where the > > > > operating system might be expected to interpret this information an= d act > > upon it. > > > > > > > > > > > > > I think runtime code and data today are mainly for supporting UEFI ru= ntime > > services - some BIOS functions for OS to utilize, OS may follow below A= CPI spec to > > treat them as reserved range: > > > https://uefi.org/specs/ACPI/6.5/15_System_Address_Map_Interfaces.html= # > > > uefi-memory-types-and-mapping-to-acpi-address-range-types > > > > > > Like I mentioned earlier, that PR is still in early phase and has not= reflected all > > the required changes yet, but the idea is to build > > gEfiMemoryTypeInformationGuid HOB from FDT reserved-memory nodes. > > > UEFI generic Payload has DxeMain integrated, however Memory Types are > > platform-specific, for example, some platforms may need bigger runtime = memory > > for their implementation, that's why we want such FDT reserved-memory n= ode to > > tell DxeMain. > > > > > > > > The Payload flow will be like this: > > > Payload creates built-in default MemoryTypes table -> > > > FDT reserved-memory node to override if required (this also ensur= es the > > same memory map cross boots so ACPI S4 works) -> > > > Build gEfiMemoryTypeInformationGuid HOB by "platfom specific" > > MemoryTypes Table -> > > > DxeMain/GCD to consume this MemoryTypes table and setup memor= y > > service -> > > > Install memory types table to UEFI system table.Configurati= on table... > > > > > > Note: if Payload built-in default MemoryTypes table works fine for th= e > > > platform, then FDT reserved-memory node does not need to provide such > > 'usage' compatible strings. (optional) This FDT node could allow > > flexibility/compatibility without rebuilding Payload binary. > > > > > > Not sure if I answered all your questions, please highlight which are= a you need > > more information. > > > > > > > The gEfiMemoryTypeInformationGuid HOB typically carries platform defaul= ts, and > > the actual memory type information is kept in a non-volatile EFI variab= le, which > > gets updated when the memory usage changes. Is this different for > > UefiPayloadPkg? > > > > (For those among the cc'ees less versed in EFI/EDK2: when you get the '= config > > changed -rebooting' message from the boot firmware, it typically means = that this > > memory type table has changed, and a reboot is necessary.) > > > > So the platform init needs to read this variable, or get the informatio= n in a > > different way. I assume it is the payload, not the platform init that u= pdates the > > variable when necessary. This means the information flows from payload(= n) to > > platform init(n+1), where n is a monotonic index tracking consecutive b= oots of the > > system. > > > > Can you explain how the DT fits into this? How are the runtime-code and > > runtime-data memory reservation nodes under /reserved-memory used to > > implement this information exchange between platform init and payload? = And > > how do the HOB and the EFI variable fit into this picture? > > > 1. With some offline discussion, we would move gEfiMemoryTypeInformationG= uid usage to FDT->upl-custom node. This is because it is edk2 implementatio= n choice and non-edk2 PlatformInit or Payload may not have such memory opti= mization implementation. (not a generic usage/requirement for PlatformInit = and Payload) > > The edk2 example flow will be like below: > > PlatformInit to GetVariable of gEfiMemoryTypeInformationGuid and create H= ob-> > PlatformInit to initialize FDT->upl-custom node to report gEfiMemoryTyp= eInformationGuid HOB information -> > UefiPayload entry to re-create gEfiMemoryTypeInformationGuid HOB basi= ng on FDT input (instead of the default MemoryType inside UefiPayload) -> > UefiPayload DxeMain/Gcd will consume gEfiMemoryTypeInformationGuid = Hob for memory type information -> > UefiPayload to initialize UEFI environment (mainly DXE dispatcher= ) -> > (additional FV binary appended to common UefiPayload binary) Pl= atformPayload to provide VariableService which is platform specific -> > UefiPayload UefiBootManager will SetVariable if memory type c= hange needed and request a warm reset -> > Back to PlatformInit ... > OK so the upl-custom node can do whatever it needs to. I imagine these will include the memory descriptor attribute field, and other parts that may be missing from the /reserved-memory DT node specification? > > 2. Now the proposed reserved-memory node usages will be for PlatformInit = to provide data which may be used by Payload or OS. This is not edk2 specif= ic and any PlatformInit/Payload could have same support. > Note: all of below are optional and PlatformInit may choose to implement = some of them or not. > > - acpi > If PlatformInit created some ACPI tables, this will report a memory regio= n which contains all the tables to Payload and Payload may base on this to = add some more tables if required. > > - acpi-nvs > If PlatformInit has created some ACPI tables which having ACPI NVS memory= dependency, this will be that nvs region. > These make sense. > - boot-code > When PlatformInit having some FW boot phase code that could be freed for = OS to use when payload transferring control to UEFI OS > > - boot-data > When PlatformInit having some FW boot phase data that could be freed for = OS to use when payload transferring control to UEFI OS. > > - runtime-code > PlatformInit may provide some services code that can be used for Payload = to initialize UEFI Runtime Services for supporting UEFI OS. > > - runtime-data > PlatformInit may provide some services data that can be used for Payload = to Initialize UEFI Runtime Services for supporting UEFI OS. > A UEFI OS must consume this information from the UEFI memory map, not from the /reserved-memory nodes. So these nodes must either not be visible to the OS at all, or carry an annotation that the OS must ignore them. Would it be possible to include a restriction in the DT schema that these are only valid in the firmware boot phase?