sev-guest-firmware.rst 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. ====================================================
  2. QEMU/Guest Firmware Interface for AMD SEV and SEV-ES
  3. ====================================================
  4. Overview
  5. ========
  6. The guest firmware image (OVMF) may contain some configuration entries
  7. which are used by QEMU before the guest launches. These are listed in a
  8. GUIDed table at a known location in the firmware image. QEMU parses
  9. this table when it loads the firmware image into memory, and then QEMU
  10. reads individual entries when their values are needed.
  11. Though nothing in the table structure is SEV-specific, currently all the
  12. entries in the table are related to SEV and SEV-ES features.
  13. Table parsing in QEMU
  14. ---------------------
  15. The table is parsed from the footer: first the presence of the table
  16. footer GUID (96b582de-1fb2-45f7-baea-a366c55a082d) at 0xffffffd0 is
  17. verified. If that is found, two bytes at 0xffffffce are the entire
  18. table length.
  19. Then the table is scanned backwards looking for the specific entry GUID.
  20. QEMU files related to parsing and scanning the OVMF table:
  21. - ``hw/i386/pc_sysfw_ovmf.c``
  22. The edk2 firmware code that constructs this structure is in the
  23. `OVMF Reset Vector file`_.
  24. Table memory layout
  25. -------------------
  26. +------------+--------+-----------------------------------------+
  27. | GPA | Length | Description |
  28. +============+========+=========================================+
  29. | 0xffffff80 | 4 | Zero padding |
  30. +------------+--------+-----------------------------------------+
  31. | 0xffffff84 | 4 | SEV hashes table base address |
  32. +------------+--------+-----------------------------------------+
  33. | 0xffffff88 | 4 | SEV hashes table size (=0x400) |
  34. +------------+--------+-----------------------------------------+
  35. | 0xffffff8c | 2 | SEV hashes table entry length (=0x1a) |
  36. +------------+--------+-----------------------------------------+
  37. | 0xffffff8e | 16 | SEV hashes table GUID: |
  38. | | | 7255371f-3a3b-4b04-927b-1da6efa8d454 |
  39. +------------+--------+-----------------------------------------+
  40. | 0xffffff9e | 4 | SEV secret block base address |
  41. +------------+--------+-----------------------------------------+
  42. | 0xffffffa2 | 4 | SEV secret block size (=0xc00) |
  43. +------------+--------+-----------------------------------------+
  44. | 0xffffffa6 | 2 | SEV secret block entry length (=0x1a) |
  45. +------------+--------+-----------------------------------------+
  46. | 0xffffffa8 | 16 | SEV secret block GUID: |
  47. | | | 4c2eb361-7d9b-4cc3-8081-127c90d3d294 |
  48. +------------+--------+-----------------------------------------+
  49. | 0xffffffb8 | 4 | SEV-ES AP reset RIP |
  50. +------------+--------+-----------------------------------------+
  51. | 0xffffffbc | 2 | SEV-ES reset block entry length (=0x16) |
  52. +------------+--------+-----------------------------------------+
  53. | 0xffffffbe | 16 | SEV-ES reset block entry GUID: |
  54. | | | 00f771de-1a7e-4fcb-890e-68c77e2fb44e |
  55. +------------+--------+-----------------------------------------+
  56. | 0xffffffce | 2 | Length of entire table including table |
  57. | | | footer GUID and length (=0x72) |
  58. +------------+--------+-----------------------------------------+
  59. | 0xffffffd0 | 16 | OVMF GUIDed table footer GUID: |
  60. | | | 96b582de-1fb2-45f7-baea-a366c55a082d |
  61. +------------+--------+-----------------------------------------+
  62. | 0xffffffe0 | 8 | Application processor entry point code |
  63. +------------+--------+-----------------------------------------+
  64. | 0xffffffe8 | 8 | "\0\0\0\0VTF\0" |
  65. +------------+--------+-----------------------------------------+
  66. | 0xfffffff0 | 16 | Reset vector code |
  67. +------------+--------+-----------------------------------------+
  68. Table entries description
  69. =========================
  70. SEV-ES reset block
  71. ------------------
  72. Entry GUID: 00f771de-1a7e-4fcb-890e-68c77e2fb44e
  73. For the initial boot of an AP under SEV-ES, the "reset" RIP must be
  74. programmed to the RAM area defined by this entry. The entry's format
  75. is:
  76. * IP value [0:15]
  77. * CS segment base [31:16]
  78. A hypervisor reads the CS segment base and IP value. The CS segment
  79. base value represents the high order 16-bits of the CS segment base, so
  80. the hypervisor must left shift the value of the CS segment base by 16
  81. bits to form the full CS segment base for the CS segment register. It
  82. would then program the EIP register with the IP value as read.
  83. SEV secret block
  84. ----------------
  85. Entry GUID: 4c2eb361-7d9b-4cc3-8081-127c90d3d294
  86. This describes the guest RAM area where the hypervisor should inject the
  87. Guest Owner secret (using SEV_LAUNCH_SECRET).
  88. SEV hashes table
  89. ----------------
  90. Entry GUID: 7255371f-3a3b-4b04-927b-1da6efa8d454
  91. This describes the guest RAM area where the hypervisor should install a
  92. table describing the hashes of certain firmware configuration device
  93. files that would otherwise be passed in unchecked. The current use is
  94. for the kernel, initrd and command line values, but others may be added.
  95. .. _OVMF Reset Vector file:
  96. https://github.com/tianocore/edk2/blob/master/OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm