public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Devon Bautista" <dbautista@newmexicoconsortium.org>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Jordan Justen <jordan.l.justen@intel.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Devon Bautista <dbautista@newmexicoconsortium.org>
Subject: [PATCH v2 1/1] OvmfPkg: Introduce 16MiB flash size for (primarily) Linuxboot
Date: Fri,  3 Sep 2021 05:26:20 +0000	[thread overview]
Message-ID: <20210903052620.30638-2-dbautista@newmexicoconsortium.org> (raw)
In-Reply-To: <20210903052620.30638-1-dbautista@newmexicoconsortium.org>

The largest size flash image currently available for OVMF builds, 4MiB,
is too small to insert a Linux kernel and initramfs into the DXEFV, and
is thus insufficient for testing Linuxboot builds via OVMF.

Introduce the FD_SIZE_16MB build macro (equivalently,
FD_SIZE_IN_KB=16384), which enlarges the full flash image to 16MiB, the
maximum size available for x86. Since QEMU commit 0657c65 (hw/i386/pc:
add max combined fw size as machine configuration option), QEMU supports
flash sizes up to 16MiB using the "max-fw-size" property.

This new 16MiB flash size uses the same non-volatile variable store size
and layout as the default 4MiB flash size to ensure compatibility when
switching to the larger flash size. Since the 4MiB target was created in
commit b24fca0 (OvmfPkg: introduce 4MB flash image (mainly) for Windows
HCK), the variable store size increased by 200KiB to 256KiB, which
should provide an adequate safety margin.

The FVMAIN_COMPACT is significantly enlarged to provide the extra space
in the DXEFV (and PEIFV, if needed).

For now, the 4MiB target remains the default.

In summary:

  Description                Compression type                 Size [KB]
  -------------------------  -----------------  -----------------------
  Non-volatile data storage  open-coded binary    528 ->   528 (    +0)
                               data
    Variable store                                256 ->   256 (    +0)
    Event log                                       4 ->     4 (    +0)
    Working block                                   4 ->     4 (    +0)
    Spare area                                    264 ->   264 (    +0)

  FVMAIN_COMPACT             uncompressed        3360 -> 15648 (+12288)
    FV FFS file              LZMA compressed
      PEIFV                  uncompressed         896 ->   896 (    +0)
        individual PEI       uncompressed
          modules
      DXEFV                  uncompressed       12288 -> 12288 (    +0)
        individual DXE       uncompressed
          modules

  SECFV                      uncompressed         208 ->   208 (    +0)
    SEC driver
    reset vector code

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Devon Bautista <dbautista@newmexicoconsortium.org>
---
 OvmfPkg/OvmfPkgIa32.dsc        |  4 +++
 OvmfPkg/OvmfPkgIa32X64.dsc     |  4 +++
 OvmfPkg/OvmfPkgX64.dsc         |  4 +++
 OvmfPkg/OvmfXen.dsc            |  4 +++
 OvmfPkg/OvmfPkgDefines.fdf.inc | 28 +++++++++++++++-----
 OvmfPkg/VarStore.fdf.inc       | 16 +++++------
 6 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index d1d92c97bae3..fadad1c1efda 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -67,11 +67,15 @@ [Defines]
 !else
 !ifdef $(FD_SIZE_4MB)
   DEFINE FD_SIZE_IN_KB           = 4096
+!else
+!ifdef $(FD_SIZE_16MB)
+  DEFINE FD_SIZE_IN_KB           = 16384
 !else
   DEFINE FD_SIZE_IN_KB           = 4096
 !endif
 !endif
 !endif
+!endif
 
 [BuildOptions]
   GCC:RELEASE_*_*_CC_FLAGS             = -DMDEPKG_NDEBUG
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index a467ab7090fb..0e8eae845901 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -66,11 +66,15 @@ [Defines]
 !else
 !ifdef $(FD_SIZE_4MB)
   DEFINE FD_SIZE_IN_KB           = 4096
+!else
+!ifdef $(FD_SIZE_16MB)
+  DEFINE FD_SIZE_IN_KB           = 16384
 !else
   DEFINE FD_SIZE_IN_KB           = 4096
 !endif
 !endif
 !endif
+!endif
 
 [BuildOptions]
   GCC:RELEASE_*_*_CC_FLAGS             = -DMDEPKG_NDEBUG
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index e56b83d95e09..36ccb4418f67 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -66,11 +66,15 @@ [Defines]
 !else
 !ifdef $(FD_SIZE_4MB)
   DEFINE FD_SIZE_IN_KB           = 4096
+!else
+!ifdef $(FD_SIZE_16MB)
+  DEFINE FD_SIZE_IN_KB           = 16384
 !else
   DEFINE FD_SIZE_IN_KB           = 4096
 !endif
 !endif
 !endif
+!endif
 
 [BuildOptions]
   GCC:RELEASE_*_*_CC_FLAGS             = -DMDEPKG_NDEBUG
diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index 1a9c06c164a8..6a7ce481e895 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -56,11 +56,15 @@ [Defines]
 !else
 !ifdef $(FD_SIZE_4MB)
   DEFINE FD_SIZE_IN_KB           = 4096
+!else
+!ifdef $(FD_SIZE_16MB)
+  DEFINE FD_SIZE_IN_KB           = 16384
 !else
   DEFINE FD_SIZE_IN_KB           = 2048
 !endif
 !endif
 !endif
+!endif
 
 [BuildOptions]
   GCC:RELEASE_*_*_CC_FLAGS             = -DMDEPKG_NDEBUG
diff --git a/OvmfPkg/OvmfPkgDefines.fdf.inc b/OvmfPkg/OvmfPkgDefines.fdf.inc
index 3b5e45253916..301600c4ef84 100644
--- a/OvmfPkg/OvmfPkgDefines.fdf.inc
+++ b/OvmfPkg/OvmfPkgDefines.fdf.inc
@@ -14,8 +14,8 @@
 # A firmware binary built with FD_SIZE_IN_KB=1024, and a firmware binary built
 # with FD_SIZE_IN_KB=2048, use the same variable store layout.
 #
-# Setting FD_SIZE_IN_KB to 4096 results in a different (much larger) variable
-# store structure that is incompatible with both of the above-mentioned
+# Setting FD_SIZE_IN_KB to 4096 or 16384 results in a different (much larger)
+# variable store structure that is incompatible with both of the above-mentioned
 # firmware binaries.
 #
 !if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
@@ -23,6 +23,13 @@
 DEFINE VARS_BLOCKS       = 0x20
 DEFINE VARS_LIVE_SIZE    = 0xE000
 DEFINE VARS_SPARE_SIZE   = 0x10000
+!else
+!if ($(FD_SIZE_IN_KB) == 16384) || ($(FD_SIZE_IN_KB) == 4096)
+DEFINE VARS_SIZE         = 0x84000
+DEFINE VARS_BLOCKS       = 0x84
+DEFINE VARS_LIVE_SIZE    = 0x40000
+DEFINE VARS_SPARE_SIZE   = 0x42000
+!endif
 !endif
 
 !if $(FD_SIZE_IN_KB) == 1024
@@ -50,11 +57,6 @@
 !endif
 
 !if $(FD_SIZE_IN_KB) == 4096
-DEFINE VARS_SIZE         = 0x84000
-DEFINE VARS_BLOCKS       = 0x84
-DEFINE VARS_LIVE_SIZE    = 0x40000
-DEFINE VARS_SPARE_SIZE   = 0x42000
-
 DEFINE FW_BASE_ADDRESS   = 0xFFC00000
 DEFINE FW_SIZE           = 0x00400000
 DEFINE FW_BLOCKS         = 0x400
@@ -66,6 +68,18 @@
 DEFINE SECFV_SIZE        = 0x34000
 !endif
 
+!if $(FD_SIZE_IN_KB) == 16384
+DEFINE FW_BASE_ADDRESS   = 0xFF000000
+DEFINE FW_SIZE           = 0x01000000
+DEFINE FW_BLOCKS         = 0x1000
+DEFINE CODE_BASE_ADDRESS = 0xFF084000
+DEFINE CODE_SIZE         = 0x00F7C000
+DEFINE CODE_BLOCKS       = 0xF7C
+DEFINE FVMAIN_SIZE       = 0x00F48000
+DEFINE SECFV_OFFSET      = 0x00FCC000
+DEFINE SECFV_SIZE        = 0x34000
+!endif
+
 SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress     = $(FW_BASE_ADDRESS)
 SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize    = $(FW_SIZE)
 SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareBlockSize = $(BLOCK_SIZE)
diff --git a/OvmfPkg/VarStore.fdf.inc b/OvmfPkg/VarStore.fdf.inc
index a1e524e39329..179ab64d4642 100644
--- a/OvmfPkg/VarStore.fdf.inc
+++ b/OvmfPkg/VarStore.fdf.inc
@@ -11,7 +11,7 @@
 !if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
 0x00000000|0x0000e000
 !endif
-!if $(FD_SIZE_IN_KB) == 4096
+!if ($(FD_SIZE_IN_KB) == 4096) || ($(FD_SIZE_IN_KB) == 16384)
 0x00000000|0x00040000
 !endif
 #NV_VARIABLE_STORE
@@ -29,7 +29,7 @@
   # FvLength: 0x20000
   0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
 !endif
-!if $(FD_SIZE_IN_KB) == 4096
+!if ($(FD_SIZE_IN_KB) == 4096) || ($(FD_SIZE_IN_KB) == 16384)
   # FvLength: 0x84000
   0x00, 0x40, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
 !endif
@@ -41,7 +41,7 @@
   # CheckSum
   0x19, 0xF9,
 !endif
-!if $(FD_SIZE_IN_KB) == 4096
+!if ($(FD_SIZE_IN_KB) == 4096) || ($(FD_SIZE_IN_KB) == 16384)
   # CheckSum
   0xAF, 0xB8,
 !endif
@@ -51,7 +51,7 @@
   # Blockmap[0]: 0x20 Blocks * 0x1000 Bytes / Block
   0x20, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
 !endif
-!if $(FD_SIZE_IN_KB) == 4096
+!if ($(FD_SIZE_IN_KB) == 4096) || ($(FD_SIZE_IN_KB) == 16384)
   # Blockmap[0]: 0x84 Blocks * 0x1000 Bytes / Block
   0x84, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
 !endif
@@ -70,7 +70,7 @@
   # This can speed up the Variable Dispatch a bit.
   0xB8, 0xDF, 0x00, 0x00,
 !endif
-!if $(FD_SIZE_IN_KB) == 4096
+!if ($(FD_SIZE_IN_KB) == 4096) || ($(FD_SIZE_IN_KB) == 16384)
   # Size: 0x40000 (gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize) -
   #          0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) = 0x3ffb8
   # This can speed up the Variable Dispatch a bit.
@@ -83,7 +83,7 @@
 !if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
 0x0000e000|0x00001000
 !endif
-!if $(FD_SIZE_IN_KB) == 4096
+!if ($(FD_SIZE_IN_KB) == 4096) || ($(FD_SIZE_IN_KB) == 16384)
 0x00040000|0x00001000
 !endif
 #NV_EVENT_LOG
@@ -91,7 +91,7 @@
 !if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
 0x0000f000|0x00001000
 !endif
-!if $(FD_SIZE_IN_KB) == 4096
+!if ($(FD_SIZE_IN_KB) == 4096) || ($(FD_SIZE_IN_KB) == 16384)
 0x00041000|0x00001000
 !endif
 #NV_FTW_WORKING
@@ -109,7 +109,7 @@
 !if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
 0x00010000|0x00010000
 !endif
-!if $(FD_SIZE_IN_KB) == 4096
+!if ($(FD_SIZE_IN_KB) == 4096) || ($(FD_SIZE_IN_KB) == 16384)
 0x00042000|0x00042000
 !endif
 #NV_FTW_SPARE
-- 
2.33.0


  reply	other threads:[~2021-09-03  5:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03  5:26 [PATCH v2 0/1] OVMF: Introduce 16MiB Flash Size Devon Bautista
2021-09-03  5:26 ` Devon Bautista [this message]
2021-09-03  7:17   ` [PATCH v2 1/1] OvmfPkg: Introduce 16MiB flash size for (primarily) Linuxboot Gerd Hoffmann
2021-09-03 19:35     ` Devon Bautista
2021-09-06  8:37       ` Gerd Hoffmann
2021-09-07  0:55         ` Devon Bautista
2021-09-09  9:09   ` [edk2-devel] " Philippe Mathieu-Daudé
2021-09-09 12:10     ` Gerd Hoffmann
2021-10-19 23:03     ` Devon Bautista

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210903052620.30638-2-dbautista@newmexicoconsortium.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox