Compare commits

...
Author SHA1 Message Date
Kate Temkin 376dc65f0e TCTI: add TCTI TCG backend for acceleration on non-JIT AArch64 2021-04-29 09:10:15 -07:00
Phillip Tennen a833a4bbe2 net/macos: implement vmnet-based netdev
This patch implements a new netdev device, reachable via -netdev
vmnet-macos, that’s backed by macOS’s vmnet framework.

The vmnet framework provides native bridging support, and its usage in
this patch is intended as a replacement for attempts to use a tap device
via the tuntaposx kernel extension. Notably, the tap/tuntaposx approach
never would have worked in the first place, as QEMU interacts with the
tap device via poll(), and macOS does not support polling device files.

vmnet requires either a special entitlement, granted via a provisioning
profile, or root access. Otherwise attempts to create the virtual
interface will fail with a “generic error” status code. QEMU may not
currently be signed with an entitlement granted in a provisioning
profile, as this would necessitate pre-signed binary build distribution,
rather than source-code distribution. As such, using this netdev
currently requires that qemu be run with root access. I’ve opened a
feedback report with Apple to allow the use of the relevant entitlement
with this use case:
https://openradar.appspot.com/radar?id=5007417364447232

vmnet offers three operating modes, all of which are supported by this
patch via the “mode=host|shared|bridge” option:

* "Host" mode: Allows the vmnet interface to communicate with other
* vmnet
interfaces that are in host mode and also with the native host.
* "Shared" mode: Allows traffic originating from the vmnet interface to
reach the Internet through a NAT. The vmnet interface can also
communicate with the native host.
* "Bridged" mode: Bridges the vmnet interface with a physical network
interface.

Each of these modes also provide some extra configuration that’s
supported by this patch:

* "Bridged" mode: The user may specify the physical interface to bridge
with. Defaults to en0.
* "Host" mode / "Shared" mode: The user may specify the DHCP range and
subnet. Allocated by vmnet if not provided.

vmnet also offers some extra configuration options that are not
supported by this patch:

* Enable isolation from other VMs using vmnet
* Port forwarding rules
* Enabling TCP segmentation offload
* Only applicable in "shared" mode: specifying the NAT IPv6 prefix
* Only available in "host" mode: specifying the IP address for the VM
within an isolated network

Note that this patch requires macOS 10.15 as a minimum, as this is when
bridging support was implemented in vmnet.framework.

Rebased to commit 571d413b5d by Akihiko
Odaki.

Signed-off-by: Phillip Tennen <[email protected]>
Signed-off-by: Akihiko Odaki <[email protected]>
Message-Id: <[email protected]>
2021-04-29 09:10:15 -07:00
Joelle van Dyne a01a0f6d13 coroutine: add libucontext as external library
iOS does not support ucontext natively for aarch64 and the sigaltstack is
also unsupported (even worse, it fails silently, see:
https://openradar.appspot.com/13002712 )

As a workaround we include a library implementation of ucontext and add it
as a build option.
2021-04-26 20:43:49 -07:00
osy c238135591 tcg: custom APRR implementation 2021-04-26 20:43:49 -07:00
Marc-André Lureau 095973359d build-sys: make libslirp a meson subproject
Remove the manual build.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2021-04-26 20:35:52 -07:00
Marc-André Lureau 35ce2ca27a slirp: update to git master
git cherry-diff:

Commits on bacb71f1c3ed5f40e393afd8be81bedfba13a401 branch that is not on 8f43a99191afb47ca3f3c6972f6306209f367ece branch
+ 1021b0dc38d39f1dc95a296fe3e05a24a087cdc6 disable_dns option
+ 0f94ceec752592e4ac632a24e3c64a97dd09bf4c limit vnameserver_addr to port 53
+ b57bafa852ef16b133907a13678ec69e9531f177 libslirp.h: fix SlirpConfig v3 documentation
+ 1abf18b2b5edb462797629ed47ad4515a195686e Update CHANGELOG
+ ff4ecf9b6c6542b24b4ac6ea178be9d44e159f79 Release v4.3.0
+ 21f1d933050a40d62612c6274c32de60b811d9ea changelog: post-release
+ 376187c4b14c795763d472214812826eebe7e9c2 Release v4.3.1
+ 73336e08902a7e826f7d960453df037380266186 changelog: post-release
+ 5c1c9d43be61571608e9b14615045b67b830daf5 udp, udp6, icmp: handle TTL value
+ 73ed49ab71998d4288e71e954ef6214b70f23d79 icmp, icmp6: Add icmp_forward_error and icmp6_forward_error
+ 7a4840a57ec7dbc37cca1ab96f058a9610b26950 udp, udp6, icmp, icmp6: Enable forwarding errors on Linux
+ e9b2bc19ae652a2907f247e621b2e4773bdd2aab TCPIPHDR_DELTA: Fix potential negative value
+ 39f9a363eec082f04513413046321abd04163148 .gitlab-ci: add a Coverity stage
+ 1b0093b973cfa0dc041522e5d4e6f576b2df642e sosendoob: better document what urgc is used for
+ 5b9ad89ebbb8afa50162c9156fabd5fc56291088 Add G_GNUC_PRINTF to local function slirp_vsnprintf
+ 8a808aa493980e212b4d5f5465330905c8294e59 meson: remove meson-dist script
+ 0b669b5fbe4d3c25a682a67f1059d8633c963b3d meson: support compiling as subproject
+ 9f82a47b81f2864422b82c1e40e51a2ed9c6ac32 Add DNS resolving for iOS
+ c0eac03e8ce1b9a743231f2fe21e7cb579fc9339 Remove the QEMU-special make build-system
+ 1bfd4d9368f9fa2e4f0731e1266bec05bbc83a80 socket: consume empty packets
+ 92413be68914f8cae2f5bad4bf3ab8491dcbc5d7 Release v4.4.0
+ 07e8cfac69766081871ab620d9f16a630543d302 changelog: post-release
+ 4c4e035813313d02b63fdeb920d56fb2fdc0a5b1 Remove some needless (void)casts
+ eee9db9d115d91aa82f33685c4e76d656db92976 fork_exec_child_setup: improve signal handling
+ 216f434a018b3af182a4f31bbe5a00daee170343 Fix unused variables

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
2021-04-26 20:35:52 -07:00
Gerd Hoffmann 79f04e8def hw/display: add virtio-ramfb device
Like virtio-vga, but using ramfb instead of legacy vga.
Useful for booting from OVMF into Windows ARM which expects a linear FB.
2021-04-26 20:35:52 -07:00
osy 7b4004767f meson: option to build as shared library
On iOS, we cannot fork() new processes, so the best way to load QEMU into an
app is through a shared library. We add a new configure option
`--enable-shared-lib` that will build the bulk of QEMU into a shared lib.
The usual executables will then link to the library.
2021-04-26 20:35:52 -07:00
Joelle van Dyne 59514b9805 slirp: feature detection for smbd
Replace Windows specific macro with a more generic feature detection
macro. Allows slirp smb feature to be disabled manually as well.
2021-04-26 20:35:48 -07:00
Joelle van DyneandWarner Losh f09f748adb block: detect DKIOCGETBLOCKCOUNT/SIZE before use
iOS hosts do not have these defined so we fallback to the
default behaviour.

Co-authored-by: Warner Losh <[email protected]>
2021-04-26 20:34:31 -07:00
Joelle van Dyne cdfab9dac4 block: check for sys/disk.h
Some BSD platforms do not have this header.
2021-04-26 20:34:31 -07:00
Joelle van Dyne e84d0a6276 block: feature detection for host block support
On Darwin (iOS), there are no system level APIs for directly accessing
host block devices. We detect this at configure time.
2021-04-26 20:34:31 -07:00
37 changed files with 4531 additions and 166 deletions

No files matched your search

+6 -3
View File
@@ -49,9 +49,9 @@
[submodule "roms/edk2"]
path = roms/edk2
url = https://gitlab.com/qemu-project/edk2.git
[submodule "slirp"]
path = slirp
url = https://gitlab.com/qemu-project/libslirp.git
[submodule "subprojects/libslirp"]
path = subprojects/libslirp
url = https://git.qemu.org/git/libslirp.git
[submodule "roms/opensbi"]
path = roms/opensbi
url = https://gitlab.com/qemu-project/opensbi.git
@@ -64,3 +64,6 @@
[submodule "roms/vbootrom"]
path = roms/vbootrom
url = https://gitlab.com/qemu-project/vbootrom.git
[submodule "libucontext"]
path = subprojects/libucontext
url = https://github.com/utmapp/libucontext.git
+1
View File
@@ -26,6 +26,7 @@
#include "disas/disas.h"
#include "exec/exec-all.h"
#include "tcg/tcg.h"
#include "tcg/tcg-apple-jit.h"
#include "qemu/atomic.h"
#include "qemu/compiler.h"
#include "qemu/timer.h"
+4 -3
View File
@@ -27,6 +27,7 @@
#include "disas/disas.h"
#include "exec/exec-all.h"
#include "tcg/tcg.h"
#include "tcg/tcg-apple-jit.h"
#if defined(CONFIG_USER_ONLY)
#include "qemu.h"
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
@@ -1128,7 +1129,7 @@ static bool alloc_code_gen_buffer_anon(size_t size, int prot,
return true;
}
#ifndef CONFIG_TCG_INTERPRETER
#if !defined(CONFIG_TCG_INTERPRETER) && !defined(CONFIG_TCG_THREADED_INTERPRETER)
#ifdef CONFIG_POSIX
#include "qemu/memfd.h"
@@ -1255,7 +1256,7 @@ static bool alloc_code_gen_buffer_splitwx_vmremap(size_t size, Error **errp)
static bool alloc_code_gen_buffer_splitwx(size_t size, Error **errp)
{
#ifndef CONFIG_TCG_INTERPRETER
#if !defined(CONFIG_TCG_INTERPRETER) && !defined(CONFIG_TCG_THREADED_INTERPRETER)
# ifdef CONFIG_DARWIN
return alloc_code_gen_buffer_splitwx_vmremap(size, errp);
# endif
@@ -1288,7 +1289,7 @@ static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp)
prot = PROT_READ | PROT_WRITE | PROT_EXEC;
flags = MAP_PRIVATE | MAP_ANONYMOUS;
#ifdef CONFIG_TCG_INTERPRETER
#if defined(CONFIG_TCG_INTERPRETER) || defined(CONFIG_TCG_THREADED_INTERPRETER)
/* The tcg interpreter does not need execute permission. */
prot = PROT_READ | PROT_WRITE;
#elif defined(CONFIG_DARWIN)
+1 -1
View File
@@ -54,7 +54,7 @@
#ifdef CONFIG_BSD
#include <sys/ioctl.h>
#include <sys/queue.h>
#ifndef __DragonFly__
#if defined(HAVE_SYS_DISK_H)
#include <sys/disk.h>
#endif
#endif
+29 -22
View File
@@ -42,6 +42,8 @@
#include "scsi/constants.h"
#if defined(__APPLE__) && (__MACH__)
#include <sys/ioctl.h>
#if defined(HAVE_HOST_BLOCK_DEVICE)
#include <paths.h>
#include <sys/param.h>
#include <IOKit/IOKitLib.h>
@@ -52,6 +54,7 @@
//#include <IOKit/storage/IOCDTypes.h>
#include <IOKit/storage/IODVDMedia.h>
#include <CoreFoundation/CoreFoundation.h>
#endif /* defined(HAVE_HOST_BLOCK_DEVICE) */
#endif
#ifdef __sun__
@@ -181,7 +184,17 @@ typedef struct BDRVRawReopenState {
bool check_cache_dropped;
} BDRVRawReopenState;
static int fd_open(BlockDriverState *bs);
static int fd_open(BlockDriverState *bs)
{
BDRVRawState *s = bs->opaque;
/* this is just to ensure s->fd is sane (its called by io ops) */
if (s->fd >= 0) {
return 0;
}
return -EIO;
}
static int64_t raw_getlength(BlockDriverState *bs);
typedef struct RawPosixAIOData {
@@ -2308,8 +2321,10 @@ static int64_t raw_getlength(BlockDriverState *bs)
again:
#endif
if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) {
size = 0;
#ifdef DIOCGMEDIASIZE
if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
size = 0;
#elif defined(DIOCGPART)
{
struct partinfo pi;
@@ -2318,9 +2333,7 @@ again:
else
size = 0;
}
if (size == 0)
#endif
#if defined(__APPLE__) && defined(__MACH__)
#elif defined(DKIOCGETBLOCKCOUNT) && defined(DKIOCGETBLOCKSIZE)
{
uint64_t sectors = 0;
uint32_t sector_size = 0;
@@ -2328,19 +2341,15 @@ again:
if (ioctl(fd, DKIOCGETBLOCKCOUNT, &sectors) == 0
&& ioctl(fd, DKIOCGETBLOCKSIZE, &sector_size) == 0) {
size = sectors * sector_size;
} else {
size = lseek(fd, 0LL, SEEK_END);
if (size < 0) {
return -errno;
}
}
}
#else
size = lseek(fd, 0LL, SEEK_END);
#endif
if (size == 0) {
size = lseek(fd, 0LL, SEEK_END);
}
if (size < 0) {
return -errno;
}
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
switch(s->type) {
case FTYPE_CD:
@@ -3027,6 +3036,7 @@ static BlockStatsSpecific *raw_get_specific_stats(BlockDriverState *bs)
return stats;
}
#if defined(HAVE_HOST_BLOCK_DEVICE)
static BlockStatsSpecific *hdev_get_specific_stats(BlockDriverState *bs)
{
BlockStatsSpecific *stats = g_new(BlockStatsSpecific, 1);
@@ -3036,6 +3046,7 @@ static BlockStatsSpecific *hdev_get_specific_stats(BlockDriverState *bs)
return stats;
}
#endif /* HAVE_HOST_BLOCK_DEVICE */
static QemuOptsList raw_create_opts = {
.name = "raw-create-opts",
@@ -3260,6 +3271,8 @@ BlockDriver bdrv_file = {
/***********************************************/
/* host device */
#if defined(HAVE_HOST_BLOCK_DEVICE)
#if defined(__APPLE__) && defined(__MACH__)
static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath,
CFIndex maxPathSize, int flags);
@@ -3552,16 +3565,6 @@ hdev_co_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
}
#endif /* linux */
static int fd_open(BlockDriverState *bs)
{
BDRVRawState *s = bs->opaque;
/* this is just to ensure s->fd is sane (its called by io ops) */
if (s->fd >= 0)
return 0;
return -EIO;
}
static coroutine_fn int
hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes)
{
@@ -3885,6 +3888,8 @@ static BlockDriver bdrv_host_cdrom = {
};
#endif /* __FreeBSD__ */
#endif /* HAVE_HOST_BLOCK_DEVICE */
static void bdrv_file_init(void)
{
/*
@@ -3892,6 +3897,7 @@ static void bdrv_file_init(void)
* registered last will get probed first.
*/
bdrv_register(&bdrv_file);
#if defined(HAVE_HOST_BLOCK_DEVICE)
bdrv_register(&bdrv_host_device);
#ifdef __linux__
bdrv_register(&bdrv_host_cdrom);
@@ -3899,6 +3905,7 @@ static void bdrv_file_init(void)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
bdrv_register(&bdrv_host_cdrom);
#endif
#endif /* HAVE_HOST_BLOCK_DEVICE */
}
block_init(bdrv_file_init);
Vendored
+59 -11
View File
@@ -362,6 +362,7 @@ tsan="no"
fortify_source="$default_feature"
strip_opt="yes"
tcg_interpreter="false"
tcg_threaded_interpreter="false"
bigendian="no"
mingw32="no"
gcov="no"
@@ -463,9 +464,11 @@ gettext="auto"
fuse="auto"
fuse_lseek="auto"
multiprocess="auto"
shared_lib="false"
malloc_trim="auto"
gio="$default_feature"
slirp_smbd="auto"
# parse CC options second
for opt do
@@ -835,8 +838,6 @@ do
fi
done
: ${smbd=${SMBD-/usr/sbin/smbd}}
# Default objcc to clang if available, otherwise use CC
if has clang; then
objcc=clang
@@ -1115,6 +1116,10 @@ for opt do
;;
--enable-tcg-interpreter) tcg_interpreter="true"
;;
--disable-tcg-tcti) tcg_threaded_interpreter="false"
;;
--enable-tcg-tcti) tcg_threaded_interpreter="true"
;;
--disable-cap-ng) cap_ng="disabled"
;;
--enable-cap-ng) cap_ng="enabled"
@@ -1565,6 +1570,14 @@ for opt do
;;
--disable-gio) gio=no
;;
--enable-slirp-smbd) slirp_smbd=yes
;;
--disable-slirp-smbd) slirp_smbd=no
;;
--enable-shared-lib) shared_lib=true
;;
--disable-shared-lib) shared_lib=false
;;
*)
echo "ERROR: unknown option $opt"
echo "Try '$0 --help' for more information"
@@ -1778,7 +1791,7 @@ Advanced options (experts only):
--oss-lib path to OSS library
--cpu=CPU Build for host CPU [$cpu]
--with-coroutine=BACKEND coroutine backend. Supported options:
ucontext, sigaltstack, windows
ucontext, libucontext, sigaltstack, windows
--enable-gcov enable test coverage analysis with gcov
--disable-blobs disable installing provided firmware blobs
--with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
@@ -1792,6 +1805,7 @@ Advanced options (experts only):
enable plugins via shared library loading
--disable-containers don't use containers for cross-building
--gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
--enable-shared-lib build QEMU as a shared library
Optional features, enabled with --enable-FEATURE and
disabled with --disable-FEATURE, default is enabled if available
@@ -1919,6 +1933,7 @@ disabled with --disable-FEATURE, default is enabled if available
fuse-lseek SEEK_HOLE/SEEK_DATA support for FUSE exports
multiprocess Out of process device emulation support
gio libgio support
slirp-smbd use smbd (at path --smbd=*) in slirp networking
NOTE: The object files are built at the place where configure is launched
EOF
@@ -4535,12 +4550,26 @@ else
error_exit "only the 'windows' coroutine backend is valid for Windows"
fi
;;
libucontext)
;;
*)
error_exit "unknown coroutine backend $coroutine"
;;
esac
fi
case $coroutine in
libucontext)
git_submodules="${git_submodules} subprojects/libucontext"
coroutine_impl=ucontext
libucontext="enabled"
;;
*)
coroutine_impl=$coroutine
libucontext="disabled"
;;
esac
if test "$coroutine_pool" = ""; then
coroutine_pool=yes
fi
@@ -5250,11 +5279,24 @@ case "$slirp" in
auto | enabled | internal)
# Simpler to always update submodule, even if not needed.
if test "$git_submodules_action" != "ignore"; then
git_submodules="${git_submodules} slirp"
git_submodules="${git_submodules} subprojects/libslirp"
fi
;;
esac
# Check for slirp smbd dupport
: ${smbd=${SMBD-/usr/sbin/smbd}}
if test "$slirp_smbd" != "no" ; then
if test "$mingw32" = "yes" ; then
if test "$slirp_smbd" = "yes" ; then
error_exit "Host smbd not supported on this platform."
fi
slirp_smbd=no
else
slirp_smbd=yes
fi
fi
##########################################
# check for usable __NR_keyctl syscall
@@ -5530,7 +5572,10 @@ fi
if test "$guest_agent" = "yes" ; then
echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
fi
echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
if test "$slirp_smbd" = "yes" ; then
echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
fi
if test "$vde" = "yes" ; then
echo "CONFIG_VDE=y" >> $config_host_mak
echo "VDE_LIBS=$vde_libs" >> $config_host_mak
@@ -5861,7 +5906,7 @@ if test "$qom_cast_debug" = "yes" ; then
echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
fi
echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
echo "CONFIG_COROUTINE_BACKEND=$coroutine_impl" >> $config_host_mak
if test "$coroutine_pool" = "yes" ; then
echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
else
@@ -6343,7 +6388,11 @@ echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
if has $sdl2_config; then
echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
fi
echo "strip = [$(meson_quote $strip)]" >> $cross
if test "$shared_lib" = "true"; then
echo "strip = [$(meson_quote $strip), '-x']" >> $cross
else
echo "strip = [$(meson_quote $strip)]" >> $cross
fi
echo "windres = [$(meson_quote $windres)]" >> $cross
if test "$cross_compile" = "yes"; then
cross_arg="--cross-file config-meson.cross"
@@ -6420,14 +6469,13 @@ NINJA=$ninja $meson setup \
-Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
-Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse \
-Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
-Dattr=$attr -Ddefault_devices=$default_devices \
-Dattr=$attr -Ddefault_devices=$default_devices -Ducontext=$libucontext \
-Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
-Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
-Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi \
$(if test "$default_features" = no; then echo "-Dauto_features=disabled"; fi) \
-Dtcg_interpreter=$tcg_interpreter \
$cross_arg \
"$PWD" "$source_path"
-Dtcg_interpreter=$tcg_interpreter -Dtcg_threaded_interpreter=$tcg_threaded_interpreter\
-Dshared_lib=$shared_lib $cross_arg "$PWD" "$source_path"
if test "$?" -ne 0 ; then
error_exit "meson setup failed"
+2
View File
@@ -152,6 +152,8 @@ static void initialize_debug_host(CPUDebug *s)
#endif
#if defined(CONFIG_TCG_INTERPRETER)
s->info.print_insn = print_insn_tci;
#elif defined(CONFIG_TCG_THREADED_INTERPRETER)
s->info.print_insn = print_insn_tcti;
#elif defined(__i386__)
s->info.mach = bfd_mach_i386_i386;
s->info.print_insn = print_insn_i386;
+1
View File
@@ -60,6 +60,7 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
virtio_gpu_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRGL'],
if_true: [files('virtio-gpu-3d.c'), pixman, virgl])
virtio_gpu_ss.add(when: 'CONFIG_VHOST_USER_GPU', if_true: files('vhost-user-gpu.c'))
virtio_gpu_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('virtio-ramfb.c'))
hw_display_modules += {'virtio-gpu': virtio_gpu_ss}
endif
+188
View File
@@ -0,0 +1,188 @@
#include "qemu/osdep.h"
#include "hw/pci/pci.h"
#include "ui/console.h"
#include "hw/qdev-properties.h"
#include "hw/virtio/virtio-gpu-pci.h"
#include "qapi/error.h"
#include "hw/display/ramfb.h"
#include "qom/object.h"
/*
* virtio-ramfb-base: This extends VirtioPCIProxy.
*/
#define TYPE_VIRTIO_RAMFB_BASE "virtio-ramfb-base"
OBJECT_DECLARE_TYPE(VirtIORAMFBBase, VirtIORAMFBBaseClass,
VIRTIO_RAMFB_BASE)
struct VirtIORAMFBBase {
VirtIOPCIProxy parent_obj;
VirtIOGPUBase *vgpu;
RAMFBState *ramfb;
};
struct VirtIORAMFBBaseClass {
VirtioPCIClass parent_class;
DeviceReset parent_reset;
};
static void virtio_ramfb_invalidate_display(void *opaque)
{
VirtIORAMFBBase *vramfb = opaque;
VirtIOGPUBase *g = vramfb->vgpu;
if (g->enable) {
g->hw_ops->invalidate(g);
}
}
static void virtio_ramfb_update_display(void *opaque)
{
VirtIORAMFBBase *vramfb = opaque;
VirtIOGPUBase *g = vramfb->vgpu;
if (g->enable) {
g->hw_ops->gfx_update(g);
} else {
ramfb_display_update(g->scanout[0].con, vramfb->ramfb);
}
}
static int virtio_ramfb_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
{
VirtIORAMFBBase *vramfb = opaque;
VirtIOGPUBase *g = vramfb->vgpu;
if (g->hw_ops->ui_info) {
return g->hw_ops->ui_info(g, idx, info);
}
return -1;
}
static void virtio_ramfb_gl_block(void *opaque, bool block)
{
VirtIORAMFBBase *vramfb = opaque;
VirtIOGPUBase *g = vramfb->vgpu;
if (g->hw_ops->gl_block) {
g->hw_ops->gl_block(g, block);
}
}
static const GraphicHwOps virtio_ramfb_ops = {
.invalidate = virtio_ramfb_invalidate_display,
.gfx_update = virtio_ramfb_update_display,
.ui_info = virtio_ramfb_ui_info,
.gl_block = virtio_ramfb_gl_block,
};
static const VMStateDescription vmstate_virtio_ramfb = {
.name = "virtio-ramfb",
.version_id = 2,
.minimum_version_id = 2,
.fields = (VMStateField[]) {
/* no pci stuff here, saving the virtio device will handle that */
/* FIXME */
VMSTATE_END_OF_LIST()
}
};
/* RAMFB device wrapper around PCI device around virtio GPU */
static void virtio_ramfb_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
{
VirtIORAMFBBase *vramfb = VIRTIO_RAMFB_BASE(vpci_dev);
VirtIOGPUBase *g = vramfb->vgpu;
int i;
/* init virtio bits */
virtio_pci_force_virtio_1(vpci_dev);
if (!qdev_realize(DEVICE(g), BUS(&vpci_dev->bus), errp)) {
return;
}
/* init ramfb */
vramfb->ramfb = ramfb_setup(errp);
graphic_console_set_hwops(g->scanout[0].con, &virtio_ramfb_ops, vramfb);
for (i = 0; i < g->conf.max_outputs; i++) {
object_property_set_link(OBJECT(g->scanout[i].con), "device",
OBJECT(vpci_dev), &error_abort);
}
}
static void virtio_ramfb_reset(DeviceState *dev)
{
VirtIORAMFBBaseClass *klass = VIRTIO_RAMFB_BASE_GET_CLASS(dev);
/* reset virtio-gpu */
klass->parent_reset(dev);
}
static Property virtio_ramfb_base_properties[] = {
DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
DEFINE_PROP_END_OF_LIST(),
};
static void virtio_ramfb_base_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
VirtIORAMFBBaseClass *v = VIRTIO_RAMFB_BASE_CLASS(klass);
PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
device_class_set_props(dc, virtio_ramfb_base_properties);
dc->vmsd = &vmstate_virtio_ramfb;
dc->hotpluggable = false;
device_class_set_parent_reset(dc, virtio_ramfb_reset,
&v->parent_reset);
k->realize = virtio_ramfb_realize;
pcidev_k->class_id = PCI_CLASS_DISPLAY_OTHER;
}
static TypeInfo virtio_ramfb_base_info = {
.name = TYPE_VIRTIO_RAMFB_BASE,
.parent = TYPE_VIRTIO_PCI,
.instance_size = sizeof(VirtIORAMFBBase),
.class_size = sizeof(VirtIORAMFBBaseClass),
.class_init = virtio_ramfb_base_class_init,
.abstract = true,
};
#define TYPE_VIRTIO_RAMFB "virtio-ramfb"
typedef struct VirtIORAMFB VirtIORAMFB;
DECLARE_INSTANCE_CHECKER(VirtIORAMFB, VIRTIO_RAMFB,
TYPE_VIRTIO_RAMFB)
struct VirtIORAMFB {
VirtIORAMFBBase parent_obj;
VirtIOGPU vdev;
};
static void virtio_ramfb_inst_initfn(Object *obj)
{
VirtIORAMFB *dev = VIRTIO_RAMFB(obj);
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
TYPE_VIRTIO_GPU);
VIRTIO_RAMFB_BASE(dev)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
}
static VirtioPCIDeviceTypeInfo virtio_ramfb_info = {
.generic_name = TYPE_VIRTIO_RAMFB,
.parent = TYPE_VIRTIO_RAMFB_BASE,
.instance_size = sizeof(VirtIORAMFB),
.instance_init = virtio_ramfb_inst_initfn,
};
static void virtio_ramfb_register_types(void)
{
type_register_static(&virtio_ramfb_base_info);
virtio_pci_types_register(&virtio_ramfb_info);
}
type_init(virtio_ramfb_register_types)
+1
View File
@@ -411,6 +411,7 @@ typedef struct disassemble_info {
typedef int (*disassembler_ftype) (bfd_vma, disassemble_info *);
int print_insn_tci(bfd_vma, disassemble_info*);
int print_insn_tcti(bfd_vma, disassemble_info*);
int print_insn_big_mips (bfd_vma, disassemble_info*);
int print_insn_little_mips (bfd_vma, disassemble_info*);
int print_insn_nanomips (bfd_vma, disassemble_info*);
+4
View File
@@ -543,7 +543,11 @@ void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr);
#if defined(CONFIG_TCG_INTERPRETER)
extern __thread uintptr_t tci_tb_ptr;
# define GETPC() tci_tb_ptr
#elif defined(CONFIG_TCG_THREADED_INTERPRETER)
extern __thread uintptr_t tcti_call_return_address;
# define GETPC() tcti_call_return_address
#else
/* Note that this is correct for TCTI also; whose gadget behaves like native code. */
# define GETPC() \
((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0)))
#endif
-24
View File
@@ -702,30 +702,6 @@ char *qemu_get_host_name(Error **errp);
*/
size_t qemu_get_host_physmem(void);
/*
* Toggle write/execute on the pages marked MAP_JIT
* for the current thread.
*/
#if defined(MAC_OS_VERSION_11_0) && \
MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
static inline void qemu_thread_jit_execute(void)
{
if (__builtin_available(macOS 11.0, *)) {
pthread_jit_write_protect_np(true);
}
}
static inline void qemu_thread_jit_write(void)
{
if (__builtin_available(macOS 11.0, *)) {
pthread_jit_write_protect_np(false);
}
}
#else
static inline void qemu_thread_jit_write(void) {}
static inline void qemu_thread_jit_execute(void) {}
#endif
/**
* Platforms which do not support system() return ENOSYS
*/
+100
View File
@@ -0,0 +1,100 @@
/*
* Apple Silicon functions for JIT handling
*
* Copyright (c) 2020 osy
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TCG_APPLE_JIT_H
#define TCG_APPLE_JIT_H
/*
* APRR handling
* Credits to: https://siguza.github.io/APRR/
* Reversed from /usr/lib/system/libsystem_pthread.dylib
*/
#if defined(__aarch64__) && defined(CONFIG_DARWIN)
#define _COMM_PAGE_START_ADDRESS (0x0000000FFFFFC000ULL) /* In TTBR0 */
#define _COMM_PAGE_APRR_SUPPORT (_COMM_PAGE_START_ADDRESS + 0x10C)
#define _COMM_PAGE_APPR_WRITE_ENABLE (_COMM_PAGE_START_ADDRESS + 0x110)
#define _COMM_PAGE_APRR_WRITE_DISABLE (_COMM_PAGE_START_ADDRESS + 0x118)
static __attribute__((__always_inline__)) bool jit_write_protect_supported(void)
{
/* Access shared kernel page at fixed memory location. */
uint8_t aprr_support = *(volatile uint8_t *)_COMM_PAGE_APRR_SUPPORT;
return aprr_support > 0;
}
/* write protect enable = write disable */
static __attribute__((__always_inline__)) void jit_write_protect(int enabled)
{
/* Access shared kernel page at fixed memory location. */
uint8_t aprr_support = *(volatile uint8_t *)_COMM_PAGE_APRR_SUPPORT;
if (aprr_support == 0 || aprr_support > 3) {
return;
} else if (aprr_support == 1) {
__asm__ __volatile__ (
"mov x0, %0\n"
"ldr x0, [x0]\n"
"msr S3_4_c15_c2_7, x0\n"
"isb sy\n"
:: "r" (enabled ? _COMM_PAGE_APRR_WRITE_DISABLE
: _COMM_PAGE_APPR_WRITE_ENABLE)
: "memory", "x0"
);
} else {
__asm__ __volatile__ (
"mov x0, %0\n"
"ldr x0, [x0]\n"
"msr S3_6_c15_c1_5, x0\n"
"isb sy\n"
:: "r" (enabled ? _COMM_PAGE_APRR_WRITE_DISABLE
: _COMM_PAGE_APPR_WRITE_ENABLE)
: "memory", "x0"
);
}
}
#else /* defined(__aarch64__) && defined(CONFIG_DARWIN) */
static __attribute__((__always_inline__)) bool jit_write_protect_supported(void)
{
return false;
}
static __attribute__((__always_inline__)) void jit_write_protect(int enabled)
{
}
#endif
static inline void qemu_thread_jit_execute(void)
{
if (jit_write_protect_supported()) {
jit_write_protect(true);
}
}
static inline void qemu_thread_jit_write(void)
{
if (jit_write_protect_supported()) {
jit_write_protect(false);
}
}
#endif /* define TCG_APPLE_JIT_H */
+1 -1
View File
@@ -1296,7 +1296,7 @@ static inline unsigned get_mmuidx(TCGMemOpIdx oi)
#define TB_EXIT_IDXMAX 1
#define TB_EXIT_REQUESTED 3
#ifdef CONFIG_TCG_INTERPRETER
#if defined(CONFIG_TCG_INTERPRETER) || defined(CONFIG_TCG_THREADED_INTERPRETER)
uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *tb_ptr);
#else
typedef uintptr_t tcg_prologue_fn(CPUArchState *env, const void *tb_ptr);
+83 -68
View File
@@ -58,6 +58,7 @@ python = import('python').find_installation()
supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64']
tcti_supported_cpus = ['aarch64']
cpu = host_machine.cpu_family()
targetos = host_machine.system()
@@ -169,6 +170,7 @@ socket = []
version_res = []
coref = []
iokit = []
vmnet = not_found
emulator_link_args = []
hvf = not_found
if targetos == 'windows'
@@ -181,7 +183,8 @@ if targetos == 'windows'
include_directories: include_directories('.'))
elif targetos == 'darwin'
coref = dependency('appleframeworks', modules: 'CoreFoundation')
iokit = dependency('appleframeworks', modules: 'IOKit')
iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
vmnet = dependency('appleframeworks', modules: 'vmnet', required: false)
elif targetos == 'sunos'
socket = [cc.find_library('socket'),
cc.find_library('nsl'),
@@ -246,6 +249,25 @@ if not get_option('tcg').disabled()
endif
if get_option('tcg_interpreter')
tcg_arch = 'tci'
elif get_option('tcg_threaded_interpreter')
if cpu not in tcti_supported_cpus
error('Unsupported CPU @0@ for TCTI, try --enable-tcg-interpreter'.format(cpu))
else
warning('TCTI is extremely experimental and incomplete! Things might break!')
tcg_arch = '@0@-tcti'.format(cpu)
endif
# Tell our compiler how to generate our TCTI gadgets.
gadget_generator = 'tcg/@0@/tcti-gadget-gen.py'.format(tcg_arch)
tcti_gadgets = custom_target('tcti-gadgets.c.inc',
output: 'tcti-gadgets.c.inc',
input: gadget_generator,
command: [find_program(gadget_generator), '@OUTPUT@'],
build_by_default: true,
build_always_stale: false)
genh += tcti_gadgets
elif config_host['ARCH'] == 'sparc64'
tcg_arch = 'sparc'
elif config_host['ARCH'] == 's390x'
@@ -1056,6 +1078,9 @@ if get_option('cfi')
add_global_link_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
endif
have_host_block_device = (targetos != 'darwin' or
cc.has_header('IOKit/storage/IOMedia.h'))
#################
# config-host.h #
#################
@@ -1138,6 +1163,7 @@ config_host_data.set('CONFIG_FUSE', fuse.found())
config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found())
config_host_data.set('CONFIG_X11', x11.found())
config_host_data.set('CONFIG_CFI', get_option('cfi'))
config_host_data.set('CONFIG_VMNET', vmnet.found())
config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
@@ -1149,6 +1175,8 @@ config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>'))
config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device)
config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h'))
config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
@@ -1276,6 +1304,8 @@ foreach target : target_dirs
config_all += { sym: 'y' }
if sym == 'CONFIG_TCG' and tcg_arch == 'tci'
config_target += { 'CONFIG_TCG_INTERPRETER': 'y' }
elif sym == 'CONFIG_TCG' and tcg_arch.endswith('tcti')
config_target += { 'CONFIG_TCG_THREADED_INTERPRETER': 'y' }
elif sym == 'CONFIG_XEN' and have_xen_pci_passthrough
config_target += { 'CONFIG_XEN_PCI_PASSTHROUGH': 'y' }
endif
@@ -1499,7 +1529,7 @@ slirp_opt = 'disabled'
if have_system
slirp_opt = get_option('slirp')
if slirp_opt in ['enabled', 'auto', 'system']
have_internal = fs.exists(meson.current_source_dir() / 'slirp/meson.build')
have_internal = fs.exists(meson.current_source_dir() / 'subprojects/libslirp/meson.build')
slirp = dependency('slirp', kwargs: static_kwargs,
method: 'pkg-config',
required: slirp_opt == 'system' or
@@ -1513,64 +1543,9 @@ if have_system
endif
endif
if slirp_opt == 'internal'
slirp_deps = []
if targetos == 'windows'
slirp_deps = cc.find_library('iphlpapi')
endif
slirp_conf = configuration_data()
slirp_conf.set('SLIRP_MAJOR_VERSION', meson.project_version().split('.')[0])
slirp_conf.set('SLIRP_MINOR_VERSION', meson.project_version().split('.')[1])
slirp_conf.set('SLIRP_MICRO_VERSION', meson.project_version().split('.')[2])
slirp_conf.set_quoted('SLIRP_VERSION_STRING', meson.project_version())
slirp_cargs = ['-DG_LOG_DOMAIN="Slirp"']
slirp_files = [
'slirp/src/arp_table.c',
'slirp/src/bootp.c',
'slirp/src/cksum.c',
'slirp/src/dhcpv6.c',
'slirp/src/dnssearch.c',
'slirp/src/if.c',
'slirp/src/ip6_icmp.c',
'slirp/src/ip6_input.c',
'slirp/src/ip6_output.c',
'slirp/src/ip_icmp.c',
'slirp/src/ip_input.c',
'slirp/src/ip_output.c',
'slirp/src/mbuf.c',
'slirp/src/misc.c',
'slirp/src/ncsi.c',
'slirp/src/ndp_table.c',
'slirp/src/sbuf.c',
'slirp/src/slirp.c',
'slirp/src/socket.c',
'slirp/src/state.c',
'slirp/src/stream.c',
'slirp/src/tcp_input.c',
'slirp/src/tcp_output.c',
'slirp/src/tcp_subr.c',
'slirp/src/tcp_timer.c',
'slirp/src/tftp.c',
'slirp/src/udp.c',
'slirp/src/udp6.c',
'slirp/src/util.c',
'slirp/src/version.c',
'slirp/src/vmstate.c',
]
configure_file(
input : 'slirp/src/libslirp-version.h.in',
output : 'libslirp-version.h',
configuration: slirp_conf)
slirp_inc = include_directories('slirp', 'slirp/src')
libslirp = static_library('slirp',
build_by_default: false,
sources: slirp_files,
c_args: slirp_cargs,
include_directories: slirp_inc)
slirp = declare_dependency(link_with: libslirp,
dependencies: slirp_deps,
include_directories: slirp_inc)
libslirp = subproject('libslirp',
default_options: ['default_library=static'])
slirp = libslirp.get_variable('libslirp_dep')
endif
endif
@@ -1633,9 +1608,18 @@ if not fdt.found() and fdt_required.length() > 0
error('fdt not available but required by targets ' + ', '.join(fdt_required))
endif
ucontext = dependency('libucontext', kwargs: static_kwargs, required : false)
if not ucontext.found() and get_option('ucontext').enabled()
libucontext_proj = subproject('libucontext',
default_options: ['default_library=static',
'freestanding=true'])
ucontext = libucontext_proj.get_variable('libucontext_dep')
endif
config_host_data.set('CONFIG_CAPSTONE', capstone.found())
config_host_data.set('CONFIG_FDT', fdt.found())
config_host_data.set('CONFIG_SLIRP', slirp.found())
config_host_data.set('CONFIG_LIBUCONTEXT', ucontext.found())
#####################
# Generated sources #
@@ -1883,7 +1867,7 @@ util_ss.add_all(trace_ss)
util_ss = util_ss.apply(config_all, strict: false)
libqemuutil = static_library('qemuutil',
sources: util_ss.sources() + stub_ss.sources() + genh,
dependencies: [util_ss.dependencies(), m, glib, socket, malloc])
dependencies: [util_ss.dependencies(), m, glib, socket, malloc, ucontext])
qemuutil = declare_dependency(link_with: libqemuutil,
sources: genh + version_res)
@@ -2212,14 +2196,31 @@ foreach target : target_dirs
arch_srcs += target_specific.sources()
arch_deps += target_specific.dependencies()
lib = static_library('qemu-' + target,
if get_option('shared_lib')
build_lib_args = {
'target_type': 'shared_library',
'install': true,
'dependencies': arch_deps + deps,
'link_language': link_language,
'link_depends': [block_syms, qemu_syms],
'link_args': link_args + cc.get_supported_link_arguments(['-Wl,-U,_qemu_main'])
}
else
build_lib_args = {
'target_type': 'static_library',
'install': false,
'dependencies': arch_deps,
'name_suffix': 'fa'
}
endif
lib = build_target('qemu-' + target,
sources: arch_srcs + genh,
dependencies: arch_deps,
objects: objects,
include_directories: target_inc,
c_args: c_args,
build_by_default: false,
name_suffix: 'fa')
kwargs: build_lib_args)
if target.endswith('-softmmu')
execs = [{
@@ -2253,6 +2254,17 @@ foreach target : target_dirs
'dependencies': []
}]
endif
if get_option('shared_lib')
build_exe_args = {
'link_with': lib,
'link_args': link_args + cc.get_supported_link_arguments(['-Wl,--exclude-libs,ALL'])
}
else
build_exe_args = {
'objects': lib.extract_all_objects(recursive: true),
'link_args': link_args
}
endif
foreach exe: execs
exe_name = exe['name']
exe_sign = 'CONFIG_HVF' in config_target
@@ -2264,11 +2276,10 @@ foreach target : target_dirs
install: true,
c_args: c_args,
dependencies: arch_deps + deps + exe['dependencies'],
objects: lib.extract_all_objects(recursive: true),
link_language: link_language,
link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
link_args: link_args,
gui_app: exe['gui'])
gui_app: exe['gui'],
kwargs: build_exe_args)
if exe_sign
emulators += {exe['name'] : custom_target(exe['name'],
@@ -2435,6 +2446,7 @@ endif
summary_info += {'Doc directory': get_option('docdir')}
summary_info += {'Build directory': meson.current_build_dir()}
summary_info += {'Source path': meson.current_source_dir()}
summary_info += {'build shared lib': get_option('shared_lib')}
summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
summary(summary_info, bool_yn: true, section: 'Directories')
@@ -2451,7 +2463,7 @@ summary_info += {'genisoimage': config_host['GENISOIMAGE']}
if targetos == 'windows' and config_host.has_key('CONFIG_GUEST_AGENT')
summary_info += {'wixl': wixl.found() ? wixl.full_path() : false}
endif
if slirp_opt != 'disabled'
if slirp_opt != 'disabled' and 'CONFIG_SLIRP_SMBD' in config_host
summary_info += {'smbd': config_host['CONFIG_SMBD_COMMAND']}
endif
summary(summary_info, bool_yn: true, section: 'Host binaries')
@@ -2585,6 +2597,8 @@ summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
if config_all.has_key('CONFIG_TCG')
if get_option('tcg_interpreter')
summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, experimental and slow)'}
elif get_option('tcg_threaded_interpreter')
summary_info += {'TCG backend': 'TCTI (TCG with threaded-dispatch bytecode interpreter, experimental and slow; but faster than TCI)'}
else
summary_info += {'TCG backend': 'native (@0@)'.format(cpu)}
endif
@@ -2599,6 +2613,7 @@ summary(summary_info, bool_yn: true, section: 'Targets and accelerators')
# Block layer
summary_info = {}
summary_info += {'libucontext support': ucontext.found()}
summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
summary_info += {'coroutine pool': config_host['CONFIG_COROUTINE_POOL'] == '1'}
if have_block
+6
View File
@@ -6,6 +6,8 @@ option('qemu_firmwarepath', type : 'string', value : '',
description: 'search PATH for firmware files')
option('sphinx_build', type : 'string', value : '',
description: 'Use specified sphinx-build [$sphinx_build] for building document (default to be empty)')
option('shared_lib', type : 'boolean', value : false,
description: 'build QEMU as a shared library')
option('default_devices', type : 'boolean', value : true,
description: 'Include a default selection of devices in emulators')
@@ -41,6 +43,8 @@ option('tcg', type: 'feature', value: 'auto',
description: 'TCG support')
option('tcg_interpreter', type: 'boolean', value: false,
description: 'TCG with bytecode interpreter (experimental and slow)')
option('tcg_threaded_interpreter', type: 'boolean', value: false,
description: 'TCG with threaded-dispatch bytecode interpreter (experimental and slow, but less slow than TCI)')
option('cfi', type: 'boolean', value: 'false',
description: 'Control-Flow Integrity (CFI)')
option('cfi_debug', type: 'boolean', value: 'false',
@@ -108,6 +112,8 @@ option('fuse', type: 'feature', value: 'auto',
description: 'FUSE block device export')
option('fuse_lseek', type : 'feature', value : 'auto',
description: 'SEEK_HOLE/SEEK_DATA support for FUSE exports')
option('ucontext', type : 'feature', value : 'disabled',
description: 'libucontext support')
option('vhost_user_blk_server', type: 'feature', value: 'auto',
description: 'build vhost-user-blk server')
+5
View File
@@ -63,4 +63,9 @@ int net_init_vhost_user(const Netdev *netdev, const char *name,
int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
NetClientState *peer, Error **errp);
#ifdef CONFIG_VMNET
int net_init_vmnet_macos(const Netdev *netdev, const char *name,
NetClientState *peer, Error **errp);
#endif
#endif /* QEMU_NET_CLIENTS_H */
+1
View File
@@ -37,5 +37,6 @@ endif
softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files(tap_posix))
softmmu_ss.add(when: 'CONFIG_WIN32', if_true: files('tap-win32.c'))
softmmu_ss.add(when: 'CONFIG_VHOST_NET_VDPA', if_true: files('vhost-vdpa.c'))
softmmu_ss.add(when: vmnet, if_true: files('vmnet-macos.c'))
subdir('can')
+3
View File
@@ -1002,6 +1002,9 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
#ifdef CONFIG_L2TPV3
[NET_CLIENT_DRIVER_L2TPV3] = net_init_l2tpv3,
#endif
#ifdef CONFIG_VMNET
[NET_CLIENT_DRIVER_VMNET_MACOS] = net_init_vmnet_macos,
#endif
};
+8 -8
View File
@@ -27,7 +27,7 @@
#include "net/slirp.h"
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
#include <pwd.h>
#include <sys/wait.h>
#endif
@@ -91,7 +91,7 @@ typedef struct SlirpState {
Slirp *slirp;
Notifier poll_notifier;
Notifier exit_notifier;
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
gchar *smb_dir;
#endif
GSList *fwd;
@@ -104,7 +104,7 @@ static QTAILQ_HEAD(, SlirpState) slirp_stacks =
static int slirp_hostfwd(SlirpState *s, const char *redir_str, Error **errp);
static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp);
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
static int slirp_smb(SlirpState *s, const char *exported_dir,
struct in_addr vserver_addr, Error **errp);
static void slirp_smb_cleanup(SlirpState *s);
@@ -377,7 +377,7 @@ static int net_slirp_init(NetClientState *peer, const char *model,
struct in6_addr ip6_prefix;
struct in6_addr ip6_host;
struct in6_addr ip6_dns;
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
struct in_addr smbsrv = { .s_addr = 0 };
#endif
NetClientState *nc;
@@ -487,7 +487,7 @@ static int net_slirp_init(NetClientState *peer, const char *model,
return -1;
}
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
if (vsmbserver && !inet_aton(vsmbserver, &smbsrv)) {
error_setg(errp, "Failed to parse SMB address");
return -1;
@@ -602,7 +602,7 @@ static int net_slirp_init(NetClientState *peer, const char *model,
}
}
}
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
if (smb_export) {
if (slirp_smb(s, smb_export, smbsrv, errp) < 0) {
goto error;
@@ -794,7 +794,7 @@ void hmp_hostfwd_add(Monitor *mon, const QDict *qdict)
}
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
/* automatic user mode samba server configuration */
static void slirp_smb_cleanup(SlirpState *s)
@@ -909,7 +909,7 @@ static int slirp_smb(SlirpState* s, const char *exported_dir,
return 0;
}
#endif /* !defined(_WIN32) */
#endif /* defined(CONFIG_SLIRP_SMBD) */
static int guestfwd_can_read(void *opaque)
{
+446
View File
@@ -0,0 +1,446 @@
/*
* vmnet.framework backed netdev for macOS 10.15+ hosts
*
* Copyright (c) 2021 Phillip Tennen <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*
*/
#include "qemu/osdep.h"
#include "qemu/main-loop.h"
#include "qemu/error-report.h"
#include "qapi/qapi-types-net.h"
#include "net/net.h"
/* macOS vmnet framework header */
#include <vmnet/vmnet.h>
typedef struct vmnet_state {
NetClientState nc;
interface_ref vmnet_iface_ref;
/* Switched on after vmnet informs us that the interface has started */
bool link_up;
/*
* If qemu_send_packet_async returns 0, this is switched off until our
* delivery callback is invoked
*/
bool qemu_ready_to_receive;
} vmnet_state_t;
int net_init_vmnet_macos(const Netdev *netdev, const char *name,
NetClientState *peer, Error **errp);
static const char *_vmnet_status_repr(vmnet_return_t status)
{
switch (status) {
case VMNET_SUCCESS:
return "success";
case VMNET_FAILURE:
return "generic failure";
case VMNET_MEM_FAILURE:
return "out of memory";
case VMNET_INVALID_ARGUMENT:
return "invalid argument";
case VMNET_SETUP_INCOMPLETE:
return "setup is incomplete";
case VMNET_INVALID_ACCESS:
return "insufficient permissions";
case VMNET_PACKET_TOO_BIG:
return "packet size exceeds MTU";
case VMNET_BUFFER_EXHAUSTED:
return "kernel buffers temporarily exhausted";
case VMNET_TOO_MANY_PACKETS:
return "number of packets exceeds system limit";
/* This error code was introduced in macOS 11.0 */
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
case VMNET_SHARING_SERVICE_BUSY:
return "sharing service busy";
#endif
default:
return "unknown status code";
}
}
static operating_modes_t _vmnet_operating_mode_enum_compat(
VmnetOperatingMode mode)
{
switch (mode) {
case VMNET_OPERATING_MODE_HOST:
return VMNET_HOST_MODE;
case VMNET_OPERATING_MODE_SHARED:
return VMNET_SHARED_MODE;
case VMNET_OPERATING_MODE_BRIDGED:
return VMNET_BRIDGED_MODE;
default:
/* Should never happen as the modes are parsed before we get here */
assert(false);
}
}
static bool vmnet_can_receive(NetClientState *nc)
{
vmnet_state_t *s = DO_UPCAST(vmnet_state_t, nc, nc);
return s->link_up;
}
static ssize_t vmnet_receive_iov(NetClientState *nc,
const struct iovec *iovs,
int iovcnt)
{
vmnet_state_t *s = DO_UPCAST(vmnet_state_t, nc, nc);
/* Combine the provided iovs into a single vmnet packet */
struct vmpktdesc *packet = g_new0(struct vmpktdesc, 1);
packet->vm_pkt_iov = g_new0(struct iovec, iovcnt);
memcpy(packet->vm_pkt_iov, iovs, sizeof(struct iovec) * iovcnt);
packet->vm_pkt_iovcnt = iovcnt;
packet->vm_flags = 0;
/* Figure out the packet size by iterating the iov's */
for (int i = 0; i < iovcnt; i++) {
const struct iovec *iov = iovs + i;
packet->vm_pkt_size += iov->iov_len;
}
/* Finally, write the packet to the vmnet interface */
int packet_count = 1;
vmnet_return_t result = vmnet_write(s->vmnet_iface_ref, packet,
&packet_count);
if (result != VMNET_SUCCESS || packet_count != 1) {
error_printf("Failed to send packet to host: %s\n",
_vmnet_status_repr(result));
}
ssize_t wrote_bytes = packet->vm_pkt_size;
g_free(packet->vm_pkt_iov);
g_free(packet);
return wrote_bytes;
}
static void vmnet_send_completed(NetClientState *nc, ssize_t len)
{
vmnet_state_t *vmnet_client_state = DO_UPCAST(vmnet_state_t, nc, nc);
/* Ready to receive more packets! */
vmnet_client_state->qemu_ready_to_receive = true;
}
static NetClientInfo net_vmnet_macos_info = {
.type = NET_CLIENT_DRIVER_VMNET_MACOS,
.size = sizeof(vmnet_state_t),
.receive_iov = vmnet_receive_iov,
.can_receive = vmnet_can_receive,
};
static bool _validate_ifname_is_valid_bridge_target(const char *ifname)
{
/* Iterate available bridge interfaces, ensure the provided one is valid */
xpc_object_t bridge_interfaces = vmnet_copy_shared_interface_list();
bool failed_to_match_iface_name = xpc_array_apply(
bridge_interfaces,
^bool(size_t index, xpc_object_t _Nonnull value) {
if (!strcmp(xpc_string_get_string_ptr(value), ifname)) {
/* The interface name is valid! Stop iterating */
return false;
}
return true;
});
if (failed_to_match_iface_name) {
error_printf("Invalid bridge interface name provided: %s\n", ifname);
error_printf("Valid bridge interfaces:\n");
xpc_array_apply(
vmnet_copy_shared_interface_list(),
^bool(size_t index, xpc_object_t _Nonnull value) {
error_printf("\t%s\n", xpc_string_get_string_ptr(value));
/* Keep iterating */
return true;
});
exit(1);
return false;
}
return true;
}
static xpc_object_t _construct_vmnet_interface_description(
const NetdevVmnetModeOptions *vmnet_opts)
{
operating_modes_t mode = _vmnet_operating_mode_enum_compat(
vmnet_opts->mode);
/* Validate options */
if (mode == VMNET_HOST_MODE || mode == VMNET_SHARED_MODE) {
NetdevVmnetModeOptionsHostOrShared mode_opts = vmnet_opts->u.host;
/* If one DHCP parameter is configured, all 3 are required */
if (mode_opts.has_dhcp_start_address ||
mode_opts.has_dhcp_end_address ||
mode_opts.has_dhcp_subnet_mask) {
if (!(mode_opts.has_dhcp_start_address &&
mode_opts.has_dhcp_end_address &&
mode_opts.has_dhcp_subnet_mask)) {
error_printf("Incomplete DHCP configuration provided\n");
exit(1);
}
}
} else if (mode == VMNET_BRIDGED_MODE) {
/* Nothing to validate */
} else {
error_printf("Unknown vmnet mode %d\n", mode);
exit(1);
}
xpc_object_t interface_desc = xpc_dictionary_create(NULL, NULL, 0);
xpc_dictionary_set_uint64(
interface_desc,
vmnet_operation_mode_key,
mode
);
if (mode == VMNET_BRIDGED_MODE) {
/*
* Configure the provided physical interface to act
* as a bridge with QEMU
*/
NetdevVmnetModeOptionsBridged mode_opts = vmnet_opts->u.bridged;
/* Bridge with en0 by default */
const char *physical_ifname = mode_opts.has_ifname ? mode_opts.ifname :
"en0";
_validate_ifname_is_valid_bridge_target(physical_ifname);
xpc_dictionary_set_string(interface_desc,
vmnet_shared_interface_name_key,
physical_ifname);
} else if (mode == VMNET_HOST_MODE || mode == VMNET_SHARED_MODE) {
/* Pass the DHCP configuration to vmnet, if the user provided one */
NetdevVmnetModeOptionsHostOrShared mode_opts = vmnet_opts->u.host;
if (mode_opts.has_dhcp_start_address) {
/* All DHCP arguments are available, as per the checks above */
xpc_dictionary_set_string(interface_desc,
vmnet_start_address_key,
mode_opts.dhcp_start_address);
xpc_dictionary_set_string(interface_desc,
vmnet_end_address_key,
mode_opts.dhcp_end_address);
xpc_dictionary_set_string(interface_desc,
vmnet_subnet_mask_key,
mode_opts.dhcp_subnet_mask);
}
}
return interface_desc;
}
int net_init_vmnet_macos(const Netdev *netdev, const char *name,
NetClientState *peer, Error **errp)
{
assert(netdev->type == NET_CLIENT_DRIVER_VMNET_MACOS);
NetdevVmnetModeOptions *vmnet_opts = netdev->u.vmnet_macos.options;
xpc_object_t iface_desc = _construct_vmnet_interface_description(vmnet_opts);
NetClientState *nc = qemu_new_net_client(&net_vmnet_macos_info, peer,
"vmnet", name);
vmnet_state_t *vmnet_client_state = DO_UPCAST(vmnet_state_t, nc, nc);
dispatch_queue_t vmnet_dispatch_queue = dispatch_queue_create(
"org.qemu.vmnet.iface_queue",
DISPATCH_QUEUE_SERIAL
);
__block vmnet_return_t vmnet_start_status = 0;
__block uint64_t vmnet_iface_mtu = 0;
__block uint64_t vmnet_max_packet_size = 0;
__block const char *vmnet_mac_address = NULL;
/*
* We can't refer to an array type directly within a block,
* so hold a pointer instead.
*/
uuid_string_t vmnet_iface_uuid = {0};
__block uuid_string_t *vmnet_iface_uuid_ptr = &vmnet_iface_uuid;
/* These are only provided in VMNET_HOST_MODE and VMNET_SHARED_MODE */
bool vmnet_provides_dhcp_info = (
vmnet_opts->mode == VMNET_OPERATING_MODE_HOST ||
vmnet_opts->mode == VMNET_OPERATING_MODE_SHARED);
__block const char *vmnet_subnet_mask = NULL;
__block const char *vmnet_dhcp_range_start = NULL;
__block const char *vmnet_dhcp_range_end = NULL;
/* Create the vmnet interface */
dispatch_semaphore_t vmnet_iface_sem = dispatch_semaphore_create(0);
interface_ref vmnet_iface_ref = vmnet_start_interface(
iface_desc,
vmnet_dispatch_queue,
^(vmnet_return_t status, xpc_object_t _Nullable interface_param) {
vmnet_start_status = status;
if (vmnet_start_status != VMNET_SUCCESS || !interface_param) {
/* Early return if the interface couldn't be started */
dispatch_semaphore_signal(vmnet_iface_sem);
return;
}
/*
* Read the configuration that vmnet provided us.
* The provided dictionary is owned by XPC and may be freed
* shortly after this block's execution.
* So, copy data buffers now.
*/
vmnet_iface_mtu = xpc_dictionary_get_uint64(
interface_param,
vmnet_mtu_key
);
vmnet_max_packet_size = xpc_dictionary_get_uint64(
interface_param,
vmnet_max_packet_size_key
);
vmnet_mac_address = strdup(xpc_dictionary_get_string(
interface_param,
vmnet_mac_address_key
));
const uint8_t *iface_uuid = xpc_dictionary_get_uuid(
interface_param,
vmnet_interface_id_key
);
uuid_unparse_upper(iface_uuid, *vmnet_iface_uuid_ptr);
/* If we're in a mode that provides DHCP info, read it out now */
if (vmnet_provides_dhcp_info) {
vmnet_dhcp_range_start = strdup(xpc_dictionary_get_string(
interface_param,
vmnet_start_address_key
));
vmnet_dhcp_range_end = strdup(xpc_dictionary_get_string(
interface_param,
vmnet_end_address_key
));
vmnet_subnet_mask = strdup(xpc_dictionary_get_string(
interface_param,
vmnet_subnet_mask_key
));
}
dispatch_semaphore_signal(vmnet_iface_sem);
});
/* And block until we receive a response from vmnet */
dispatch_semaphore_wait(vmnet_iface_sem, DISPATCH_TIME_FOREVER);
/* Did we manage to start the interface? */
if (vmnet_start_status != VMNET_SUCCESS || !vmnet_iface_ref) {
error_printf("Failed to start interface: %s\n",
_vmnet_status_repr(vmnet_start_status));
if (vmnet_start_status == VMNET_FAILURE) {
error_printf("Hint: vmnet requires running with root access\n");
}
return -1;
}
info_report("Started vmnet interface with configuration:");
info_report("MTU: %llu", vmnet_iface_mtu);
info_report("Max packet size: %llu", vmnet_max_packet_size);
info_report("MAC: %s", vmnet_mac_address);
if (vmnet_provides_dhcp_info) {
info_report("DHCP IPv4 start: %s", vmnet_dhcp_range_start);
info_report("DHCP IPv4 end: %s", vmnet_dhcp_range_end);
info_report("IPv4 subnet mask: %s", vmnet_subnet_mask);
}
info_report("UUID: %s", vmnet_iface_uuid);
/* The interface is up! Set a block to run when packets are received */
vmnet_client_state->vmnet_iface_ref = vmnet_iface_ref;
vmnet_return_t event_cb_stat = vmnet_interface_set_event_callback(
vmnet_iface_ref,
VMNET_INTERFACE_PACKETS_AVAILABLE,
vmnet_dispatch_queue,
^(interface_event_t event_mask, xpc_object_t _Nonnull event) {
if (event_mask != VMNET_INTERFACE_PACKETS_AVAILABLE) {
error_printf("Unknown vmnet interface event 0x%08x\n", event_mask);
return;
}
/* If we're unable to handle more packets now, drop this packet */
if (!vmnet_client_state->qemu_ready_to_receive) {
return;
}
/*
* TODO(Phillip Tennen <[email protected]>): There may be more than
* one packet available.
* As an optimization, we could read
* vmnet_estimated_packets_available_key packets now.
*/
char *packet_buf = g_malloc0(vmnet_max_packet_size);
struct iovec *iov = g_new0(struct iovec, 1);
iov->iov_base = packet_buf;
iov->iov_len = vmnet_max_packet_size;
int pktcnt = 1;
struct vmpktdesc *v = g_new0(struct vmpktdesc, pktcnt);
v->vm_pkt_size = vmnet_max_packet_size;
v->vm_pkt_iov = iov;
v->vm_pkt_iovcnt = 1;
v->vm_flags = 0;
vmnet_return_t result = vmnet_read(vmnet_iface_ref, v, &pktcnt);
if (result != VMNET_SUCCESS) {
error_printf("Failed to read packet from host: %s\n",
_vmnet_status_repr(result));
}
/* Ensure we read exactly one packet */
assert(pktcnt == 1);
/* Dispatch this block to a global queue instead of the main queue,
* which is only created when the program has a Cocoa event loop.
* If QEMU is started with -nographic, no Cocoa event loop will be
* created and thus the main queue will be unavailable.
*/
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH,
0),
^{
qemu_mutex_lock_iothread();
/*
* Deliver the packet to the guest
* If the delivery succeeded synchronously, this returns the length
* of the sent packet.
*/
if (qemu_send_packet_async(nc, iov->iov_base,
v->vm_pkt_size,
vmnet_send_completed) == 0) {
vmnet_client_state->qemu_ready_to_receive = false;
}
/*
* It's safe to free the packet buffers.
* Even if delivery needs to wait, qemu_net_queue_append copies
* the packet buffer.
*/
g_free(v);
g_free(iov);
g_free(packet_buf);
qemu_mutex_unlock_iothread();
});
});
/* Did we manage to set an event callback? */
if (event_cb_stat != VMNET_SUCCESS) {
error_printf("Failed to set up a callback to receive packets: %s\n",
_vmnet_status_repr(vmnet_start_status));
exit(1);
}
/* We're now ready to receive packets */
vmnet_client_state->qemu_ready_to_receive = true;
vmnet_client_state->link_up = true;
/* Include DHCP info if we're in a relevant mode */
if (vmnet_provides_dhcp_info) {
snprintf(nc->info_str, sizeof(nc->info_str), "dhcp_start=%s,dhcp_end=%s,mask=%s",
vmnet_dhcp_range_start,
vmnet_dhcp_range_end,
vmnet_subnet_mask);
} else {
snprintf(nc->info_str, sizeof(nc->info_str), "mac=%s", vmnet_mac_address);
}
return 0;
}
+7 -3
View File
@@ -897,7 +897,8 @@
'discriminator': 'driver',
'data': {
'file': 'BlockStatsSpecificFile',
'host_device': 'BlockStatsSpecificFile',
'host_device': { 'type': 'BlockStatsSpecificFile',
'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' },
'nvme': 'BlockStatsSpecificNvme' } }
##
@@ -2814,7 +2815,9 @@
{ 'enum': 'BlockdevDriver',
'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs',
'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps',
'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi',
'gluster', 'host_cdrom',
{'name': 'host_device', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' },
'http', 'https', 'iscsi',
'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
{ 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' },
@@ -4017,7 +4020,8 @@
'ftps': 'BlockdevOptionsCurlFtps',
'gluster': 'BlockdevOptionsGluster',
'host_cdrom': 'BlockdevOptionsFile',
'host_device':'BlockdevOptionsFile',
'host_device': { 'type': 'BlockdevOptionsFile',
'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' },
'http': 'BlockdevOptionsCurlHttp',
'https': 'BlockdevOptionsCurlHttps',
'iscsi': 'BlockdevOptionsIscsi',
+118 -2
View File
@@ -450,6 +450,115 @@
'*vhostdev': 'str',
'*queues': 'int' } }
##
# @VmnetOperatingMode:
#
# The operating modes in which a vmnet netdev can run
# Only available on macOS
#
# @host: the guest may communicate with the host
# and other guest network interfaces
#
# @shared: the guest may reach the Internet through a NAT,
# and may communicate with the host and other guest
# network interfaces
#
# @bridged: the guest's traffic is bridged with a
# physical network interface of the host
#
# Since: 6.0
##
{ 'enum': 'VmnetOperatingMode',
'data': [ 'host', 'shared', 'bridged' ],
'if': 'defined(CONFIG_VMNET)' }
##
# @NetdevVmnetModeOptionsBridged:
#
# Options for the vmnet-macos netdev
# that are only available in 'bridged' mode
# Only available on macOS
#
# @ifname: the physical network interface to bridge with
# (defaults to en0 if not specified)
#
# Since: 6.0
##
{ 'struct': 'NetdevVmnetModeOptionsBridged',
'data': { '*ifname': 'str' },
'if': 'defined(CONFIG_VMNET)' }
##
# @NetdevVmnetModeOptionsHostOrShared:
#
# Options for the vmnet-macos netdev
# that are only available in 'host' or 'shared' mode
# Only available on macOS
#
# @dhcp-start-address: the gateway address to use for the interface.
# The range to dhcp_end_address is placed in the DHCP pool.
# (only valid with mode=host|shared)
# (must be specified with dhcp-end-address and
# dhcp-subnet-mask)
# (allocated automatically if unset)
#
# @dhcp-end-address: the DHCP IPv4 range end address to use for the interface.
# (only valid with mode=host|shared)
# (must be specified with dhcp-start-address and
# dhcp-subnet-mask)
# (allocated automatically if unset)
#
# @dhcp-subnet-mask: the IPv4 subnet mask (string) to use on the interface.
# (only valid with mode=host|shared)
# (must be specified with dhcp-start-address and
# dhcp-end-address)
# (allocated automatically if unset)
#
# Since: 6.0
##
{ 'struct': 'NetdevVmnetModeOptionsHostOrShared',
'data': {
'*dhcp-start-address': 'str' ,
'*dhcp-end-address': 'str',
'*dhcp-subnet-mask': 'str' },
'if': 'defined(CONFIG_VMNET)' }
##
# @NetdevVmnetModeOptions:
#
# Options specific to different operating modes of a vmnet netdev
# Only available on macOS
#
# @mode: the operating mode vmnet should run in
#
# Since: 6.0
##
{ 'union': 'NetdevVmnetModeOptions',
'base': { 'mode': 'VmnetOperatingMode' },
'discriminator': 'mode',
'data': {
'bridged': 'NetdevVmnetModeOptionsBridged',
'host': 'NetdevVmnetModeOptionsHostOrShared',
'shared': 'NetdevVmnetModeOptionsHostOrShared' },
'if': 'defined(CONFIG_VMNET)' }
##
# @NetdevVmnetOptions:
#
# vmnet network backend
# Only available on macOS
#
# @options: a structure specifying the mode and mode-specific options
# (once QAPI supports a union type as a branch to another union type,
# this structure can be changed to a union, and the contents of
# NetdevVmnetModeOptions moved here)
#
# Since: 6.0
##
{ 'struct': 'NetdevVmnetOptions',
'data': {'options': 'NetdevVmnetModeOptions' },
'if': 'defined(CONFIG_VMNET)' }
##
# @NetClientDriver:
#
@@ -458,10 +567,13 @@
# Since: 2.7
#
# @vhost-vdpa since 5.1
#
# @vmnet-macos since 6.0 (only available on macOS)
##
{ 'enum': 'NetClientDriver',
'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa' ] }
'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa',
{ 'name': 'vmnet-macos', 'if': 'defined(CONFIG_VMNET)' } ] }
##
# @Netdev:
@@ -475,6 +587,8 @@
# Since: 1.2
#
# 'l2tpv3' - since 2.1
#
# 'vmnet-macos' since 6.0 (only available on macOS)
##
{ 'union': 'Netdev',
'base': { 'id': 'str', 'type': 'NetClientDriver' },
@@ -490,7 +604,9 @@
'hubport': 'NetdevHubPortOptions',
'netmap': 'NetdevNetmapOptions',
'vhost-user': 'NetdevVhostUserOptions',
'vhost-vdpa': 'NetdevVhostVDPAOptions' } }
'vhost-vdpa': 'NetdevVhostVDPAOptions',
'vmnet-macos': { 'type': 'NetdevVmnetOptions',
'if': 'defined(CONFIG_VMNET)' } } }
##
# @RxState:
+9
View File
@@ -2542,6 +2542,15 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
#ifdef __linux__
"-netdev vhost-vdpa,id=str,vhostdev=/path/to/dev\n"
" configure a vhost-vdpa network,Establish a vhost-vdpa netdev\n"
#endif
#ifdef CONFIG_VMNET
"-netdev vmnet-macos,id=str,mode=bridged[,ifname=ifname]\n"
" configure a macOS-provided vmnet network in \"physical interface bridge\" mode\n"
" the physical interface to bridge with defaults to en0 if unspecified\n"
"-netdev vmnet-macos,id=str,mode=host|shared\n"
" [,dhcp_start_address=addr,dhcp_end_address=addr,dhcp_subnet_mask=mask]\n"
" configure a macOS-provided vmnet network in \"host\" or \"shared\" mode\n"
" the DHCP configuration will be set automatically if unspecified\n"
#endif
"-netdev hubport,id=str,hubid=n[,netdev=nd]\n"
" configure a hub port on the hub with ID 'n'\n", QEMU_ARCH_ALL)
+12 -12
View File
@@ -75,18 +75,18 @@ def process_tests(test, targets, suites):
print('run-test-%d: $(.test.deps.%d)' % (i,i))
print('\t@$(call .test.run,%d,$(.test.output-format))' % (i,))
test_suites = test['suite'] or ['default']
is_slow = any(s.endswith('-slow') for s in test_suites)
for s in test_suites:
# The suite name in the introspection info is "PROJECT:SUITE"
s = s.split(':')[1]
if s.endswith('-slow'):
s = s[:-5]
if is_slow:
suites[s].slow_tests.append(i)
else:
suites[s].tests.append(i)
suites[s].executables.add(executable)
#test_suites = test['suite'] or ['default']
#is_slow = any(s.endswith('-slow') for s in test_suites)
#for s in test_suites:
# # The suite name in the introspection info is "PROJECT:SUITE"
# s = s.split(':')[1]
# if s.endswith('-slow'):
# s = s[:-5]
# if is_slow:
# suites[s].slow_tests.append(i)
# else:
# suites[s].tests.append(i)
# suites[s].executables.add(executable)
def emit_prolog(suites, prefix):
all_tap = ' '.join(('%s-report-%s.tap' % (prefix, k) for k in suites.keys()))
Submodule slirp deleted from 8f43a99191.
Submodule subprojects/libslirp added at bacb71f1c3.
File diff suppressed because it is too large. Load diff
+21
View File
@@ -0,0 +1,21 @@
/* SPDX-License-Identifier: MIT */
/*
* TCI target-specific constraint sets.
* Copyright (c) 2021 Linaro
*/
/*
* C_On_Im(...) defines a constraint set with <n> outputs and <m> inputs.
* Each operand should be a sequence of constraint letters as defined by
* tcg-target-con-str.h; the constraint combination is inclusive or.
*/
C_O0_I2(r, r)
C_O0_I3(r, r, r)
C_O0_I4(r, r, r, r)
C_O1_I1(r, r)
C_O1_I2(r, 0, r)
C_O1_I2(r, r, r)
C_O1_I4(r, r, r, r, r)
C_O2_I1(r, r, r)
C_O2_I2(r, r, r, r)
C_O2_I4(r, r, r, r, r, r)
+11
View File
@@ -0,0 +1,11 @@
/* SPDX-License-Identifier: MIT */
/*
* Define TCI target-specific operand constraints.
* Copyright (c) 2021 Linaro
*/
/*
* Define constraint letters for register sets:
* REGS(letter, register_mask)
*/
REGS('r', MAKE_64BIT_MASK(0, TCG_TARGET_NB_REGS))
File diff suppressed because it is too large. Load diff
+220
View File
@@ -0,0 +1,220 @@
/*
* Tiny Code Generator for QEMU
*
* Copyright (c) 2009, 2011 Stefan Weil
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*
* This code implements a TCG which does not generate machine code for some
* real target machine but which generates virtual machine code for an
* interpreter. Interpreted pseudo code is slow, but it works on any host.
*
* Some remarks might help in understanding the code:
*
* "target" or "TCG target" is the machine which runs the generated code.
* This is different to the usual meaning in QEMU where "target" is the
* emulated machine. So normally QEMU host is identical to TCG target.
* Here the TCG target is a virtual machine, but this virtual machine must
* use the same word size like the real machine.
* Therefore, we need both 32 and 64 bit virtual machines (interpreter).
*/
#ifndef TCG_TARGET_H
#define TCG_TARGET_H
#if UINTPTR_MAX == UINT32_MAX
# error We only support AArch64 running in 64B mode.
#elif UINTPTR_MAX == UINT64_MAX
# define TCG_TARGET_REG_BITS 64
#else
# error Unknown pointer size for tcti target
#endif
#define TCG_TARGET_INSN_UNIT_SIZE 1
#define TCG_TARGET_TLB_DISPLACEMENT_BITS 32
// We're an interpreted target; even if we're JIT-compiling to our interpreter's
// weird psuedo-native bytecode. We'll indicate that we're intepreted.
#define TCG_TARGET_INTERPRETER 1
//
// Supported optional instructions.
//
// Divs.
#define TCG_TARGET_HAS_div_i32 1
#define TCG_TARGET_HAS_rem_i32 1
#define TCG_TARGET_HAS_div_i64 1
#define TCG_TARGET_HAS_rem_i64 1
// Extends.
#define TCG_TARGET_HAS_ext8s_i32 1
#define TCG_TARGET_HAS_ext16s_i32 1
#define TCG_TARGET_HAS_ext8u_i32 1
#define TCG_TARGET_HAS_ext16u_i32 1
#define TCG_TARGET_HAS_ext8s_i64 1
#define TCG_TARGET_HAS_ext16s_i64 1
#define TCG_TARGET_HAS_ext32s_i64 1
#define TCG_TARGET_HAS_ext8u_i64 1
#define TCG_TARGET_HAS_ext16u_i64 1
#define TCG_TARGET_HAS_ext32u_i64 1
// Logicals.
#define TCG_TARGET_HAS_neg_i32 1
#define TCG_TARGET_HAS_not_i32 1
#define TCG_TARGET_HAS_neg_i64 1
#define TCG_TARGET_HAS_not_i64 1
#define TCG_TARGET_HAS_andc_i32 1
#define TCG_TARGET_HAS_orc_i32 1
#define TCG_TARGET_HAS_eqv_i32 1
#define TCG_TARGET_HAS_andc_i64 1
#define TCG_TARGET_HAS_eqv_i64 1
#define TCG_TARGET_HAS_orc_i64 1
// We don't curretly support rotates, since AArch64 lacks ROL.
// We'll fix this later.
#define TCG_TARGET_HAS_rot_i32 0
#define TCG_TARGET_HAS_rot_i64 0
// Swaps.
#define TCG_TARGET_HAS_bswap16_i32 1
#define TCG_TARGET_HAS_bswap32_i32 1
#define TCG_TARGET_HAS_bswap16_i64 1
#define TCG_TARGET_HAS_bswap32_i64 1
#define TCG_TARGET_HAS_bswap64_i64 1
#define TCG_TARGET_HAS_MEMORY_BSWAP 1
// Specify we'll handle direct jumps.
#define TCG_TARGET_HAS_direct_jump 1
//
// Potential TODOs.
//
// TODO: implement DEPOSIT as BFI.
#define TCG_TARGET_HAS_deposit_i32 0
#define TCG_TARGET_HAS_deposit_i64 0
// TODO: implement EXTRACT as BFX.
#define TCG_TARGET_HAS_extract_i32 0
#define TCG_TARGET_HAS_sextract_i32 0
#define TCG_TARGET_HAS_extract_i64 0
#define TCG_TARGET_HAS_sextract_i64 0
// TODO: it might be worth writing a gadget for this
#define TCG_TARGET_HAS_movcond_i32 0
#define TCG_TARGET_HAS_movcond_i64 0
//
// Unsupported instructions.
//
// ARMv8 doesn't have instructions for NAND/NOR.
#define TCG_TARGET_HAS_nand_i32 0
#define TCG_TARGET_HAS_nor_i32 0
#define TCG_TARGET_HAS_nor_i64 0
#define TCG_TARGET_HAS_nand_i64 0
// aarch64's CLZ is implemented without a condition, so it
#define TCG_TARGET_HAS_clz_i32 0
#define TCG_TARGET_HAS_ctz_i32 0
#define TCG_TARGET_HAS_ctpop_i32 0
#define TCG_TARGET_HAS_clz_i64 0
#define TCG_TARGET_HAS_ctz_i64 0
#define TCG_TARGET_HAS_ctpop_i64 0
// GOTO_PTR is too complex to emit a simple gadget for.
// We'll let C handle it, since the overhead is similar.
#define TCG_TARGET_HAS_goto_ptr 0
// We don't have a simple gadget for this, since we're always assuming softmmu.
#define TCG_TARGET_HAS_qemu_st8_i32 0
// No AArch64 equivalent.a
#define TCG_TARGET_HAS_extrl_i64_i32 0
#define TCG_TARGET_HAS_extrh_i64_i32 0
#define TCG_TARGET_HAS_extract2_i64 0
// These should always be zero on our 64B platform.
#define TCG_TARGET_HAS_muls2_i64 0
#define TCG_TARGET_HAS_add2_i32 0
#define TCG_TARGET_HAS_sub2_i32 0
#define TCG_TARGET_HAS_mulu2_i32 0
#define TCG_TARGET_HAS_add2_i64 0
#define TCG_TARGET_HAS_sub2_i64 0
#define TCG_TARGET_HAS_mulu2_i64 0
#define TCG_TARGET_HAS_muluh_i64 0
#define TCG_TARGET_HAS_mulsh_i64 0
#define TCG_TARGET_HAS_extract2_i32 0
#define TCG_TARGET_HAS_muls2_i32 0
#define TCG_TARGET_HAS_muluh_i32 0
#define TCG_TARGET_HAS_mulsh_i32 0
//
// Platform metadata.
//
// Number of registers available.
// It might make sense to up these, since we can also use x16 -> x25?
#define TCG_TARGET_NB_REGS 16
/* List of registers which are used by TCG. */
typedef enum {
TCG_REG_R0 = 0,
TCG_REG_R1,
TCG_REG_R2,
TCG_REG_R3,
TCG_REG_R4,
TCG_REG_R5,
TCG_REG_R6,
TCG_REG_R7,
TCG_REG_R8,
TCG_REG_R9,
TCG_REG_R10,
TCG_REG_R11,
TCG_REG_R12,
TCG_REG_R13,
TCG_REG_R14,
TCG_REG_R15,
TCG_AREG0 = TCG_REG_R14,
TCG_REG_CALL_STACK = TCG_REG_R15,
} TCGReg;
// Specify the shape of the stack our runtime will use.
#define TCG_TARGET_CALL_STACK_OFFSET 0
#define TCG_TARGET_STACK_ALIGN 16
// We're interpreted, so we'll use our own code to run TB_EXEC.
#define HAVE_TCG_QEMU_TB_EXEC
// We'll need to enforce memory ordering with barriers.
#define TCG_TARGET_DEFAULT_MO (0)
void tci_disas(uint8_t opc);
void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t);
#endif /* TCG_TARGET_H */
+788
View File
@@ -0,0 +1,788 @@
#!/usr/bin/env python3
""" Gadget-code generator for QEMU TCTI on AArch64.
Generates a C-code include file containing 'gadgets' for use by TCTI.
"""
import sys
import itertools
# Get a handle on the file we'll be working with, and redirect print to it.
if len(sys.argv) > 1:
out_file = open(sys.argv[1], "w")
# Hook our print function, so it always outputs to the relevant file.
core_print = print
print = lambda *a, **k : core_print(*a, **k, file=out_file)
# Epilogue code follows at the end of each gadget, and handles continuing execution.
EPILOGUE = (
# Load our next gadget address from our bytecode stream, advancing it.
"ldr x27, [x28], #8",
# Jump to the next gadget.
"br x27"
)
# The number of general-purpose registers we're affording the TCG. This must match
# the configuration in the TCTI target.
TCG_REGISTER_COUNT = 16
TCG_REGISTER_NUMBERS = list(range(TCG_REGISTER_COUNT))
# Helper that provides each of the AArch64 condition codes of interest.
ARCH_CONDITION_CODES = ["eq", "ne", "lt", "ge", "le", "gt", "lo", "hs", "ls", "hi"]
# We'll create a variety of gadgets that assume the MMU's TLB is stored at certain
# offsets into its structure. These should match the offsets in tcg-target.c.in.
QEMU_ALLOWED_MMU_OFFSETS = [ 64, 96, 128 ]
# Statistics.
gadgets = 0
instructions = 0
def simple(name, *lines):
""" Generates a simple gadget that needs no per-register specialization. """
global gadgets, instructions
gadgets += 1
# Create our C/ASM framing.
#print(f"__attribute__((naked)) static void gadget_{name}(void)")
print(f"__attribute__((naked)) void gadget_{name}(void);")
print(f"__attribute__((naked)) void gadget_{name}(void)")
print("{")
# Add the core gadget
print("\tasm(")
for line in lines + EPILOGUE:
print(f"\t\t\"{line} \\n\"")
instructions += 1
print("\t);")
# End our framing.
print("}\n")
def with_register_substitutions(name, substitutions, *lines, immediate_range=range(0)):
""" Generates a collection of gadgtes with register substitutions. """
def substitutions_for_letter(letter, number, line):
""" Helper that transforms Wd => w1, implementing gadget substitutions. """
# Register substitutions...
line = line.replace(f"X{letter}", f"x{number}")
line = line.replace(f"W{letter}", f"w{number}")
# ... immediate substitutions.
line = line.replace(f"I{letter}", f"{number}")
return line
# Build a list of all the various stages we'll iterate over...
immediate_parameters = list(immediate_range)
parameters = ([TCG_REGISTER_NUMBERS] * len(substitutions))
# ... adding immediates, if need be.
if immediate_parameters:
parameters.append(immediate_parameters)
substitutions = substitutions + ['i']
# Generate a list of register-combinations we'll support.
permutations = itertools.product(*parameters)
# For each permutation...
for permutation in permutations:
new_lines = lines
# Replace each placeholder element with its proper value...
for index, element in enumerate(permutation):
letter = substitutions[index]
number = element
# Create new gadgets for the releavnt line...
new_lines = [substitutions_for_letter(letter, number, line) for line in new_lines]
# ... and emit the gadget.
permutation_id = "_arg".join(str(number) for number in permutation)
simple(f"{name}_arg{permutation_id}", *new_lines)
def with_dnm(name, *lines):
""" Generates a collection of gadgets with substitutions for Xd, Xn, and Xm, and equivalents. """
with_register_substitutions(name, ("d", "n", "m"), *lines)
# Print out an array that contains all of our gadgets, for lookup.
print(f"void* gadget_{name}[{TCG_REGISTER_COUNT}][{TCG_REGISTER_COUNT}][{TCG_REGISTER_COUNT}] = ", end="")
print("{")
# D array
for d in TCG_REGISTER_NUMBERS:
print("\t{")
# N array
for n in TCG_REGISTER_NUMBERS:
print("\t\t{", end="")
# M array
for m in TCG_REGISTER_NUMBERS:
print(f"gadget_{name}_arg{d}_arg{n}_arg{m}", end=", ")
print("},")
print("\t},")
print("};")
def with_dn_immediate(name, *lines, immediate_range):
""" Generates a collection of gadgets with substitutions for Xd, Xn, and Xm, and equivalents. """
with_register_substitutions(name, ["d", "n"], *lines, immediate_range=immediate_range)
# Print out an array that contains all of our gadgets, for lookup.
print(f"void* gadget_{name}[{TCG_REGISTER_COUNT}][{TCG_REGISTER_COUNT}][{len(immediate_range)}] = ", end="")
print("{")
# D array
for d in TCG_REGISTER_NUMBERS:
print("\t{")
# N array
for n in TCG_REGISTER_NUMBERS:
print("\t\t{", end="")
# M array
for i in immediate_range:
print(f"gadget_{name}_arg{d}_arg{n}_arg{i}", end=", ")
print("},")
print("\t},")
print("};")
def with_pair(name, substitutions, *lines):
""" Generates a collection of gadgets with two subtstitutions."""
with_register_substitutions(name, substitutions, *lines)
# Print out an array that contains all of our gadgets, for lookup.
print(f"void* gadget_{name}[{TCG_REGISTER_COUNT}][{TCG_REGISTER_COUNT}] = ", end="")
print("{")
# N array
for a in TCG_REGISTER_NUMBERS:
print("\t\t{", end="")
# M array
for b in TCG_REGISTER_NUMBERS:
print(f"gadget_{name}_arg{a}_arg{b}", end=", ")
print("},")
print("};")
def math_dnm(name, mnemonic):
""" Equivalent to `with_dnm`, but creates a _i32 and _i64 variant. For simple math. """
with_dnm(f'{name}_i32', f"{mnemonic} Wd, Wn, Wm")
with_dnm(f'{name}_i64', f"{mnemonic} Xd, Xn, Xm")
def math_dn(name, mnemonic):
""" Equivalent to `with_dn`, but creates a _i32 and _i64 variant. For simple math. """
with_dn(f'{name}_i32', f"{mnemonic} Wd, Wn")
with_dn(f'{name}_i64', f"{mnemonic} Xd, Xn")
def with_nm(name, *lines):
""" Generates a collection of gadgets with substitutions for Xn, and Xm, and equivalents. """
with_pair(name, ('n', 'm',), *lines)
def with_dn(name, *lines):
""" Generates a collection of gadgets with substitutions for Xd, and Xn, and equivalents. """
with_pair(name, ('d', 'n',), *lines)
def ldst_dn(name, *lines):
""" Generates a collection of gadgets with substitutions for Xd, and Xn, and equivalents.
This variant is optimized for loads and stores, and optimizes common offset cases.
"""
#
# Simple case: create our gadgets.
#
with_dn(name, "ldr x27, [x28], #8", *lines)
#
# Optimization case: create variants of our gadgets with our offsets replaced with common immediates.
#
immediate_lines_pos = [line.replace("x27", "#Ii") for line in lines]
with_dn_immediate(f"{name}_imm", *immediate_lines_pos, immediate_range=range(64))
immediate_lines_aligned = [line.replace("x27", "#(Ii << 3)") for line in lines]
with_dn_immediate(f"{name}_sh8_imm", *immediate_lines_aligned, immediate_range=range(64))
immediate_lines_neg = [line.replace("x27", "#-Ii") for line in lines]
with_dn_immediate(f"{name}_neg_imm", *immediate_lines_neg, immediate_range=range(64))
def with_single(name, substitution, *lines):
""" Generates a collection of gadgets with two subtstitutions."""
with_register_substitutions(name, (substitution,), *lines)
# Print out an array that contains all of our gadgets, for lookup.
print(f"void* gadget_{name}[{TCG_REGISTER_COUNT}] = ", end="")
print("{")
for n in TCG_REGISTER_NUMBERS:
print(f"gadget_{name}_arg{n}", end=", ")
print("};")
def with_d_immediate(name, *lines, immediate_range=range(0)):
""" Generates a collection of gadgets with two subtstitutions."""
with_register_substitutions(name, ['d'], *lines, immediate_range=immediate_range)
# Print out an array that contains all of our gadgets, for lookup.
print(f"void* gadget_{name}[{TCG_REGISTER_COUNT}][{len(immediate_range)}] = ", end="")
print("{")
# D array
for a in TCG_REGISTER_NUMBERS:
print("\t\t{", end="")
# I array
for b in immediate_range:
print(f"gadget_{name}_arg{a}_arg{b}", end=", ")
print("},")
print("};")
def with_d(name, *lines):
""" Generates a collection of gadgets with substitutions for Xd. """
with_single(name, 'd', *lines)
# Assembly code for saving our machine state before entering the C runtime.
C_CALL_PROLOGUE = [
# Store our machine state.
"str x25, [sp, #-16]!",
"stp x14, x15, [sp, #-16]!",
"stp x12, x13, [sp, #-16]!",
"stp x10, x11, [sp, #-16]!",
"stp x8, x9, [sp, #-16]!",
"stp x6, x7, [sp, #-16]!",
"stp x4, x5, [sp, #-16]!",
"stp x2, x3, [sp, #-16]!",
"stp x0, x1, [sp, #-16]!",
"stp x28, lr, [sp, #-16]!",
]
# Assembly code for restoring our machine state after leaving the C runtime.
C_CALL_EPILOGUE = [
"ldp x28, lr, [sp], #16",
"ldp x0, x1, [sp], #16",
"ldp x2, x3, [sp], #16",
"ldp x4, x5, [sp], #16",
"ldp x6, x7, [sp], #16",
"ldp x8, x9, [sp], #16",
"ldp x10, x11, [sp], #16",
"ldp x12, x13, [sp], #16",
"ldp x14, x15, [sp], #16",
"ldr x25, [sp], #16",
]
def create_tlb_fastpath(is_aligned, is_write, offset, miss_label="0"):
""" Creates a set of instructions that perform a soft-MMU TLB lookup.
This is used for `qemu_ld`/qemu_st` instructions; to emit a prologue that
hopefully helps us skip a slow call into the C runtime when a Guest Virtual
-> Host Virtual mapping is in the softmmu's TLB.
This "fast-path" prelude behaves as follows:
- If a TLB entry is found for the address stored in Xn, then x27
is stored to an "addend" that can be added to the guest virtual addres
to get the host virtual address (the address in our local memory space).
- If a TLB entry isn't found, it branches to the "miss_label" (by default, 0:),
so address lookup can be handled by the fastpath.
Clobbers x24, and x26; provides output in x27.
"""
fast_path = [
# Load env_tlb(env)->f[mmu_idx].{mask,table} into {x26,x27}.
f"ldp x26, x27, [x14, #-{offset}]",
# Extract the TLB index from the address into X26.
"and x26, x26, Xn, lsr #7", # Xn = addr regsiter
# Add the tlb_table pointer, creating the CPUTLBEntry address into X27.
"add x27, x27, x26",
# Load the tlb comparator into X26, and the fast path addend into X27.
"ldr x26, [x27, #8]" if is_write else "ldr x26, [x27]",
"ldr x27, [x27, #0x18]",
]
if is_aligned:
fast_path.extend([
# Store the page mask part of the address into X24.
"and x24, Xn, #0xfffffffffffff000",
# Compare the masked address with the TLB value.
"cmp x26, x24",
# If we're not equal, this isn't a TLB hit. Jump to our miss handler.
f"b.ne {miss_label}f",
])
else:
fast_path.extend([
# If we're not aligned, add in our alignment value to ensure we don't
# don't straddle the end of a page.
"add x24, Xn, #7",
# Store the page mask part of the address into X24.
"and x24, x24, #0xfffffffffffff000",
# Compare the masked address with the TLB value.
"cmp x26, x24",
# If we're not equal, this isn't a TLB hit. Jump to our miss handler.
f"b.ne {miss_label}f",
])
return fast_path
def ld_thunk(name, fastpath_32b, fastpath_64b, slowpath_helper, immediate=None, is_aligned=False, force_slowpath=False):
""" Creates a thunk into our C runtime for a QEMU ST operation. """
# Use only offset 0 (no real offset) if we're forcing slowpath;
# otherwise, use all of our allowed MMU offsets.
offsets = [0] if force_slowpath else QEMU_ALLOWED_MMU_OFFSETS
for offset in offsets:
for is_32b in (True, False):
fastpath = fastpath_32b if is_32b else fastpath_64b
gadget_name = f"{name}_off{offset}_i32" if is_32b else f"{name}_off{offset}_i64"
postscript = () if immediate else ("add x28, x28, #8",)
# If we have a pure-assembly fast path, start our gadget with it.
if fastpath and not force_slowpath:
fastpath_ops = [
# Create a fastpath that jumps to miss_lable on a TLB miss,
# or sets x27 to the TLB addend on a TLB hit.
*create_tlb_fastpath(is_aligned=is_aligned, is_write=False, offset=offset),
# On a hit, we can just perform an appropriate load...
*fastpath,
# Run our patch-up post-script, if we have one.
*postscript,
# ... and then we're done!
*EPILOGUE,
]
# Otherwise, we'll save arguments for our slow path.
else:
fastpath_ops = []
#
# If we're not taking our fast path, we'll call into our C runtime to take the slow path.
#
with_dn(gadget_name,
*fastpath_ops,
"0:",
"mov x27, Xn",
# Save our registers in preparation for entering a C call.
*C_CALL_PROLOGUE,
# Per our calling convention:
# - Move our architectural environment into x0, from x14.
# - Move our target address into x1. [Placed in x27 below.]
# - Move our operation info into x2, from an immediate32.
# - Move the next bytecode pointer into x3, from x28.
"mov x0, x14",
"mov x1, x27",
f"mov x2, #{immediate}" if (immediate is not None) else "ldr x2, [x28], #8",
"mov x3, x28",
# Perform our actual core code.
f"bl _{slowpath_helper}",
# Temporarily store our result in a register that won't get trashed.
"mov x27, x0",
# Restore our registers after our C call.
*C_CALL_EPILOGUE,
# Finally, call our postscript...
*postscript,
# ... and place our results in the target register.
"mov Wd, w27" if is_32b else "mov Xd, x27"
)
def st_thunk(name, fastpath_32b, fastpath_64b, slowpath_helper, immediate=None, is_aligned=False, force_slowpath=False):
""" Creates a thunk into our C runtime for a QEMU ST operation. """
# Use only offset 0 (no real offset) if we're forcing slowpath;
# otherwise, use all of our allowed MMU offsets.
offsets = [0] if force_slowpath else QEMU_ALLOWED_MMU_OFFSETS
for offset in offsets:
for is_32b in (True, False):
fastpath = fastpath_32b if is_32b else fastpath_64b
gadget_name = f"{name}_off{offset}_i32" if is_32b else f"{name}_off{offset}_i64"
postscript = () if immediate else ("add x28, x28, #8",)
# If we have a pure-assembly fast path, start our gadget with it.
if fastpath and not force_slowpath:
fastpath_ops = [
# Create a fastpath that jumps to miss_lable on a TLB miss,
# or sets x27 to the TLB addend on a TLB hit.
*create_tlb_fastpath(is_aligned=is_aligned, is_write=True, offset=offset),
# On a hit, we can just perform an appropriate load...
*fastpath,
# Run our patch-up post-script, if we have one.
*postscript,
# ... and then we're done!
*EPILOGUE,
]
else:
fastpath_ops = []
#
# If we're not taking our fast path, we'll call into our C runtime to take the slow path.
#
with_dn(gadget_name,
*fastpath_ops,
"0:",
# Move our arguments into registers that we're not actively using.
# This ensures that they won't be trounced by our calling convention
# if this is reading values from x0-x4.
"mov w27, Wd" if is_32b else "mov x27, Xd",
"mov x26, Xn",
# Save our registers in preparation for entering a C call.
*C_CALL_PROLOGUE,
# Per our calling convention:
# - Move our architectural environment into x0, from x14.
# - Move our target address into x1. [Moved into x26 above].
# - Move our target value into x2. [Moved into x27 above].
# - Move our operation info into x3, from an immediate32.
# - Move the next bytecode pointer into x4, from x28.
"mov x0, x14",
"mov x1, x26",
"mov x2, x27",
f"mov x3, #{immediate}" if (immediate is not None) else "ldr x3, [x28], #8",
"mov x4, x28",
# Perform our actual core code.
f"bl _{slowpath_helper}",
# Restore our registers after our C call.
*C_CALL_EPILOGUE,
# Finally, call our postscript.
*postscript
)
#
# Gadget definitions.
#
print("/* Automatically generated by tcti-gadget-gen.py. Do not edit. */\n")
# Call a C language helper function by address.
simple("call",
# Get our C runtime function's location as a pointer-sized immediate...
"ldr x27, [x28], #8",
# Store our TB return address for our helper.
"str x28, [x25]",
# Prepare ourselves to call into our C runtime...
*C_CALL_PROLOGUE,
# ... perform the call itself ...
"blr x27",
# Save the result of our call for later.
"mov x27, x0",
# ... and restore our environment.
*C_CALL_EPILOGUE,
# Restore our return value.
"mov x0, x27"
)
# Branch to a given immediate address.
simple("br",
# Use our immediate argument as our new bytecode-pointer location.
"ldr x28, [x28]"
)
# Exit from a translation buffer execution.
simple("exit_tb",
# We have a single immediate argument, which contains our return code.
# Place it into x0, as one would a return code.
"ldr x0, [x28], #8",
# And finally, return back to the code that invoked our gadget stream.
"ret"
)
for condition in ARCH_CONDITION_CODES:
# Performs a comparison between two operands.
with_dnm(f"setcond_i32_{condition}",
"subs Wd, Wn, Wm",
f"cset Wd, {condition}"
)
with_dnm(f"setcond_i64_{condition}",
"subs Xd, Xn, Xm",
f"cset Xd, {condition}"
)
#
# NOTE: we use _dnm for the conditional branches, even though we don't
# actually do anything different based on the d argument. This gemerates
# effectively 16 identical `brcond` gadgets for each condition; which we
# use in the backend to spread out the actual branch sources we use.
#
# This is a slight mercy for the branch predictor, as not every conditional
# branch is funneled throught the same address.
#
# Branches iff a given comparison is true.
with_dnm(f'brcond_i32_{condition}',
# Grab our immediate argument.
"ldr x27, [x28], #8",
# Perform our comparison and conditional branch.
"subs Wzr, Wn, Wm",
f"b{condition} 1f",
"0:", # not taken
# Perform our end-of-instruction epilogue.
*EPILOGUE,
"1:" # taken
# Update our bytecode pointer to take the label.
"mov x28, x27"
)
# Branches iff a given comparison is true.
with_dnm(f'brcond_i64_{condition}',
# Grab our immediate argument.
"ldr x27, [x28], #8",
# Perform our comparison and conditional branch.
"subs Xzr, Xn, Xm",
f"b{condition} 1f",
"0:", # not taken
# Perform our end-of-instruction epilogue.
*EPILOGUE,
"1:" # taken
# Update our bytecode pointer to take the label.
"mov x28, x27"
)
# MOV variants.
with_dn("mov_i32", "mov Wd, Wn")
with_dn("mov_i64", "mov Xd, Xn")
with_d("movi_i32", "ldr Wd, [x28], #8")
with_d("movi_i64", "ldr Xd, [x28], #8")
# Create MOV variants that have common constants built in to the gadget.
# This optimization helps costly reads from memories for simple operations.
with_d_immediate("movi_imm_i32", "mov Wd, #Ii", immediate_range=range(64))
with_d_immediate("movi_imm_i64", "mov Xd, #Ii", immediate_range=range(64))
# LOAD variants.
# TODO: should the signed variants have X variants for _i64?
ldst_dn("ld8u", "ldrb Wd, [Xn, x27]")
ldst_dn("ld8s_i32", "ldrsb Wd, [Xn, x27]")
ldst_dn("ld8s_i64", "ldrsb Xd, [Xn, x27]")
ldst_dn("ld16u", "ldrh Wd, [Xn, x27]")
ldst_dn("ld16s_i32", "ldrsh Wd, [Xn, x27]")
ldst_dn("ld16s_i64", "ldrsh Xd, [Xn, x27]")
ldst_dn("ld32u", "ldr Wd, [Xn, x27]")
ldst_dn("ld32s_i64", "ldrsw Xd, [Xn, x27]")
ldst_dn("ld_i64", "ldr Xd, [Xn, x27]")
# STORE variants.
ldst_dn("st8", "strb Wd, [Xn, x27]")
ldst_dn("st16", "strh Wd, [Xn, x27]")
ldst_dn("st_i32", "str Wd, [Xn, x27]")
ldst_dn("st_i64", "str Xd, [Xn, x27]")
# QEMU LD/ST are handled in our C runtime rather than with simple gadgets,
# as they're nontrivial.
# Trivial arithmetic.
math_dnm("add" , "add" )
math_dnm("sub" , "sub" )
math_dnm("mul" , "mul" )
math_dnm("div" , "sdiv")
math_dnm("divu", "udiv")
# Division remainder
with_dnm("rem_i32", "sdiv w27, Wn, Wm", "msub Wd, w27, Wm, Wn")
with_dnm("rem_i64", "sdiv x27, Xn, Xm", "msub Xd, x27, Xm, Xn")
with_dnm("remu_i32", "udiv w27, Wn, Wm", "msub Wd, w27, Wm, Wn")
with_dnm("remu_i64", "udiv x27, Xn, Xm", "msub Xd, x27, Xm, Xn")
# Trivial logical.
math_dn( "not", "mvn")
math_dn( "neg", "neg")
math_dnm("and", "and")
math_dnm("andc", "bic")
math_dnm("or", "orr")
math_dnm("orc", "orn")
math_dnm("xor", "eor")
math_dnm("eqv", "eon")
math_dnm("shl", "lsl")
math_dnm("shr", "lsr")
math_dnm("sar", "asr")
# AArch64 lacks a Rotate Left; so we instead rotate right by a negative.
# TODO: validate this?
#math_dnm("rotr", "ror")
#with_dnm("rotl_i32", "neg w27, Wm", "ror Wd, Wn, w27")
#with_dnm("rotl_i64", "neg x27, Xm", "ror Xd, Xn, x27")
# Numeric extension.
math_dn("ext8s", "sxtb")
with_dn("ext8u", "and Xd, Xn, #0xff")
math_dn("ext16s", "sxth")
with_dn("ext16u", "and Wd, Wn, #0xffff")
with_dn("ext32s_i64", "sxtw Xd, Wn")
with_dn("ext32u_i64", "and Xd, Xn, #0xffffffff")
# Byte swapping.
with_dn("bswap16", "rev w27, Wn", "lsr Wd, w27, #16")
with_dn("bswap32", "rev Wd, Wn")
with_dn("bswap64", "rev Xd, Xn")
# Memory barriers.
simple("mb_all", "dmb ish")
simple("mb_st", "dmb ishst")
simple("mb_ld", "dmb ishld")
# Handlers for QEMU_LD, which handles guest <- host loads.
for subtype in ('aligned', 'unaligned', 'slowpath'):
is_aligned = (subtype == 'aligned')
is_slowpath = (subtype == 'slowpath')
ld_thunk(f"qemu_ld_ub_{subtype}", is_aligned=is_aligned, slowpath_helper="helper_ret_ldub_mmu",
fastpath_32b=["ldrb Wd, [Xn, x27]"], fastpath_64b=["ldrb Wd, [Xn, x27]"],
force_slowpath=is_slowpath,
)
ld_thunk(f"qemu_ld_sb_{subtype}", is_aligned=is_aligned, slowpath_helper="helper_ret_ldub_mmu_signed",
fastpath_32b=["ldrsb Wd, [Xn, x27]"], fastpath_64b=["ldrsb Xd, [Xn, x27]"],
force_slowpath=is_slowpath,
)
ld_thunk(f"qemu_ld_leuw_{subtype}", is_aligned=is_aligned, slowpath_helper="helper_le_lduw_mmu",
fastpath_32b=["ldrh Wd, [Xn, x27]"], fastpath_64b=["ldrh Wd, [Xn, x27]"],
force_slowpath=is_slowpath,
)
ld_thunk(f"qemu_ld_lesw_{subtype}", is_aligned=is_aligned, slowpath_helper="helper_le_lduw_mmu_signed",
fastpath_32b=["ldrsh Wd, [Xn, x27]"], fastpath_64b=["ldrsh Xd, [Xn, x27]"],
force_slowpath=is_slowpath,
)
ld_thunk(f"qemu_ld_leul_{subtype}", is_aligned=is_aligned, slowpath_helper="helper_le_ldul_mmu",
fastpath_32b=["ldr Wd, [Xn, x27]"], fastpath_64b=["ldr Wd, [Xn, x27]"],
force_slowpath=is_slowpath,
)
ld_thunk(f"qemu_ld_lesl_{subtype}", is_aligned=is_aligned, slowpath_helper="helper_le_ldul_mmu_signed",
fastpath_32b=["ldrsw Xd, [Xn, x27]"], fastpath_64b=["ldrsw Xd, [Xn, x27]"],
force_slowpath=is_slowpath,
)
ld_thunk(f"qemu_ld_leq_{subtype}", is_aligned=is_aligned, slowpath_helper="helper_le_ldq_mmu",
fastpath_32b=["ldr Xd, [Xn, x27]"], fastpath_64b=["ldr Xd, [Xn, x27]"],
force_slowpath=is_slowpath,
)
# Special variant for the most common mode, as a speedup optimization.
ld_thunk(f"qemu_ld_leq_{subtype}_mode3a", is_aligned=is_aligned, slowpath_helper="helper_le_ldq_mmu",
fastpath_32b=["ldr Xd, [Xn, x27]"], fastpath_64b=["ldr Xd, [Xn, x27]"],
force_slowpath=is_slowpath, immediate=0x3a
)
# For now, leave the rare/big-endian stuff slow-path only.
ld_thunk(f"qemu_ld_beuw_{subtype}", None, None, "helper_be_lduw_mmu",
is_aligned=is_aligned, force_slowpath=is_slowpath)
ld_thunk(f"qemu_ld_besw_{subtype}", None, None, "helper_be_lduw_mmu_signed",
is_aligned=is_aligned, force_slowpath=is_slowpath)
ld_thunk(f"qemu_ld_beul_{subtype}", None, None, "helper_be_ldul_mmu",
is_aligned=is_aligned, force_slowpath=is_slowpath)
ld_thunk(f"qemu_ld_besl_{subtype}", None, None, "helper_be_ldul_mmu_signed",
is_aligned=is_aligned, force_slowpath=is_slowpath)
ld_thunk(f"qemu_ld_beq_{subtype}", None, None, "helper_be_ldq_mmu",
is_aligned=is_aligned, force_slowpath=is_slowpath)
# Handlers for QEMU_ST, which handles guest -> host stores.
for subtype in ('aligned', 'unaligned', 'slowpath'):
is_aligned = (subtype == 'aligned')
is_slowpath = (subtype == 'slowpath')
st_thunk(f"qemu_st_ub_{subtype}", is_aligned=is_aligned, slowpath_helper="helper_ret_stb_mmu",
fastpath_32b=["strb Wd, [Xn, x27]"], fastpath_64b=["strb Wd, [Xn, x27]"],
force_slowpath=is_slowpath,
)
st_thunk(f"qemu_st_leuw_{subtype}", is_aligned=is_aligned, slowpath_helper="helper_le_stw_mmu",
fastpath_32b=["strh Wd, [Xn, x27]"], fastpath_64b=["strh Wd, [Xn, x27]"],
force_slowpath=is_slowpath,
)
st_thunk(f"qemu_st_leul_{subtype}", is_aligned=is_aligned, slowpath_helper="helper_le_stl_mmu",
fastpath_32b=["str Wd, [Xn, x27]"], fastpath_64b=["str Wd, [Xn, x27]"],
force_slowpath=is_slowpath,
)
st_thunk(f"qemu_st_leq_{subtype}", is_aligned=is_aligned, slowpath_helper="helper_le_stq_mmu",
fastpath_32b=["str Xd, [Xn, x27]"], fastpath_64b=["str Xd, [Xn, x27]"],
force_slowpath=is_slowpath,
)
# Special optimization for the most common modes.
st_thunk(f"qemu_st_leq_{subtype}_mode3a", is_aligned=is_aligned, slowpath_helper="helper_le_stq_mmu",
fastpath_32b=["str Xd, [Xn, x27]"], fastpath_64b=["str Xd, [Xn, x27]"],
force_slowpath=is_slowpath, immediate=0x3a
)
# For now, leave the rare/big-endian stuff slow-path only.
st_thunk(f"qemu_st_beuw_{subtype}", None, None, "helper_be_stw_mmu",
is_aligned=is_aligned, force_slowpath=is_slowpath)
st_thunk(f"qemu_st_beul_{subtype}", None, None, "helper_be_stl_mmu",
is_aligned=is_aligned, force_slowpath=is_slowpath)
st_thunk(f"qemu_st_beq_{subtype}", None, None, "helper_be_stq_mmu",
is_aligned=is_aligned, force_slowpath=is_slowpath)
# Statistics.
sys.stderr.write(f"\nGenerated {gadgets} gadgets with {instructions} instructions ({instructions * 4} B).\n\n")
+8 -7
View File
@@ -49,6 +49,7 @@
#include "hw/boards.h"
#endif
#include "tcg/tcg-apple-jit.h"
#include "tcg/tcg-op.h"
#if UINTPTR_MAX == UINT32_MAX
@@ -164,7 +165,7 @@ TCGv_env cpu_env = 0;
const void *tcg_code_gen_epilogue;
uintptr_t tcg_splitwx_diff;
#ifndef CONFIG_TCG_INTERPRETER
#if !defined(CONFIG_TCG_INTERPRETER) && !defined(CONFIG_TCG_THREADED_INTERPRETER)
tcg_prologue_fn *tcg_qemu_tb_exec;
#endif
@@ -1226,7 +1227,7 @@ void tcg_prologue_init(TCGContext *s)
region.start = buf0;
region.end = buf0 + total_size;
#ifndef CONFIG_TCG_INTERPRETER
#if !defined(CONFIG_TCG_INTERPRETER) && !defined(CONFIG_TCG_THREADED_INTERPRETER)
tcg_qemu_tb_exec = (tcg_prologue_fn *)tcg_splitwx_to_rx(buf0);
#endif
@@ -1252,7 +1253,7 @@ void tcg_prologue_init(TCGContext *s)
#endif
buf1 = s->code_ptr;
#ifndef CONFIG_TCG_INTERPRETER
#if !defined(CONFIG_TCG_INTERPRETER) && !defined(CONFIG_TCG_THREADED_INTERPRETER)
flush_idcache_range((uintptr_t)tcg_splitwx_to_rx(buf0), (uintptr_t)buf0,
tcg_ptr_byte_diff(buf1, buf0));
#endif
@@ -1980,7 +1981,7 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args)
#endif
#if defined(__sparc__) && !defined(__arch64__) \
&& !defined(CONFIG_TCG_INTERPRETER)
&& !defined(CONFIG_TCG_INTERPRETER) && !defined(CONFIG_TCG_THREADED_INTERPRETER)
/* We have 64-bit values in one register, but need to pass as two
separate parameters. Split them. */
int orig_sizemask = sizemask;
@@ -2030,7 +2031,7 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args)
pi = 0;
if (ret != NULL) {
#if defined(__sparc__) && !defined(__arch64__) \
&& !defined(CONFIG_TCG_INTERPRETER)
&& !defined(CONFIG_TCG_INTERPRETER) && !defined(CONFIG_TCG_THREADED_INTERPRETER)
if (orig_sizemask & 1) {
/* The 32-bit ABI is going to return the 64-bit value in
the %o0/%o1 register pair. Prepare for this by using
@@ -2108,7 +2109,7 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args)
tcg_debug_assert(pi <= ARRAY_SIZE(op->args));
#if defined(__sparc__) && !defined(__arch64__) \
&& !defined(CONFIG_TCG_INTERPRETER)
&& !defined(CONFIG_TCG_INTERPRETER) && !defined(CONFIG_TCG_THREADED_INTERPRETER)
/* Free all of the parts we allocated above. */
for (i = real_args = 0; i < orig_nargs; ++i) {
int is_64bit = orig_sizemask & (1 << (i+1)*2);
@@ -4788,7 +4789,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
return -2;
}
#ifndef CONFIG_TCG_INTERPRETER
#if !defined(CONFIG_TCG_INTERPRETER) && !defined(CONFIG_TCG_THREADED_INTERPRETER)
/* flush instruction cache */
flush_idcache_range((uintptr_t)tcg_splitwx_to_rx(s->code_buf),
(uintptr_t)s->code_buf,
+9
View File
@@ -23,7 +23,16 @@
#undef _FORTIFY_SOURCE
#endif
#include "qemu/osdep.h"
#if defined(CONFIG_LIBUCONTEXT)
#include <libucontext/libucontext.h>
#define ucontext_t libucontext_ucontext_t
#define getcontext libucontext_getcontext
#define setcontext libucontext_setcontext
#define swapcontext libucontext_swapcontext
#define makecontext libucontext_makecontext
#else
#include <ucontext.h>
#endif
#include "qemu/coroutine_int.h"
#ifdef CONFIG_VALGRIND_H
+4
View File
@@ -39,6 +39,10 @@ extern int madvise(char *, size_t, int);
#include "qemu/error-report.h"
#include "monitor/monitor.h"
#ifdef CONFIG_DARWIN
#include "tcg/tcg-apple-jit.h"
#endif
static bool fips_enabled = false;
static const char *hw_version = QEMU_HW_VERSION;