{"id":2232952,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2232952/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260505112014.102993-5-alex.bennee@linaro.org/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.2/projects/14/?format=json","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":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260505112014.102993-5-alex.bennee@linaro.org>","list_archive_url":null,"date":"2026-05-05T11:20:10","name":"[v5,4/7] target/arm: implements SEV/SEVL for all modes","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"bb2e90cb1d3914eaa81b83a9c6e06550dca015da","submitter":{"id":39532,"url":"http://patchwork.ozlabs.org/api/1.2/people/39532/?format=json","name":"Alex Bennée","email":"alex.bennee@linaro.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260505112014.102993-5-alex.bennee@linaro.org/mbox/","series":[{"id":502820,"url":"http://patchwork.ozlabs.org/api/1.2/series/502820/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502820","date":"2026-05-05T11:20:06","name":"target/arm: fully model WFxT instructions for A-profile","version":5,"mbox":"http://patchwork.ozlabs.org/series/502820/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2232952/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2232952/checks/","tags":{},"related":[],"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=U5xlRFfo;\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 4g8x003j8Sz1yJV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 05 May 2026 21:20:48 +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 1wKDpD-0007Hj-Qa; Tue, 05 May 2026 07:20:28 -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 1wKDp9-0007G1-AS\n for qemu-devel@nongnu.org; Tue, 05 May 2026 07:20:23 -0400","from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c])\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 1wKDp6-0005pa-7z\n for qemu-devel@nongnu.org; Tue, 05 May 2026 07:20:22 -0400","by mail-wr1-x42c.google.com with SMTP id\n ffacd0b85a97d-43d7badbd7dso2358339f8f.2\n for <qemu-devel@nongnu.org>; Tue, 05 May 2026 04:20:19 -0700 (PDT)","from draig.lan ([185.124.0.195]) by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-45054b02c5asm3784684f8f.19.2026.05.05.04.20.15\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 05 May 2026 04:20:15 -0700 (PDT)","from draig.lan (localhost [IPv6:::1])\n by draig.lan (Postfix) with ESMTP id AF1185FA53;\n Tue, 05 May 2026 12:20:14 +0100 (BST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1777980018; x=1778584818; 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=HgMS5WqoQTNwMotfKg5CtyWMirTfACd/41i5C9cIqU0=;\n b=U5xlRFfojiQHGor0XcDFlcktv5CAZ3/u3S8YXtK1gYuiXjxlQp3moiIgv+WIfMbi9N\n hJpvwPPD+ADl/sziuEks0nO8We/5XNH3NPUp7DH2OXVUaxD3HkZ+3/+M7rD+Of0MJZ9m\n N3h8RA65HcF58kMnKU0MLeC2V4rcPlvj9DOHITG+eQQGsPtB6otMkOUjM8HicClhC6vV\n Jfp2u6B02zwWtftTUltros6KS4/7bLqyWC1YTr4X/UafoEx0W1Wip9gCEZ51tTZDdWsw\n qAzoAbfO4Hg8bOa1HS0FZ+mxkKw4USvMTIGxqorgX/4Vk0c4VyGADK0GcNs46rf2Je+0\n mezw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777980018; x=1778584818;\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=HgMS5WqoQTNwMotfKg5CtyWMirTfACd/41i5C9cIqU0=;\n b=oaD/s1Awj4YQBD3ALObvBK70hpdHwPFpgGJdnXd91OBFbuRyU5L3NRJoQKap3jYGud\n 3d8XbsbRM6Tb8fUmLoUFCEfMhMzhKf5jnJfZs1pV+ictz7EPM93eX+zTkQbS9Fld6vOJ\n /wDFFDuY25xJ1OlAJCBXQwTj01jsX7JvA+gsrkyAPLo8B/ZXAydk/KMQu4TdDtyjHInM\n vm6Cf2f1A/FBdLryM7Qpp24QT3oO/HPuVH4KIBhHzgDorF5tCRpLbs7hdZlD9JVeJdyi\n 6wwh9B0rEc1u0VNfv1hHN67GWmOnEaoECyoZy3pL6yKBpjUyVHJ9PezYmF3yXtvu0+mV\n MmPQ==","X-Gm-Message-State":"AOJu0Yw313oaRHQiXZbe0OUPB3afVFmRvknnbsFM3ka2R3WuaV3w0w64\n KpimdHpuZ6UY87ub1wkdeOOnMXrbDx60bGB/MWT/IEqgocp42Y/Jht4jbele0ZSv62M=","X-Gm-Gg":"AeBDieukDqMFqLhUEF3uvEsG3e+2O3By2G/TeJWO7M2tn0GKJOgu/EcQL50Um0fhvbT\n g6S397i2DgZXaFSMq0Tn89H1llgGYEGRgmrOGwXiiov/eHoEODlnebJpRYonTnfMqkE1Ul0yHhP\n H6Jgm9hwo43aD1v7rhBOhmfwmTP7JSyF/YB4HzSyzjYxMkpavZIHtIKvVYYRlsaaWY+jR4siu0x\n h/oTvhdpBiKb4Jtc6g9u+DV5IdJrzw5r1j6Je5GZZ61DuRBEGTfsbpGZh2y3MivYsLQBezUuu8c\n 6qwBdeHNyKVfJsQbLKuOagb43yjoDzuUmTCMKuvMJJXXBaiJ7AM7B4Yhh4AH/wxFfnLfDCNV/95\n hIgF6Srfm6YNy/3d02RX9O5htHrOoftHoqMoFLKOOx0gvm/XqwSliJBrZPi4XzbJw4twGZ46vN3\n vHFVOX1RgpIx+jQKcsu0ergPteR/ZKlSDAig==","X-Received":"by 2002:a05:6000:61e:b0:43d:7b90:fa23 with SMTP id\n ffacd0b85a97d-44bb65df7c8mr22454198f8f.29.1777980018492;\n Tue, 05 May 2026 04:20:18 -0700 (PDT)","From":"=?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>","To":"qemu-devel@nongnu.org","Cc":"Peter Maydell <peter.maydell@linaro.org>, kvm@vger.kernel.org,\n Alexander Graf <agraf@csgraf.de>,\n Mohamed Mediouni <mohamed@unpredictable.fr>,\n Paolo Bonzini <pbonzini@redhat.com>, Pedro Barbuda <pbarbuda@microsoft.com>,\n qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>,\n Richard Henderson <richard.henderson@linaro.org>","Subject":"[PATCH v5 4/7] target/arm: implements SEV/SEVL for all modes","Date":"Tue,  5 May 2026 12:20:10 +0100","Message-ID":"<20260505112014.102993-5-alex.bennee@linaro.org>","X-Mailer":"git-send-email 2.47.3","In-Reply-To":"<20260505112014.102993-1-alex.bennee@linaro.org>","References":"<20260505112014.102993-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::42c;\n envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.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=unavailable 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":"Remove the restrictions that make this a M-profile only operation and\nenable the instructions for all Arm profiles.\n\nReviewed-by: Richard Henderson <richard.henderson@linaro.org>\nSigned-off-by: Alex Bennée <alex.bennee@linaro.org>\n\n---\nv2\n  - fix alignment in a32.decode\n  - set bool directly, defend with QEMU_BUILD_BUG_ON\n  - s/instructions/profiles/\n  - share get_event_reg between translate/translate-a64\n---\n target/arm/tcg/translate.h     | 18 ++++++++++++++++++\n target/arm/tcg/a32.decode      |  5 ++---\n target/arm/tcg/a64.decode      |  5 ++---\n target/arm/tcg/t16.decode      |  4 +---\n target/arm/tcg/t32.decode      |  4 +---\n target/arm/tcg/op_helper.c     |  4 +---\n target/arm/tcg/translate-a64.c | 17 +++++++++++++++++\n target/arm/tcg/translate.c     | 13 ++++++++-----\n 8 files changed, 50 insertions(+), 20 deletions(-)","diff":"diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h\nindex 77fdc5f3a17..340848793d4 100644\n--- a/target/arm/tcg/translate.h\n+++ b/target/arm/tcg/translate.h\n@@ -854,6 +854,24 @@ static inline void gen_restore_rmode(TCGv_i32 old, TCGv_ptr fpst)\n     gen_helper_set_rmode(old, old, fpst);\n }\n \n+/*\n+ * Event Register signalling.\n+ *\n+ * A bunch of activities trigger events, we just need to latch on to\n+ * true. The event eventually gets consumed by WFE/WFET.\n+ *\n+ * user-mode treats these as NOPs.\n+ */\n+\n+static inline void gen_event_reg(void)\n+{\n+#ifndef CONFIG_USER_ONLY\n+    TCGv_i32 set_event = tcg_constant_i32(1);\n+    QEMU_BUILD_BUG_ON(sizeof_field(CPUARMState, event_register) != 1);\n+    tcg_gen_st8_i32(set_event, tcg_env, offsetof(CPUARMState, event_register));\n+#endif\n+}\n+\n /*\n  * Helpers for implementing sets of trans_* functions.\n  * Defer the implementation of NAME to FUNC, with optional extra arguments.\ndiff --git a/target/arm/tcg/a32.decode b/target/arm/tcg/a32.decode\nindex f2ca4809495..547aa2b1490 100644\n--- a/target/arm/tcg/a32.decode\n+++ b/target/arm/tcg/a32.decode\n@@ -192,9 +192,8 @@ SMULTT           .... 0001 0110 .... 0000 .... 1110 ....      @rd0mn\n       WFE        ---- 0011 0010 0000 1111 ---- 0000 0010\n       WFI        ---- 0011 0010 0000 1111 ---- 0000 0011\n \n-      # TODO: Implement SEV, SEVL; may help SMP performance.\n-      # SEV      ---- 0011 0010 0000 1111 ---- 0000 0100\n-      # SEVL     ---- 0011 0010 0000 1111 ---- 0000 0101\n+      SEV        ---- 0011 0010 0000 1111 ---- 0000 0100\n+      SEVL       ---- 0011 0010 0000 1111 ---- 0000 0101\n \n       ESB        ---- 0011 0010 0000 1111 ---- 0001 0000\n     ]\ndiff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode\nindex 01b1b3e38be..dcb3099dd5c 100644\n--- a/target/arm/tcg/a64.decode\n+++ b/target/arm/tcg/a64.decode\n@@ -237,9 +237,8 @@ ERETA           1101011 0100 11111 00001 m:1 11111 11111 &reta  # ERETAA, ERETAB\n     YIELD       1101 0101 0000 0011 0010 0000 001 11111\n     WFE         1101 0101 0000 0011 0010 0000 010 11111\n     WFI         1101 0101 0000 0011 0010 0000 011 11111\n-    # We implement WFE to never block, so our SEV/SEVL are NOPs\n-    # SEV       1101 0101 0000 0011 0010 0000 100 11111\n-    # SEVL      1101 0101 0000 0011 0010 0000 101 11111\n+    SEV         1101 0101 0000 0011 0010 0000 100 11111\n+    SEVL        1101 0101 0000 0011 0010 0000 101 11111\n     # Our DGL is a NOP because we don't merge memory accesses anyway.\n     # DGL       1101 0101 0000 0011 0010 0000 110 11111\n     XPACLRI     1101 0101 0000 0011 0010 0000 111 11111\ndiff --git a/target/arm/tcg/t16.decode b/target/arm/tcg/t16.decode\nindex 778fbf16275..9a8f89538ac 100644\n--- a/target/arm/tcg/t16.decode\n+++ b/target/arm/tcg/t16.decode\n@@ -228,10 +228,8 @@ REVSH           1011 1010 11 ... ...            @rdm\n     WFE         1011 1111 0010 0000\n     WFI         1011 1111 0011 0000\n \n-    # M-profile SEV is implemented.\n-    # TODO: Implement SEV for other profiles, and SEVL for all profiles; may help SMP performance.\n     SEV         1011 1111 0100 0000\n-    # SEVL      1011 1111 0101 0000\n+    SEVL        1011 1111 0101 0000\n \n     # The canonical nop has the second nibble as 0000, but the whole of the\n     # rest of the space is a reserved hint, behaves as nop.\ndiff --git a/target/arm/tcg/t32.decode b/target/arm/tcg/t32.decode\nindex 49b8d0037ec..8ae277fe112 100644\n--- a/target/arm/tcg/t32.decode\n+++ b/target/arm/tcg/t32.decode\n@@ -369,10 +369,8 @@ CLZ              1111 1010 1011 ---- 1111 .... 1000 ....      @rdm\n         WFE      1111 0011 1010 1111 1000 0000 0000 0010\n         WFI      1111 0011 1010 1111 1000 0000 0000 0011\n \n-        # M-profile SEV is implemented.\n-        # TODO: Implement SEV for other profiles, and SEVL for all profiles; may help SMP performance.\n         SEV      1111 0011 1010 1111 1000 0000 0000 0100\n-        # SEVL   1111 0011 1010 1111 1000 0000 0000 0101\n+        SEVL     1111 0011 1010 1111 1000 0000 0000 0101\n \n         ESB      1111 0011 1010 1111 1000 0000 0001 0000\n       ]\ndiff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c\nindex 504526153a6..2b1fb1e059d 100644\n--- a/target/arm/tcg/op_helper.c\n+++ b/target/arm/tcg/op_helper.c\n@@ -476,9 +476,7 @@ void HELPER(sev)(CPUARMState *env)\n     CPUState *cs = env_cpu(env);\n     CPU_FOREACH(cs) {\n         ARMCPU *target_cpu = ARM_CPU(cs);\n-        if (arm_feature(&target_cpu->env, ARM_FEATURE_M)) {\n-            target_cpu->env.event_register = true;\n-        }\n+        target_cpu->env.event_register = true;\n         if (!qemu_cpu_is_self(cs)) {\n             qemu_cpu_kick(cs);\n         }\ndiff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c\nindex 25f0a806512..07014717316 100644\n--- a/target/arm/tcg/translate-a64.c\n+++ b/target/arm/tcg/translate-a64.c\n@@ -2033,6 +2033,23 @@ static bool trans_WFI(DisasContext *s, arg_WFI *a)\n     return true;\n }\n \n+static bool trans_SEV(DisasContext *s, arg_SEV *a)\n+{\n+    /*\n+     * SEV is a NOP for user-mode emulation.\n+     */\n+#ifndef CONFIG_USER_ONLY\n+    gen_helper_sev(tcg_env);\n+#endif\n+    return true;\n+}\n+\n+static bool trans_SEVL(DisasContext *s, arg_SEV *a)\n+{\n+    gen_event_reg();\n+    return true;\n+}\n+\n static bool trans_WFE(DisasContext *s, arg_WFI *a)\n {\n     /*\ndiff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c\nindex ce427c5a3ca..50d0184e84e 100644\n--- a/target/arm/tcg/translate.c\n+++ b/target/arm/tcg/translate.c\n@@ -3246,17 +3246,20 @@ static bool trans_YIELD(DisasContext *s, arg_YIELD *a)\n static bool trans_SEV(DisasContext *s, arg_SEV *a)\n {\n     /*\n-     * Currently SEV is a NOP for non-M-profile and in user-mode emulation.\n-     * For system-mode M-profile, it sets the event register.\n+     * SEV is a NOP for user-mode emulation.\n      */\n #ifndef CONFIG_USER_ONLY\n-    if (arm_dc_feature(s, ARM_FEATURE_M)) {\n-        gen_helper_sev(tcg_env);\n-    }\n+    gen_helper_sev(tcg_env);\n #endif\n     return true;\n }\n \n+static bool trans_SEVL(DisasContext *s, arg_SEV *a)\n+{\n+    gen_event_reg();\n+    return true;\n+}\n+\n static bool trans_WFE(DisasContext *s, arg_WFE *a)\n {\n     /*\n","prefixes":["v5","4/7"]}