FvmainCompactScratchEnd.fdf.inc 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ## @file
  2. # This FDF include file computes the end of the scratch buffer used in
  3. # DecompressMemFvs() [OvmfPkg/Sec/SecMain.c]. It is based on the decompressed
  4. # (ie. original) size of the LZMA-compressed section of the one FFS file in
  5. # the FVMAIN_COMPACT firmware volume.
  6. #
  7. # Copyright (C) 2015, Red Hat, Inc.
  8. #
  9. # SPDX-License-Identifier: BSD-2-Clause-Patent
  10. ##
  11. # The GUID EE4E5898-3914-4259-9D6E-DC7BD79403CF means "LzmaCustomDecompress".
  12. # The decompressed output will have the following structure (see the file
  13. # "9E21FD93-9C72-4c15-8C4B-E77F1DB2D792SEC1.guided.dummy" in the
  14. # Build/Ovmf*/*/FV/Ffs/9E21FD93-9C72-4c15-8C4B-E77F1DB2D792/ directory):
  15. #
  16. # Size Contents
  17. # ------------------- --------------------------------------------------------
  18. # 4 EFI_COMMON_SECTION_HEADER, stating size 124 (0x7C) and
  19. # type 0x19 (EFI_SECTION_RAW). The purpose of this section
  20. # is to pad the start of PEIFV to 128 bytes.
  21. # 120 Zero bytes (padding).
  22. #
  23. # 4 EFI_COMMON_SECTION_HEADER, stating size
  24. # (PcdOvmfPeiMemFvSize + 4), and type 0x17
  25. # (EFI_SECTION_FIRMWARE_VOLUME_IMAGE).
  26. # PcdOvmfPeiMemFvSize PEIFV. Note that the above sizes pad the offset of this
  27. # object to 128 bytes. See also the "guided.dummy.txt"
  28. # file in the same directory.
  29. #
  30. # 4 EFI_COMMON_SECTION_HEADER, stating size 12 (0xC) and
  31. # type 0x19 (EFI_SECTION_RAW). The purpose of this section
  32. # is to pad the start of DXEFV to 16 bytes.
  33. # 8 Zero bytes (padding).
  34. #
  35. # 4 EFI_COMMON_SECTION_HEADER, stating size
  36. # (PcdOvmfDxeMemFvSize + 4), and type 0x17
  37. # (EFI_SECTION_FIRMWARE_VOLUME_IMAGE).
  38. # PcdOvmfDxeMemFvSize DXEFV. Note that the above sizes pad the offset of this
  39. # object to 16 bytes. See also the "guided.dummy.txt" file
  40. # in the same directory.
  41. #
  42. # The total size after decompression is (128 + PcdOvmfPeiMemFvSize + 16 +
  43. # PcdOvmfDxeMemFvSize).
  44. DEFINE OUTPUT_SIZE = (128 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize + 16 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize)
  45. # LzmaCustomDecompressLib uses a constant scratch buffer size of 64KB; see
  46. # SCRATCH_BUFFER_REQUEST_SIZE in
  47. # "MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c".
  48. DEFINE DECOMP_SCRATCH_SIZE = 0x00010000
  49. # Note: when we use PcdOvmfDxeMemFvBase in this context, BaseTools have not yet
  50. # offset it with MEMFD's base address. For that reason we have to do it manually.
  51. #
  52. # The calculation below mirrors DecompressMemFvs() [OvmfPkg/Sec/SecMain.c].
  53. DEFINE OUTPUT_BASE = ($(MEMFD_BASE_ADDRESS) + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase + 0x00100000)
  54. DEFINE DECOMP_SCRATCH_BASE_UNALIGNED = ($(OUTPUT_BASE) + $(OUTPUT_SIZE))
  55. DEFINE DECOMP_SCRATCH_BASE_ALIGNMENT = 0x000FFFFF
  56. DEFINE DECOMP_SCRATCH_BASE_MASK = 0xFFF00000
  57. DEFINE DECOMP_SCRATCH_BASE = (($(DECOMP_SCRATCH_BASE_UNALIGNED) + $(DECOMP_SCRATCH_BASE_ALIGNMENT)) & $(DECOMP_SCRATCH_BASE_MASK))
  58. SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd = $(DECOMP_SCRATCH_BASE) + $(DECOMP_SCRATCH_SIZE)
  59. #
  60. # The range of pages that should be pre-validated during the SEC phase when SEV-SNP is active in the guest VM.
  61. SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecValidatedStart = $(MEMFD_BASE_ADDRESS) + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
  62. SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecValidatedEnd = $(DECOMP_SCRATCH_BASE) + $(DECOMP_SCRATCH_SIZE)