get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.0/patches/2175261/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2175261,
    "url": "http://patchwork.ozlabs.org/api/1.0/patches/2175261/?format=api",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/1.0/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": "<20251217164549.4311-2-farosas@suse.de>",
    "date": "2025-12-17T16:45:47",
    "name": "[v2,1/2] target/ppc: Fix env->quiesced migration",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "18fad55fe45ab8ce9f9e61ea73db6901ddf206dc",
    "submitter": {
        "id": 85343,
        "url": "http://patchwork.ozlabs.org/api/1.0/people/85343/?format=api",
        "name": "Fabiano Rosas",
        "email": "farosas@suse.de"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20251217164549.4311-2-farosas@suse.de/mbox/",
    "series": [
        {
            "id": 485728,
            "url": "http://patchwork.ozlabs.org/api/1.0/series/485728/?format=api",
            "date": "2025-12-17T16:45:47",
            "name": "ppc: Fix migration issue with quiesced state",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/485728/mbox/"
        }
    ],
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2175261/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 (1024-bit key;\n unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256\n header.s=susede2_rsa header.b=KT8UW5z5;\n\tdkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=pSD3vPHR;\n\tdkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.a=rsa-sha256 header.s=susede2_rsa header.b=KT8UW5z5;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=pSD3vPHR;\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=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)",
            "smtp-out1.suse.de;\n\tnone"
        ],
        "Received": [
            "from lists.gnu.org (lists.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 4dWfpl0XWvz1xty\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 18 Dec 2025 03:47:11 +1100 (AEDT)",
            "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vVufh-0004Ne-03; Wed, 17 Dec 2025 11:46:41 -0500",
            "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1vVufA-0004GE-Dr\n for qemu-devel@nongnu.org; Wed, 17 Dec 2025 11:46:12 -0500",
            "from smtp-out1.suse.de ([195.135.223.130])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1vVuf2-00078h-9p\n for qemu-devel@nongnu.org; Wed, 17 Dec 2025 11:46:03 -0500",
            "from imap1.dmz-prg2.suse.org (unknown [10.150.64.97])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-out1.suse.de (Postfix) with ESMTPS id 439D4336A5;\n Wed, 17 Dec 2025 16:45:56 +0000 (UTC)",
            "from imap1.dmz-prg2.suse.org (localhost [127.0.0.1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E82773EA65;\n Wed, 17 Dec 2025 16:45:53 +0000 (UTC)",
            "from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167])\n by imap1.dmz-prg2.suse.org with ESMTPSA id kM+ZKUHeQmlyDQAAD6G6ig\n (envelope-from <farosas@suse.de>); Wed, 17 Dec 2025 16:45:53 +0000"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1765989956;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=TbvuXOg1Y4LlrzptIx8Hb9bXB4IRb9OH83ReYs2vues=;\n b=KT8UW5z5BBszDmV7/ydrLO2X6xPRt4Pr84cdHiPWot6/rC5co4YD6rz0mi7amNLvfa7kIh\n GabTFRmKBide2Wdkt0zL2cgqFMXFgnL9nboEbH1EDYAq35Lz3zu9iYdezUWVgBWDZ4k82i\n aEmJi8BIDYsNWsYVnAudGvgtOP+MkNo=",
            "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1765989956;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=TbvuXOg1Y4LlrzptIx8Hb9bXB4IRb9OH83ReYs2vues=;\n b=pSD3vPHRoaRkj2yIwxR4PM0RmNWG4ZrDt3R7talD9kd3dYpvlMCd7cpLx7x8YVQ2m8qXJH\n 4uVmDbxqFrTjC3Dg==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1765989956;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=TbvuXOg1Y4LlrzptIx8Hb9bXB4IRb9OH83ReYs2vues=;\n b=KT8UW5z5BBszDmV7/ydrLO2X6xPRt4Pr84cdHiPWot6/rC5co4YD6rz0mi7amNLvfa7kIh\n GabTFRmKBide2Wdkt0zL2cgqFMXFgnL9nboEbH1EDYAq35Lz3zu9iYdezUWVgBWDZ4k82i\n aEmJi8BIDYsNWsYVnAudGvgtOP+MkNo=",
            "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1765989956;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=TbvuXOg1Y4LlrzptIx8Hb9bXB4IRb9OH83ReYs2vues=;\n b=pSD3vPHRoaRkj2yIwxR4PM0RmNWG4ZrDt3R7talD9kd3dYpvlMCd7cpLx7x8YVQ2m8qXJH\n 4uVmDbxqFrTjC3Dg=="
        ],
        "From": "Fabiano Rosas <farosas@suse.de>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "thuth@redhat.com, peterx@redhat.com, Fabian Vogt <fvogt@suse.de>,\n Nicholas Piggin <npiggin@gmail.com>,\n Harsh Prateek Bora <harshpb@linux.ibm.com>,\n Chinmay Rath <rathc@linux.ibm.com>",
        "Subject": "[PATCH v2 1/2] target/ppc: Fix env->quiesced migration",
        "Date": "Wed, 17 Dec 2025 13:45:47 -0300",
        "Message-ID": "<20251217164549.4311-2-farosas@suse.de>",
        "X-Mailer": "git-send-email 2.51.0",
        "In-Reply-To": "<20251217164549.4311-1-farosas@suse.de>",
        "References": "<20251217164549.4311-1-farosas@suse.de>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Spamd-Result": "default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%];\n NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[];\n R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000];\n MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[];\n RCVD_VIA_SMTP_AUTH(0.00)[];\n FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[];\n MIME_TRACE(0.00)[0:+];\n FREEMAIL_CC(0.00)[redhat.com,suse.de,gmail.com,linux.ibm.com];\n DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,gitlab.com:url,suse.de:mid,suse.de:email];\n FROM_HAS_DN(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7];\n RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[];\n FROM_EQ_ENVFROM(0.00)[]; TO_DN_SOME(0.00)[];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n FREEMAIL_ENVRCPT(0.00)[gmail.com]",
        "X-Spam-Score": "-2.80",
        "Received-SPF": "pass client-ip=195.135.223.130; envelope-from=farosas@suse.de;\n helo=smtp-out1.suse.de",
        "X-Spam_score_int": "-43",
        "X-Spam_score": "-4.4",
        "X-Spam_bar": "----",
        "X-Spam_report": "(-4.4 / 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_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,\n RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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-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": "The commit referenced (from QEMU 10.0) has changed the way the pseries\nmachine marks a cpu as quiesced. Previously, the cpu->halted value\nfrom QEMU common cpu code was (incorrectly) used. With the fix, the\nenv->quiesced variable starts being used, which improves on the\noriginal situation, but also causes a side effect after migration:\n\nThe env->quiesced is set at reset and never migrated, which causes the\ndestination QEMU to stop delivering interrupts and hang the machine.\n\nTo fix the issue from this point on, start migrating the env->quiesced\nvalue.\n\nFor QEMU versions < 10.0, sending the new element on the stream would\ncause migration to be aborted, so add the appropriate compatibility\nproperty to omit the new subsection.\n\nIndependently of this patch, all migrations from QEMU versions < 10.0\nwould result in a hang since the older QEMU never migrates\nenv->quiesced. This is bad because it leaves machines already running\non the old QEMU without a migration path into newer versions.\n\nAs a workaround, use a few heuristics to infer the new value of\nenv->quiesced based on cpu->halted, LPCR and PSSCR bits that are\nusually set/cleared along with quiesced.\n\nNote that this was tested with -cpu power9 and -machine ic-mode=xive\ndue to another bug affecting migration of XICS guests. Tested both\nforward and backward migration and savevm/loadvm from 9.2 and 10.0.\n\nAlso tested loadvm of a savevm image that contains a mix of cpus both\nhalted and not halted.\n\nReported-by: Fabian Vogt <fvogt@suse.de>\nResolves: https://gitlab.com/qemu-project/qemu/-/issues/3079\nFixes: fb802acdc8b (\"ppc/spapr: Fix RTAS stopped state\")\nSigned-off-by: Fabiano Rosas <farosas@suse.de>\n---\n hw/ppc/spapr.c        |  6 +++++\n target/ppc/cpu.h      |  1 +\n target/ppc/cpu_init.c |  7 +++++\n target/ppc/machine.c  | 63 +++++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 77 insertions(+)",
    "diff": "diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c\nindex 99b843ba2f..9dde61a667 100644\n--- a/hw/ppc/spapr.c\n+++ b/hw/ppc/spapr.c\n@@ -4776,8 +4776,14 @@ DEFINE_SPAPR_MACHINE(10, 1);\n  */\n static void spapr_machine_10_0_class_options(MachineClass *mc)\n {\n+    static GlobalProperty spapr_compat_10_0[] = {\n+        { TYPE_POWERPC_CPU, \"rtas-stopped-state\", \"false\" },\n+    };\n+\n     spapr_machine_10_1_class_options(mc);\n     compat_props_add(mc->compat_props, hw_compat_10_0, hw_compat_10_0_len);\n+    compat_props_add(mc->compat_props, spapr_compat_10_0,\n+                     G_N_ELEMENTS(spapr_compat_10_0));\n }\n \n DEFINE_SPAPR_MACHINE(10, 0);\ndiff --git a/target/ppc/cpu.h b/target/ppc/cpu.h\nindex 787020f6f9..bbd661e96c 100644\n--- a/target/ppc/cpu.h\n+++ b/target/ppc/cpu.h\n@@ -1529,6 +1529,7 @@ struct ArchCPU {\n     void *machine_data;\n     int32_t node_id; /* NUMA node this CPU belongs to */\n     PPCHash64Options *hash64_opts;\n+    bool rtas_stopped_state;\n \n     /* Those resources are used only during code translation */\n     /* opcode handlers */\ndiff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c\nindex 86ead740ee..8dac1cd812 100644\n--- a/target/ppc/cpu_init.c\n+++ b/target/ppc/cpu_init.c\n@@ -55,6 +55,11 @@\n /* #define PPC_DEBUG_SPR */\n /* #define USE_APPLE_GDB */\n \n+static const Property powerpc_cpu_properties[] = {\n+    DEFINE_PROP_BOOL(\"rtas-stopped-state\", PowerPCCPU,\n+                      rtas_stopped_state, true),\n+};\n+\n static inline void vscr_init(CPUPPCState *env, uint32_t val)\n {\n     /* Altivec always uses round-to-nearest */\n@@ -7529,6 +7534,8 @@ static void ppc_cpu_class_init(ObjectClass *oc, const void *data)\n                                       &pcc->parent_unrealize);\n     pcc->pvr_match = ppc_pvr_match_default;\n \n+    device_class_set_props(dc, powerpc_cpu_properties);\n+\n     resettable_class_set_parent_phases(rc, NULL, ppc_cpu_reset_hold, NULL,\n                                        &pcc->parent_phases);\n \ndiff --git a/target/ppc/machine.c b/target/ppc/machine.c\nindex d72e5ecb94..ba63a7debb 100644\n--- a/target/ppc/machine.c\n+++ b/target/ppc/machine.c\n@@ -6,6 +6,7 @@\n #include \"mmu-hash64.h\"\n #include \"migration/cpu.h\"\n #include \"qapi/error.h\"\n+#include \"qemu/error-report.h\"\n #include \"kvm_ppc.h\"\n #include \"power8-pmu.h\"\n #include \"system/replay.h\"\n@@ -257,6 +258,45 @@ static int cpu_post_load(void *opaque, int version_id)\n         ppc_store_sdr1(env, env->spr[SPR_SDR1]);\n     }\n \n+    if (!cpu->rtas_stopped_state) {\n+        /*\n+         * The source QEMU doesn't have fb802acdc8 and still uses halt +\n+         * PM bits in LPCR to implement RTAS stopped state. The new (this)\n+         * QEMU will have put the secondary vcpus in stopped state,\n+         * waiting for the start-cpu RTAS call. That call will never come\n+         * if the source cpus were already running. Try to infer the cpus\n+         * state and set env->quiesced accordingly.\n+         *\n+         * env->quiesced = true  ==> the cpu is waiting to start\n+         * env->quiesced = false ==> the cpu is running (unless halted)\n+         */\n+\n+        /*\n+         * Halted _could_ mean quiesced, but it could also be cede,\n+         * confer_self, power management, etc.\n+         */\n+        if (CPU(cpu)->halted) {\n+            PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);\n+            /*\n+             * Both the PSSCR_EC bit and LPCR PM bits set at cpu reset\n+             * and rtas_stop and cleared at rtas_start, it's a good\n+             * heuristic.\n+             */\n+            if ((env->spr[SPR_PSSCR] & PSSCR_EC) &&\n+                (env->spr[SPR_LPCR] & pcc->lpcr_pm)) {\n+                env->quiesced = true;\n+            } else {\n+                env->quiesced = false;\n+            }\n+        } else {\n+            /*\n+             * Old QEMU sets halted during rtas_stop_self. Not halted,\n+             * therefore definitely not quiesced.\n+             */\n+            env->quiesced = false;\n+        }\n+    }\n+\n     post_load_update_msr(env);\n \n     if (tcg_enabled()) {\n@@ -649,6 +689,28 @@ static const VMStateDescription vmstate_reservation = {\n     }\n };\n \n+static bool rtas_stopped_needed(void *opaque)\n+{\n+    PowerPCCPU *cpu = opaque;\n+\n+    return cpu->rtas_stopped_state;\n+}\n+\n+static const VMStateDescription vmstate_rtas_stopped = {\n+    .name = \"cpu/rtas_stopped\",\n+    .version_id = 1,\n+    .minimum_version_id = 1,\n+    .needed = rtas_stopped_needed,\n+    .fields = (const VMStateField[]) {\n+        /*\n+         * \"RTAS stopped\" state, independent of halted state. For QEMU\n+         * < 10.0, this is taken from cpu->halted at cpu_post_load()\n+         */\n+        VMSTATE_BOOL(env.quiesced, PowerPCCPU),\n+        VMSTATE_END_OF_LIST()\n+    }\n+};\n+\n #ifdef TARGET_PPC64\n static bool bhrb_needed(void *opaque)\n {\n@@ -715,6 +777,7 @@ const VMStateDescription vmstate_ppc_cpu = {\n         &vmstate_tlbmas,\n         &vmstate_compat,\n         &vmstate_reservation,\n+        &vmstate_rtas_stopped,\n         NULL\n     }\n };\n",
    "prefixes": [
        "v2",
        "1/2"
    ]
}