From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.13171.1685024875764676407 for ; Thu, 25 May 2023 07:27:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZLmb7yG8; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3E2ED645DC for ; Thu, 25 May 2023 14:27:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A38BCC433EF for ; Thu, 25 May 2023 14:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685024874; bh=TzwR8B04sjhggEltnggrKZnn7ua5zYpcEPZ+Ix5jDXU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZLmb7yG8graW6CQdJA8MzYdvkac3yyAapVxL8CzaKhWtAMIpCA+FhfNdO5TCDx13U NvhY9F0X8Bn4NhwjOaxMf3tgFpLImVVPwp12MlqsLq5WS2w190t253eAHdnrufHwtf dD2xqu31YQZpow/JU3fvQcKQe4jO2MI/VT4K1WLMqQbi6lb4J5QxTSzJ1D3O7jH27v TQvurgSRaUdOWoVJUN1S3Vq5d3/qOPpEaGc4+CPyXm9e3uVZgQa0t8eXr451FgVZsa 76LBinIE0aWYHHQHNI6LPSI5FejAty5mEnqUmVUv3/bmdJHzOqjn+P18TF/IpdwRP5 IljD3lMNjTw6w== Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-4f3edc05aa5so2464939e87.3 for ; Thu, 25 May 2023 07:27:54 -0700 (PDT) X-Gm-Message-State: AC+VfDxX6IQbIqQPWsj8Pe3bs/69keZFVpPTQ/MDxz7zfOfegnnsLGYX /U49XZyRxoiPUBsY3/3kv7FMRFTcKt/UFJqiz2k= X-Google-Smtp-Source: ACHHUZ4YFViLuIW2fxxJP2XnjNQQ5I0SWBKpz/qx/oWohpnkLhdrPtSPGOHwMccrCnwEqyefLyrdwmNN1h7As2BHc7w= X-Received: by 2002:ac2:510e:0:b0:4f4:b28d:73eb with SMTP id q14-20020ac2510e000000b004f4b28d73ebmr3692612lfb.12.1685024872672; Thu, 25 May 2023 07:27:52 -0700 (PDT) MIME-Version: 1.0 References: <20230306173316.10319-1-tphan@ventanamicro.com> <20230306173316.10319-6-tphan@ventanamicro.com> In-Reply-To: From: "Ard Biesheuvel" Date: Thu, 25 May 2023 16:27:41 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH 5/7] OvmfPkg/VirtNorFlashDxe: Not add memory space if it exists To: devel@edk2.groups.io, tphan@ventanamicro.com Cc: michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, sunilvl@ventanamicro.com, git@danielschaefer.me, andrei.warkentin@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 24 May 2023 at 20:13, Tuan Phan wrote: > > > > On Mon, Mar 6, 2023 at 9:53=E2=80=AFAM Ard Biesheuvel w= rote: >> >> On Mon, 6 Mar 2023 at 18:33, Tuan Phan wrote: >> > >> > The flash base address can be added to GCD before this driver run. >> > So only add it if it has not been done. >> > >> >> How do you end up in this situation? >> >> You cannot skip this registration, as it is required to get the region >> marked as EFI_MEMORY_RUNTIME, and without that, EFI variables will be >> broken when running under the OS. > > > Ard, > The patch only skips AddMemorySpace if it is already done in the early SE= C phase for RiscV platform. > The EFI_MEMORY_RUNTIME always be set in the next line with SetMemorySpace= Attributes. > So how does the SEC phase create GCD regions to begin with? This really sounds like there is a problem elsewhere tbh. >> >> > Signed-off-by: Tuan Phan >> > --- >> > OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 25 +++++++++++++++-------= - >> > 1 file changed, 16 insertions(+), 9 deletions(-) >> > >> > diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtN= orFlashDxe/VirtNorFlashDxe.c >> > index f9a41f6aab0f..8875824f3333 100644 >> > --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c >> > +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c >> > @@ -372,10 +372,11 @@ NorFlashFvbInitialize ( >> > IN NOR_FLASH_INSTANCE *Instance >> > ) >> > { >> > - EFI_STATUS Status; >> > - UINT32 FvbNumLba; >> > - EFI_BOOT_MODE BootMode; >> > - UINTN RuntimeMmioRegionSize; >> > + EFI_STATUS Status; >> > + UINT32 FvbNumLba; >> > + EFI_BOOT_MODE BootMode; >> > + UINTN RuntimeMmioRegionSize; >> > + EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc; >> > >> > DEBUG ((DEBUG_BLKIO, "NorFlashFvbInitialize\n")); >> > ASSERT ((Instance !=3D NULL)); >> > @@ -390,13 +391,19 @@ NorFlashFvbInitialize ( >> > // is written as the base of the flash region (ie: Instance->= DeviceBaseAddress) >> > RuntimeMmioRegionSize =3D (Instance->RegionBaseAddress - Instance->= DeviceBaseAddress) + Instance->Size; >> > >> > - Status =3D gDS->AddMemorySpace ( >> > - EfiGcdMemoryTypeMemoryMappedIo, >> > + Status =3D gDS->GetMemorySpaceDescriptor ( >> > Instance->DeviceBaseAddress, >> > - RuntimeMmioRegionSize, >> > - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME >> > + &Desc >> > ); >> > - ASSERT_EFI_ERROR (Status); >> > + if (Status =3D=3D EFI_NOT_FOUND) { >> > + Status =3D gDS->AddMemorySpace ( >> > + EfiGcdMemoryTypeMemoryMappedIo, >> > + Instance->DeviceBaseAddress, >> > + RuntimeMmioRegionSize, >> > + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME >> > + ); >> > + ASSERT_EFI_ERROR (Status); >> > + } >> > >> > Status =3D gDS->SetMemorySpaceAttributes ( >> > Instance->DeviceBaseAddress, >> > -- >> > 2.25.1 >> > >> > >> > >> > ------------ >> > Groups.io Links: You receive all messages sent to this group. >> > View/Reply Online (#100754): https://edk2.groups.io/g/devel/message/10= 0754 >> > Mute This Topic: https://groups.io/mt/97430554/1131722 >> > Group Owner: devel+owner@edk2.groups.io >> > Unsubscribe: https://edk2.groups.io/g/devel/unsub [ardb@kernel.org] >> > ------------ >> > >> > > >=20