From nobody Thu May 2 11:27:59 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1495120491454288.4655967261118; Thu, 18 May 2017 08:14:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 52B402195FD6D; Thu, 18 May 2017 08:14:48 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B59B821AEBAC8 for ; Thu, 18 May 2017 08:14:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 29CDD80487; Thu, 18 May 2017 15:14:46 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-86.phx2.redhat.com [10.3.116.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52CDF8186D; Thu, 18 May 2017 15:14:44 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 29CDD80487 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 29CDD80487 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 18 May 2017 17:14:32 +0200 Message-Id: <20170518151436.16566-2-lersek@redhat.com> In-Reply-To: <20170518151436.16566-1-lersek@redhat.com> References: <20170518151436.16566-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 18 May 2017 15:14:46 +0000 (UTC) Subject: [edk2] [PATCH v2 1/5] OvmfPkg/EmuVariableFvbRuntimeDxe: strip trailing whitespace X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Regression-tested-by: Gary Lin --- Notes: v2: - no changes - add Gary's R-t-b OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h | 16 +++---- OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c | 44 ++++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h b/OvmfPkg/EmuVariableFv= bRuntimeDxe/Fvb.h index f34fad2cdd48..4247d21d72f8 100644 --- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h +++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h @@ -1,18 +1,18 @@ /*++ =20 Copyright (c) 2006, Intel Corporation. All rights reserved.
-This program and the accompanying materials =20 -are licensed and made available under the terms and conditions of the BSD = License =20 -which accompanies this distribution. The full text of the license may be = found at =20 -http://opensource.org/licenses/bsd-license.php = =20 - = =20 -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, = =20 -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. =20 +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD = License +which accompanies this distribution. The full text of the license may be = found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. =20 Module Name: =20 FwBlockService.h - =20 + Abstract: =20 Firmware volume block driver for Intel Firmware Hub (FWH) device diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c b/OvmfPkg/EmuVariableFv= bRuntimeDxe/Fvb.c index 9f9babc9cc33..30f69b999ab0 100644 --- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c +++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c @@ -120,14 +120,14 @@ FvbVirtualAddressChangeEvent ( only for memory-mapped firmware volumes. =20 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instan= ce. - =20 + @param Address Pointer to a caller-allocated EFI_PHYSICAL_ADDRESS that, on successful return from GetPhysicalAddress(), contains the base address of the firmware volume. - =20 + @retval EFI_SUCCESS The firmware volume base address is returned. - =20 + @retval EFI_NOT_SUPPORTED The firmware volume is not memory mapped. =20 **/ @@ -168,9 +168,9 @@ FvbProtocolGetPhysicalAddress ( blocks in this range have a size of BlockSize. =20 - =20 + @retval EFI_SUCCESS The firmware volume base address is retu= rned. - =20 + @retval EFI_INVALID_PARAMETER The requested LBA is out of range. =20 **/ @@ -246,7 +246,7 @@ FvbProtocolGetAttributes ( settings of the firmware volume. Type EFI_FVB_ATTRIBUTES_2 is defined in EFI_FIRMWARE_VOLUME_HEADER. - =20 + @retval EFI_SUCCESS The firmware volume attributes were return= ed. =20 @retval EFI_INVALID_PARAMETER The attributes requested are in @@ -302,7 +302,7 @@ FvbProtocolSetAttributes ( =20 @retval EFI_SUCCESS The erase request was successfully completed. - =20 + @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state. @retval EFI_DEVICE_ERROR The block device is not functioning @@ -311,7 +311,7 @@ FvbProtocolSetAttributes ( partially erased. @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable argument list do - not exist in the firmware volume. =20 + not exist in the firmware volume. =20 **/ EFI_STATUS @@ -420,29 +420,29 @@ FvbProtocolEraseBlocks ( returns. =20 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instan= ce. - =20 + @param Lba The starting logical block index to write to. - =20 + @param Offset Offset into the block at which to begin writing. - =20 + @param NumBytes Pointer to a UINTN. At entry, *NumBytes contains the total size of the buffer. At exit, *NumBytes contains the total number of bytes actually written. - =20 + @param Buffer Pointer to a caller-allocated buffer that contains the source for the write. - =20 + @retval EFI_SUCCESS The firmware volume was written successfully. - =20 + @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary. On output, NumBytes contains the total number of bytes actually written. - =20 + @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state. - =20 + @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not be written. =20 @@ -503,7 +503,7 @@ FvbProtocolWrite ( aware that a read may be partially completed. =20 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instan= ce. - =20 + @param Lba The starting logical block index from which to read. =20 @@ -519,15 +519,15 @@ FvbProtocolWrite ( =20 @retval EFI_SUCCESS The firmware volume was read successfully and contents are in Buffer. - =20 + @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA boundary. On output, NumBytes contains the total number of bytes returned in Buffer. - =20 + @retval EFI_ACCESS_DENIED The firmware volume is in the ReadDisabled state. - =20 + @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be read. @@ -715,9 +715,9 @@ InitializeFvAndVariableStoreHeaders ( /** Main entry point. =20 - @param[in] ImageHandle The firmware allocated handle for the EFI imag= e. =20 + @param[in] ImageHandle The firmware allocated handle for the EFI imag= e. @param[in] SystemTable A pointer to the EFI System Table. - =20 + @retval EFI_SUCCESS Successfully initialized. =20 **/ --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 11:27:59 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1495120495664537.8122438308337; Thu, 18 May 2017 08:14:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8D1A52195FD4A; Thu, 18 May 2017 08:14:50 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1B4852195FD78 for ; Thu, 18 May 2017 08:14:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 88E7340F17; Thu, 18 May 2017 15:14:48 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-86.phx2.redhat.com [10.3.116.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAE1A80E62; Thu, 18 May 2017 15:14:47 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 88E7340F17 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 88E7340F17 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 18 May 2017 17:14:33 +0200 Message-Id: <20170518151436.16566-3-lersek@redhat.com> In-Reply-To: <20170518151436.16566-1-lersek@redhat.com> References: <20170518151436.16566-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 18 May 2017 15:14:48 +0000 (UTC) Subject: [edk2] [PATCH v2 2/5] OvmfPkg/EmuVariableFvbRuntimeDxe: change block size to 4KB X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" EmuVariableFvbRuntimeDxe currently produces a Firmware Volume Block protocol that is based on a block map of two blocks, each block having PcdFlashNvStorageFtwSpareSize for size. (The total size is 2 * PcdFlashNvStorageFtwSpareSize.) FaultTolerantWriteDxe in turn expects the block size to be a power of two. In the 4MB build of OVMF, PcdFlashNvStorageFtwSpareSize is 264KB, which is not a power of two. In order to equip EmuVariableFvbRuntimeDxe for this build, shrink the block size to 4KB (EFI_PAGE_SIZE), and grow the block count from 2 to EFI_SIZE_TO_PAGES(2 * PcdFlashNvStorageFtwSpareSize). The total size remains 2 * PcdFlashNvStorageFtwSpareSize --------------------------------- * EFI_PAGE_SIZE EFI_PAGE_SIZE Right now EmuVariableFvbRuntimeDxe open-codes the block count of 2 in various limit checks, so introduce a few new macros: - EMU_FVB_NUM_TOTAL_BLOCKS, for the LHS of the above product, - EMU_FVB_NUM_SPARE_BLOCKS for the half of that. Also rework the FVB protocol members to support an arbitrary count of blocks. Keep the invariant intact that the first half of the firmware volume hosts the variable store and the FTW working block, and that the second half maps the FTW spare area. Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D527 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Regression-tested-by: Gary Lin --- Notes: v2: - rebase to separated-out patch "OvmfPkg/EmuVariableFvbRuntimeDxe: correct NumOfLba vararg type in EraseBlocks()"; end result is identical to v1 [Jordan] - add Gary's R-t-b OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h | 10 +- OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c | 147 +++++++++----------- 2 files changed, 75 insertions(+), 82 deletions(-) diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h b/OvmfPkg/EmuVariableFv= bRuntimeDxe/Fvb.h index 4247d21d72f8..beb11e3f9a90 100644 --- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h +++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h @@ -58,8 +58,14 @@ typedef struct { // // Constants // -#define EMU_FVB_BLOCK_SIZE (FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize)) -#define EMU_FVB_SIZE (2 * FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize)) +#define EMU_FVB_BLOCK_SIZE \ + EFI_PAGE_SIZE +#define EMU_FVB_NUM_SPARE_BLOCKS \ + EFI_SIZE_TO_PAGES ((UINTN)FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize)) +#define EMU_FVB_NUM_TOTAL_BLOCKS \ + (2 * EMU_FVB_NUM_SPARE_BLOCKS) +#define EMU_FVB_SIZE \ + (EMU_FVB_NUM_TOTAL_BLOCKS * EMU_FVB_BLOCK_SIZE) #define FTW_WRITE_QUEUE_SIZE \ (FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) - \ sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER)) diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c b/OvmfPkg/EmuVariableFv= bRuntimeDxe/Fvb.c index 30f69b999ab0..11c8b1b75cb8 100644 --- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c +++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c @@ -74,8 +74,8 @@ EFI_FW_VOL_BLOCK_DEVICE mEmuVarsFvb =3D { } }, NULL, // BufferPtr - FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize), // BlockSize - 2 * FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize), // Size + EMU_FVB_BLOCK_SIZE, // BlockSize + EMU_FVB_SIZE, // Size { // FwVolBlockInstance FvbProtocolGetAttributes, FvbProtocolSetAttributes, @@ -185,14 +185,14 @@ FvbProtocolGetBlockSize ( { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; =20 - if (Lba > 1) { + if (Lba >=3D EMU_FVB_NUM_TOTAL_BLOCKS) { return EFI_INVALID_PARAMETER; } =20 FvbDevice =3D FVB_DEVICE_FROM_THIS (This); =20 *BlockSize =3D FvbDevice->BlockSize; - *NumberOfBlocks =3D (UINTN) (2 - (UINTN) Lba); + *NumberOfBlocks =3D (UINTN)(EMU_FVB_NUM_TOTAL_BLOCKS - Lba); =20 return EFI_SUCCESS; } @@ -322,68 +322,58 @@ FvbProtocolEraseBlocks ( ) { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - VA_LIST args; + VA_LIST Args; EFI_LBA StartingLba; UINTN NumOfLba; - UINT8 Erase; - VOID *ErasePtr; + UINT8 *ErasePtr; UINTN EraseSize; =20 FvbDevice =3D FVB_DEVICE_FROM_THIS (This); - Erase =3D 0; - - VA_START (args, This); =20 + // + // Check input parameters + // + VA_START (Args, This); do { - StartingLba =3D VA_ARG (args, EFI_LBA); + StartingLba =3D VA_ARG (Args, EFI_LBA); if (StartingLba =3D=3D EFI_LBA_LIST_TERMINATOR) { break; } + NumOfLba =3D VA_ARG (Args, UINTN); =20 - NumOfLba =3D VA_ARG (args, UINTN); - - // - // Check input parameters - // - if ((NumOfLba =3D=3D 0) || (StartingLba > 1) || ((StartingLba + NumOfL= ba) > 2)) { - VA_END (args); + if (StartingLba > EMU_FVB_NUM_TOTAL_BLOCKS || + NumOfLba > EMU_FVB_NUM_TOTAL_BLOCKS - StartingLba) { + VA_END (Args); return EFI_INVALID_PARAMETER; } - - if (StartingLba =3D=3D 0) { - Erase =3D (UINT8) (Erase | BIT0); - } - if ((StartingLba + NumOfLba) =3D=3D 2) { - Erase =3D (UINT8) (Erase | BIT1); - } - } while (1); + VA_END (Args); =20 - VA_END (args); - - ErasePtr =3D (UINT8*) FvbDevice->BufferPtr; - EraseSize =3D 0; + // + // Erase blocks + // + VA_START (Args, This); + do { + StartingLba =3D VA_ARG (Args, EFI_LBA); + if (StartingLba =3D=3D EFI_LBA_LIST_TERMINATOR) { + break; + } + NumOfLba =3D VA_ARG (Args, UINTN); =20 - if ((Erase & BIT0) !=3D 0) { - EraseSize =3D EraseSize + FvbDevice->BlockSize; - } else { - ErasePtr =3D (VOID*) ((UINT8*)ErasePtr + FvbDevice->BlockSize); - } + ErasePtr =3D FvbDevice->BufferPtr; + ErasePtr +=3D (UINTN)StartingLba * FvbDevice->BlockSize; + EraseSize =3D NumOfLba * FvbDevice->BlockSize; =20 - if ((Erase & BIT1) !=3D 0) { - EraseSize =3D EraseSize + FvbDevice->BlockSize; - } + SetMem (ErasePtr, EraseSize, ERASED_UINT8); + } while (1); + VA_END (Args); =20 - if (EraseSize !=3D 0) { - SetMem ( - (VOID*) ErasePtr, - EraseSize, - ERASED_UINT8 - ); - VA_START (args, This); - PlatformFvbBlocksErased (This, args); - VA_END (args); - } + // + // Call platform hook + // + VA_START (Args, This); + PlatformFvbBlocksErased (This, Args); + VA_END (Args); =20 return EFI_SUCCESS; } @@ -458,31 +448,30 @@ FvbProtocolWrite ( IN UINT8 *Buffer ) { - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; UINT8 *FvbDataPtr; + EFI_STATUS Status; =20 FvbDevice =3D FVB_DEVICE_FROM_THIS (This); =20 - if ((Lba > 1) || (Offset > FvbDevice->BlockSize)) { + if (Lba >=3D EMU_FVB_NUM_TOTAL_BLOCKS || + Offset > FvbDevice->BlockSize) { return EFI_INVALID_PARAMETER; } =20 - if ((Offset + *NumBytes) > FvbDevice->BlockSize) { + Status =3D EFI_SUCCESS; + if (*NumBytes > FvbDevice->BlockSize - Offset) { *NumBytes =3D FvbDevice->BlockSize - Offset; + Status =3D EFI_BAD_BUFFER_SIZE; } =20 - FvbDataPtr =3D - (UINT8*) FvbDevice->BufferPtr + - MultU64x32 (Lba, (UINT32) FvbDevice->BlockSize) + - Offset; + FvbDataPtr =3D FvbDevice->BufferPtr; + FvbDataPtr +=3D (UINTN)Lba * FvbDevice->BlockSize; + FvbDataPtr +=3D Offset; =20 - if (*NumBytes > 0) { - CopyMem (FvbDataPtr, Buffer, *NumBytes); - PlatformFvbDataWritten (This, Lba, Offset, *NumBytes, Buffer); - } - - return EFI_SUCCESS; + CopyMem (FvbDataPtr, Buffer, *NumBytes); + PlatformFvbDataWritten (This, Lba, Offset, *NumBytes, Buffer); + return Status; } =20 =20 @@ -545,28 +534,28 @@ FvbProtocolRead ( { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; UINT8 *FvbDataPtr; + EFI_STATUS Status; =20 FvbDevice =3D FVB_DEVICE_FROM_THIS (This); =20 - if ((Lba > 1) || (Offset > FvbDevice->BlockSize)) { + if (Lba >=3D EMU_FVB_NUM_TOTAL_BLOCKS || + Offset > FvbDevice->BlockSize) { return EFI_INVALID_PARAMETER; } =20 - if ((Offset + *NumBytes) > FvbDevice->BlockSize) { + Status =3D EFI_SUCCESS; + if (*NumBytes > FvbDevice->BlockSize - Offset) { *NumBytes =3D FvbDevice->BlockSize - Offset; + Status =3D EFI_BAD_BUFFER_SIZE; } =20 - FvbDataPtr =3D - (UINT8*) FvbDevice->BufferPtr + - MultU64x32 (Lba, (UINT32) FvbDevice->BlockSize) + - Offset; + FvbDataPtr =3D FvbDevice->BufferPtr; + FvbDataPtr +=3D (UINTN)Lba * FvbDevice->BlockSize; + FvbDataPtr +=3D Offset; =20 - if (*NumBytes > 0) { - CopyMem (Buffer, FvbDataPtr, *NumBytes); - PlatformFvbDataRead (This, Lba, Offset, *NumBytes, Buffer); - } - - return EFI_SUCCESS; + CopyMem (Buffer, FvbDataPtr, *NumBytes); + PlatformFvbDataRead (This, Lba, Offset, *NumBytes, Buffer); + return Status; } =20 =20 @@ -663,7 +652,7 @@ InitializeFvAndVariableStoreHeaders ( // EFI_FV_BLOCK_MAP_ENTRY BlockMap[1]; { { - 2, // UINT32 NumBlocks; + EMU_FVB_NUM_TOTAL_BLOCKS, // UINT32 NumBlocks; EMU_FVB_BLOCK_SIZE // UINT32 Length; } } @@ -745,7 +734,7 @@ FvbInitialize ( (PcdGet32 (PcdVariableStoreSize) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize) ) > - EMU_FVB_BLOCK_SIZE + EMU_FVB_NUM_SPARE_BLOCKS * EMU_FVB_BLOCK_SIZE ) { DEBUG ((EFI_D_ERROR, "EMU Variable invalid PCD sizes\n")); return EFI_INVALID_PARAMETER; @@ -779,10 +768,7 @@ FvbInitialize ( Initialize =3D FALSE; } } else { - Ptr =3D AllocateAlignedRuntimePages ( - EFI_SIZE_TO_PAGES (EMU_FVB_SIZE), - SIZE_64KB - ); + Ptr =3D AllocateRuntimePages (EFI_SIZE_TO_PAGES (EMU_FVB_SIZE)); } =20 mEmuVarsFvb.BufferPtr =3D Ptr; @@ -808,7 +794,8 @@ FvbInitialize ( // // Initialize the Fault Tolerant Write spare block // - SubPtr =3D (VOID*) ((UINT8*) Ptr + EMU_FVB_BLOCK_SIZE); + SubPtr =3D (VOID*) ((UINT8*) Ptr + + EMU_FVB_NUM_SPARE_BLOCKS * EMU_FVB_BLOCK_SIZE); PcdStatus =3D PcdSet32S (PcdFlashNvStorageFtwSpareBase, (UINT32)(UINTN) SubPtr); ASSERT_RETURN_ERROR (PcdStatus); --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 11:27:59 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1495120495005915.06974420214; Thu, 18 May 2017 08:14:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CB8902195FD7B; Thu, 18 May 2017 08:14:52 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4A16721A1349C for ; Thu, 18 May 2017 08:14:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B63D972482; Thu, 18 May 2017 15:14:49 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-86.phx2.redhat.com [10.3.116.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFE8F7E5B7; Thu, 18 May 2017 15:14:48 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B63D972482 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B63D972482 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 18 May 2017 17:14:34 +0200 Message-Id: <20170518151436.16566-4-lersek@redhat.com> In-Reply-To: <20170518151436.16566-1-lersek@redhat.com> References: <20170518151436.16566-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 18 May 2017 15:14:49 +0000 (UTC) Subject: [edk2] [PATCH v2 3/5] OvmfPkg/PlatformPei: align EmuVariableNvStore at any page boundary X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" EmuVariableFvbRuntimeDxe now uses a 4KB (EFI_PAGE_SIZE) block size. Cc: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Regression-tested-by: Gary Lin --- Notes: v2: - no changes - add Gary's R-t-b OvmfPkg/PlatformPei/Platform.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 1b4dc00b0180..3e9fda7c7ab0 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -504,7 +504,6 @@ ReserveEmuVariableNvStore ( { EFI_PHYSICAL_ADDRESS VariableStore; RETURN_STATUS PcdStatus; - UINT32 Alignment; =20 // // Allocate storage for NV variables early on so it will be @@ -512,26 +511,15 @@ ReserveEmuVariableNvStore ( // across reboots, this allows the NV variable storage to survive // a VM reboot. // - Alignment =3D PcdGet32 (PcdFlashNvStorageFtwSpareSize); - if ((Alignment & (Alignment - 1)) !=3D 0) { - // - // Round up Alignment to the next power of two. - // - Alignment =3D GetPowerOfTwo32 (Alignment) << 1; - } - VariableStore =3D (EFI_PHYSICAL_ADDRESS)(UINTN) - AllocateAlignedRuntimePages ( - EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)), - Alignment + AllocateRuntimePages ( + EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) ); DEBUG ((EFI_D_INFO, - "Reserved variable store memory: 0x%lX; size: %dkb, " - "alignment: 0x%x\n", + "Reserved variable store memory: 0x%lX; size: %dkb\n", VariableStore, - (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024, - Alignment + (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024 )); PcdStatus =3D PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore); ASSERT_RETURN_ERROR (PcdStatus); --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 11:27:59 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1495120499874916.2188242330745; Thu, 18 May 2017 08:14:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0862921959725; Thu, 18 May 2017 08:14:53 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6F1222195FD7A for ; Thu, 18 May 2017 08:14:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DCFCE80048; Thu, 18 May 2017 15:14:50 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-86.phx2.redhat.com [10.3.116.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16F537E5B7; Thu, 18 May 2017 15:14:49 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DCFCE80048 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DCFCE80048 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 18 May 2017 17:14:35 +0200 Message-Id: <20170518151436.16566-5-lersek@redhat.com> In-Reply-To: <20170518151436.16566-1-lersek@redhat.com> References: <20170518151436.16566-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 18 May 2017 15:14:51 +0000 (UTC) Subject: [edk2] [PATCH v2 4/5] OvmfPkg/README: document 4MB flash layout X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D527 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- Notes: v2: - no changes OvmfPkg/README | 39 ++++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/README b/OvmfPkg/README index 304e69fbe545..33ff9432bb3e 100644 --- a/OvmfPkg/README +++ b/OvmfPkg/README @@ -245,15 +245,20 @@ longer.) =20 =3D=3D=3D OVMF Flash Layout =3D=3D=3D =20 -Like all current IA32/X64 system designs, OVMF's firmware -device (rom/flash) appears in QEMU's physical address space -just below 4GB (0x100000000). +Like all current IA32/X64 system designs, OVMF's firmware device (rom/flas= h) +appears in QEMU's physical address space just below 4GB (0x100000000). =20 -The layout of the firmware device in memory looks like: +OVMF supports building a 1MB, 2MB or 4MB flash image (see the DSC files fo= r the +FD_SIZE_1MB, FD_SIZE_2MB, FD_SIZE_4MB build defines). The base address for= the +1MB image in QEMU physical memory is 0xfff00000. The base address for the = 2MB +image is 0xffe00000. The base address for the 4MB image is 0xffc00000. + +Using the 1MB or 2MB image, the layout of the firmware device in memory lo= oks +like: =20 +--------------------------------------- 4GB (0x100000000) | VTF0 (16-bit reset code) and OVMF SEC -| (SECFV) +| (SECFV, 208KB/0x34000) +--------------------------------------- varies based on flash size | | Compressed main firmware image @@ -271,9 +276,27 @@ The layout of the firmware device in memory looks like: | area (56KB/0xe000) +--------------------------------------- base address =20 -OVMF supports building a 1MB or a 2MB flash image. The base address for -a 1MB image in QEMU physical memory is 0xfff00000. The base address for -a 2MB image is 0xffe00000. +Using the 4MB image, the layout of the firmware device in memory looks lik= e: + ++--------------------------------------- base + 0x400000 (4GB/0x100000000) +| VTF0 (16-bit reset code) and OVMF SEC +| (SECFV, 208KB/0x34000) ++--------------------------------------- base + 0x3cc000 +| +| Compressed main firmware image +| (FVMAIN_COMPACT, 3360KB/0x348000) +| ++--------------------------------------- base + 0x84000 +| Fault-tolerant write (FTW) +| Spare blocks (264KB/0x42000) ++--------------------------------------- base + 0x42000 +| FTW Work block (4KB/0x1000) ++--------------------------------------- base + 0x41000 +| Event log area (4KB/0x1000) ++--------------------------------------- base + 0x40000 +| Non-volatile variable storage +| area (256KB/0x40000) ++--------------------------------------- base address (0xffc00000) =20 The code in SECFV locates FVMAIN_COMPACT, and decompresses the main firmware (MAINFV) into RAM memory at address 0x800000. The --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 11:27:59 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1495120502611991.4302085553375; Thu, 18 May 2017 08:15:02 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3CE8A21AEBAD5; Thu, 18 May 2017 08:14:54 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AE28421A1349C for ; Thu, 18 May 2017 08:14:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18A95C02C03E; Thu, 18 May 2017 15:14:52 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-86.phx2.redhat.com [10.3.116.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4928380F9B; Thu, 18 May 2017 15:14:51 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 18A95C02C03E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 18A95C02C03E From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 18 May 2017 17:14:36 +0200 Message-Id: <20170518151436.16566-6-lersek@redhat.com> In-Reply-To: <20170518151436.16566-1-lersek@redhat.com> References: <20170518151436.16566-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 18 May 2017 15:14:52 +0000 (UTC) Subject: [edk2] [PATCH v2 5/5] OvmfPkg: make the 4MB flash size the default (again) X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The previously default 2MB can be explicitly selected with -D FD_SIZE_2MB or -D FD_SIZE_IN_KB=3D2048 Cc: Jordan Justen Suggested-by: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek (cherry picked from commit bba8dfbec3bbc4fba7fa6398ba3cf76593e0725e) --- Notes: v2: - no changes - we can postpone this one patch if we want to wait for Xen to update hvmloader OvmfPkg/OvmfPkgIa32.dsc | 2 +- OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- OvmfPkg/OvmfPkgX64.dsc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index bd115c9ced93..8f0ab9f721fe 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -54,7 +54,7 @@ [Defines] !ifdef $(FD_SIZE_4MB) DEFINE FD_SIZE_IN_KB =3D 4096 !else - DEFINE FD_SIZE_IN_KB =3D 2048 + DEFINE FD_SIZE_IN_KB =3D 4096 !endif !endif !endif diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 9727db842922..4b2136262865 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -54,7 +54,7 @@ [Defines] !ifdef $(FD_SIZE_4MB) DEFINE FD_SIZE_IN_KB =3D 4096 !else - DEFINE FD_SIZE_IN_KB =3D 2048 + DEFINE FD_SIZE_IN_KB =3D 4096 !endif !endif !endif diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 61aaed761657..2ee30fb00a28 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -54,7 +54,7 @@ [Defines] !ifdef $(FD_SIZE_4MB) DEFINE FD_SIZE_IN_KB =3D 4096 !else - DEFINE FD_SIZE_IN_KB =3D 2048 + DEFINE FD_SIZE_IN_KB =3D 4096 !endif !endif !endif --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel