Received: by 2002:a17:504:664e:b0:1be9:327d:8ee3 with SMTP id l14csp3821494njk; Sun, 22 Dec 2024 20:10:30 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWXEVo6dSB5tdcB980A7H26r1gvKKksyCExCTZ7oKa6pZJBsxhe4OZog1tSZNtFdyDVkXZGhRMnySZttA==@linaro.org X-Google-Smtp-Source: AGHT+IEjt9Y0N4rDjR4g+hATBS19+yphVk7gDIOjs6+gRLtRvWHy96gE05qipHa1rltd2XDIaTn0 X-Received: by 2002:a05:622a:1a23:b0:467:61c1:df38 with SMTP id d75a77b69052e-46a4b1135fcmr206898591cf.12.1734927030470; Sun, 22 Dec 2024 20:10:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734927030; cv=none; d=google.com; s=arc-20240605; b=hLNHnEYMAks0USM7mVzZtxEr86Vf68CZ8pYKPFlHds6rZk+xMPCWZkwtdopAmJJeDN q50A/gmz4Z7h9M5NlTrhTjkzzYYoXdg9SnUX9LtbEnwz4fA6Ego6VUWaSaTX+JKOW+su YFn2vVq6ileGzppWlSb80FJ9ftyt6gxQLWG7ykgAfTjr1GC5PxBHbCfQt+2kO3neGWLx FDVLn+N6FBRlF8cAMbUIKohpizRHN2jC1bcwz27iZ8qdrN/UXqW+gINwn1aoC2/jccHb 1RCEifb92YpL6EwH3oNsUeA5dVwr5KB7jbDB6DpnLkwje6JEd1PO4FpIBoil26FAlTOC aczg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=KQguSZN8sSKDeZZrzzB2zGOKmo+eCQfE3oCj7Gt4Jdw=; fh=oo7dzRE2DDou0LQPKSKPDfcTkjDaDSka8xVPecONyZI=; b=e2zRuK4trNOmQi97JiksOpjz88s0R6kl29zhJs/oXoSuO+ENRsRFqwvLmOF4SVIkfG Kge2/FA6U/e+hcNFRmbJ6r4IpDBuEuJi/k4Q7eyRkU25rrbeYUTnkpgf98ajZcmWQ9Iw P8IFabkOVw3tpUUoE2hZU/e5rzv2cQqrA4rp09tmeIiN1oA0HyOHsSTxctZO3Gyzz3Ic 8hvl4iKlOUC8zOVGQZuinEYk975Lw7ayg1MwuyKCszp8OQWaCTM69t27YWi30UIDSj5P cT9JhQTc/7cVbUrQXL6pR4qmnUjpuBh0/CLw1ypwMsQ/64dhyPcdVp4OZ5Oy6h2WCKgN athg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=getutm.app Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3eb9a62asi104485631cf.230.2024.12.22.20.10.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Dec 2024 20:10:30 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=getutm.app 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) 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-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) 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) 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: 8bit 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+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: V/F0iClbk7vS 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(ARMHostCPUFeatures *ahcf) r |= hv_vcpu_get_sys_reg(fd, HV_SYS_REG_MIDR_EL1, &ahcf->midr); r |= hv_vcpu_destroy(fd); - 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); + } ahcf->isar = host_isar; @@ -923,26 +925,34 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) uint32_t hvf_arm_get_default_ipa_bit_size(void) { - uint32_t default_ipa_size; - hv_return_t ret = hv_vm_config_get_default_ipa_size(&default_ipa_size); - assert_hvf_ok(ret); + if (__builtin_available(macOS 13.0, *)) { + uint32_t default_ipa_size; + hv_return_t ret = hv_vm_config_get_default_ipa_size(&default_ipa_size); + assert_hvf_ok(ret); - return default_ipa_size; + return default_ipa_size; + } else { + return 0; + } } uint32_t hvf_arm_get_max_ipa_bit_size(void) { - uint32_t max_ipa_size; - hv_return_t ret = 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 = hv_vm_config_get_max_ipa_size(&max_ipa_size); + assert_hvf_ok(ret); - /* - * 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 <= 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 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 <= to it. + */ + return round_down_to_parange_bit_size(max_ipa_size); + } else { + return 0; + } } 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 = hv_vm_config_create(); + hv_vm_config_t config; - ret = hv_vm_config_set_ipa_size(config, pa_range); - if (ret != HV_SUCCESS) { - goto cleanup; + if (__builtin_available(macOS 13.0, *)) { + config = hv_vm_config_create(); + ret = hv_vm_config_set_ipa_size(config, pa_range); + if (ret != HV_SUCCESS) { + goto cleanup; + } + chosen_ipa_bit_size = pa_range; + } else { + config = NULL; } - chosen_ipa_bit_size = pa_range; ret = hv_vm_create(config); -- 2.41.0