{"id":2231083,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2231083/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430104434.1482407-5-alex.bennee@linaro.org/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/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":""},"msgid":"<20260430104434.1482407-5-alex.bennee@linaro.org>","date":"2026-04-30T10:44:31","name":"[v4,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.1/people/39532/?format=json","name":"Alex Bennée","email":"alex.bennee@linaro.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430104434.1482407-5-alex.bennee@linaro.org/mbox/","series":[{"id":502271,"url":"http://patchwork.ozlabs.org/api/1.1/series/502271/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502271","date":"2026-04-30T10:44:31","name":"target/arm: fully model WFxT instructions for A-profile","version":4,"mbox":"http://patchwork.ozlabs.org/series/502271/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2231083/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2231083/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=iEDEtUBc;\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 4g5rRR5fHcz1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 20:45:23 +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 1wIOt9-0008O6-Ak; Thu, 30 Apr 2026 06:44:59 -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 1wIOt0-0008H5-IM\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 06:44:51 -0400","from mail-wm1-x334.google.com ([2a00:1450:4864:20::334])\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 1wIOsu-0005KU-Fs\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 06:44:50 -0400","by mail-wm1-x334.google.com with SMTP id\n 5b1f17b1804b1-4893940bb5eso4454265e9.3\n for <qemu-devel@nongnu.org>; Thu, 30 Apr 2026 03:44:40 -0700 (PDT)","from draig.lan ([185.124.0.195]) by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-48a7c2fb999sm57693735e9.6.2026.04.30.03.44.35\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 30 Apr 2026 03:44:37 -0700 (PDT)","from draig.lan (localhost [IPv6:::1])\n by draig.lan (Postfix) with ESMTP id 2EF7B5F93C;\n Thu, 30 Apr 2026 11:44:35 +0100 (BST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1777545879; x=1778150679; 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=79oNSzazrmD/SxlRhRbJhCodKfa86P0QEATN+wnG5EA=;\n b=iEDEtUBcc3dpwF5dVcfSzie8szrOzc0XhMB2fJk0NbGlrvbL4tmRPE/Xbd2T5crHJU\n 1Wx3FGhVnUQ/vwrXqQ6cslTK80dZtlmsGyuzp/KRqdEjHsQ2oDlPyncZAzMqYdN89cuO\n 5G39q9eqcoFJgvK+SQXAJDn5C5w2EjH+wt/W5Z0PS2evO9kDY0Q9kysmBX5LDN70skFa\n T4CjSmyfjVx/40MfUZwlGhsddEpmRqXs6OUdLXJRsKuWW1+axTt+h1p9+/BiE3JD9OiH\n hx/aL7LWJ+h2AifmFeZKwAe1sgVHeBmW6CS8KAdKRZrlzO17hpGCoQ7FAKprQMN9X8Q8\n KJ5w==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777545879; x=1778150679;\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=79oNSzazrmD/SxlRhRbJhCodKfa86P0QEATN+wnG5EA=;\n b=nTpXMS1c2V3zOvWPOkBowVnhaHBco/H3c6bhsKFRYksHn8JiSvLC66Gs3a+f/DrVaI\n bE1k399ZHa7VY/8ufStX1LpPX5GeVsWVifH3U396rBbsksjWI6ysGUtW8mCybgIv8IW5\n ptq5rbdF80ATh9xbX3EGGK5EiCvuHtyu3+pVjwxI5BD1+Fz1am2NH8+fXkeyHIrrUc4h\n srnJWFOyAQ+v+3KwifjJDmV46jeUSKROTYdYr3by1o9xCsTIK2Hv81cYzOQ2Me90ld5W\n tBw8DuKUaCa4xp45uLYMEPliyVVWIvtUPMhx5XN6TaoGqqM1CFUshhOtzgi13KRByJkP\n t7wA==","X-Gm-Message-State":"AOJu0YwZY93L7TxE4KqiK0dm1o26q5mVAQsbo2bMFXI+5L0JDlj8eahr\n JHDhlC0sa5cxMh7s9oDM2c/R2OCaX6cviR8WolMWc8h7WVJ1WAeVYqNrYnDE8agZAG8=","X-Gm-Gg":"AeBDievvo6ZayZ/DGeq3lFJl7fHkKAmMRB9kWj5VLe+3Bn+mkaHIETm8czA/OfTbUsy\n VZRBgAV9Xq1yUeYez0EQhM51Jdx7kyv5WoDC1THHeLbNbLPEcaj2L38b7rvdGbx8sDyauJ7q8Ny\n y5hDK+RIDrhVKpV43eLv5O3Um0UXEMf24U+irBbM2RKfMkgETi2xEp1ckbCfeulrUOODvfJ0Azr\n qrw7Fwn13Z6Y2d8uFrw1jE7R27vuRfOmKw/5KMdCDBXPgZ6tK1p9itFisL6xNR2E/kOZ8dj0nYd\n LVRcztyMkUKOoe234lbCXbz6X3vJp3c65T5pg/iFR/ZPQ7+Q2PdMZYRummL6d7+96lEW0bTPwrk\n 1laiz7tplz0MhDC4vrq3XN/QCaYfTknzrb8UvtfrF/YlvAvVmdyCS4+I5m3G9rkCUHVb0q/ScYK\n IFLr3rPIfrjqSjqGWA8WUGCsRp76nu2gDx0g==","X-Received":"by 2002:a05:600c:4e46:b0:488:d243:8da9 with SMTP id\n 5b1f17b1804b1-48a844e49e3mr39845665e9.1.1777545878718;\n Thu, 30 Apr 2026 03:44:38 -0700 (PDT)","From":"=?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>","To":"qemu-devel@nongnu.org","Cc":"Mohamed Mediouni <mohamed@unpredictable.fr>, qemu-arm@nongnu.org,\n Pedro Barbuda <pbarbuda@microsoft.com>,\n Peter Maydell <peter.maydell@linaro.org>,\n Paolo Bonzini <pbonzini@redhat.com>, kvm@vger.kernel.org,\n Alexander Graf <agraf@csgraf.de>,\n =?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>","Subject":"[PATCH v4 4/7] target/arm: implements SEV/SEVL for all modes","Date":"Thu, 30 Apr 2026 11:44:31 +0100","Message-ID":"<20260430104434.1482407-5-alex.bennee@linaro.org>","X-Mailer":"git-send-email 2.47.3","In-Reply-To":"<20260430104434.1482407-1-alex.bennee@linaro.org>","References":"<20260430104434.1482407-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::334;\n envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.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\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":["v4","4/7"]}