diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2016-05-23 16:15:51 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2016-05-23 16:15:52 +0100 |
| commit | c9158547617584bb9d19db7fb139998fbef80133 (patch) | |
| tree | 7fd630b63555af50eaabc3101afe070345904db7 /scripts/signrom.py | |
| parent | 2b5f477789aa4d0a4aa444533558e21e63a310ec (diff) | |
| parent | 1453e6627d19a8d6d54480c6980f5cef5dfc6833 (diff) | |
| download | focaccia-qemu-c9158547617584bb9d19db7fb139998fbef80133.tar.gz focaccia-qemu-c9158547617584bb9d19db7fb139998fbef80133.zip | |
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* NMI cleanups (Bandan) * RAMBlock/Memory cleanups and fixes (Dominik, Gonglei, Fam, me) * first part of linuxboot support for fw_cfg DMA (Richard) * IOAPIC fix (Peter Xu) * iSCSI SG_IO fix (Vadim) * Various infrastructure bug fixes (Zhijian, Peter M., Stefan) * CVE fixes (Prasad) # gpg: Signature made Mon 23 May 2016 16:06:18 BST using RSA key ID 78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" * remotes/bonzini/tags/for-upstream: (24 commits) cpus: call the core nmi injection function nmi: remove x86 specific nmi handling target-i386: add a generic x86 nmi handler coccinelle: add g_assert_cmp* to macro file iscsi: pass SCSI status back for SG_IO esp: check dma length before reading scsi command(CVE-2016-4441) esp: check command buffer length before write(CVE-2016-4439) scripts/signrom.py: Check for magic in option ROMs. scripts/signrom.py: Allow option ROM checksum script to write the size header. Remove config-devices.mak on 'make clean' cpus.c: Use pthread_sigmask() rather than sigprocmask() memory: remove unnecessary masking of MemoryRegion ram_addr memory: Drop FlatRange.romd_mode memory: Remove code for mr->may_overlap exec: adjust rcu_read_lock requirement memory: drop find_ram_block() vl: change runstate only if new state is different from current state ioapic: clear remote irr bit for edge-triggered interrupts ioapic: keep RO bits for IOAPIC entry target-i386: key sfence availability on CPUID_SSE, not CPUID_SSE2 ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/signrom.py')
| -rw-r--r-- | scripts/signrom.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/scripts/signrom.py b/scripts/signrom.py index f9c35ccfca..5629bca222 100644 --- a/scripts/signrom.py +++ b/scripts/signrom.py @@ -17,11 +17,33 @@ if len(sys.argv) < 3: fin = open(sys.argv[1], 'rb') fout = open(sys.argv[2], 'wb') -fin.seek(2) -size = ord(fin.read(1)) * 512 - 1 +magic = fin.read(2) +if magic != '\x55\xaa': + sys.exit("%s: option ROM does not begin with magic 55 aa" % sys.argv[1]) +size_byte = ord(fin.read(1)) fin.seek(0) -data = fin.read(size) + +if size_byte == 0: + # If the caller left the size field blank then we will fill it in, + # also rounding the whole input to a multiple of 512 bytes. + data = fin.read() + # +1 because we need a byte to store the checksum. + size = len(data) + 1 + # Round up to next multiple of 512. + size += 511 + size -= size % 512 + if size >= 65536: + sys.exit("%s: option ROM size too large" % sys.argv[1]) + # size-1 because a final byte is added below to store the checksum. + data = data.ljust(size-1, '\0') + data = data[:2] + chr(size/512) + data[3:] +else: + # Otherwise the input file specifies the size so use it. + # -1 because we overwrite the last byte of the file with the checksum. + size = size_byte * 512 - 1 + data = fin.read(size) + fout.write(data) checksum = 0 |