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

Re: [PATCH] x86emul: rework wrapping of libc functions in test and fuzzing harnesses


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 17 Aug 2023 16:48: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=8+8z5Otw+v2Pq1kLymvwrcxF1IpnD1u3tSLmev4/sEg=; b=H0z5H9UotqTnBvAMj6/aUu8gGzV03ODQL5ifEVX5XvG9MPe9qNoNF9eASwhOTbIpipRMzfxeKD2LP0PPeH/vaUCwhOCJy475FV6W5MkojL4cg2yGxMyzbhTuHZP3ia/kBLt8OREvICfNpoRQ9IC3UhUw47yUuuWdMESq3c7fwOjny5HyjFeMgLGlEgn7pnNweWvh84kzA2ggIJYCF5gO5NSDRT0nKRO5GRxh09n3sCAzn/TNH/suuggudgCtv0EhYhd4iSmbPcWknBKbrrt5AR5wcNL4+XK69R5KaQ0vxc+D/lbH1jCODD5fZgFpacGXBqkMM6tzswIDzyzcdvOz1w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gwA0vdCQnCHUUUcsMT6OeHnCCiqkxbeqvRntG+ai/uLvUQLjRIhDE2vGANuRxllTB15qXUuMJp9bk3dl0n7LGQot8DpiAofTiyWzKGU536H+YSNRgsPJzVd7wGN4YUGs9GOJfOQthkr6r18r54jhSsmW9o/hIMKFfbqpIwaT7F89fI6I0Ik3cjkg/z29e14zJXi3/5BOHCCV/JHAwPe3yY4FRpvb8ovAlI1atp9ORtFswBtrx2i+XySZImuKbxuIjunobWrcEX2XysyzGYdlvNOcE14v7f2n4lnGHGmgQr/G5QXcdQ2mSuRUszuisnhfuhWQ/9/fxtFTAWtFwmtf0w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 17 Aug 2023 15:49:05 +0000
  • Ironport-data: A9a23:G4MwK6PjjUwLksrvrR2HlsFynXyQoLVcMsEvi/4bfWQNrUp21mBSz 2EZCmCEP/uONjTxKIhxb9mx/BsB78eBmoBnSgto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CU6jufQAOKnUoYoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGjxSs/vrRC9H5qyo42tI5wNmP5ingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0rcoWUZNq OIkEhQALR6IruWXxJm4ENA506zPLOGzVG8ekldJ6GmDSM0AGNXESaiM4sJE1jAtgMwIBezZe 8cSdTtoalLHfgFLPVAUTpk5mY9EhFGmK2Ee9A3T+PVxvzC7IA9ZidABNPL8fNCQSNoTtUGfv m/cpEzyAw0ANczZwj2Amp6prraWzH2kBNJPT9VU8NY00VGDgW00IiEUVACRjqGUjmq7Ctt2f hl8Fi0G6PJaGFaQZtv3UgC8oXWElgUBQNcWGOo/gCmSzoLE7gDfAXILJhZRZdpjuMIoSDgC0 l6Sg8ivFTFpqKeSS3+W6vGTtzzaBMQOBWoLZCtBVg1c5dDm+Ns3lkiXEo4lF7OphNroHz222 yqNsCU1m7QUi4gMyrm/+lfExTmro/AlUzII2+keZUr9hisRWWJvT9XABYTzhRqYELukcw==
  • Ironport-hdrordr: A9a23:f8NHLa92IXUrefKCsmduk+AcI+orL9Y04lQ7vn2ZKSY5TiX4rb HKoB1/73XJYVkqN03I9ervBEDiewK/yXcW2+ks1N6ZNWGLhILBFupfBODZsl7d8kPFl9K01c 1bAtJD4N+bNykGsS4tijPIb+rJw7O8gd+Vbf+19QYIcenzAZsQlzuQDGygYypLbTgDP7UVPr yG6PFKojKxEE5nFfhSVhE+Lo7+T8SgruOeXSI7
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 17/08/2023 2:13 pm, Jan Beulich wrote:
> On 17.08.2023 14:58, Andrew Cooper wrote:
>> On 17/08/2023 12:47 pm, Jan Beulich wrote:
>>> Our present approach is working fully behind the compiler's back. This
>>> was found to not work with LTO. Employ ld's --wrap= option instead. Note
>>> that while this makes the build work at least with new enough gcc (it
>>> doesn't with gcc7, for example, due to tool chain side issues afaict),
>>> according to my testing things still won't work when building the
>>> fuzzing harness with afl-cc: While with the gcc7 tool chain I see afl-as
>>> getting invoked, this does not happen with gcc13. Yet without using that
>>> assembler wrapper the resulting binary will look uninstrumented to
>>> afl-fuzz.
>>>
>>> While checking the resulting binaries I noticed that we've gained uses
>>> of snprintf() and strstr(), which only just so happen to not cause any
>>> problems. Add a wrappers for them as well.
>>>
>>> Since we don't have any actual uses of v{,sn}printf(), no definitions of
>>> their wrappers appear (just yet). But I think we want
>>> __wrap_{,sn}printf() to properly use __real_v{,sn}printf() right away,
>>> which means we need delarations of the latter.
>>>
>>> Reported-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>>> Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> This does resolve the build issue.  I do get a binary out of the end, so
>> Tested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>.
> Thanks.
>
>>   I presume that you've smoke tested the resulting binary?
> The fuzzer one? No. I didn't think it is of any use when not driven by afl.
> I did a proper test of the test harness one, albeit not with LTO in use (I
> focused on the fuzzer one with the LTO issue).

The fuzzer is only built because it's active-by-default in tools/, not
because it's used.

The test harness is the one that gets used routinely in testing.

>
>> However, I do see something else in the logs which is concerning. 
>> Likely unrelated.
>>
>> make[6]: Entering directory
>> '/builddir/build/BUILD/xen-4.18.0/tools/tests/x86_emulator'
>> gcc -m32 -march=i686 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall
>> -Wstrict-prototypes -Wdeclaration-after-statement
>> -Wno-unused-but-set-variable -Wno-unused-local-typedefs -g3 -Werror -Og
>> -fno-omit-frame-pointer
>> -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
>> -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -mno-tls-direct-seg-refs
>> -fno-pie -fno-stack-protector -fno-exceptions
>> -fno-asynchronous-unwind-tables -fno-builtin -g0 -D_64f2 -mavx512fp16
>> -ffixed-xmm0 -Os -DVEC_SIZE=64 -DFLOAT_SIZE=2 -c avx512fp16.c
>> make[6]: Leaving directory
>> '/builddir/build/BUILD/xen-4.18.0/tools/tests/x86_emulator'
>> /tmp/ccrznrqa.s: Assembler messages:
>> /tmp/ccrznrqa.s:98: Error: no such instruction: `vmovw .LC0,%xmm3'
>> /tmp/ccrznrqa.s:99: Error: no such instruction: `vmovw %xmm3,58(%esp)'
>> /tmp/ccrznrqa.s:105: Error: no such instruction: `vcvtsi2shl
>> %eax,%xmm1,%xmm1'
>> /tmp/ccrznrqa.s:106: Error: no such instruction: `vmovw
>> %xmm3,382(%esp,%eax,2)'
>> /tmp/ccrznrqa.s:107: Error: no such instruction: `vmovw
>> %xmm1,-2(%edx,%eax,2)'
>> /tmp/ccrznrqa.s:108: Error: no such instruction: `vcvtsi2shl
>> %ecx,%xmm1,%xmm1'
>> /tmp/ccrznrqa.s:109: Error: no such instruction: `vmovw
>> %xmm1,318(%esp,%eax,2)'
>> /tmp/ccrznrqa.s:113: Error: no such instruction: `vaddph
>> 256(%esp),%zmm7,%zmm5'
>> <snip many>
>> simd-fma.c:208: Error: no such instruction: `vfmaddsub231ph
>> 60(%esp){1to32},%zmm6,%zmm5'
>> simd-fma.c:209: Error: no such instruction: `vfmaddsub231ph
>> 60(%esp){1to32},%zmm6,%zmm1'
>>
>> GCC is 12.2.1, binutils is 2.37
>>
>> AVX512_FP16 was added in bintuils 2.38 so I understand the simd-fma.c
>> complains,
> Right. I assume the gcc is not the system one, or else I'd find it
> odd to have a compiler backed by a less capable assembler.

It is the system one, but it's entirely possible that there has been a
bootstrapping error.  We're trying something a bit new.

There are tasks to update both.  I'll keep an eye on the result.

~Andrew



 


Rackspace

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