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.web10.46505.1685355450083660571 for ; Mon, 29 May 2023 03:17:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mYq6bfQY; 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 900C661362; Mon, 29 May 2023 10:17:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94F91C4339E; Mon, 29 May 2023 10:17:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685355449; bh=1h6GrSrZfcPeW1WMvT2gx7Sy4MgaDf09z4U8NbGxzo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mYq6bfQYgmT7Sf6GkEhZTGA69E5h4xfqWdS+KfBE5obHnpS4oTc9SbrlPaHOMxNzo zgQfu17NMUHx2nhdPSGOWzOwcXl7j/GtcjZ3D14Ktly6+AA4WHflxUBP1pziEOw3Xc rOnu8ej2xkZ0BmSGuQItqp+ve7/MWsyOQIdsqiGoVGpTBVnEf8WkZvCAh/H2JlFMcM gNeuZBDhOTNLBsu020jr0px3P/Y89vH9TuGasxpKQNBw6wrobUeKOv9v5NQwGQ8r3l JQhgimilbl57Sbjl/JdLIeqdrTX8KVVwxDlORfcAEP5aQ1BJwUVEJ9Ukoq/1E2X30c A7utiVVg1cnHg== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Ray Ni , Jiewen Yao , Gerd Hoffmann , Taylor Beebe , Oliver Smith-Denny , Dandan Bi , Liming Gao , "Kinney, Michael D" , Leif Lindholm , Michael Kubacki Subject: [RFC PATCH 04/11] MdeModulePkg/DxeCore: Avoid caching memory mapped FFS files Date: Mon, 29 May 2023 12:16:58 +0200 Message-Id: <20230529101705.2476949-5-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230529101705.2476949-1-ardb@kernel.org> References: <20230529101705.2476949-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable If a firmware volume is memory mapped, it means we can access it contents directly, and so caching serves little purpose beyond potentially a minor performance improvement. However, given that most files are read only a single time, and dispatched from a decompressed firmware volume in DRAM, we can just avoid the redundant caching here. Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c | 22 -------------------- 1 file changed, 22 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c b/MdeModulePkg/Core/Dx= e/FwVol/FwVolRead.c index 2ff22c93aad48d7e..69df96685d680868 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c @@ -284,7 +284,6 @@ FvReadFile ( UINT8 *SrcPtr;=0D EFI_FFS_FILE_HEADER *FfsHeader;=0D UINTN InputBufferSize;=0D - UINTN WholeFileSize;=0D =0D if (NameGuid =3D=3D NULL) {=0D return EFI_INVALID_PARAMETER;=0D @@ -316,27 +315,6 @@ FvReadFile ( // Get a pointer to the header=0D //=0D FfsHeader =3D FvDevice->LastKey->FfsHeader;=0D - if (FvDevice->IsMemoryMapped) {=0D - //=0D - // Memory mapped FV has not been cached, so here is to cache by file.= =0D - //=0D - if (!FvDevice->LastKey->FileCached) {=0D - //=0D - // Cache FFS file to memory buffer.=0D - //=0D - WholeFileSize =3D IS_FFS_FILE2 (FfsHeader) ? FFS_FILE2_SIZE (FfsHead= er) : FFS_FILE_SIZE (FfsHeader);=0D - FfsHeader =3D AllocateCopyPool (WholeFileSize, FfsHeader);=0D - if (FfsHeader =3D=3D NULL) {=0D - return EFI_OUT_OF_RESOURCES;=0D - }=0D -=0D - //=0D - // Let FfsHeader in FfsFileEntry point to the cached file buffer.=0D - //=0D - FvDevice->LastKey->FfsHeader =3D FfsHeader;=0D - FvDevice->LastKey->FileCached =3D TRUE;=0D - }=0D - }=0D =0D //=0D // Remember callers buffer size=0D --=20 2.39.2