Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2226475/?format=api
{ "id": 2226475, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2226475/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260422125250.1303100-33-alex.bennee@linaro.org/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.1/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260422125250.1303100-33-alex.bennee@linaro.org>", "date": "2026-04-22T12:52:49", "name": "[v3,32/32] target/arm: implement WFET", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "a7b0b0d61484822f01a2a22add0289d09479ef58", "submitter": { "id": 39532, "url": "http://patchwork.ozlabs.org/api/1.1/people/39532/?format=api", "name": "Alex Bennée", "email": "alex.bennee@linaro.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260422125250.1303100-33-alex.bennee@linaro.org/mbox/", "series": [ { "id": 501008, "url": "http://patchwork.ozlabs.org/api/1.1/series/501008/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=501008", "date": "2026-04-22T12:52:20", "name": "target/arm: fully model WFxT instructions for A-profile", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/501008/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2226475/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2226475/checks/", "tags": {}, "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=L5OvlGbJ;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0zvG21CMz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 23:04:10 +1000 (AEST)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wFXE5-0001IG-Fv; Wed, 22 Apr 2026 09:02:45 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <alex.bennee@linaro.org>)\n id 1wFXE1-0001Bh-8S\n for qemu-devel@nongnu.org; Wed, 22 Apr 2026 09:02:41 -0400", "from mail-wm1-x343.google.com ([2a00:1450:4864:20::343])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <alex.bennee@linaro.org>)\n id 1wFXDz-0001AQ-Dx\n for qemu-devel@nongnu.org; Wed, 22 Apr 2026 09:02:40 -0400", "by mail-wm1-x343.google.com with SMTP id\n 5b1f17b1804b1-48374014a77so70814605e9.3\n for <qemu-devel@nongnu.org>; Wed, 22 Apr 2026 06:02:39 -0700 (PDT)", "from draig.lan ([185.124.0.195]) by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-488ffc5e3f4sm230898655e9.2.2026.04.22.06.02.30\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 22 Apr 2026 06:02:36 -0700 (PDT)", "from draig.lan (localhost [IPv6:::1])\n by draig.lan (Postfix) with ESMTP id A142B61853;\n Wed, 22 Apr 2026 13:52:53 +0100 (BST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1776862958; x=1777467758; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=QCL3cJadHa1d1ZmZ7wv954PwO2cS/d7rv5lfGjMfQE4=;\n b=L5OvlGbJe1GvsSlhDH9K83VVHWsKxtN7WBdiAw2dmrBpSWaLBGQ2CydNXw16WrVwNo\n VXAjBgwcmzgSYtV+2hJ99sYt13BmyPOzwsusCMzZDqNEJp5S+DTbwqdhJvN4p3y9ufvb\n 6CzRRHyFgWbRn6dhQlJKctfujsrRbYXFBhDGHol59GAmSHxBWrLXXPe38uCPcoonfj6v\n dgmzbmQmmiH24zjeTHusiPwo5Y3WTirjyyFtw0igZfjrHqANnMnh9p44dXXuplQd4/qI\n KW0KDbNFxjdOawok5lGzc8+Qg1kiNvuYes0TWYXQ6ijWwljGtiJ3/eJWE4hBjguBH8Pb\n Mp6w==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776862958; x=1777467758;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=QCL3cJadHa1d1ZmZ7wv954PwO2cS/d7rv5lfGjMfQE4=;\n b=aGgvsDGFs5yiK8x0C/q6oxY4OR8tUrkZXxj8L38QiWlIBXF2XpX5xTPUncYG9ACoqe\n JjzDbRzlznyDtF8C/EW1WG0aAu6GGN27/IS0WMiunN6Z8dXr7PUo1QtYByL51U85MTbB\n qtFI2lx3ofq/aAtdme16AXTYxivUurF7+BRbVHOGCBg3e6FJBqRaeXLMvxPm8PNZVXf4\n 13auG18Pan15qWMu8ruGhHu8AGAB3XpxMGAWEYrgBK6WhJ3ckdQoVWPp3hdV85kYpvkW\n +KbxpYh5unnWa459AobzspL0iRiIwoYoaek7bPBGzV+7SNJWiwD3vWns1BTHo/I+BBXU\n pVXg==", "X-Gm-Message-State": "AOJu0YwL0UqmpXH5WYrPf3N1vla4BYtANgvDdeq6/fO6HkxvvxyuL9Fj\n BD6uNOtNTC/sugFb7c/iIhaaNIMbY7+t8nNNxBNVrKJ+C+8Bnhq2M/PsqewGJXieECgb+vPdpwx\n k3wmw5Be9XA==", "X-Gm-Gg": "AeBDieuob/1DlXXcqQ05TtDltTAcmW59Ppmv4UyOm3ym685011RCrkwULHKrTl8Rnux\n masbhzRStldGk/+dlHe2HoG5iAC1H9kjTF7btIzrlt0fnrYK1pOzLzKdhLGjKd3oZurBssi/xkc\n QkBJ/2WNgB+M7iXa5dRyd65n4qevhpwhLC+voega1oho/kR4S3qGsJLCzPK5JCPV41YtN/vtw7n\n winLhafl0m53S2GIZXSzoFkrjw2TKKO9MWLyiToz7vSmoTvzmCRjNonJthz1r4RCCR9WCjJZav+\n 83Nxx4rWqQgL/WWcq8v2dKqLjm4ewBB3kvk6MItCzv6rKiGwya5Y6QsPyAiwNZZYdyU067zMeZG\n 5bVl0rXje2ZjBkjQ3d4lJxC8Tv5DouUFFmkfsoIKR4wZeVFuRRpsPVxG6IphbjOZeknDOdhenk5\n LCPZ9TZVuPXlUUq1A/QJ+YX0tG1LpwMhzd8A==", "X-Received": "by 2002:a05:600c:8183:b0:488:b187:d898 with SMTP id\n 5b1f17b1804b1-488fb771445mr269452895e9.14.1776862957733;\n Wed, 22 Apr 2026 06:02:37 -0700 (PDT)", "From": "=?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>", "To": "qemu-devel@nongnu.org", "Cc": "Pedro Barbuda <pbarbuda@microsoft.com>, Alexander Graf <agraf@csgraf.de>,\n Peter Maydell <peter.maydell@linaro.org>,\n Paolo Bonzini <pbonzini@redhat.com>,\n Mohamed Mediouni <mohamed@unpredictable.fr>, kvm@vger.kernel.org,\n qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>", "Subject": "[PATCH v3 32/32] target/arm: implement WFET", "Date": "Wed, 22 Apr 2026 13:52:49 +0100", "Message-ID": "<20260422125250.1303100-33-alex.bennee@linaro.org>", "X-Mailer": "git-send-email 2.47.3", "In-Reply-To": "<20260422125250.1303100-1-alex.bennee@linaro.org>", "References": "<20260422125250.1303100-1-alex.bennee@linaro.org>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=2a00:1450:4864:20::343;\n envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x343.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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n 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": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "Now we have the event stream and SEV/SEVL implemented we can finally\nenable WFET for Aarch64.\n\nSigned-off-by: Alex Bennée <alex.bennee@linaro.org>\n\n---\nv2\n - fix exception syndrome by using enum value\n - use env->halt_reason\nv3\n - fix check_wfx_trap(s/false/true/) as it is a WFE\n---\n target/arm/tcg/helper-defs.h | 1 +\n target/arm/tcg/op_helper.c | 80 ++++++++++++++++++++++++++++++++++\n target/arm/tcg/translate-a64.c | 15 ++++---\n 3 files changed, 89 insertions(+), 7 deletions(-)", "diff": "diff --git a/target/arm/tcg/helper-defs.h b/target/arm/tcg/helper-defs.h\nindex ebdf09be38a..5e4d828dd55 100644\n--- a/target/arm/tcg/helper-defs.h\n+++ b/target/arm/tcg/helper-defs.h\n@@ -56,6 +56,7 @@ DEF_HELPER_1(setend, void, env)\n DEF_HELPER_2(wfi, void, env, i32)\n DEF_HELPER_2(wfe, void, env, i32)\n DEF_HELPER_2(wfit, void, env, i32)\n+DEF_HELPER_2(wfet, void, env, i32)\n DEF_HELPER_1(yield, void, env)\n DEF_HELPER_1(pre_hvc, void, env)\n DEF_HELPER_2(pre_smc, void, env, i32)\ndiff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c\nindex fe34c94e890..112e0c2eb1a 100644\n--- a/target/arm/tcg/op_helper.c\n+++ b/target/arm/tcg/op_helper.c\n@@ -620,6 +620,86 @@ void HELPER(wfe)(CPUARMState *env, uint32_t insn_len)\n #endif\n }\n \n+void HELPER(wfet)(CPUARMState *env, uint32_t rd)\n+{\n+#ifdef CONFIG_USER_ONLY\n+ /*\n+ * As for WFIT make it NOP here, because trying to raise EXCP_HLT\n+ * would trigger an abort.\n+ */\n+ return;\n+#else\n+ ARMCPU *cpu = env_archcpu(env);\n+ CPUState *cs = env_cpu(env);\n+ uint32_t excp;\n+ int target_el = check_wfx_trap(env, true, &excp);\n+ /* The WFET should time out when CNTVCT_EL0 >= the specified value. */\n+ uint64_t cntval = gt_get_countervalue(env);\n+ uint64_t timeout = env->xregs[rd];\n+ /*\n+ * We want the value that we would get if we read CNTVCT_EL0 from\n+ * the current exception level, so the direct_access offset, not\n+ * the indirect_access one. Compare the pseudocode LocalTimeoutEvent(),\n+ * which calls VirtualCounterTimer().\n+ */\n+ uint64_t offset = gt_direct_access_timer_offset(env, GTIMER_VIRT);\n+ uint64_t cntvct = cntval - offset;\n+ uint64_t nexttick;\n+ int64_t next_event;\n+\n+ /*\n+ * As for WFE if the event register is already set we can consume\n+ * the event and return immediately.\n+ */\n+ if (env->event_register) {\n+ env->event_register = false;\n+ return;\n+ }\n+\n+\n+ if (cpu_has_work(cs) || cntvct >= timeout) {\n+ /*\n+ * Don't bother to go into our \"low power state\" if\n+ * we would just wake up immediately.\n+ */\n+ return;\n+ }\n+\n+ /* We might sleep, so now we check to see if we should trap */\n+ if (target_el) {\n+ env->pc -= 4;\n+ raise_exception(env, excp, syn_wfx(1, 0xe, rd, true, WFET, false), target_el);\n+ }\n+\n+ /*\n+ * Finally work out if the timeout or event stream will kick in\n+ * earlier.\n+ */\n+ if (uadd64_overflow(timeout, offset, &nexttick)) {\n+ nexttick = UINT64_MAX;\n+ }\n+ if (nexttick > INT64_MAX / gt_cntfrq_period_ns(cpu)) {\n+ nexttick = INT64_MAX;\n+ }\n+\n+ next_event = gt_calc_next_event_stream(env);\n+ if (next_event > 0 && next_event < nexttick) {\n+ timer_mod(cpu->wfxt_timer, next_event);\n+ } else {\n+ if (nexttick == INT64_MAX) {\n+ timer_mod_ns(cpu->wfxt_timer, INT64_MAX);\n+ } else {\n+ timer_mod(cpu->wfxt_timer, nexttick);\n+ }\n+ }\n+\n+ env->halt_reason = HALT_WFE;\n+ cs->exception_index = EXCP_HLT;\n+ cs->halted = 1;\n+ cpu_loop_exit(cs);\n+#endif\n+}\n+\n void HELPER(yield)(CPUARMState *env)\n {\n CPUState *cs = env_cpu(env);\ndiff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c\nindex 83b2a6e848f..c8c8a27956b 100644\n--- a/target/arm/tcg/translate-a64.c\n+++ b/target/arm/tcg/translate-a64.c\n@@ -2093,14 +2093,15 @@ static bool trans_WFET(DisasContext *s, arg_WFET *a)\n return false;\n }\n \n- /*\n- * We rely here on our WFE implementation being a NOP, so we\n- * don't need to do anything different to handle the WFET timeout\n- * from what trans_WFE does.\n- */\n- if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) {\n- s->base.is_jmp = DISAS_WFE;\n+ if (s->ss_active) {\n+ /* Act like a NOP under architectural singlestep */\n+ return true;\n }\n+\n+ gen_a64_update_pc(s, 4);\n+ gen_helper_wfet(tcg_env, tcg_constant_i32(a->rd));\n+ /* Go back to the main loop to check for interrupts */\n+ s->base.is_jmp = DISAS_EXIT;\n return true;\n }\n \n", "prefixes": [ "v3", "32/32" ] }