|
From: | Amir Gonnen |
Subject: | Building QEMU as a shared library |
Date: | Wed, 15 Dec 2021 08:18:53 +0000 |
Hi, Before sending a patch, I would like to check if it's of interest to the community. My goal is to simulate a mixed architecture system. Today QEMU strongly assumes that the simulated system is a *single architecture*. Changing this assumption and supporting mixed architecture in QEMU proved to be
non-trivial and may require significant development effort. Common code such as
TCG and others explicitly include architecture specific header files, for example. A possible solution, discussed on
https://stackoverflow.com/q/63229262/619493 is to separate the simulation to multiple processes (as done by Xilinx) and to use some form of Interprocess Communication channel between them. Such solution has several disadvantages: - Harder to synchronize simulation between processes - Performance impact of Interprocess Communication - Harder to debug, profile and maintain Instead, I would like to suggest a new approach we use at Neuroblade to achieve this: Build QEMU as a shared library that can be loaded and used directly in a larger simulation. Today we build qemu-system-nios2 shared library and load it from qemu-system-x86_64 in order
to simulate an x86_64 system that also consists of multiple nios2 cores. In our simulation, two independent "main" functions are running on different threads, and
simulation synchronization is reduced to synchronizing threads. To achieve this, I needed to do the following changes in QEMU: 1. Avoid Glib global context. Use a different context (g_main_context_new) for each QEMU instance. 2. Change meson.build to build QEMU as a shared library (with PIC enabled for static libraries) 3. Define a C API for the library and export it (with a -Wl,--version-script) These changes seem enough for simulating mixed architecture system on a single process. If this approach sounds useful, I'll be happy to send patches. I'd appreciate if you could provide your feedback! Thanks, Amir The contents of this email message and any attachments are intended solely for the addressee(s) and may contain confidential and/or privileged information and may be legally protected from disclosure. If you are not the intended recipient of this message or their agent, or if this message has been addressed to you in error, please immediately alert the sender by reply email and then delete this message and any attachments. If you are not the intended recipient, you are hereby notified that any use, dissemination, copying, or storage of this message or its attachments is strictly prohibited. |
[Prev in Thread] | Current Thread | [Next in Thread] |