From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXU0c-0003ME-QB for qemu-devel@nongnu.org; Wed, 10 Aug 2016 09:57:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXU0Z-00084y-02 for qemu-devel@nongnu.org; Wed, 10 Aug 2016 09:57:26 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:36524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXU0Y-00084s-Lp for qemu-devel@nongnu.org; Wed, 10 Aug 2016 09:57:22 -0400 Received: by mail-wm0-x244.google.com with SMTP id i138so9676423wmf.3 for ; Wed, 10 Aug 2016 06:57:22 -0700 (PDT) Received: from 640k.lan (94-39-152-88.adsl-ull.clienti.tiscali.it. [94.39.152.88]) by smtp.gmail.com with ESMTPSA id a9sm43257024wjf.16.2016.08.10.06.57.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Aug 2016 06:57:20 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 10 Aug 2016 15:57:04 +0200 Message-Id: <1470837437-14713-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1470837437-14713-1-git-send-email-pbonzini@redhat.com> References: <1470837437-14713-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 01/14] linuxboot_dma: avoid guest ABI breakage on gcc vs. clang compilation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Recent GCC compiles linuxboot_dma.c to 921 bytes, while CentOS 6 needs 1029 and clang needs 1527. Because the size of the ROM, rounded to the next 512 bytes, must match, this causes the API to break between a <1K ROM and one that is bigger. We want to make the ROM 1.5 KB in size, but it's better to make clang produce leaner ROMs, because currently it is worryingly close to the limit. To fix this prevent clang's happy inlining (which -Os cannot prevent). This only requires adding a noinline attribute. Second, the patch makes sure that the ROM has enough padding to prevent ABI breakage on different compilers. The size is now hardcoded in the file that is passed to signrom.py, as was the case before commit 6f71b77 ("scripts/signrom.py: Allow option ROM checksum script to write the size header.", 2016-05-23); signrom.py however will still pad the input to the requested size. This ensures that the padding goes beyond the next multiple of 512 if necessary, and also avoids the need for -fno-toplevel-reorder which clang doesn't support. signrom.py can then error out if the requested size is too small for the actual size of the compiled ROM. Signed-off-by: Paolo Bonzini --- pc-bios/linuxboot_dma.bin | Bin 1024 -> 1536 bytes pc-bios/optionrom/linuxboot_dma.c | 8 ++++++-- scripts/signrom.py | 27 +++++++++++---------------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/pc-bios/linuxboot_dma.bin b/pc-bios/linuxboot_dma.bin index e1f623a1245efff0d46ea5b685e0f18e4ef98d74..238a195d3869995067f158d243d852778d38a736 100644 GIT binary patch literal 1536 zcmeHFO=}ZT6n#mjn#9N?ZK{K0k;PaL-DD+#E`)TKK>SF%@QZ?;pp*(SMO{f8vv`CI z_!9&-x)zKBLZ%f_LNuh%S`|r(v{S59T@^nv-g)U07ybYjeTz4D&OPs(`|i7ihXW1v z&y{3)emWlr%H&aYT!!qlh)#^<3M_khdgexI>gwdhOV?7FoX`3Gb8V4T4OV^17z*G` zOn^I3n-~Xwj#DUg8S@xQE3`AD-$A|K(7+ertc1X4;Vf$ie}Jj?IftcP?P z=6ZtIvqam3<7z0a3aQvV%fdk;)OF zd{0P_V?yG)1kU@?8C~hi6fr;?lBo<)AHR4WO3UI?t{W35w~doH(lT=XJJbR$+43du zx6Kjoh43q=nR%#VPPwh#*%zRfiBT!H$tO_6LEl;^Qi;M&6PFP6(lryXhx%9clkV4F zTOA6?dUuL?mn5!9JS1>O;H0C$j!T^o+y{~$mHc7Bzbo;i#1jI)+1JVFQP?AWovfaO zJK4t*I(6nOC3y=6=4q%Dn4e?=0EZ1s*zc=ft{1q{%>6iWxrfC#EH)uF?F&uL= cH&7qfG012%;B+Eu-5wcjuk8-}=N-898@_u-5C8xG literal 1024 zcmd6mziX307{@Q^tG-DiZ>p(g$dKVIh%T9=qM-1)wGcJY!KxJW`(h~-Bt;!#jBtbm z9lAI>If`HmD0vg9wINblk!l@67gN$=2eDW*ug_gPT>JyP;dt+J&wZbtZ~C#n!Tz~o zj3=j(KEJ*^#!l)_mQr7*PmQM8$hE2ITk*;3<5#ZUh})ymX8Y&b7go%$;tR&$u7;7u zd7Q&ph$V;`5*|d8xQX0)4B`i}tBiRJVivhZ(1A#CL)y8mD6B{CjnC`{bTm=MXKl`$#}Z zhxPS-dEM@GB`+A9wh{9%R=26W}#UCn8I#H!Vog7g7j= 65536: - sys.exit("%s: option ROM size too large" % sys.argv[1]) +size = size_byte * 512 +if len(data) > size: + sys.stderr.write('error: ROM is too large (%d > %d)\n' % (len(data), size)) + sys.exit(1) +elif len(data) < size: + # Add padding if necessary, rounding the whole input to a multiple of + # 512 bytes according to the third byte of the input. # 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) + if ord(data[-1:]) != 0: + sys.stderr.write('WARNING: ROM includes nonzero checksum\n') + data = data[:size-1] fout.write(data) -- 1.8.3.1