qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Support for using TCG frontend as a library
@ 2016-11-27 19:32 Alessandro Di Federico
  2016-11-29 16:26 ` Paolo Bonzini
  0 siblings, 1 reply; 16+ messages in thread
From: Alessandro Di Federico @ 2016-11-27 19:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Yan, Jonas Zaddach (jzaddach)

Hi all,
  QEMU is a great emulator, but in recent years it has also been used
for instrumentation purposes [QIRA,AFL] or as a lifter for static
analysis purposes [rev.ng,angr,libqemu,S²E]. I'd like to hear your
take on the second use case, and the possibility of offering upstream
support for it.

The general idea is to introduce a new build configuration which
produces a library for each supported input ISA exposing the TCG
frontend in a unified way. We could call it libtcg-$ARCH.so. In
practice, given a buffer containing code for a certain architecture,
the user program loads the appropriate version of this library and asks
it to produce the corresponding TCG instructions.

I've been investigating the needs of the various projects that might be
interested in using it and they sum up to the following:

* Be able to load in the same process multiple libtcg-$ARCH.so for
  different architectures.
* Obtain the TCG instructions from code in a memory buffer.
* Dump the assembly code of the code in a memory buffer.
* Dump the TCG instructions in textual form.

For what concerns helpers, it would be nice to have some metadata about
them, for instance the parts of the CPU state they can change. It would
also be nice to have a build configuration which produces a library
containing all the helpers ready to be used, or, even better, a library
as LLVM bitcode, which can then be further processed/analyzed.

Here you can find some relevant parts of my draft implementation part
of rev.ng:

* The interface exposed to users:
  https://polimicg.org/gitlab/revng/qemu/blob/develop/linux-user/ptc.h
* Implementation of the interface functions:
  https://polimicg.org/gitlab/revng/qemu/blob/develop/linux-user/ptc.c
* For the changes introduced elsewhere look for CONFIG_LIBTINYCODE:
  https://polimicg.org/gitlab/search?utf8=%E2%9C%93&search=CONFIG_LIBTINYCODE&group_id=&project_id=83&search_code=true&repository_ref=develop

It's rough but it works (see [rev.ng]). I'm interested to hear your
opinion and willingness to take patches. Being able to unify the
various efforts in this direction would be good, having upstream
support would be amazing.

--
Alessandro Di Federico
PhD student at Politecnico di Milano

[QIRA] http://qira.me/
[AFL] http://lcamtuf.coredump.cx/afl/ (for the black-box mode)
[rev.ng] https://rev.ng/
[angr] http://angr.io/ (currently using VEX IR, QEMU support planned)
[libqemu] https://github.com/zaddach/libqemu
[S²E] http://s2e.epfl.ch/

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-12-02 10:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-27 19:32 [Qemu-devel] Support for using TCG frontend as a library Alessandro Di Federico
2016-11-29 16:26 ` Paolo Bonzini
2016-11-29 16:55   ` Liviu Ionescu
2016-11-30 23:01   ` Alessandro Di Federico
2016-12-01  8:50     ` Paolo Bonzini
2016-12-01 11:54       ` Liviu Ionescu
2016-12-01 12:38         ` Peter Maydell
2016-12-01 13:33           ` Liviu Ionescu
2016-12-01 14:38             ` Peter Maydell
2016-12-01 18:39               ` Liviu Ionescu
2016-12-01 19:13                 ` Peter Maydell
2016-12-01 19:45                   ` Liviu Ionescu
2016-12-02  9:40                     ` Peter Maydell
2016-12-02 10:12                       ` Liviu Ionescu
2016-12-02 10:24                         ` Peter Maydell
2016-12-02 10:51                           ` Liviu Ionescu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).