From nobody Sat Sep 6 17:00:59 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1756894267; cv=none; d=zohomail.com; s=zohoarc; b=TSRfO0U6RZsZquCE3K+Hld0QsIRchC+SoCBh5yh6VZbSYDK5ZVUl7tOZI7TZY3XJ/U4SHHJ0rTLUHjAoUfmRVJszUg5auTk346cGOAn9YZ+mcK5YA6mZqZcJp8UOIWTE49ftAmMzcyoMaLLIHOWx4g1nN4ErgJKUmumboNqLq7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756894267; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=W6UGFBv7QtABA3WFkaPUA0uUav3GpS4iAJMcQFZCcBg=; b=e6SEkgVrxnLRqBJHoIi3nNyZW9+qgYbDJTzyXe0YnP1i33u8pMsnshwficAPMOZ+ww6VF3JF/ydLGq1U1a3evb7JZ82J6QKNeNXJllLc7rd9rM9IDxebBcLgqosz6GWCjzH71gu9NPE9b+pwhlKuFGgzsAhgdhgJ9iZnYpO5hn8= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756894267863156.22781526499443; Wed, 3 Sep 2025 03:11:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utkR0-0004TJ-1M; Wed, 03 Sep 2025 06:09:46 -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 1utkQt-0004Hi-EG for qemu-devel@nongnu.org; Wed, 03 Sep 2025 06:09:40 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1utkQr-0008Rd-Mp for qemu-devel@nongnu.org; Wed, 03 Sep 2025 06:09:39 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3d1bf79d7acso2366916f8f.0 for ; Wed, 03 Sep 2025 03:09:37 -0700 (PDT) Received: from localhost.localdomain (98.red-88-29-180.dynamicip.rima-tde.net. [88.29.180.98]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f0c6dc1sm316744055e9.1.2025.09.03.03.09.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 03 Sep 2025 03:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756894175; x=1757498975; 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=W6UGFBv7QtABA3WFkaPUA0uUav3GpS4iAJMcQFZCcBg=; b=gAgpxahBzJNxvXfvPDzAC20jmWPrd2E4lS88xUe7uJ3MhoYbFrbvxKehQJ35vQsT2F CJtTSIU4xhXezivF4C5ifSNVXx8f8Nm4yt9VjsFwdvv7bcikPtFC3cuIiCf7YkSZPVgB fmOFh4gtuGsFJ/vQUIbwDbGBvUEsm1DAU5P+PpG5EqkeUj9S+HzKNWmU2MFEs8RYp70t jfQd6JeLan9BlzK/EVUXJINpB4q/THK3W+5cEyua6K2YZqX9S11O4lo++eopdK8invYd rsLYAXVdtE8CGsntwT5isSPJP2Zhi+3mCGRAcwTqIc0WTV3Rt8m3VHu+doaXzyz/72Wa m8yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756894175; x=1757498975; 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=W6UGFBv7QtABA3WFkaPUA0uUav3GpS4iAJMcQFZCcBg=; b=BGso+Us1seiX8EihrkhzACUdlSKaObFi9UoAx9ResqZoo5lgeXUJ8jy5y2WiaOkifq L3snX9XHkG44Az/0ktbcuOGjAHLv33hf6t6HEYCYVswBgMDqsoMYYK9BIMNJNmXzK3Rf 2TTSKt0qg0B6B+uTvWIdaJjyPiUZ0H/9C+s2m/lJ5oHLY/HWRuR5H+jmFBf0KuaLz89R WCr+dnDmSp/WzSmn/1/KlXHo20touEUwklT9hLVnA0BFouUYmKCIYLh7EDVrox0WRpIr wVfzcJZc0kxPUB38HMKtwexTNp3Kg+qOATgKFWFYGrGWrcFATw9TsKHMsXryTYYvrad2 hmiA== X-Gm-Message-State: AOJu0YwFLdtiQHGjTCj0x6G7LVWaNieDNH8ZZgs2erDwKYW/AVsOQIjD UtLP94EZ727YKSuKSSsr/EZLurTc+64s369zxmZGo5J0AAWEvfP63ohFDmpJQJ05JDJEtlgUw9K UfLlUDWdR3g== X-Gm-Gg: ASbGncuA6cT4LCtMK6PHcTXTbfaAhRaS1WVDEqM0nwZ8nvG358SCcgbmuUmwiGKMqxb 0LjsNHCVjq2UpapsbVk2t+SnbLRMMyhwOHmyZ0eE5A7Txq/yjh3m7P6uhbfP4fFvRYbeF67GHV4 j6lJXJOqlpaNeK/MPa2ZNsAFLFszhc0AokicpP5/fQDWbRW2eTTcaLPSMPHr3E7jaXtpQHX+dWR AHaUkVX04cH4JBc0m1F9TsNOiI6LPrZgGnfTPkSb+YL0NMfcrzI2W/B5bImUGfK4ZNNkRcQWIiY zmzR7guHM6PUqXs7WjQPmRqv2VUCV5bSaCy5uxWZNtWS1vSf2CQbFaNBi9EJFwymPcUGXuYnzdC nE8RR+SxMxL4oHvgJ/lWXYXkDT99Yl+kdUajqRY7nyTSePeRRvSPyompTkDc/pIkRs8OYbKpJRd g/WldBsmmcGKCL36nZ X-Google-Smtp-Source: AGHT+IGEjVimI8+MizAyDYl5SGJcK7K4/JM92msUcSztcGMPOkbzUd2GtuhDPJe1Sw+RFeT5xVbjpg== X-Received: by 2002:a05:6000:250a:b0:3d0:3eae:576d with SMTP id ffacd0b85a97d-3d1de4b1c23mr10459789f8f.22.1756894175503; Wed, 03 Sep 2025 03:09:35 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alexander Graf , Richard Henderson , qemu-arm@nongnu.org, Mohamed Mediouni , Peter Maydell , Mads Ynddal , Phil Dennis-Jordan , Stefan Hajnoczi , Cameron Esfahani , Roman Bolshakov , Paolo Bonzini Subject: [PATCH 17/24] target/arm/hvf: Factor hvf_handle_vmexit() out Date: Wed, 3 Sep 2025 12:06:53 +0200 Message-ID: <20250903100702.16726-18-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250903100702.16726-1-philmd@linaro.org> References: <20250903100702.16726-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1756894270714124100 Factor hvf_handle_vmexit() out of hvf_vcpu_exec(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/arm/hvf/hvf.c | 51 ++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 3db0a8e288c..0cfe3066c23 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -2111,10 +2111,34 @@ static int hvf_handle_exception(CPUState *cpu, hv_v= cpu_exit_exception_t *excp) return ret; } =20 -int hvf_arch_vcpu_exec(CPUState *cpu) +/* Must be called by the owning thread */ +static int hvf_handle_vmexit(CPUState *cpu, hv_vcpu_exit_t *exit) { ARMCPU *arm_cpu =3D ARM_CPU(cpu); - hv_vcpu_exit_t *hvf_exit =3D cpu->accel->exit; + int ret =3D 0; + + switch (exit->reason) { + case HV_EXIT_REASON_EXCEPTION: + hvf_sync_vtimer(cpu); + ret =3D hvf_handle_exception(cpu, &exit->exception); + break; + case HV_EXIT_REASON_VTIMER_ACTIVATED: + qemu_set_irq(arm_cpu->gt_timer_outputs[GTIMER_VIRT], 1); + cpu->accel->vtimer_masked =3D true; + break; + case HV_EXIT_REASON_CANCELED: + /* we got kicked, no exit to process */ + break; + default: + g_assert_not_reached(); + } + + return ret; +} + +int hvf_arch_vcpu_exec(CPUState *cpu) +{ + int ret; hv_return_t r; =20 if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) && @@ -2133,6 +2157,7 @@ int hvf_arch_vcpu_exec(CPUState *cpu) bql_lock(); switch (r) { case HV_SUCCESS: + ret =3D hvf_handle_vmexit(cpu, cpu->accel->exit); break; case HV_ILLEGAL_GUEST_STATE: trace_hvf_illegal_guest_state(); @@ -2141,27 +2166,7 @@ int hvf_arch_vcpu_exec(CPUState *cpu) g_assert_not_reached(); } =20 - /* handle VMEXIT */ - uint64_t exit_reason =3D hvf_exit->reason; - - switch (exit_reason) { - case HV_EXIT_REASON_EXCEPTION: - /* This is the main one, handle below. */ - break; - case HV_EXIT_REASON_VTIMER_ACTIVATED: - qemu_set_irq(arm_cpu->gt_timer_outputs[GTIMER_VIRT], 1); - cpu->accel->vtimer_masked =3D true; - return 0; - case HV_EXIT_REASON_CANCELED: - /* we got kicked, no exit to process */ - return 0; - default: - g_assert_not_reached(); - } - - hvf_sync_vtimer(cpu); - - return hvf_handle_exception(cpu, &hvf_exit->exception); + return ret; } =20 static const VMStateDescription vmstate_hvf_vtimer =3D { --=20 2.51.0