From nobody Tue May 7 00:10:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604813309; cv=none; d=zohomail.com; s=zohoarc; b=UhUO1byNs5uAdIZYHeixg5mr3Qs9M8fbFyAenm59LpijsMVnw/xfwoUDM7XeEhY8kPs19xhSHoh0EMqw7s7EutNiUbigqkYpHqz7XhjHCFh40X/PG6e3frbfo2JwcaaX2EsM0hdHpBViwpv9qSVL3ZtE/BaNKhJJtOjohfFyRLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604813309; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bscmMwY4Zssj6aPfsBCqE7bxrqB1fahSzU0ekRzQJRo=; b=aZgMqRxw0jvcbhjtRjfoi7+uSxRbp1kRHpW/hAVqkruNW4kewafYs66Bb0ojFEWgEZg7hXhqIc3Rf6Chmky2kUjuJFpsVYRR5be3h26To5jeibrm/Ahzaa+1KZKsIgB7ghTCXF78lZHwxzx0KqmCSdFeFS/921rGrK0gfsZUVSc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604813308960543.6393836496424; Sat, 7 Nov 2020 21:28:28 -0800 (PST) Received: from localhost ([::1]:54856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbdFb-0003CX-AY for importer@patchew.org; Sun, 08 Nov 2020 00:28:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbdDR-0001QS-Ig; Sun, 08 Nov 2020 00:26:13 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:51186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kbdDP-0004tw-Cz; Sun, 08 Nov 2020 00:26:13 -0500 Received: by mail-pj1-f66.google.com with SMTP id ie6so1528686pjb.0; Sat, 07 Nov 2020 21:26:10 -0800 (PST) Received: from localhost.localdomain ([73.93.155.42]) by smtp.gmail.com with ESMTPSA id hz18sm6994406pjb.13.2020.11.07.21.26.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Nov 2020 21:26:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bscmMwY4Zssj6aPfsBCqE7bxrqB1fahSzU0ekRzQJRo=; b=WVirQvv6y0dlSvrtqFavtH+QYFAlMZ7VfkCSPXj9KDKWKlGLJVSNq200IOf6l9LBQn zQ4si2wPwcVTTeIYZ1EdXtvo5zizkZmcX5FAY3NV8Ne3UfDle4XAvbmR5cEhBWCxsQ45 qWK9OE/QSbldkittuv/fCKzpFlqhC5Wf1pYkddzv4J7xjAHSWho8fZhn7x24PrQvOlbN 2rAC4SGQRbM9quDNCqt/oZRU52cDXYxl9HA3gq7tyjUh9UENMzlAW6lPDmwkHyiq74X8 ajsJeXw1S60OaezH4e6Lh0p0Fg27zHsh+LMDOWW4I5csnUFu1aTAWmyziln4wKPvTwlT WVlw== X-Gm-Message-State: AOAM530CNUa5JhqI63CebZ8lZDJf5TXSh/7kxB6A1JOqsy7SH9wcJNox 6leKxS9JkxPD7sXO6KdK3Ao77fIeQ3E= X-Google-Smtp-Source: ABdhPJxXtn5fcQ/8A5Z4Eaulp0E6SRZZgmFu3/L7WZdVDJmD81ucbIfB+JiXe8p7ynW7Vmh1tY74Jg== X-Received: by 2002:a17:90a:aa89:: with SMTP id l9mr6790299pjq.0.1604813169226; Sat, 07 Nov 2020 21:26:09 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v4 1/7] configure: option to disable host block devices Date: Sat, 7 Nov 2020 21:25:59 -0800 Message-Id: <20201108052605.45840-2-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201108052605.45840-1-j@getutm.app> References: <20201108052605.45840-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=209.85.216.66; envelope-from=osy86github@gmail.com; helo=mail-pj1-f66.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/08 00:26:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , "open list:raw" , Markus Armbruster , Max Reitz , Joelle van Dyne Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Some hosts (iOS) have a sandboxed filesystem and do not provide low-level APIs for interfacing with host block devices. Signed-off-by: Joelle van Dyne --- configure | 4 ++++ meson.build | 1 + qapi/block-core.json | 4 +++- block/file-posix.c | 8 +++++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 2c3c69f118..97a879808d 100755 --- a/configure +++ b/configure @@ -448,6 +448,7 @@ meson=3D"" ninja=3D"" skip_meson=3Dno gettext=3D"" +host_block_device_support=3D"yes" =20 bogus_os=3D"no" malloc_trim=3D"auto" @@ -5907,6 +5908,9 @@ if test "$default_devices" =3D "yes" ; then else echo "CONFIG_MINIKCONF_MODE=3D--allnoconfig" >> $config_host_mak fi +if test "$host_block_device_support" =3D "yes" ; then + echo "CONFIG_HOST_BLOCK_DEVICE=3Dy" >> $config_host_mak +fi if test "$debug_tcg" =3D "yes" ; then echo "CONFIG_DEBUG_TCG=3Dy" >> $config_host_mak fi diff --git a/meson.build b/meson.build index 39ac5cf6d8..fd822346e7 100644 --- a/meson.build +++ b/meson.build @@ -2166,6 +2166,7 @@ summary_info +=3D {'vvfat support': config_host.h= as_key('CONFIG_VVFAT')} summary_info +=3D {'qed support': config_host.has_key('CONFIG_QED')} summary_info +=3D {'parallels support': config_host.has_key('CONFIG_PARALL= ELS')} summary_info +=3D {'sheepdog support': config_host.has_key('CONFIG_SHEEPD= OG')} +summary_info +=3D {'host block dev support': config_host.has_key('CONFIG_H= OST_BLOCK_DEVICE')} summary_info +=3D {'capstone': capstone_opt =3D=3D 'disabled' ? f= alse : capstone_opt} summary_info +=3D {'libpmem support': config_host.has_key('CONFIG_LIBPME= M')} summary_info +=3D {'libdaxctl support': config_host.has_key('CONFIG_LIBDAX= CTL')} diff --git a/qapi/block-core.json b/qapi/block-core.json index 1b8b4156b4..ddcb61b8e8 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2848,7 +2848,9 @@ { 'enum': 'BlockdevDriver', 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', 'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ft= ps', - 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscs= i', + 'gluster', 'host_cdrom', + {'name': 'host_device', 'if': 'defined(CONFIG_HOST_BLOCK_DEVIC= E)' }, + 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallel= s', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', { 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' }, diff --git a/block/file-posix.c b/block/file-posix.c index c63926d592..52f7c20525 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -41,7 +41,7 @@ #include "scsi/pr-manager.h" #include "scsi/constants.h" =20 -#if defined(__APPLE__) && (__MACH__) +#if defined(CONFIG_HOST_BLOCK_DEVICE) && defined(__APPLE__) && (__MACH__) #include #include #include @@ -3247,6 +3247,8 @@ BlockDriver bdrv_file =3D { /***********************************************/ /* host device */ =20 +#if defined(CONFIG_HOST_BLOCK_DEVICE) + #if defined(__APPLE__) && defined(__MACH__) static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath, CFIndex maxPathSize, int flags); @@ -3872,6 +3874,8 @@ static BlockDriver bdrv_host_cdrom =3D { }; #endif /* __FreeBSD__ */ =20 +#endif /* CONFIG_HOST_BLOCK_DEVICE */ + static void bdrv_file_init(void) { /* @@ -3879,6 +3883,7 @@ static void bdrv_file_init(void) * registered last will get probed first. */ bdrv_register(&bdrv_file); +#if defined(CONFIG_HOST_BLOCK_DEVICE) bdrv_register(&bdrv_host_device); #ifdef __linux__ bdrv_register(&bdrv_host_cdrom); @@ -3886,6 +3891,7 @@ static void bdrv_file_init(void) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) bdrv_register(&bdrv_host_cdrom); #endif +#endif /* CONFIG_HOST_BLOCK_DEVICE */ } =20 block_init(bdrv_file_init); --=20 2.28.0 From nobody Tue May 7 00:10:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604813310; cv=none; d=zohomail.com; s=zohoarc; b=VOCxHEK8GBz4HBKXZubwnZUKt30fDUUFrVCrVB+iuEUkEKDDVcDJe1lnctfoq+1oBLenxzgnUwx+pFXfO9EknbfRxTNkGNotiBsBRIIuc2oy/E/bHjUECh15HF3D+4aHh92ZZBXNBpVFODW+BKYlBEN1X6eKy+ShWYAVx0RVU2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604813310; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=clC6oHTfnrMMN3FfznLE0Frgl/AYxxtTAqo83NQAGqs=; b=TMkIbh+y251Et8nVZW7DZnYaXGk8VXVhV0uf+Zofs0fjpNpsz2gFOqtZx8ZAs+WC8X6aorjHcer2zUkJQckyk6T5AI6MN+xAVYqlVsAvHmCK2pEljRs10YfRqGQEFiJjfYVvUZYOk9ZAXLinigkLXPeLeEGlbC4LD/LRwf38mds= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604813310722940.773314052065; Sat, 7 Nov 2020 21:28:30 -0800 (PST) Received: from localhost ([::1]:54864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbdFd-0003Cf-Hh for importer@patchew.org; Sun, 08 Nov 2020 00:28:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbdDR-0001QR-Ir for qemu-devel@nongnu.org; Sun, 08 Nov 2020 00:26:13 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41745) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kbdDP-0004u4-Hp for qemu-devel@nongnu.org; Sun, 08 Nov 2020 00:26:13 -0500 Received: by mail-pg1-f195.google.com with SMTP id g12so4190464pgm.8 for ; Sat, 07 Nov 2020 21:26:11 -0800 (PST) Received: from localhost.localdomain ([73.93.155.42]) by smtp.gmail.com with ESMTPSA id hz18sm6994406pjb.13.2020.11.07.21.26.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Nov 2020 21:26:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=clC6oHTfnrMMN3FfznLE0Frgl/AYxxtTAqo83NQAGqs=; b=bKzkdDrWgEC+sR7IsuC0rgpuEet4Rckm72gwgNe9cea6hz3MQlMVeXXeAhmO+8D0A4 ac+zfen8UxC8MBO78IEBD4tIoaldYRccV9edAqgN4lemL8SmuAy5r3aUWd70HBe/G2qz MpgBJokMcuckD++FLoiU45xkyibvkaEqoWbjyieGvswTp0XD4XyQuf8D6J4TLLG7QSbg ifBdlQmXrQFMQzfsgE1eHLMpkZoKxpb88qOHrDBN4lP5P3ZCD3QZotaJTc632PTvnxdB 2nAaMQo2121RIFKfDNCm3T+7QmGEkXtWDTnx+q9dE/H959EZCXbYa5Zc92sWGYxKM+ti hetg== X-Gm-Message-State: AOAM531iaYstr3JCI+RMvy+qQJ0a6p8HGpNtpGjTUtPwCu3pdti9OFtT sd+z0xvJTisVND4/IVxVouSp4PE3l1A= X-Google-Smtp-Source: ABdhPJz/wWamFbuj+IHzGJzgkpgzzlj1eF0viciv3DQHjacfJ5ESOmQDRjNdXA1Iwpt4Zu/CO/BDrQ== X-Received: by 2002:a63:ff4e:: with SMTP id s14mr8027436pgk.137.1604813170112; Sat, 07 Nov 2020 21:26:10 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v4 2/7] configure: cross-compiling with empty cross_prefix Date: Sat, 7 Nov 2020 21:26:00 -0800 Message-Id: <20201108052605.45840-3-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201108052605.45840-1-j@getutm.app> References: <20201108052605.45840-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=209.85.215.195; envelope-from=osy86github@gmail.com; helo=mail-pg1-f195.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/08 00:26:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The iOS toolchain does not use the host prefix naming convention. So we need to enable cross-compile options while allowing the PREFIX to be blank. Signed-off-by: Joelle van Dyne Reviewed-by: Thomas Huth --- configure | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 97a879808d..fda7a875f7 100755 --- a/configure +++ b/configure @@ -234,6 +234,7 @@ cpu=3D"" iasl=3D"iasl" interp_prefix=3D"/usr/gnemul/qemu-%M" static=3D"no" +cross_compile=3D"no" cross_prefix=3D"" audio_drv_list=3D"" block_drv_rw_whitelist=3D"" @@ -458,6 +459,7 @@ for opt do optarg=3D$(expr "x$opt" : 'x[^=3D]*=3D\(.*\)') case "$opt" in --cross-prefix=3D*) cross_prefix=3D"$optarg" + cross_compile=3D"yes" ;; --cc=3D*) CC=3D"$optarg" ;; @@ -1657,7 +1659,7 @@ $(echo Available targets: $default_target_list | \ --target-list-exclude=3DLIST exclude a set of targets from the default t= arget-list =20 Advanced options (experts only): - --cross-prefix=3DPREFIX use PREFIX for compile tools [$cross_prefix] + --cross-prefix=3DPREFIX use PREFIX for compile tools, PREFIX can be b= lank [$cross_prefix] --cc=3DCC use C compiler CC [$cc] --iasl=3DIASL use ACPI compiler IASL [$iasl] --host-cc=3DCC use C compiler CC [$host_cc] for code run at @@ -6933,7 +6935,7 @@ if has $sdl2_config; then fi echo "strip =3D [$(meson_quote $strip)]" >> $cross echo "windres =3D [$(meson_quote $windres)]" >> $cross -if test -n "$cross_prefix"; then +if test "$cross_compile" =3D "yes"; then cross_arg=3D"--cross-file config-meson.cross" echo "[host_machine]" >> $cross if test "$mingw32" =3D "yes" ; then --=20 2.28.0 From nobody Tue May 7 00:10:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604813338; cv=none; d=zohomail.com; s=zohoarc; b=nkYHKAC/zQEKSGSG7SzQ8HqT/3rbtvtvsHfWIOHSTKMKVzouPqgInp+okG/o2UdSpaBZ1vhQp18qgMwBFV6jOxDbU4+GUBczsjKtHU6oRyIAVbk+HwrYi560WB092JrXjk2qpQ5poteotJrS+tDK8oI6ddQepNEypIHhKj/73To= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604813338; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cM7lsRAmlkTbvOM+j4lORMBpE+S8g7GDEIfq9+p1rSs=; b=IzTQwlrjAr/I5kjd7PhhITHupkJaVBWOj9ACByGk6Oi4U/xKcMPiy0kpjfxmNnRSCgdQpVgb6nzJB56cUaBNVLCyk+8bP1Fc+PxwG6so+krhegfBS9BUphvXyWkXl4aev17jAxNznOiKTf7NBO2ok5WwAc2h+8sGy8J+TQ8P71w= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604813338625323.0950319534983; Sat, 7 Nov 2020 21:28:58 -0800 (PST) Received: from localhost ([::1]:56542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbdG5-0003vq-F2 for importer@patchew.org; Sun, 08 Nov 2020 00:28:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbdDT-0001Rp-R5; Sun, 08 Nov 2020 00:26:15 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38947) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kbdDR-0004uz-Nf; Sun, 08 Nov 2020 00:26:15 -0500 Received: by mail-pl1-f193.google.com with SMTP id x23so2945828plr.6; Sat, 07 Nov 2020 21:26:13 -0800 (PST) Received: from localhost.localdomain ([73.93.155.42]) by smtp.gmail.com with ESMTPSA id hz18sm6994406pjb.13.2020.11.07.21.26.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Nov 2020 21:26:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cM7lsRAmlkTbvOM+j4lORMBpE+S8g7GDEIfq9+p1rSs=; b=nBC458PTVgs6s124koLFEpsg8wo2NG1t8l4zo4tXdx3H8aCx0qG/B1w8tx5hOnufkb lXhqkVdFVMoGTP5/K1pTetZAwqxz/oxLqOv42D2bxxYjwy6GiMUtQp09jKbKBKE+E6US 4cQzsQ5bNC7b5KdwzB+58vHsKa3IsurzETIy3TnbK7MXn6lDgHr+UykfBjQ1quJnR1+U aqHqBWPAq1U6jdYUN22/w1itaJtocChEIj8Z7Q296a6FLOZTvtBgeJ+odUTFmwVL/nKm 4/jJcfvE/wVD8/847DIOy28T5SHNdEw8dFrnapvfhctUxHPVVrThG7eSBUaSm9ea4xFv jQFg== X-Gm-Message-State: AOAM533RIJ4wqjXi2SShenrRQ0v4npv0vyJPU2bGOG+8DeQu69dEgLmH sIOuI4OjyFVVzdTEmSsArr9amv2HgdU= X-Google-Smtp-Source: ABdhPJxOZUW+zmV7bhIiMdniFBbUxyjKcNDt1Y/NnrsYOxaTq4judaAXT20D2BLZJ9gOaSYsnanXZw== X-Received: by 2002:a17:90a:5882:: with SMTP id j2mr6708123pji.177.1604813171825; Sat, 07 Nov 2020 21:26:11 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v4 3/7] qemu: add support for iOS host Date: Sat, 7 Nov 2020 21:26:01 -0800 Message-Id: <20201108052605.45840-4-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201108052605.45840-1-j@getutm.app> References: <20201108052605.45840-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=209.85.214.193; envelope-from=osy86github@gmail.com; helo=mail-pl1-f193.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/08 00:26:08 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Laurent Vivier , Thomas Huth , "open list:Block layer core" , Jason Wang , Michael Roth , Max Reitz , Joelle van Dyne , Paolo Bonzini , Samuel Thibault Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This introduces support for building for iOS hosts. When the correct Xcode toolchain is used, iOS host will be detected automatically. * block: disable features not supported by iOS sandbox * slirp: disable SMB features for iOS * osdep: disable system() calls for iOS Signed-off-by: Joelle van Dyne --- docs/devel/index.rst | 1 + docs/devel/ios.rst | 28 +++++++++++++++++++++++++++ configure | 43 ++++++++++++++++++++++++++++++++++++++++- meson.build | 2 +- include/qemu/osdep.h | 11 +++++++++++ block.c | 2 +- block/file-posix.c | 31 +++++++++++++++++------------ net/slirp.c | 16 +++++++-------- qga/commands-posix.c | 6 ++++++ MAINTAINERS | 7 +++++++ tests/qtest/meson.build | 7 +++---- 11 files changed, 127 insertions(+), 27 deletions(-) create mode 100644 docs/devel/ios.rst diff --git a/docs/devel/index.rst b/docs/devel/index.rst index 77baae5c77..a46740929f 100644 --- a/docs/devel/index.rst +++ b/docs/devel/index.rst @@ -34,3 +34,4 @@ Contents: clocks qom block-coroutine-wrapper + ios diff --git a/docs/devel/ios.rst b/docs/devel/ios.rst new file mode 100644 index 0000000000..b4ab11bec1 --- /dev/null +++ b/docs/devel/ios.rst @@ -0,0 +1,28 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +iOS Support +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +To run qemu on the iOS platform, some modifications were required. Most of= the +modifications are conditioned on the ``CONFIG_IOS`` and configuration vari= able. + +Build support +------------- + +For the code to compile, certain changes in the block driver and the slirp +driver had to be made. There is no ``system()`` call, so it has been repla= ced +with an assertion error. There should be no code path that call system() f= rom +iOS. + +``ucontext`` support is broken on iOS. The implementation from ``libuconte= xt`` +is used instead. + +JIT support +----------- + +On iOS, allocating RWX pages require special entitlements not usually gran= ted to +apps. However, it is possible to use `bulletproof JIT`_ with a development +certificate. This means that we need to allocate one chunk of memory with = RX +permissions and then mirror map the same memory with RW permissions. We ge= nerate +code to the mirror mapping and execute the original mapping. + +.. _bulletproof JIT: https://www.blackhat.com/docs/us-16/materials/us-16-K= rstic.pdf diff --git a/configure b/configure index fda7a875f7..2a6db88a46 100755 --- a/configure +++ b/configure @@ -557,6 +557,19 @@ EOF compile_object } =20 +check_ios() { + cat > $TMPC < $TMPC < @@ -599,7 +612,11 @@ elif check_define __DragonFly__ ; then elif check_define __NetBSD__; then targetos=3D'NetBSD' elif check_define __APPLE__; then - targetos=3D'Darwin' + if check_ios ; then + targetos=3D'iOS' + else + targetos=3D'Darwin' + fi else # This is a fatal error, but don't report it yet, because we # might be going to just print the --help text, or it might @@ -777,6 +794,22 @@ Darwin) # won't work when we're compiling with gcc as a C compiler. QEMU_CFLAGS=3D"-DOS_OBJECT_USE_OBJC=3D0 $QEMU_CFLAGS" ;; +iOS) + bsd=3D"yes" + darwin=3D"yes" + ios=3D"yes" + if [ "$cpu" =3D "x86_64" ] ; then + QEMU_CFLAGS=3D"-arch x86_64 $QEMU_CFLAGS" + QEMU_LDFLAGS=3D"-arch x86_64 $QEMU_LDFLAGS" + fi + host_block_device_support=3D"no" + audio_drv_list=3D"" + audio_possible_drivers=3D"" + QEMU_LDFLAGS=3D"-framework CoreFoundation $QEMU_LDFLAGS" + # Disable attempts to use ObjectiveC features in os/object.h since they + # won't work when we're compiling with gcc as a C compiler. + QEMU_CFLAGS=3D"-DOS_OBJECT_USE_OBJC=3D0 $QEMU_CFLAGS" +;; SunOS) solaris=3D"yes" make=3D"${MAKE-gmake}" @@ -5962,6 +5995,10 @@ if test "$darwin" =3D "yes" ; then echo "CONFIG_DARWIN=3Dy" >> $config_host_mak fi =20 +if test "$ios" =3D "yes" ; then + echo "CONFIG_IOS=3Dy" >> $config_host_mak +fi + if test "$solaris" =3D "yes" ; then echo "CONFIG_SOLARIS=3Dy" >> $config_host_mak fi @@ -6926,6 +6963,7 @@ echo "cpp_link_args =3D [${LDFLAGS:+$(meson_quote $LD= FLAGS)}]" >> $cross echo "[binaries]" >> $cross echo "c =3D [$(meson_quote $cc)]" >> $cross test -n "$cxx" && echo "cpp =3D [$(meson_quote $cxx)]" >> $cross +test -n "$objcc" && echo "objc =3D [$(meson_quote $objcc)]" >> $cross echo "ar =3D [$(meson_quote $ar)]" >> $cross echo "nm =3D [$(meson_quote $nm)]" >> $cross echo "pkgconfig =3D [$(meson_quote $pkg_config_exe)]" >> $cross @@ -6944,6 +6982,9 @@ if test "$cross_compile" =3D "yes"; then if test "$linux" =3D "yes" ; then echo "system =3D 'linux'" >> $cross fi + if test "$darwin" =3D "yes" ; then + echo "system =3D 'darwin'" >> $cross + fi case "$ARCH" in i386|x86_64) echo "cpu_family =3D 'x86'" >> $cross diff --git a/meson.build b/meson.build index fd822346e7..8894171bd1 100644 --- a/meson.build +++ b/meson.build @@ -176,7 +176,7 @@ if targetos =3D=3D 'windows' include_directories: include_directo= ries('.')) elif targetos =3D=3D 'darwin' coref =3D dependency('appleframeworks', modules: 'CoreFoundation') - iokit =3D dependency('appleframeworks', modules: 'IOKit') + iokit =3D dependency('appleframeworks', modules: 'IOKit', required: 'CON= FIG_IOS' not in config_host) cocoa =3D dependency('appleframeworks', modules: 'Cocoa', required: get_= option('cocoa')) elif targetos =3D=3D 'sunos' socket =3D [cc.find_library('socket'), diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index f9ec8c84e9..eb8d06cbf5 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -686,4 +686,15 @@ char *qemu_get_host_name(Error **errp); */ size_t qemu_get_host_physmem(void); =20 +/** + * iOS does not support system() so we replace it with an assertion failur= e. + */ +#ifdef CONFIG_IOS +#define system ios_does_not_support_system +static inline int ios_does_not_support_system(const char *command) +{ + assert(0); +} +#endif /* CONFIG_IOS */ + #endif diff --git a/block.c b/block.c index 56bacc9e9f..e99cbf25ee 100644 --- a/block.c +++ b/block.c @@ -53,7 +53,7 @@ #ifdef CONFIG_BSD #include #include -#ifndef __DragonFly__ +#if !defined(__DragonFly__) && !defined(CONFIG_IOS) #include #endif #endif diff --git a/block/file-posix.c b/block/file-posix.c index 52f7c20525..5560fd20ac 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -181,7 +181,17 @@ typedef struct BDRVRawReopenState { bool check_cache_dropped; } BDRVRawReopenState; =20 -static int fd_open(BlockDriverState *bs); +static int fd_open(BlockDriverState *bs) +{ + BDRVRawState *s =3D bs->opaque; + + /* this is just to ensure s->fd is sane (its called by io ops) */ + if (s->fd >=3D 0) { + return 0; + } + return -EIO; +} + static int64_t raw_getlength(BlockDriverState *bs); =20 typedef struct RawPosixAIOData { @@ -252,6 +262,12 @@ static int raw_normalize_devicepath(const char **filen= ame, Error **errp) } #endif =20 +#if defined(CONFIG_IOS) +static int probe_logical_blocksize(int fd, unsigned int *sector_size_p) +{ + return -ENOTSUP; /* not supported on iOS */ +} +#else /* CONFIG_IOS */ /* * Get logical block size via ioctl. On success store it in @sector_size_p. */ @@ -284,6 +300,7 @@ static int probe_logical_blocksize(int fd, unsigned int= *sector_size_p) =20 return success ? 0 : -errno; } +#endif /* !CONFIG_IOS */ =20 /** * Get physical block size of @fd. @@ -2306,7 +2323,7 @@ again: } if (size =3D=3D 0) #endif -#if defined(__APPLE__) && defined(__MACH__) +#if !defined(CONFIG_IOS) && defined(__APPLE__) && defined(__MACH__) { uint64_t sectors =3D 0; uint32_t sector_size =3D 0; @@ -3541,16 +3558,6 @@ hdev_co_ioctl(BlockDriverState *bs, unsigned long in= t req, void *buf) } #endif /* linux */ =20 -static int fd_open(BlockDriverState *bs) -{ - BDRVRawState *s =3D bs->opaque; - - /* this is just to ensure s->fd is sane (its called by io ops) */ - if (s->fd >=3D 0) - return 0; - return -EIO; -} - static coroutine_fn int hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) { diff --git a/net/slirp.c b/net/slirp.c index 77042e6df7..8413042c09 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -27,7 +27,7 @@ #include "net/slirp.h" =20 =20 -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(CONFIG_IOS) #include #include #endif @@ -90,7 +90,7 @@ typedef struct SlirpState { Slirp *slirp; Notifier poll_notifier; Notifier exit_notifier; -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(CONFIG_IOS) gchar *smb_dir; #endif GSList *fwd; @@ -103,7 +103,7 @@ static QTAILQ_HEAD(, SlirpState) slirp_stacks =3D static int slirp_hostfwd(SlirpState *s, const char *redir_str, Error **err= p); static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **e= rrp); =20 -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(CONFIG_IOS) static int slirp_smb(SlirpState *s, const char *exported_dir, struct in_addr vserver_addr, Error **errp); static void slirp_smb_cleanup(SlirpState *s); @@ -368,7 +368,7 @@ static int net_slirp_init(NetClientState *peer, const c= har *model, struct in6_addr ip6_prefix; struct in6_addr ip6_host; struct in6_addr ip6_dns; -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(CONFIG_IOS) struct in_addr smbsrv =3D { .s_addr =3D 0 }; #endif NetClientState *nc; @@ -478,7 +478,7 @@ static int net_slirp_init(NetClientState *peer, const c= har *model, return -1; } =20 -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(CONFIG_IOS) if (vsmbserver && !inet_aton(vsmbserver, &smbsrv)) { error_setg(errp, "Failed to parse SMB address"); return -1; @@ -593,7 +593,7 @@ static int net_slirp_init(NetClientState *peer, const c= har *model, } } } -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(CONFIG_IOS) if (smb_export) { if (slirp_smb(s, smb_export, smbsrv, errp) < 0) { goto error; @@ -785,7 +785,7 @@ void hmp_hostfwd_add(Monitor *mon, const QDict *qdict) =20 } =20 -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(CONFIG_IOS) =20 /* automatic user mode samba server configuration */ static void slirp_smb_cleanup(SlirpState *s) @@ -900,7 +900,7 @@ static int slirp_smb(SlirpState* s, const char *exporte= d_dir, return 0; } =20 -#endif /* !defined(_WIN32) */ +#endif /* !defined(_WIN32) && !defined(CONFIG_IOS) */ =20 static int guestfwd_can_read(void *opaque) { diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 3711080d07..66a2f2ac9e 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -34,6 +34,12 @@ =20 #ifndef CONFIG_HAS_ENVIRON #ifdef __APPLE__ +#include "TargetConditionals.h" +#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR +#define APPLE_USE_CRT_EXTERNS +#endif +#endif +#ifdef APPLE_USE_CRT_EXTERNS #include #define environ (*_NSGetEnviron()) #else diff --git a/MAINTAINERS b/MAINTAINERS index 63223e1183..1ec4c67a62 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -528,6 +528,13 @@ F: include/*/*win32* X: qga/*win32* F: qemu.nsi =20 +IOS +M: Joelle van Dyne +S: Maintained +K: ^Subject:.*(?i)iOS +F: docs/devel/ios.rst +F: include/tcg/tcg-apple-jit.h + Alpha Machines -------------- M: Richard Henderson diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index c19f1c8503..8a151ee2da 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -46,12 +46,11 @@ qtests_i386 =3D \ (config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-test'] : [= ]) + \ (config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-swtpm-test= '] : []) + \ (config_all_devices.has_key('CONFIG_RTL8139_PCI') ? ['rtl8139-test'] : [= ]) + \ + (not config_host.has_key('CONFIG_IOS') ? ['bios-tables-test', 'hd-geo-te= st'] : []) + \ qtests_pci + = \ ['fdc-test', 'ide-test', - 'hd-geo-test', 'boot-order-test', - 'bios-tables-test', 'rtc-test', 'i440fx-test', 'fuzz-test', @@ -148,9 +147,9 @@ qtests_arm =3D \ 'boot-serial-test', 'hexloader-test'] =20 -# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-tes= t unconditional +# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-tes= t unconditional (except on iOS) qtests_aarch64 =3D \ - (cpu !=3D 'arm' ? ['bios-tables-test'] : []) + = \ + (cpu !=3D 'arm' and not config_host.has_key('CONFIG_IOS') ? ['bios-table= s-test'] : []) + \ (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-= test'] : []) + \ (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-= swtpm-test'] : []) + \ ['arm-cpu-features', --=20 2.28.0 From nobody Tue May 7 00:10:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604813723; cv=none; d=zohomail.com; s=zohoarc; b=ZU601hBh1jPHRadG6yAuZfS0kSJrbJWGYECBIMyEWhFN+8dLNq/Sv3mLjpiX5BIGpaiVT/6afpE/z1Et2mhGNJKQHbr8uFk0Rbme5uzBYdMaNoTmVi51CDe3p7alzoAI3/E5Quy+++FdbmFCJIoAQyi67svHClTlzK3ucuNvDFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604813723; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2EGdgJu0Lqq71e+aPYEq0GYxDtNLTm9bz2zccPRlgqk=; b=EgA5GgDkJVgWaHt845pkS/EQb7df7Ey1pQhmOqY51qliWTwdzCjZeahHnysK4d3wARx1Orhr/fg7M9iOZvBXU5G8cFrI93vPiADwbWD6ZXLgvJpB9Pm37Xy3yifMmsQsnFc8oYlHQZJBd56S4kv88N0UV6yhJq+0yCkc4dSzaiM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604813723814455.21730118170103; Sat, 7 Nov 2020 21:35:23 -0800 (PST) Received: from localhost ([::1]:38358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbdMI-000087-Kb for importer@patchew.org; Sun, 08 Nov 2020 00:35:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbdDU-0001ST-DA for qemu-devel@nongnu.org; Sun, 08 Nov 2020 00:26:16 -0500 Received: from mail-pf1-f180.google.com ([209.85.210.180]:43204) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kbdDS-0004vm-HJ for qemu-devel@nongnu.org; Sun, 08 Nov 2020 00:26:16 -0500 Received: by mail-pf1-f180.google.com with SMTP id z3so5079448pfb.10 for ; Sat, 07 Nov 2020 21:26:14 -0800 (PST) Received: from localhost.localdomain ([73.93.155.42]) by smtp.gmail.com with ESMTPSA id hz18sm6994406pjb.13.2020.11.07.21.26.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Nov 2020 21:26:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2EGdgJu0Lqq71e+aPYEq0GYxDtNLTm9bz2zccPRlgqk=; b=qg/0WxDrhU0mrcrVaCnsGWhHnmwZQweBaegATVzDfGamZe8aBvmP9j0/t4Jbmi+DUl 1x0ExEh0qlmnpQswjHuTRKkeJyIi74MxY8hPoE6yhpBJbEtIDByL+d07jlQ0my3N0PKC 1SHPKfkVpvWbP3r2YOD5kMv3MRcJksop1DFQEClCMhSsaIt6uAOqUGepkk1ldHWmxDux Mh7MzbaHle5vyDH5My9NCidAnhVpBA67StNLF4g7SooZYZvfTxe2sNfD1BqL+fD0O5Nu +cN5ypwiQvGi3VIc4BKQvWklNbLDEOHUxQHy3W+W5KE16B7ZgVEhN9Of5ZXbVB93rlQV +xxw== X-Gm-Message-State: AOAM532RI4H9R+7U2qX8d0fgA+2Wo20GFfre2O9nAtQcymIaM5fGhXQt iCnElFuw9r1cG7qtGwywJmKE98RTZWM= X-Google-Smtp-Source: ABdhPJxp9yK+bYDVSR7ZqnclJIDOJkB3zQreNcB43ej4qjodzjkA2SOhqabVhU7PPmhee0w7sLVqgA== X-Received: by 2002:aa7:8e87:0:b029:18b:cfd8:261c with SMTP id a7-20020aa78e870000b029018bcfd8261cmr4476186pfr.61.1604813173007; Sat, 07 Nov 2020 21:26:13 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v4 4/7] coroutine: add libucontext as external library Date: Sat, 7 Nov 2020 21:26:02 -0800 Message-Id: <20201108052605.45840-5-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201108052605.45840-1-j@getutm.app> References: <20201108052605.45840-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=209.85.210.180; envelope-from=osy86github@gmail.com; helo=mail-pf1-f180.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/08 00:26:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Joelle van Dyne , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Joelle van Dyne --- configure | 23 ++++++++++++++++++++--- meson.build | 28 +++++++++++++++++++++++++++- util/coroutine-ucontext.c | 9 +++++++++ .gitmodules | 3 +++ libucontext | 1 + meson_options.txt | 2 ++ 6 files changed, 62 insertions(+), 4 deletions(-) create mode 160000 libucontext diff --git a/configure b/configure index 2a6db88a46..d1c6aa9750 100755 --- a/configure +++ b/configure @@ -1750,7 +1750,7 @@ Advanced options (experts only): --oss-lib path to OSS library --cpu=3DCPU Build for host CPU [$cpu] --with-coroutine=3DBACKEND 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=3DSDK-path enable Windows VSS support in QEMU Guest Agent @@ -4883,6 +4883,8 @@ if test "$coroutine" =3D ""; then coroutine=3Dwin32 elif test "$ucontext_works" =3D "yes"; then coroutine=3Ducontext + elif test "$ios" =3D "yes"; then + coroutine=3Dlibucontext else coroutine=3Dsigaltstack fi @@ -4906,12 +4908,27 @@ else error_exit "only the 'windows' coroutine backend is valid for Window= s" fi ;; + libucontext) + ;; *) error_exit "unknown coroutine backend $coroutine" ;; esac fi =20 +case $coroutine in +libucontext) + git_submodules=3D"${git_submodules} libucontext" + mkdir -p libucontext + coroutine_impl=3Ducontext + libucontext=3D"enabled" + ;; +*) + coroutine_impl=3D$coroutine + libucontext=3D"disabled" + ;; +esac + if test "$coroutine_pool" =3D ""; then coroutine_pool=3Dyes fi @@ -6457,7 +6474,7 @@ if test "$rbd" =3D "yes" ; then echo "RBD_LIBS=3D$rbd_libs" >> $config_host_mak fi =20 -echo "CONFIG_COROUTINE_BACKEND=3D$coroutine" >> $config_host_mak +echo "CONFIG_COROUTINE_BACKEND=3D$coroutine_impl" >> $config_host_mak if test "$coroutine_pool" =3D "yes" ; then echo "CONFIG_COROUTINE_POOL=3D1" >> $config_host_mak else @@ -7035,7 +7052,7 @@ NINJA=3D$ninja $meson setup \ -Dcocoa=3D$cocoa -Dmpath=3D$mpath -Dsdl=3D$sdl -Dsdl_image=3D$sdl_= image \ -Dvnc=3D$vnc -Dvnc_sasl=3D$vnc_sasl -Dvnc_jpeg=3D$vnc_jpeg -Dvnc_p= ng=3D$vnc_png \ -Dgettext=3D$gettext -Dxkbcommon=3D$xkbcommon -Du2f=3D$u2f -Dvirti= ofsd=3D$virtiofsd \ - -Dcapstone=3D$capstone -Dslirp=3D$slirp -Dfdt=3D$fdt \ + -Dcapstone=3D$capstone -Dslirp=3D$slirp -Dfdt=3D$fdt -Ducontext=3D= $libucontext \ -Diconv=3D$iconv -Dcurses=3D$curses -Dlibudev=3D$libudev\ -Ddocs=3D$docs -Dsphinx_build=3D$sphinx_build -Dinstall_blobs=3D$b= lobs \ $cross_arg \ diff --git a/meson.build b/meson.build index 8894171bd1..e62324d5ac 100644 --- a/meson.build +++ b/meson.build @@ -1259,9 +1259,34 @@ if not fdt.found() and fdt_required.length() > 0 error('fdt not available but required by targets ' + ', '.join(fdt_requi= red)) endif =20 +ucontext =3D not_found +if get_option('ucontext').enabled() + if not fs.is_dir(meson.current_source_dir() / 'libucontext/arch' / cpu) + error('libucontext is wanted but not implemented for host ' + cpu) + endif + arch =3D host_machine.cpu() + ucontext_cargs =3D ['-DG_LOG_DOMAIN=3D"ucontext"', '-DCUSTOM_IMPL'] + ucontext_files =3D [ + 'libucontext/arch' / arch / 'getcontext.S', + 'libucontext/arch' / arch / 'setcontext.S', + 'libucontext/arch' / arch / 'makecontext.c', + 'libucontext/arch' / arch / 'startcontext.S', + 'libucontext/arch' / arch / 'swapcontext.S', + ] + + ucontext_inc =3D include_directories('libucontext/include') + libucontext =3D static_library('ucontext', + sources: ucontext_files, + c_args: ucontext_cargs, + include_directories: ucontext_inc) + ucontext =3D declare_dependency(link_with: libucontext, + include_directories: ucontext_inc) +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()) =20 ##################### # Generated sources # @@ -1477,7 +1502,7 @@ util_ss.add_all(trace_ss) util_ss =3D util_ss.apply(config_all, strict: false) libqemuutil =3D static_library('qemuutil', sources: util_ss.sources() + stub_ss.sources(= ) + genh, - dependencies: [util_ss.dependencies(), m, gli= b, socket, malloc]) + dependencies: [util_ss.dependencies(), m, gli= b, socket, malloc, ucontext]) qemuutil =3D declare_dependency(link_with: libqemuutil, sources: genh + version_res) =20 @@ -2135,6 +2160,7 @@ if targetos =3D=3D 'windows' summary_info +=3D {'QGA MSI support': config_host.has_key('CONFIG_QGA_= MSI')} endif summary_info +=3D {'seccomp support': config_host.has_key('CONFIG_SECCOM= P')} +summary_info +=3D {'libucontext support': ucontext.found()} summary_info +=3D {'coroutine backend': config_host['CONFIG_COROUTINE_BACK= END']} summary_info +=3D {'coroutine pool': config_host['CONFIG_COROUTINE_POOL= '] =3D=3D '1'} summary_info +=3D {'debug stack usage': config_host.has_key('CONFIG_DEBUG_= STACK_USAGE')} diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c index 904b375192..1e1dd43512 100644 --- a/util/coroutine-ucontext.c +++ b/util/coroutine-ucontext.c @@ -23,7 +23,16 @@ #undef _FORTIFY_SOURCE #endif #include "qemu/osdep.h" +#if defined(CONFIG_LIBUCONTEXT) +#include +#define ucontext_t libucontext_ucontext_t +#define getcontext libucontext_getcontext +#define setcontext libucontext_setcontext +#define swapcontext libucontext_swapcontext +#define makecontext libucontext_makecontext +#else #include +#endif #include "qemu/coroutine_int.h" =20 #ifdef CONFIG_VALGRIND_H diff --git a/.gitmodules b/.gitmodules index 2bdeeacef8..065b52867f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -64,3 +64,6 @@ [submodule "roms/vbootrom"] path =3D roms/vbootrom url =3D https://git.qemu.org/git/vbootrom.git +[submodule "libucontext"] + path =3D libucontext + url =3D https://github.com/utmapp/libucontext.git diff --git a/libucontext b/libucontext new file mode 160000 index 0000000000..7094e4c427 --- /dev/null +++ b/libucontext @@ -0,0 +1 @@ +Subproject commit 7094e4c42723b6178a4e2b60d4631d8a88f40719 diff --git a/meson_options.txt b/meson_options.txt index b4f1801875..da24102898 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -64,6 +64,8 @@ option('xkbcommon', type : 'feature', value : 'auto', description: 'xkbcommon support') option('virtiofsd', type: 'feature', value: 'auto', description: 'build virtiofs daemon (virtiofsd)') +option('ucontext', type : 'feature', value : 'disabled', + description: 'libucontext support') =20 option('capstone', type: 'combo', value: 'auto', choices: ['disabled', 'enabled', 'auto', 'system', 'internal'], --=20 2.28.0 From nobody Tue May 7 00:10:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604813868; cv=none; d=zohomail.com; s=zohoarc; b=dmKQBfdJfSYz6nZc+QVwnt9zc6CdRmA6wlyA9FPtISIFbmww8H1ZxC2NFx/Ilyj8LURg0Geya0Mh3meirkS9PMirip9loYw6sH4gEcXJ0RypR7Zq7qFyzhE3baVlgbOqRwnLwBZG+xxTmHw1oqb4xrp1uG9aTq0tItiXyMMQAKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604813868; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IfWDGFIhMp3jXxBnSlVW2+A/U5la+FYoeeC16IgzEnQ=; b=cSzZuS83Igm5jGGxjqd2XfLW4aOSsCFCKQM/R7danG8kdF6NdtAzbnyfPqR3m5A/E+Pn4NvapqusaUYQ14ADf7WOHHDHOHJqxfKM2U6RDrW+phJOFpZF4nAgG0UG9MmYdHJ+3glKro0XyuZHyYKjN/1vVwUUWHC4y1R0mA1HjHM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604813868288123.99004152311568; Sat, 7 Nov 2020 21:37:48 -0800 (PST) Received: from localhost ([::1]:40472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbdOd-0001Dg-1l for importer@patchew.org; Sun, 08 Nov 2020 00:37:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbdDU-0001TJ-VR for qemu-devel@nongnu.org; Sun, 08 Nov 2020 00:26:16 -0500 Received: from mail-pf1-f171.google.com ([209.85.210.171]:42739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kbdDT-0004wB-Fc for qemu-devel@nongnu.org; Sun, 08 Nov 2020 00:26:16 -0500 Received: by mail-pf1-f171.google.com with SMTP id x13so5082139pfa.9 for ; Sat, 07 Nov 2020 21:26:15 -0800 (PST) Received: from localhost.localdomain ([73.93.155.42]) by smtp.gmail.com with ESMTPSA id hz18sm6994406pjb.13.2020.11.07.21.26.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Nov 2020 21:26:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IfWDGFIhMp3jXxBnSlVW2+A/U5la+FYoeeC16IgzEnQ=; b=siZ4njzTQOuS9IEbx03AIwKd7RVN1BPeet/zHUAoQTLmSwXhs6BgohonKpA92RFGWO BRwqoYHdBEufmEN960uQpBOnGkuxP1maYLbo+jvoW3FVCNRdMul7JaBUWjDHLFKfusDF wd0OSnXX7sbIHLGGGICWt0H/Q5E/DMvN/DS/y5PljW1KUudLqxIzkKa0eKo+3vcgyc3R 6igl/DAwwswHy5QGt7M7vSKZJiZDDxQbyIURWLF8Z6HUGCwF3nxGmoOlpGXrf6HJGcTe z+L+/zoRZRyk6QbgXHmRRTGPfNHVJDxiKS7eKKssB8oifb0NbmNbBHDDf8w2WRl9VWVI OHMQ== X-Gm-Message-State: AOAM531uTYxi2X+hDfd2tNN15cvVEuYnNOEaBaccIV4kROoJsN0HygEh yvFWo03Ip6y1jJTtPfhH613TaGYZ9AE= X-Google-Smtp-Source: ABdhPJygqrvwSD74rWwAv/A8zJaetN9th5EWDG6QDScJiS0/O4MfPCfSzzQoUzAhTty7t/3/4liGUg== X-Received: by 2002:a63:4c19:: with SMTP id z25mr8190096pga.58.1604813174043; Sat, 07 Nov 2020 21:26:14 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v4 5/7] slirp: update build flags for iOS resolv fix Date: Sat, 7 Nov 2020 21:26:03 -0800 Message-Id: <20201108052605.45840-6-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201108052605.45840-1-j@getutm.app> References: <20201108052605.45840-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=209.85.210.171; envelope-from=osy86github@gmail.com; helo=mail-pf1-f171.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/08 00:26:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" A future libslirp update will use libresolv on Darwin systems, so we add the flags in QEMU build now. Reviewed-by: Stefan Hajnoczi Signed-off-by: Joelle van Dyne --- meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meson.build b/meson.build index e62324d5ac..664d9f93a5 100644 --- a/meson.build +++ b/meson.build @@ -1156,6 +1156,8 @@ if have_system slirp_deps =3D [] if targetos =3D=3D 'windows' slirp_deps =3D cc.find_library('iphlpapi') + elif targetos =3D=3D 'darwin' + slirp_deps =3D cc.find_library('resolv') endif slirp_conf =3D configuration_data() slirp_conf.set('SLIRP_MAJOR_VERSION', meson.project_version().split('.= ')[0]) --=20 2.28.0 From nobody Tue May 7 00:10:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604813550; cv=none; d=zohomail.com; s=zohoarc; b=Wn5OZhvmikZi7QeDkxPSEX3B+WnKg4B+jJP/0Y7NYHb4z2eHScTImvXyUEv+VUgJoVpe67kfuPX72FFwS7CoBmnYfVSDMeFxpPscnB+8P0U7dzX8Dpj2CqSJtM3TJqOa/ngh7yiaMsp3OfPoI6JbnyDSUJO7DmaZ0tH4eQZa+uM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604813550; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oqTRRse3ML08CbYMBMir3imYmfVxmJCy/vR5/9jdsfA=; b=YK11lU9NKe2eS8cJ+YdS++ro53bUxMEeyq2vggfDpMAHTECq8+f1+nTxvApuIOXwG75Cnv2yd0onGz/2+9MjFKs2mpaQDFwxqKo6Klv7cE1AXnZTrtgfAF03z8zrYMOzgRtJYBFp0qbPP5KqkvkEcaIMF305sH5X591WlDEaYX8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604813550812898.6279459504474; Sat, 7 Nov 2020 21:32:30 -0800 (PST) Received: from localhost ([::1]:34922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbdJV-00074A-Kr for importer@patchew.org; Sun, 08 Nov 2020 00:32:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbdDW-0001WC-Rt for qemu-devel@nongnu.org; Sun, 08 Nov 2020 00:26:18 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44405) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kbdDU-0004wN-Qx for qemu-devel@nongnu.org; Sun, 08 Nov 2020 00:26:18 -0500 Received: by mail-pf1-f193.google.com with SMTP id y7so5079663pfq.11 for ; Sat, 07 Nov 2020 21:26:16 -0800 (PST) Received: from localhost.localdomain ([73.93.155.42]) by smtp.gmail.com with ESMTPSA id hz18sm6994406pjb.13.2020.11.07.21.26.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Nov 2020 21:26:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oqTRRse3ML08CbYMBMir3imYmfVxmJCy/vR5/9jdsfA=; b=iq/+8XBwGSfV6XbcqWHwwt4/5XnkPgFolgewlSfbA0SvzsgYTGUef594J2EM61RKvq Li+9bjmGcPBanwmqPYXVdO5LbeO7Qp29cjAYN1Dz6o/JKrw0zscY9Mt/2pJa7AfOGlB2 YGwd7JGM66cQ2tvw23yuS5Akcn+FZzJghtnLzzfVIBNYYV4EKREaqDTyBegpyGYSypCP h/kQ/yMHYHhNxgjhEc7NmTn45OgaOahd1AWlLjVoMhfxIUCffP0pHVXYdvICHLFULugL Bmq7UWbzHk34+Nv7hCyJywwdROl0JNzdt3Y1Ib/pGZUtZH8tiAGSNNaYLP48kXb1LxgE 0tHQ== X-Gm-Message-State: AOAM530nPs5O+yVHuA3cBX/YM6f+mnf8Vl0XYhoJj57zpapYg3MWrrR5 sOhRUz1AyPo2rMf7IUuqV7pBHekNUv8= X-Google-Smtp-Source: ABdhPJxy7bogSBqMmNMScL1eQM8fhefsTZJebgG6OEHzQn+L+bN/TeV7XjGi93Z/8zBkTpmHg8o6OA== X-Received: by 2002:a63:de07:: with SMTP id f7mr7893829pgg.27.1604813175266; Sat, 07 Nov 2020 21:26:15 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v4 6/7] tcg: implement JIT for iOS and Apple Silicon Date: Sat, 7 Nov 2020 21:26:04 -0800 Message-Id: <20201108052605.45840-7-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201108052605.45840-1-j@getutm.app> References: <20201108052605.45840-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=209.85.210.193; envelope-from=osy86github@gmail.com; helo=mail-pf1-f193.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/08 00:26:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Joelle van Dyne , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When entitlements are available (macOS or jailbroken iOS), a hardware feature called APRR exists on newer Apple Silicon that can cheaply mark JIT pages as either RX or RW. Reverse engineered functions from libsystem_pthread.dylib are implemented to handle this. The following rules apply for JIT write protect: * JIT write-protect is enabled before tcg_qemu_tb_exec() * JIT write-protect is disabled after tcg_qemu_tb_exec() returns * JIT write-protect is disabled inside do_tb_phys_invalidate() but if it is called inside of tcg_qemu_tb_exec() then write-protect will be enabled again before returning. * JIT write-protect is disabled by cpu_loop_exit() for interrupt handling. * JIT write-protect is disabled everywhere else. See https://developer.apple.com/documentation/apple_silicon/porting_just-in= -time_compilers_to_apple_silicon Signed-off-by: Joelle van Dyne --- include/exec/exec-all.h | 2 + include/tcg/tcg-apple-jit.h | 86 +++++++++++++++++++++++++++++++++++++ include/tcg/tcg.h | 3 ++ accel/tcg/cpu-exec-common.c | 2 + accel/tcg/cpu-exec.c | 2 + accel/tcg/translate-all.c | 46 ++++++++++++++++++++ tcg/tcg.c | 4 ++ 7 files changed, 145 insertions(+) create mode 100644 include/tcg/tcg-apple-jit.h diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index aa65103702..3829f3d470 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -549,6 +549,8 @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, targe= t_ulong pc, target_ulong cs_base, uint32_t flags, uint32_t cf_mask); void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr); +void tb_exec_lock(void); +void tb_exec_unlock(void); =20 /* GETPC is the true target of the return instruction that we'll execute. = */ #if defined(CONFIG_TCG_INTERPRETER) diff --git a/include/tcg/tcg-apple-jit.h b/include/tcg/tcg-apple-jit.h new file mode 100644 index 0000000000..9efdb2000d --- /dev/null +++ b/include/tcg/tcg-apple-jit.h @@ -0,0 +1,86 @@ +/* + * 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 . + */ + +#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 TTBR= 0 */ +#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 =3D *(volatile uint8_t *)_COMM_PAGE_APRR_SUPPORT; + return aprr_support > 0; +} + +/* write protect enable =3D write disable */ +static __attribute__((__always_inline__)) void jit_write_protect(int enabl= ed) +{ + /* Access shared kernel page at fixed memory location. */ + uint8_t aprr_support =3D *(volatile uint8_t *)_COMM_PAGE_APRR_SUPPORT; + if (aprr_support =3D=3D 0 || aprr_support > 3) { + return; + } else if (aprr_support =3D=3D 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 enabl= ed) +{ +} + +#endif + +#endif /* define TCG_APPLE_JIT_H */ diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 477919aeb6..b16b687d0b 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -625,6 +625,9 @@ struct TCGContext { size_t code_gen_buffer_size; void *code_gen_ptr; void *data_gen_ptr; +#if defined(CONFIG_DARWIN) && !defined(CONFIG_TCG_INTERPRETER) + bool code_gen_locked; /* on Darwin each thread tracks W^X flags */ +#endif =20 /* Threshold to flush the translated code buffer. */ void *code_gen_highwater; diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c index 12c1e3e974..f1eb767b02 100644 --- a/accel/tcg/cpu-exec-common.c +++ b/accel/tcg/cpu-exec-common.c @@ -64,6 +64,8 @@ void cpu_reloading_memory_map(void) =20 void cpu_loop_exit(CPUState *cpu) { + /* Unlock JIT write protect if applicable. */ + tb_exec_unlock(); /* Undo the setting in cpu_tb_exec. */ cpu->can_do_io =3D 1; siglongjmp(cpu->jmp_env, 1); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 8df0a1782e..960e0c1f36 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -176,7 +176,9 @@ static inline TranslationBlock *cpu_tb_exec(CPUState *c= pu, } #endif /* DEBUG_DISAS */ =20 + tb_exec_lock(); ret =3D tcg_qemu_tb_exec(env, tb_ptr); + tb_exec_unlock(); cpu->can_do_io =3D 1; /* * TODO: Delay swapping back to the read-write region of the TB diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 06102871e7..5773c561cb 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -27,6 +27,9 @@ #include "disas/disas.h" #include "exec/exec-all.h" #include "tcg/tcg.h" +#if defined(CONFIG_DARWIN) +#include "tcg/tcg-apple-jit.h" +#endif #if defined(CONFIG_USER_ONLY) #include "qemu.h" #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) @@ -61,6 +64,9 @@ #include "sysemu/tcg.h" #include "qapi/error.h" =20 +static bool tb_exec_is_locked(void); +static void tb_exec_change(bool locked); + /* #define DEBUG_TB_INVALIDATE */ /* #define DEBUG_TB_FLUSH */ /* make various TB consistency checks */ @@ -1339,6 +1345,7 @@ void tcg_exec_init(unsigned long tb_size, int splitwx) splitwx, &error_fatal); assert(ok); =20 + tb_exec_unlock(); #if defined(CONFIG_SOFTMMU) /* There's no guest base to take into account, so go ahead and initialize the prologue now. */ @@ -1615,8 +1622,11 @@ static void do_tb_phys_invalidate(TranslationBlock *= tb, bool rm_from_page_list) PageDesc *p; uint32_t h; tb_page_addr_t phys_pc; + bool code_gen_locked; =20 assert_memory_lock(); + code_gen_locked =3D tb_exec_is_locked(); + tb_exec_unlock(); =20 /* make sure no further incoming jumps will be chained to this TB */ qemu_spin_lock(&tb->jmp_lock); @@ -1629,6 +1639,7 @@ static void do_tb_phys_invalidate(TranslationBlock *t= b, bool rm_from_page_list) tb->trace_vcpu_dstate); if (!(tb->cflags & CF_NOCACHE) && !qht_remove(&tb_ctx.htable, tb, h)) { + tb_exec_change(code_gen_locked); return; } =20 @@ -1661,6 +1672,8 @@ static void do_tb_phys_invalidate(TranslationBlock *t= b, bool rm_from_page_list) =20 qatomic_set(&tcg_ctx->tb_phys_invalidate_count, tcg_ctx->tb_phys_invalidate_count + 1); + + tb_exec_change(code_gen_locked); } =20 static void tb_phys_invalidate__locked(TranslationBlock *tb) @@ -2899,3 +2912,36 @@ void tcg_flush_softmmu_tlb(CPUState *cs) tlb_flush(cs); #endif } + +#if defined(CONFIG_DARWIN) && !defined(CONFIG_TCG_INTERPRETER) +static bool tb_exec_is_locked(void) +{ + return tcg_ctx->code_gen_locked; +} + +static void tb_exec_change(bool locked) +{ + if (jit_write_protect_supported()) { + jit_write_protect(locked); + } + tcg_ctx->code_gen_locked =3D locked; +} +#else /* not needed on non-Darwin platforms */ +static bool tb_exec_is_locked(void) +{ + return false; +} + +static void tb_exec_change(bool locked) {} +#endif + +void tb_exec_lock(void) +{ + /* assumes sys_icache_invalidate already called */ + tb_exec_change(true); +} + +void tb_exec_unlock(void) +{ + tb_exec_change(false); +} diff --git a/tcg/tcg.c b/tcg/tcg.c index d3052031cb..5ed79d2724 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -809,6 +809,8 @@ static void alloc_tcg_plugin_context(TCGContext *s) void tcg_register_thread(void) { tcg_ctx =3D &tcg_init_ctx; + + tb_exec_unlock(); } #else void tcg_register_thread(void) @@ -843,6 +845,8 @@ void tcg_register_thread(void) err =3D tcg_region_initial_alloc__locked(tcg_ctx); g_assert(!err); qemu_mutex_unlock(®ion.lock); + + tb_exec_unlock(); } #endif /* !CONFIG_USER_ONLY */ =20 --=20 2.28.0 From nobody Tue May 7 00:10:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604813315; cv=none; d=zohomail.com; s=zohoarc; b=cc0idCEBTz9LMLGBvO+413cpp7TTJcRuM7EGMMDkTY7HcXKhSxqpuE0vtKPqonpzup1a2sfnCn/IK3NeEjLVfjw81k2LoBKBPSOmW2k7G/0MJtBm8F4VthngaSTabCCGwcyubNAD5XwKwl7FQvdC4LuzS1g3eAvHfzlD7UGiQmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604813315; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DqK0hZ8mt8LWfTZqV1hfM2y+gt2SV2gfJzd9rHBJS8g=; b=cALVlNMGVmALY5WsGnVmQUkROJNkFl8ELM3kv6BaCmSi421QwtLuCI60w0o4x/Mzm2EsxPMCZ4TAvncOXmwx/a4DTCcM0wleinfPCyDqJK5Z1I2CAhuz8Ah/VVV1A9uAjLwGuGXl4PMvGwxH4qsNOrn837S5ERIoGDQF3ZX2qbE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604813315038812.4684648135991; Sat, 7 Nov 2020 21:28:35 -0800 (PST) Received: from localhost ([::1]:55262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbdFh-0003Nh-SY for importer@patchew.org; Sun, 08 Nov 2020 00:28:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbdDY-0001Ye-7X; Sun, 08 Nov 2020 00:26:20 -0500 Received: from mail-pf1-f182.google.com ([209.85.210.182]:34551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kbdDW-0004xI-No; Sun, 08 Nov 2020 00:26:19 -0500 Received: by mail-pf1-f182.google.com with SMTP id o129so5112874pfb.1; Sat, 07 Nov 2020 21:26:17 -0800 (PST) Received: from localhost.localdomain ([73.93.155.42]) by smtp.gmail.com with ESMTPSA id hz18sm6994406pjb.13.2020.11.07.21.26.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Nov 2020 21:26:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DqK0hZ8mt8LWfTZqV1hfM2y+gt2SV2gfJzd9rHBJS8g=; b=hN5p0J4HLkid8amfNbV2h9E0lquFW9LqgnCLfuGorzhNW5wVtDeoQ6A8Np/XzOILK/ itijVds+O9yhwesj0okktJfyHnGHRa/kvZ4GmYv2VrGcyEpLIDRiYICZWnyMyK+1mizL zSxDg01AYfWb5em2OvrPXDGBhoTv5OhrtSjnJ2BZpV9YqYqdwTGuPhZpMBtFnemDxYEF 0fAB1zRQSttJN5lsfTqrd9TfdPAM0hVcZOyXyQVp+D9zAWtvBGVairUcsXi1HIXrzkIN 7AplDBzzxL+RXdz/zWOyD/zNkdTPzBB/mwd3UKGKAb0DcC+FJU1KDGtTZrhJIMtDg7Yp KaTw== X-Gm-Message-State: AOAM530wPHTUTQPFYkW+FH3d8FS3Uw6F1BnC1iPGTwnbcDqMi9PrCX2j NvNnxXdJtajjZyjapwVcuKqFzOQVTGM= X-Google-Smtp-Source: ABdhPJxs/tKfn73Ob7Zhs5pFo4+/NTK209PI+9+fFtcXaOlmDCkzyOZ/za/DIHoQxh7pqu89I5AlXg== X-Received: by 2002:a65:6649:: with SMTP id z9mr7914138pgv.18.1604813176408; Sat, 07 Nov 2020 21:26:16 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v4 7/7] block: check availablity for preadv/pwritev on mac Date: Sat, 7 Nov 2020 21:26:05 -0800 Message-Id: <20201108052605.45840-8-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201108052605.45840-1-j@getutm.app> References: <20201108052605.45840-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=209.85.210.182; envelope-from=osy86github@gmail.com; helo=mail-pf1-f182.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/08 00:26:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Joelle van Dyne , "open list:raw" , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" macOS 11/iOS 14 added preadv/pwritev APIs. Due to weak linking, configure will succeed with CONFIG_PREADV even when targeting a lower OS version. We therefore need to check at run time if we can actually use these APIs. Signed-off-by: Joelle van Dyne --- block/file-posix.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index 5560fd20ac..b5a7ce483d 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1394,12 +1394,24 @@ static bool preadv_present =3D true; static ssize_t qemu_preadv(int fd, const struct iovec *iov, int nr_iov, off_t offset) { +#ifdef CONFIG_DARWIN /* preadv introduced in macOS 11 */ + if (!__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) { + preadv_present =3D false; + return -ENOSYS; + } else +#endif return preadv(fd, iov, nr_iov, offset); } =20 static ssize_t qemu_pwritev(int fd, const struct iovec *iov, int nr_iov, off_t offset) { +#ifdef CONFIG_DARWIN /* pwritev introduced in macOS 11 */ + if (!__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) { + preadv_present =3D false; + return -ENOSYS; + } else +#endif return pwritev(fd, iov, nr_iov, offset); } =20 --=20 2.28.0