From nobody Fri May 17 07:56:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=1695391839; cv=none; d=zohomail.com; s=zohoarc; b=UVb6+Idfi/CBxtBk/ewUSF3M9RoCJ5uPAxjGCjKmKA/iso8NyYS5Z49L5z9Ad5lPrUkIw+iw3AHfZXX4K3DoXwboucfTdTfWIJEb2rrSZlLCmEHEK0SjD+tbGvpRIhxlcTda+BoKMCfYt6a4x8exZ9+1w7H3X1Gb8UzOAMuBo2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695391839; 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=NwlBBf3rtKK44LxBF31RQ5uFpkLivnaBoZpAWCqLFCs=; b=UPd2Clhem9cxo81LCcjyuDQMjfQiyGs1dpXYwP7DAvOVdUq9y+pccdg0Lzp3SwTHcI35YtPdwOL5U4kMBL/Qj41EP9QSv26jW7cbn42OsIy8gWunmFcsQ6RAyo++VyRrJoaCj+Bqr148nB6IcpRwkV4PZnBlBIdOUjL4wHgHcS8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1695391838918628.9179129803869; Fri, 22 Sep 2023 07:10:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjgqr-0002vF-LO; Fri, 22 Sep 2023 10:09:49 -0400 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 1qjgqm-0002u6-1X for qemu-devel@nongnu.org; Fri, 22 Sep 2023 10:09:44 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qjgqk-0008P3-Js for qemu-devel@nongnu.org; Fri, 22 Sep 2023 10:09:43 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31fe2c8db0dso1925941f8f.3 for ; Fri, 22 Sep 2023 07:09:42 -0700 (PDT) Received: from localhost.localdomain (89-104-8-249.customer.bnet.at. [89.104.8.249]) by smtp.gmail.com with ESMTPSA id g27-20020a170906395b00b009ae587ce128sm2725823eje.216.2023.09.22.07.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 07:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1695391781; x=1695996581; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NwlBBf3rtKK44LxBF31RQ5uFpkLivnaBoZpAWCqLFCs=; b=yhjg11L28hHZw8onSiiyz0iJ8CTuC9ATQ7JVX+O+jlfSrNnNHbvUq0wB41HuUZbWum 0PgNOPsR7JGcKnkSPty7wjsE04SudNyF6cDAdrinRtbYtR3ESg2xuDO+vAMtFgbOgGN4 snf3pV7BODov6fV9MfSvwE5XGTpJm5O+77TUQYMckV+vVYzOB+cTPZ5SwjPJQi9MqA9n qziL7N4VqPWXohLJ5YDNHPPxp7o5zyVS73z40YmkaB/+k18JS46ELEliIP6RlVWz1riq Bct1ATj4vvlfmcEb9njIw4fKm8FShqTaShDBoLQR84oFwsB/F/JVJLXFgH2Q98AlaZrh bQoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695391781; x=1695996581; 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=NwlBBf3rtKK44LxBF31RQ5uFpkLivnaBoZpAWCqLFCs=; b=AfDbBmKmQCLvkPbfRkBU6FV/0lxify0JqrOCaK5fP3ZB0bF8W3W69Oy98pVY/tDLeD 581CZHs9ForvhqTfT4LrSsGyohHtC2N9hLlhsQdvok6qEgrUTl+GfFAOedRuAnvPnxNW ze8f13yZ7CMij/Vah43o0IOBEld4zJ26DmJSldInjPGE853SUTJu54NLgVpQGdj5jUbl ftBnaTtQ6jP+ZvAPVhQZXxEghaTV1osF8YK+ig5zlJTpSvBO9SHhg/WuRbs7d/Gvx6W5 WGfxYIGI87qck0eXNph6CAQI7SJwS+kXm/lARYo32qpHjh5Vv7PK+zK6YPftmC4N4hCU WxEQ== X-Gm-Message-State: AOJu0Yw7k0cWRkFgLYnOOJObzazsfwvCMSX4BdialyOVHqZ1kZ4I0UuL pLEL+UzLX81G3Q0u/6CmTYQ39dYDl+x3/3QQyUM= X-Google-Smtp-Source: AGHT+IHoBMN1jFEO04emIPxLz8c1aKi9bFLbR7D1HioY0UNIggIa6G/4kdSgIBW8PxmbAPfQoQAh9g== X-Received: by 2002:adf:fc92:0:b0:31f:fa61:961d with SMTP id g18-20020adffc92000000b0031ffa61961dmr8334632wrr.63.1695391781119; Fri, 22 Sep 2023 07:09:41 -0700 (PDT) From: Phil Dennis-Jordan To: qemu-devel@nongnu.org Cc: dirty@apple.com, rbolshakov@ddn.com, lists@philjordan.eu, Phil Dennis-Jordan Subject: [PATCH 1/3] i386: hvf: Adds support for INVTSC cpuid bit Date: Fri, 22 Sep 2023 16:09:12 +0200 Message-Id: <20230922140914.13906-2-phil@philjordan.eu> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230922140914.13906-1-phil@philjordan.eu> References: <20230922140914.13906-1-phil@philjordan.eu> 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: neutral client-ip=2a00:1450:4864:20::429; envelope-from=phil@philjordan.eu; helo=mail-wr1-x429.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 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-ZohoMail-DKIM: pass (identity @philjordan-eu.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1695391840323100001 Content-Type: text/plain; charset="utf-8" This patch adds the INVTSC bit to the Hypervisor.framework accelerator's CPUID bit passthrough allow-list. Previously, specifying +invtsc in the CPU configuration would fail with the following warning despite the host CPU advertising the feature: qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000007H:EDX.invtsc [bit 8] x86 macOS itself relies on a fixed rate TSC for its own Mach absolute time timestamp mechanism, so there's no reason we can't enable this bit for gues= ts. Signed-off-by: Phil Dennis-Jordan Reviewed-by: Roman Bolshakov Tested-by: Roman Bolshakov --- target/i386/hvf/x86_cpuid.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/i386/hvf/x86_cpuid.c b/target/i386/hvf/x86_cpuid.c index 7323a7a94b..d2721bd2a7 100644 --- a/target/i386/hvf/x86_cpuid.c +++ b/target/i386/hvf/x86_cpuid.c @@ -145,6 +145,10 @@ uint32_t hvf_get_supported_cpuid(uint32_t func, uint32= _t idx, CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_OSVW | CPUID_EXT3_XO= P | CPUID_EXT3_FMA4 | CPUID_EXT3_TBM; break; + case 0x80000007: + edx &=3D CPUID_APM_INVTSC; + eax =3D ebx =3D ecx =3D 0; + break; default: return 0; } --=20 2.36.1 From nobody Fri May 17 07:56:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=1695391839; cv=none; d=zohomail.com; s=zohoarc; b=iEBuovrn4BHTfV91XNPuop2eecRdXiJnEoXk3DeT3KPZEn5uPiCDAWwxFx6Stcz6iOM+D/nOIWFGdMUbxBRtZOiQ1sRbPfAQPa1ySaaxUzSsZtLUsruFwfn5cyNnEaPVs+DWzj8O2nTQzqI2uYByWa425wiOFpzJugaB+N7hWF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695391839; 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=RwgPyvay9DFmsLuOUJUHjUScLN28OjxwI/Y1FI48aMc=; b=OIZjjSrlLQEvg61n4bop9sSG7nyV6JUThcgVScFKnsFqXl2Yxj0UpLWsh7CXBy3VSD1jLl/y+U/z6V/8MUL81r3AYlTho8J1ZkPYFS83ETZtXDu3MnaWCHIRkWdtf9h+oEBCPpqQZeRDSBb5b3gJ6/p9TnbXEQdfPMpSrnzEMlI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 169539183967357.978325980038335; Fri, 22 Sep 2023 07:10:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjgqw-0002xy-P6; Fri, 22 Sep 2023 10:09:54 -0400 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 1qjgqp-0002uv-Dq for qemu-devel@nongnu.org; Fri, 22 Sep 2023 10:09:47 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qjgqn-0008PY-Ub for qemu-devel@nongnu.org; Fri, 22 Sep 2023 10:09:47 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c007d6159aso37174111fa.3 for ; Fri, 22 Sep 2023 07:09:45 -0700 (PDT) Received: from localhost.localdomain (89-104-8-249.customer.bnet.at. [89.104.8.249]) by smtp.gmail.com with ESMTPSA id g27-20020a170906395b00b009ae587ce128sm2725823eje.216.2023.09.22.07.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 07:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1695391784; x=1695996584; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RwgPyvay9DFmsLuOUJUHjUScLN28OjxwI/Y1FI48aMc=; b=RUwVJC1EJcctYPFti4fCvVIX+NkdzJtzSZeUljmJsL1hj+qZILfjB51Z7bvMR4Tz3U p6OITbZz+E6E0Dc6rQFzCZZ9nK5HHbDJq4C8Ap8iRp7tCj5NHp4yrfvH4jn+hN14YCis itDahkmERN1DWTlXgNiH3e1YTBTWPY1UwhV50btxmHlv6ZGKjXxa2AYKUUR69R0hyst2 bX3MiigiZuqHugzdRCqDfc3MSWGkhc8pr+uKgEHsyJD0ozmNAFda7MvqNelAaDdCJi8H c9Rjc9G9sI/3iJJH33LrBNse82eHeb/PYiOOfRdV/oQrlpDronGYYxhMLTrwbRIo2q1d b+NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695391784; x=1695996584; 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=RwgPyvay9DFmsLuOUJUHjUScLN28OjxwI/Y1FI48aMc=; b=t/OA3C7qDNtxddUqS0ylPkg6fZ4pUsQaoX9jGwtyFzKTrirenA5ZYw+8NChv4GFhV+ 36I/Ftbn1hU79j60ERay7NyY3o55e4nlzGhz3p5NSP2z3rpBC/5difot0N1swAWRRcQP 3NzRoFrXfUyXJRxM5V8/OlwIba0xwZH9m7h5CKnXUI3OFBczu9NbM40LdI73Usfp5ZrH 5B4UG8kbqxLTlD32cSZiWwBjBHRdbyVzf+2gkkdSr44RJ9jFOy1PNB2zwtSYX+tsqAFm frAkREC1+RRIc48ZzRKQOiR/qa2a2JlThN8JwoYDozCOGF47azF6/+6hNi9hSi7mo7jr IRVw== X-Gm-Message-State: AOJu0YzQBH7hZffvqmgysXw2yF+5NWmwtaQJM8/6PXlbyd5GOxLk5Tm2 pAiyZ/Q2YKY2EIpnwZrQjHTueqSiIU51jQCn9Ek= X-Google-Smtp-Source: AGHT+IETnI/4u8YyfHlagvukoYXzlEM9QY8mUCNmZocylHYkU7Q/8cYIrAIgdBXhby/cWT4JpsiIbA== X-Received: by 2002:a2e:9b86:0:b0:2bf:fb49:6619 with SMTP id z6-20020a2e9b86000000b002bffb496619mr7325385lji.23.1695391784123; Fri, 22 Sep 2023 07:09:44 -0700 (PDT) From: Phil Dennis-Jordan To: qemu-devel@nongnu.org Cc: dirty@apple.com, rbolshakov@ddn.com, lists@philjordan.eu, Phil Dennis-Jordan Subject: [PATCH 2/3] i386: hvf: In kick_vcpu use hv_vcpu_interrupt to force exit Date: Fri, 22 Sep 2023 16:09:13 +0200 Message-Id: <20230922140914.13906-3-phil@philjordan.eu> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230922140914.13906-1-phil@philjordan.eu> References: <20230922140914.13906-1-phil@philjordan.eu> 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: neutral client-ip=2a00:1450:4864:20::22e; envelope-from=phil@philjordan.eu; helo=mail-lj1-x22e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 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-ZohoMail-DKIM: pass (identity @philjordan-eu.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1695391840969100007 Content-Type: text/plain; charset="utf-8" When interrupting a vCPU thread, this patch actually tells the hypervisor to stop running guest code on that vCPU. Calling hv_vcpu_interrupt actually forces a vCPU exit, analogously to hv_vcpus_exit on aarch64. Previously, hvf_kick_vcpu_thread relied upon hv_vcpu_run returning very frequently, including many spurious exits, which made it less of a problem = that nothing was actively done to stop the vCPU thread running guest code. The newer, more efficient hv_vcpu_run_until exits much more rarely, so a tr= ue "kick" is needed. Signed-off-by: Phil Dennis-Jordan --- target/i386/hvf/hvf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index cb2cd0b02f..55bd7d2af8 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -209,7 +209,10 @@ static inline bool apic_bus_freq_is_known(CPUX86State = *env) =20 void hvf_kick_vcpu_thread(CPUState *cpu) { + hv_vcpuid_t hvf_vcpuid; cpus_kick_thread(cpu); + hvf_vcpuid =3D cpu->accel->fd; + hv_vcpu_interrupt(&hvf_vcpuid, 1); } =20 int hvf_arch_init(void) --=20 2.36.1 From nobody Fri May 17 07:56:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=1695391855; cv=none; d=zohomail.com; s=zohoarc; b=TsTKC51GPxG/0f83wnuIjzlSKySCgJIIGuxp5fXC+abjg/Fif9ElMbnxwkJ7TgELWIqlRls+wnBKgA9JropwbQJXpR1ybLoej3jBFeizqyOjf+x09/PDEXg5wrladSFrlpdiWprN7oQLPfr9s9foyjvThtRr/I6ZnNOLIKhyO6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695391855; h=Content-Type: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=WgvxkIY3+j2qIvKdDbYfJBN2du/aHpWbM4Y0iyDsskY=; b=SMgDFm6qmDH6edNSyl6eUbUhAICUPJKXCrJ0gV3bpY77sAsY16iZ4E2Y2tI81OXexpMWUSh6AdviskAUkhUNh7KzL1EpLTKa/BauwLrsejiySUpIHw12GK42i6YmaH0dj8j0aRpp3VwJEAkx2PSRBF0zFlZfr9k+S8y1iKCRYmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1695391855942285.95178817283886; Fri, 22 Sep 2023 07:10:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjgqx-0002yn-Fm; Fri, 22 Sep 2023 10:09:55 -0400 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 1qjgqs-0002w0-He for qemu-devel@nongnu.org; Fri, 22 Sep 2023 10:09:52 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qjgqq-0008Py-Ca for qemu-devel@nongnu.org; Fri, 22 Sep 2023 10:09:49 -0400 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2bfea381255so37141771fa.3 for ; Fri, 22 Sep 2023 07:09:48 -0700 (PDT) Received: from localhost.localdomain (89-104-8-249.customer.bnet.at. [89.104.8.249]) by smtp.gmail.com with ESMTPSA id g27-20020a170906395b00b009ae587ce128sm2725823eje.216.2023.09.22.07.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 07:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1695391786; x=1695996586; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WgvxkIY3+j2qIvKdDbYfJBN2du/aHpWbM4Y0iyDsskY=; b=EJtFwnG6zCCNE0iw3NW0ALzTsi+lkMRJEPTzXPI5k1kfg78KhBsGT4KKYH7OPOI8jK T+Fk7uynpXTC6epeZuGUx7XM5qBCcjGmKzcG7OIBJWEIfWB8JpBvPSs+50ug923lG+Cn Ic9UrbUyM11jAGkwFp+UsTfTp+xGou2NUqc5qWFfIzRhX61YUaRw1wacSwkmhZbzvLy4 qVcnXoA2IFpggvSXecmox28gHM3uVVv2WswXIqWXOJBx3i74RNsj7FS8xBC/Hfda8nA1 crO+QaLfPHDNBA6W+3fYCOusLaXxB4KGaOtnk0syR4F+Dy+X3UpmJvYX+BAPVFFUONXL VAZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695391786; x=1695996586; 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=WgvxkIY3+j2qIvKdDbYfJBN2du/aHpWbM4Y0iyDsskY=; b=q4sZnB23ZFavlGUIvUKjATyreISolCE8GG2xp12XuxkY9xVMiMtlTk93ZyGCYHRv5B xVGLa/AjTBBNbiTfeXXrwwMwaqOG2nb7FJ99WuWVbfO2k2nY780p6DUsMQrl9DGeookS m+ex6LdeZ+bgwFntliKxLcNzbP/il9jUGaaX3BGQr7NAsrdDkjcNwWdm7HhuKK44iHAO RbU542fFKrScPEFvo17WsOoTfoBg4klTd9Qe5HA1gXN2K+BphZK/d1A9e6HSJDGm+NPG gw7Hs8dvAmG9ko2T+6B8wZBucQgFB0gKjbqulOaxaZDe/4dSsxyNaSNchetYkq/5EUro Nw/A== X-Gm-Message-State: AOJu0YzDXUpYxmcl/SLKBeycfSZSZWTDZd42bWII5Vmmlq6OtX3fS/Zn gTFBNlSQ/OQVzeF40z1nzhQpAeMKRg7pifOF1wQ= X-Google-Smtp-Source: AGHT+IGUqOhxUCB82o+yTrCJioaXz1V/a3rdke6PWrJaTZB/0NHLVQM35YmT3MUbasnmhSo3hqKiEg== X-Received: by 2002:a2e:9c07:0:b0:2c0:2583:520e with SMTP id s7-20020a2e9c07000000b002c02583520emr7651387lji.41.1695391786598; Fri, 22 Sep 2023 07:09:46 -0700 (PDT) From: Phil Dennis-Jordan To: qemu-devel@nongnu.org Cc: dirty@apple.com, rbolshakov@ddn.com, lists@philjordan.eu, Phil Dennis-Jordan Subject: [PATCH 3/3] i386: hvf: Updates API usage to use modern vCPU run function Date: Fri, 22 Sep 2023 16:09:14 +0200 Message-Id: <20230922140914.13906-4-phil@philjordan.eu> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230922140914.13906-1-phil@philjordan.eu> References: <20230922140914.13906-1-phil@philjordan.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: neutral client-ip=2a00:1450:4864:20::22f; envelope-from=phil@philjordan.eu; helo=mail-lj1-x22f.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 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-ZohoMail-DKIM: pass (identity @philjordan-eu.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1695391857270100001 macOS 10.15 introduced the more efficient hv_vcpu_run_until() function to supersede hv_vcpu_run(). According to the documentation, there is no longer any reason to use the latter on modern host OS versions. Observed behaviour of the newer function is that as documented, it exits much less frequently - and most of the original function=E2=80=99s exits se= em to have been effectively pointless. Another reason to use the new function is that it is a prerequisite for using newer features such as in-kernel APIC support. (Not covered by this patch.) This change implements the upgrade by selecting one of three code paths at compile time: two static code paths for the new and old functions respectively, when building for targets where the new function is either not available, or where the built executable won=E2=80=99t run on older platforms lacking the new function anyway. The third code path selects dynamically based on runtime detected availability of the weakly-linked symbol. Signed-off-by: Phil Dennis-Jordan --- target/i386/hvf/hvf.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 55bd7d2af8..e4c785c686 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -410,6 +410,27 @@ static void hvf_cpu_x86_cpuid(CPUX86State *env, uint32= _t index, uint32_t count, } } =20 +static hv_return_t hvf_vcpu_run(hv_vcpuid_t vcpu_id) +{ + /* + * hv_vcpu_run_until is available and recommended from macOS 10.15+. + * Test for availability at runtime and fall back to hv_vcpu_run() only + * where necessary. + */ +#ifndef MAC_OS_X_VERSION_10_15 + return hv_vcpu_run(vcpu_id); +#elif MAC_OS_X_VERSION_MIN_REQUIRED >=3D MAC_OS_X_VERSION_10_15 + return hv_vcpu_run_until(vcpu_id, HV_DEADLINE_FOREVER); +#else /* MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15 */ + /* 10.15 SDK or newer, but could be < 10.15 at runtime */ + if (__builtin_available(macOS 10.15, *)) { + return hv_vcpu_run(vcpu_id); + } else { + return hv_vcpu_run_until(vcpu_id, HV_DEADLINE_FOREVER); + } +#endif +} + int hvf_vcpu_exec(CPUState *cpu) { X86CPU *x86_cpu =3D X86_CPU(cpu); @@ -438,7 +459,7 @@ int hvf_vcpu_exec(CPUState *cpu) return EXCP_HLT; } =20 - hv_return_t r =3D hv_vcpu_run(cpu->accel->fd); + hv_return_t r =3D hvf_vcpu_run(cpu->accel->fd); assert_hvf_ok(r); =20 /* handle VMEXIT */ --=20 2.36.1