[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Build errors with fuzz/x86_instruction_emulator harness


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 14 Aug 2023 16:34:37 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sTHPQv2CsGuGXE2CEzb8nMBug0A8CGzXYyLjD63Ozhg=; b=h5V/ihsblTGU4ZmD0BmkjuKfoQcKyPmCTMLJXu4ZN+0fr+beb4sYYwHk6HO8Bkvt6mjJ582IUyDNyeMGOBdusIvq2mtgloOS/Ij3XcJeSd3EJr6lr3drwthgOzXJh92vTv07wPD0a6EzHMScgV/Frw7LMC6wO5mT3sWoD1RYL9lVBanOzhzSvsPdswlbzJOEUJ7acuVh1ooFU8VUILWN3AoX2uViU1p6dd1rDfaDzKfcaWs9EMKFCxWgVrCzYErNPjwKEMl3QlVvOe7/OZMV5v+4e7y/YE46PPUx8rpiKkCPFHQLTl9ckz3gXcYi+vVAG6ch6xBI9Zoa4L9g1oO2gw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JkWioMcZ6HQ8q3gbkm4hOQQm3wu3sdu6AZKT2JKM64uASP7isf4+/WZmAf9+vhJf94uX/ORtrhRtXPAMEZuIrlITZ3ZH81csE91StIwXo7NjG/GPlWVj1Lc+Iy0o8qkplmhu3RJsyTFF6SqV8babZN/WbLB1LAVvSsffocXcaE3GNmXwPzvSpa1f1oaMuRBUwZ/0CGcs6xFMFgSWC2j8ersyL3Av3hjLbDWlhqMLAERa5vHY2ERDsqkoGRBVz84goRwu7zvfNfuv1g6glbT/r4hHn5tZj/AZR3EFPmjvQ0ndDN0+XPm6X8oo4p+KsK6LW8qpmEVcYSkAoHi/wiufnA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Mon, 14 Aug 2023 15:35:00 +0000
  • Ironport-data: A9a23:kkjU364bwpwQomQjf/7aegxRtCHGchMFZxGqfqrLsTDasY5as4F+v mEfXm2Aaf2LNDemedAlao2z80xTupaDydVgS1M5qiwzHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvynTraCYnsrLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9lU35ZwehBtC5gZlPaAS4AeE/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5my +VbLRsGdhK4ns3n/I+EQclXg+QoM5y+VG8fkikIITDxK98DGMqGb4CUoNhS0XE3m9xEGuvYa 4wBcz1zYR/cYhpJfFAKFJY5m+TujX76G9FagAvN+exrvC6OnUooj+SF3Nn9I7RmQe18mEqCq 32A1GP+GhwAb/SUyCaf82LqjejK9c/+cNtLROLirKEy0DV/wEQpCQJJVgCCj8DppXalX/YcB 0Yloigx+P1aGEuDC4OVsweDiHyOswMYWtFQO/Yn8wzLwa3Riy6JC25BQjNfZdgOsM4tWSdsx lKPh8nuBzFkrPuSU331y1uPhTa7OCxQIWpcYyYBFFEB+4O6/911iQ/TRNF+FqLzlsfyBTz73 zGNqm45mqkXiskIka68+Dgrng6Rm3QAdSZtji2/Y45vxlkRiFKND2Bw1WXm0A==
  • Ironport-hdrordr: A9a23:+B3PqqqSLA9HcT4ZMCy7YYwaV5rdeYIsimQD101hICG9Evb0qy lhppQmPH7P+VAssRQb8+xoV5PufZqxz/BICMwqTNWftWrdyQyVxeNZnOjfKlTbckWTygce79 YET0EXMrbN5DNB/KLHCWeDcurJwLO8gd+VbeW19QYScem9AZsQnjuQCWygYz1LrBEtP+tBKH IFjPA32gZJfx4sH7yGL0hAZcfvjfvRmqnrZBYXbiRXlDVn3VuTmcXH+wHz5GZlbw9y
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14/08/2023 4:21 pm, Jan Beulich wrote:
> On 14.08.2023 16:52, Andrew Cooper wrote:
>> See the attached log snippet.  This is current staging, with a GCC 13
>> toolchain.
>>
>> First of all, a minor issue.  Counting the number of
>> `-D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__`'s, we
>> have included CFLAGS on the CC line 4 times.  This is something that
>> appears to be in common with all of tools/ and is probably the primary
>> contributor to exceeding the Gitlab CI 4M log limit...
>>
>> Next the error.  This doesn't build when CFLAGS coming in from the
>> packaging environment include `-flto=auto`.
>>
>> Clearly our wrapping trick doesn't work with LTO, but it's not obvious why.
>>
>> readelf -Wa tools/fuzz/x86_instruction_emulator/wrappers.o | grep emul_
>>   [223] .gnu.lto_emul_fwrite.38.43da3a7fd30cc0a1 PROGBITS       
>> 0000000000000000 01c2ec 000194 00   E  0   0  1
>>   [224] .gnu.lto_emul_memcmp.39.43da3a7fd30cc0a1 PROGBITS       
>> 0000000000000000 01c480 0001a7 00   E  0   0  1
>>   [225] .gnu.lto_emul_memcpy.40.43da3a7fd30cc0a1 PROGBITS       
>> 0000000000000000 01c627 000175 00   E  0   0  1
>>   [226] .gnu.lto_emul_memset.41.43da3a7fd30cc0a1 PROGBITS       
>> 0000000000000000 01c79c 000186 00   E  0   0  1
>>   [227] .gnu.lto_emul_printf.42.43da3a7fd30cc0a1 PROGBITS       
>> 0000000000000000 01c922 0002cd 00   E  0   0  1
>>   [228] .gnu.lto_emul_putchar.43.43da3a7fd30cc0a1 PROGBITS       
>> 0000000000000000 01cbef 000216 00   E  0   0  1
>>   [229] .gnu.lto_emul_puts.44.43da3a7fd30cc0a1 PROGBITS       
>> 0000000000000000 01ce05 000180 00   E  0   0  1
>>
>> shows that there's something relevant in the object file.
> But only sections, no symbols. Doing a simple test with a trivial source
> file, I observe that no actual code is emitted at all, and hence also no
> symbols. Which means our trick - working entirely behind the back of the
> compiler by inserting .equ in the assembly output - takes no effect on
> our own sources. And really the errors in the log fragment you provided
> all point back to standard library headers, where (just a guess)
> something may be done that cause _some_ code to be emitted, for which
> our overrides then take effect.

It turns out it was GCC 12 not GCC 13.  Things build cleanly with no LTO.

>> Manual poking about in the build environment indicates that
>> tools/tests/x86_instruction_emulator is similarly impacted.
>>
>> Any ideas?
>>
>> Obviously we can inhibit LTO for the x86_emul userspace, but that ought
>> to be a last resort.
> To get the build issue addressed, merely suppressing LTO for wrappers.o
> may suffice (provided such mixing is permitted in the first place).
> However, due to our overrides not taking effect (as per above) I can't
> see how the resulting binaries then would work correctly.

Indeed.  While I don't particularly care for the fuzzing harness (It's a
little dubious that it builds by default but doesn't install anything),
the main emulator harness does need to function properly.  That gets
widespred use in testing.

> Question therefore is whether we can find a way of effecting the needed
> overrides (including for compiler generated calls) without resorting to
> emitting .equ (or alike), and hence without doing it fully behind the
> compiler's back.

--wrap= each symbol, except when compiling wrappers.c ?

This seems to be the normal way to mock out functions including malloc()
and friends.

~Andrew



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.