[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 21/45] hw/i386: Replace magic number with field length calculation
From: |
Michael S. Tsirkin |
Subject: |
[PULL 21/45] hw/i386: Replace magic number with field length calculation |
Date: |
Fri, 4 Mar 2022 08:40:00 -0500 |
From: Dov Murik <dovmurik@linux.ibm.com>
Replce the literal magic number 48 with length calculation (32 bytes at
the end of the firmware after the table footer + 16 bytes of the OVMF
table footer GUID).
No functional change intended.
Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
Message-Id: <20220222071906.2632426-3-dovmurik@linux.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
hw/i386/pc_sysfw_ovmf.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/hw/i386/pc_sysfw_ovmf.c b/hw/i386/pc_sysfw_ovmf.c
index df15c9737b..07a4c267fa 100644
--- a/hw/i386/pc_sysfw_ovmf.c
+++ b/hw/i386/pc_sysfw_ovmf.c
@@ -30,6 +30,8 @@
#define OVMF_TABLE_FOOTER_GUID "96b582de-1fb2-45f7-baea-a366c55a082d"
+static const int bytes_after_table_footer = 32;
+
static bool ovmf_flash_parsed;
static uint8_t *ovmf_table;
static int ovmf_table_len;
@@ -53,12 +55,13 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t
flash_size)
/*
* if this is OVMF there will be a table footer
- * guid 48 bytes before the end of the flash file. If it's
- * not found, silently abort the flash parsing.
+ * guid 48 bytes before the end of the flash file
+ * (= 32 bytes after the table + 16 bytes the GUID itself).
+ * If it's not found, silently abort the flash parsing.
*/
qemu_uuid_parse(OVMF_TABLE_FOOTER_GUID, &guid);
guid = qemu_uuid_bswap(guid); /* guids are LE */
- ptr = flash_ptr + flash_size - 48;
+ ptr = flash_ptr + flash_size - (bytes_after_table_footer + sizeof(guid));
if (!qemu_uuid_is_equal((QemuUUID *)ptr, &guid)) {
return;
}
--
MST
- [PULL 13/45] tests/qtest/libqos/pci: Introduce pio_limit, (continued)
- [PULL 13/45] tests/qtest/libqos/pci: Introduce pio_limit, Michael S. Tsirkin, 2022/03/04
- [PULL 14/45] tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable, Michael S. Tsirkin, 2022/03/04
- [PULL 15/45] tests/qtest/vhost-user-blk-test: Temporary hack to get tests passing on aarch64, Michael S. Tsirkin, 2022/03/04
- [PULL 16/45] tests/qtest/libqos: Add generic pci host bridge in arm-virt machine, Michael S. Tsirkin, 2022/03/04
- [PULL 17/45] hw/virtio: vdpa: Fix leak of host-notifier memory-region, Michael S. Tsirkin, 2022/03/04
- [PULL 18/45] vhost-vdpa: make notifiers _init()/_uninit() symmetric, Michael S. Tsirkin, 2022/03/04
- [PULL 19/45] intel_iommu: support snoop control, Michael S. Tsirkin, 2022/03/04
- [PULL 20/45] hw/i386: Improve bounds checking in OVMF table parsing, Michael S. Tsirkin, 2022/03/04
- [PULL 21/45] hw/i386: Replace magic number with field length calculation,
Michael S. Tsirkin <=
- [PULL 22/45] virtio-iommu: Default to bypass during boot, Michael S. Tsirkin, 2022/03/04
- [PULL 23/45] virtio-iommu: Support bypass domain, Michael S. Tsirkin, 2022/03/04
- [PULL 24/45] tests/qtest/virtio-iommu-test: Check bypass config, Michael S. Tsirkin, 2022/03/04
- [PULL 25/45] hw/i386/pc_piix: Mark the machine types from version 1.4 to 1.7 as deprecated, Michael S. Tsirkin, 2022/03/04
- [PULL 26/45] hw/pci-bridge/pxb: Fix missing swizzle, Michael S. Tsirkin, 2022/03/04
- [PULL 27/45] virtio-net: Unlimit tx queue size if peer is vdpa, Michael S. Tsirkin, 2022/03/04
- [PULL 28/45] pcie: Add support for Single Root I/O Virtualization (SR/IOV), Michael S. Tsirkin, 2022/03/04
- [PULL 29/45] pcie: Add some SR/IOV API documentation in docs/pcie_sriov.txt, Michael S. Tsirkin, 2022/03/04
- [PULL 30/45] pcie: Add a helper to the SR/IOV API, Michael S. Tsirkin, 2022/03/04
- [PULL 31/45] pcie: Add 1.2 version token for the Power Management Capability, Michael S. Tsirkin, 2022/03/04