From nobody Mon Dec 23 23:36:16 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; dmarc=fail(p=none dis=none) header.from=getutm.app Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734927033636852.8606528925314; Sun, 22 Dec 2024 20:10:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tPZlU-0000HU-56; Sun, 22 Dec 2024 23:09:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tPZlR-0000GN-TE for qemu-devel@nongnu.org; Sun, 22 Dec 2024 23:09:53 -0500 Received: from mail-pl1-f179.google.com ([209.85.214.179]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tPZlQ-0001PM-B3 for qemu-devel@nongnu.org; Sun, 22 Dec 2024 23:09:53 -0500 Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-21675fd60feso44372655ad.2 for ; Sun, 22 Dec 2024 20:09:51 -0800 (PST) Received: from localhost.localdomain ([2601:642:4c02:c8b4:911f:687c:35b2:bc4e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9f4429sm63921115ad.173.2024.12.22.20.09.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 22 Dec 2024 20:09:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734926990; x=1735531790; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CEkjq0W66WCq5brXRIKY0Ob+ncJIl6VOgGA08W2xzgo=; b=oa2U1EC8zjAi1S96y2qSDdPtnNO9X1pG/gB/AfvPj7keXuzbnFrDz+poJ66VZ28otQ 5YkfmplWlzxVZsdl6ln0rmfp4d5L5YBB4jJdsPUgU/g4V0mGdaOLbCJgJXnztNdhu7jr syjcy832X6+KSieXTl63Sfjc0YhMQB3Mx0LmqNzxqxEVjY+75DspxjceZyK2ltY78AdO K/365bhcPD0K3e7XAM9TtHv6zKx8bqi3Fd5FkEjARfuWZsCq+qBkDQ1pc/S6EWPF4qkt vXrOJpAAO6u88i0v5WWQbzHp8pS6Mf8HfUMd/1TEOVFh8FWILzk3uQVi283i7cJhcy+B 5Y7w== X-Gm-Message-State: AOJu0YyHRmZJODs3nji3qfkGaGXWMORpj4OQ9D5S7euL19OW3sCv4L41 8nucP12JW/SvBHjIVpqZZEEnNnT62Lb4yulINJ2DL0mtTBWIkLJkIY48oqvQ X-Gm-Gg: ASbGncuBc8cCGHmBbdJfSF42egi8SJXqS/uuNV2C/LY2pEplRNMrnmf/IwKFh6plSlM MePGDIe0sjsvtyR8Jj5iyC0aRF0f8NEKo8EeOz0duPMxchYSIxAK4XWFyu9N3XzzTIpwsUoaCqV jBaJZwC5ax77e7s1MB0NVPqrzG+7T67peNeHot/SvvliKDz+yOdLBpFsHbb8y1k/+L+YEJSX6Ng iU6RLbEoo+Zxis3b13hhQ8Qed83NGiUr8tS198ecWAYBVb1LjC8DzMU+o936sYm1Gxbj1x9tV7c r7wEa4lUfg== X-Google-Smtp-Source: AGHT+IE42LHgYuthXRv5QS47k4tJYEmG+mBA2qVN8LcARdg4iKgbEE5uJORdd1U8ubKPZNNb3Nseeg== X-Received: by 2002:a17:902:ecc2:b0:216:6435:5001 with SMTP id d9443c01a7336-219e6f3ab68mr131110755ad.57.1734926990302; Sun, 22 Dec 2024 20:09:50 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Cc: Joelle van Dyne , Jason Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/2] vmnet: disable unavailable features on older macOS Date: Sun, 22 Dec 2024 20:09:44 -0800 Message-ID: <20241223040945.82871-2-j@getutm.app> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20241223040945.82871-1-j@getutm.app> References: <20241223040945.82871-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.179; envelope-from=osy86dev@gmail.com; helo=mail-pl1-f179.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.167, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1734927033855116600 Content-Type: text/plain; charset="utf-8" Some options require macOS 11 or newer APIs. Instead of crashing (target version not set) or failing to compile (target version set), we will just return an error when the user tries to use the option. Signed-off-by: Joelle van Dyne --- net/vmnet-host.c | 48 +++++++++++++++++++++++++++++++-------------- net/vmnet-shared.c | 23 +++++++++++++++++----- net/vmnet-bridged.m | 18 ++++++++++++++--- 3 files changed, 66 insertions(+), 23 deletions(-) diff --git a/net/vmnet-host.c b/net/vmnet-host.c index 49fb25c224..f3f0ac89e4 100644 --- a/net/vmnet-host.c +++ b/net/vmnet-host.c @@ -21,12 +21,28 @@ static bool validate_options(const Netdev *netdev, Error **errp) { const NetdevVmnetHostOptions *options =3D &(netdev->u.vmnet_host); - QemuUUID net_uuid; =20 - if (options->net_uuid && - qemu_uuid_parse(options->net_uuid, &net_uuid) < 0) { - error_setg(errp, "Invalid UUID provided in 'net-uuid'"); - return false; + if (__builtin_available(macOS 11, *)) { + QemuUUID net_uuid; + if (options->net_uuid && + qemu_uuid_parse(options->net_uuid, &net_uuid) < 0) { + error_setg(errp, "Invalid UUID provided in 'net-uuid'"); + return false; + } + } else { + if (options->has_isolated) { + error_setg(errp, + "vmnet-host.isolated feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } + + if (options->net_uuid) { + error_setg(errp, + "vmnet-host.net-uuid feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } } =20 if ((options->start_address || @@ -53,16 +69,18 @@ static xpc_object_t build_if_desc(const Netdev *netdev) vmnet_operation_mode_key, VMNET_HOST_MODE); =20 - xpc_dictionary_set_bool(if_desc, - vmnet_enable_isolation_key, - options->isolated); - - QemuUUID net_uuid; - if (options->net_uuid) { - qemu_uuid_parse(options->net_uuid, &net_uuid); - xpc_dictionary_set_uuid(if_desc, - vmnet_network_identifier_key, - net_uuid.data); + if (__builtin_available(macOS 11, *)) { + xpc_dictionary_set_bool(if_desc, + vmnet_enable_isolation_key, + options->isolated); + + QemuUUID net_uuid; + if (options->net_uuid) { + qemu_uuid_parse(options->net_uuid, &net_uuid); + xpc_dictionary_set_uuid(if_desc, + vmnet_network_identifier_key, + net_uuid.data); + } } =20 if (options->start_address) { diff --git a/net/vmnet-shared.c b/net/vmnet-shared.c index 4726b07253..e6c65f3417 100644 --- a/net/vmnet-shared.c +++ b/net/vmnet-shared.c @@ -21,6 +21,17 @@ static bool validate_options(const Netdev *netdev, Error= **errp) { const NetdevVmnetSharedOptions *options =3D &(netdev->u.vmnet_shared); =20 + if (__builtin_available(macOS 11, *)) { + /* clang requires a true branch */ + } else { + if (options->has_isolated) { + error_setg(errp, + "vmnet-shared.isolated feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } + } + if ((options->start_address || options->end_address || options->subnet_mask) && @@ -66,11 +77,13 @@ static xpc_object_t build_if_desc(const Netdev *netdev) options->subnet_mask); } =20 - xpc_dictionary_set_bool( - if_desc, - vmnet_enable_isolation_key, - options->isolated - ); + if (__builtin_available(macOS 11, *)) { + xpc_dictionary_set_bool( + if_desc, + vmnet_enable_isolation_key, + options->isolated + ); + } =20 return if_desc; } diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m index a04a14fa11..13fa2d16b6 100644 --- a/net/vmnet-bridged.m +++ b/net/vmnet-bridged.m @@ -88,6 +88,16 @@ static bool validate_options(const Netdev *netdev, Error= **errp) return false; } =20 + if (__builtin_available(macOS 11, *)) { + /* clang requires a true branch */ + } else { + if (options->has_isolated) { + error_setg(errp, + "vmnet-bridged.isolated feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } + } return true; } =20 @@ -106,9 +116,11 @@ static xpc_object_t build_if_desc(const Netdev *netdev) vmnet_shared_interface_name_key, options->ifname); =20 - xpc_dictionary_set_bool(if_desc, - vmnet_enable_isolation_key, - options->isolated); + if (__builtin_available(macOS 11, *)) { + xpc_dictionary_set_bool(if_desc, + vmnet_enable_isolation_key, + options->isolated); + } =20 return if_desc; } --=20 2.41.0 From nobody Mon Dec 23 23:36:16 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; dmarc=fail(p=none dis=none) header.from=getutm.app Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734927030972734.3537390179943; Sun, 22 Dec 2024 20:10:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tPZlV-0000Ht-KY; Sun, 22 Dec 2024 23:09:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tPZlT-0000H4-Hh; Sun, 22 Dec 2024 23:09:55 -0500 Received: from mail-pg1-f171.google.com ([209.85.215.171]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tPZlR-0001Pa-Vl; Sun, 22 Dec 2024 23:09:55 -0500 Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-889e8847d56so483817a12.1; Sun, 22 Dec 2024 20:09:53 -0800 (PST) Received: from localhost.localdomain ([2601:642:4c02:c8b4:911f:687c:35b2:bc4e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9f4429sm63921115ad.173.2024.12.22.20.09.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 22 Dec 2024 20:09:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734926992; x=1735531792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KQguSZN8sSKDeZZrzzB2zGOKmo+eCQfE3oCj7Gt4Jdw=; b=OmtY6pdTbN6nD35MH3rchyJFAOQS43k9alA4OHB2zmbG5mHxpt61W1Qw+xb9RON5JN Ak3kIYrLHdEaqksJMNLxYAE9vcSgeAW9xsA4+ooGUbok+MJtOxcTtS2zNg56vvjthkqY q9K/6PhXyute0eYGlzpVPd/lmDda+7zIVXlVYQVwMamMC8tsoH7+Ik1xVv/p285Z2LQg 6MsBtTml9K/ixrClGvrZM2L3HB5Zuzmc5vlnHYNEYd/GxllXVG33U9EAIhEs1GvjNVv5 Fs4C9tBZRSkRPrtVl0X/yIW3WTXGtcem9yADf3s8AoCHSj/74T1XLgySWrNHhATddfWe aw3Q== X-Forwarded-Encrypted: i=1; AJvYcCWzZxeK42AsBmShLRwX2bxeWShhJzCURcloq9pZMuyQGWaQxzHMuXs5gB7Rzj4nxxsdsXTnfkHiaw==@nongnu.org X-Gm-Message-State: AOJu0YzC8dusblwk539D2NWeQ1ZajLVHiBk1LfP0wB4RixfTdIGt1LDF iS3RhsNh1951yXQVtryb8KA+xJdP39CAo4jCCceWpGd+IQ0kySxXjsV++7Id X-Gm-Gg: ASbGncv90Q5OfRs7JnnZ5XExIvU/HUtEbqLge7acJxQyi6vPPKjANDiKzRmgkbXnFPh fAUZLlHxyswD/tX6zNlM+uagpTvmFvyXQlKveth/TN2Sm+FwMsTB7H2sESkDJJfEl2rvm/s2GXO sCLm2HMkIl8lhgvWtg3E6rr6rGK0kRC5Ly/0ZlAX5sSTt1WWnRVhi1YxRJ6+ymACXMxqCWXwgOA 7qmb+EmEaDwomv+jtwj0Ff4C9bXFW+YO9gRuy4+gPcmAb+VCc68yYb+Z1zgt9GetG25+oTye4VD VuiOLClQMQ== X-Google-Smtp-Source: AGHT+IGy6yX0dhHHyfMu5kMCMm52RxBCpW696v37iD0285o4csaNlcVLQrxPmvRkQttgbd+b+qeLJw== X-Received: by 2002:a17:90b:2b83:b0:2ef:9dbc:38d1 with SMTP id 98e67ed59e1d1-2f4435ad5e6mr21538981a91.5.1734926991675; Sun, 22 Dec 2024 20:09:51 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Cc: Joelle van Dyne , Alexander Graf , Peter Maydell , qemu-arm@nongnu.org (open list:ARM TCG CPUs) Subject: [PATCH 2/2] hvf: arm: disable unavailable features on older macOS Date: Sun, 22 Dec 2024 20:09:45 -0800 Message-ID: <20241223040945.82871-3-j@getutm.app> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20241223040945.82871-1-j@getutm.app> References: <20241223040945.82871-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.171; envelope-from=osy86dev@gmail.com; helo=mail-pg1-f171.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.167, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1734927032480116600 Content-Type: text/plain; charset="utf-8" IPA size queries were introduced in macOS 13. When QEMU is built targeting a lower version, the compile will fail. If targeting a higher version and the binary is executed on an older version, QEMU will crash. This will restore the behaviour before IPA max size querying was added which means VMs with 64+ GB of RAM will not work if running on < macOS 13. Signed-off-by: Joelle van Dyne --- target/arm/hvf/hvf.c | 55 ++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 0afd96018e..da60476dbc 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -897,7 +897,9 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFea= tures *ahcf) r |=3D hv_vcpu_get_sys_reg(fd, HV_SYS_REG_MIDR_EL1, &ahcf->midr); r |=3D hv_vcpu_destroy(fd); =20 - clamp_id_aa64mmfr0_parange_to_ipa_size(&host_isar.id_aa64mmfr0); + if (__builtin_available(macOS 13.0, *)) { + clamp_id_aa64mmfr0_parange_to_ipa_size(&host_isar.id_aa64mmfr0); + } =20 ahcf->isar =3D host_isar; =20 @@ -923,26 +925,34 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUF= eatures *ahcf) =20 uint32_t hvf_arm_get_default_ipa_bit_size(void) { - uint32_t default_ipa_size; - hv_return_t ret =3D hv_vm_config_get_default_ipa_size(&default_ipa_siz= e); - assert_hvf_ok(ret); + if (__builtin_available(macOS 13.0, *)) { + uint32_t default_ipa_size; + hv_return_t ret =3D hv_vm_config_get_default_ipa_size(&default_ipa= _size); + assert_hvf_ok(ret); =20 - return default_ipa_size; + return default_ipa_size; + } else { + return 0; + } } =20 uint32_t hvf_arm_get_max_ipa_bit_size(void) { - uint32_t max_ipa_size; - hv_return_t ret =3D hv_vm_config_get_max_ipa_size(&max_ipa_size); - assert_hvf_ok(ret); + if (__builtin_available(macOS 13.0, *)) { + uint32_t max_ipa_size; + hv_return_t ret =3D hv_vm_config_get_max_ipa_size(&max_ipa_size); + assert_hvf_ok(ret); =20 - /* - * We clamp any IPA size we want to back the VM with to a valid PARange - * value so the guest doesn't try and map memory outside of the valid = range. - * This logic just clamps the passed in IPA bit size to the first valid - * PARange value <=3D to it. - */ - return round_down_to_parange_bit_size(max_ipa_size); + /* + * We clamp any IPA size we want to back the VM with to a valid PA= Range + * value so the guest doesn't try and map memory outside of the va= lid + * range. This logic just clamps the passed in IPA bit size to the= first + * valid PARange value <=3D to it. + */ + return round_down_to_parange_bit_size(max_ipa_size); + } else { + return 0; + } } =20 void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu) @@ -973,13 +983,18 @@ void hvf_arch_vcpu_destroy(CPUState *cpu) hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range) { hv_return_t ret; - hv_vm_config_t config =3D hv_vm_config_create(); + hv_vm_config_t config; =20 - ret =3D hv_vm_config_set_ipa_size(config, pa_range); - if (ret !=3D HV_SUCCESS) { - goto cleanup; + if (__builtin_available(macOS 13.0, *)) { + config =3D hv_vm_config_create(); + ret =3D hv_vm_config_set_ipa_size(config, pa_range); + if (ret !=3D HV_SUCCESS) { + goto cleanup; + } + chosen_ipa_bit_size =3D pa_range; + } else { + config =3D NULL; } - chosen_ipa_bit_size =3D pa_range; =20 ret =3D hv_vm_create(config); =20 --=20 2.41.0