From nobody Wed Nov 5 23:49:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.41 as permitted sender) client-ip=209.85.128.41; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f41.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.41 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1619120377; cv=none; d=zohomail.com; s=zohoarc; b=YlQ8frFrRRbtW892G2DV20WT/i0KDHrJd+hDueiPD5uTe5DzohpSkFAIYsVryFG3dBEpWVom4kZiCseIZronLKOu9RFhUJj5g/E1lO32C56uBrGrwrbTI8C6RIy5qjsbBxB7lXjLImRbT8DnmILJkJNESKz9iQpjzc5BVR5+jcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619120377; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kR/07YuyIEQWuHZD87qpk3O+O1bGxZyn441vbmFYrqk=; b=PBXc3isegFv3gCuqfisi/ma9QiTWADK7I1NWMoKhYZxkSzAMMp24EMCDnkyq+qvqjyEHdgtu6RnDBpmICZV9RxUZxRrQ74mmmwlqBaalbfwNPqEeYW1qAbRvJTTV4COQRTzlKQ/rqSS3igsPfEnJrkvLq+QlZlyb+dOxgcdbgHk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.41 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by mx.zohomail.com with SMTPS id 1619120377704130.1286985663437; Thu, 22 Apr 2021 12:39:37 -0700 (PDT) Received: by mail-wm1-f41.google.com with SMTP id y5-20020a05600c3645b0290132b13aaa3bso1026wmq.1 for ; Thu, 22 Apr 2021 12:39:37 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (39.red-81-40-121.staticip.rima-tde.net. [81.40.121.39]) by smtp.gmail.com with ESMTPSA id s14sm5052614wrm.51.2021.04.22.12.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 12:39:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kR/07YuyIEQWuHZD87qpk3O+O1bGxZyn441vbmFYrqk=; b=B61HVxiHPvc2L1Q3rWC05ArMLEC43GpyOd0QNbmsgh0jYMsLaJgyRnSufjZCxpCZfc QeaDb5jYj1O4HVDDsPP0FyykEPfXuebljtGPmWaZZpNPdg1zPlQXSPLne8wo5g+rhgqL MSxc6R2OuWrGvoRkhmaLycS9PYT6d2EUF5jdtBJKfPt+nWNHjKHav8DKAXHzTGAnWvBX vly7gcCrJDfF5HdaQ3Hwbqt+Fr+1KmHeaWSJCGtdlY68hzmwF0VzTJkD0K1/dHPMv69R BL4NPQNRM0xwuG0m0vgDrK75saORy2Og6N6BaBWsgI3u+ag3JoaGI6cpC8Fc8qakhxxl m6pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=kR/07YuyIEQWuHZD87qpk3O+O1bGxZyn441vbmFYrqk=; b=HujokbXWfjQ3rIXhirgyQc/XeFjRbVHyZYY1S41VAl4Ondtp9cdKsZwwaJq9JELGl8 fQfh7pVPq8Fhm6+DZZVboe7KObeCfef6uiRG5/WaP39yGCjzcR8SxS3gz3nQ10H+v3vk AWAcxtyZZPGrf9JJYEz3gbesP8l9Ajfjq02PO6k84n/uNxpG6xLpfIgQG8lJ6CUTcsTj I15a/T0lToULNDUYIFNUPv4NXwiWgF1rsRcyolh1AmNpq2yGR+H65xmPFgEgOWz5GUQd 8dlyYAttkCPrU3/ui/zpp3nv0+paRHYRTa5ljzbQfZJa6n+Xo6DPAymPdTvv7T88JyAR MH/Q== X-Gm-Message-State: AOAM530VAUeLEBQybk/CmIR8Zrwy0jVgf+jmnZnIMYQSkP0ZVAcch8Iz FUHUFqwapXPHqh5IT1WQnvY= X-Google-Smtp-Source: ABdhPJzk+c0E3j8WXodKdxjcpUdgd3h2Ptl8ACAVLC1Zse3Q3pZjVjVabU66yn5XYMaQ5ZckFQVqrg== X-Received: by 2002:a7b:c7c8:: with SMTP id z8mr1754764wmk.112.1619120375904; Thu, 22 Apr 2021 12:39:35 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , qemu-riscv@nongnu.org, Juan Quintela , Peter Maydell , Claudio Fontana , qemu-arm@nongnu.org, Eduardo Habkost , qemu-ppc@nongnu.org, Richard Henderson , Laurent Vivier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Yoshinori Sato , Guan Xuetao , Max Filippov Subject: [PATCH v6 06/18] cpu: Assert DeviceClass::vmsd is NULL on user emulation Date: Thu, 22 Apr 2021 21:38:50 +0200 Message-Id: <20210422193902.2644064-7-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210422193902.2644064-1-f4bug@amsat.org> References: <20210422193902.2644064-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Migration is specific to system emulation. Restrict current DeviceClass::vmsd to sysemu using #ifdef'ry, and assert in cpu_exec_realizefn() that dc->vmsd not set under user emulation. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- cpu.c | 1 + target/sh4/cpu.c | 5 +++-- target/unicore32/cpu.c | 4 ++++ target/xtensa/cpu.c | 4 +++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cpu.c b/cpu.c index bfbe5a66f95..4fed04219df 100644 --- a/cpu.c +++ b/cpu.c @@ -138,6 +138,7 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) #endif /* CONFIG_TCG */ =20 #ifdef CONFIG_USER_ONLY + assert(qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL); assert(cc->vmsd =3D=3D NULL); #else if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index ac65c88f1f8..35d4251aaf3 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -218,10 +218,12 @@ static void superh_cpu_initfn(Object *obj) env->movcal_backup_tail =3D &(env->movcal_backup); } =20 +#ifndef CONFIG_USER_ONLY static const VMStateDescription vmstate_sh_cpu =3D { .name =3D "cpu", .unmigratable =3D 1, }; +#endif =20 #include "hw/core/tcg-cpu-ops.h" =20 @@ -257,12 +259,11 @@ static void superh_cpu_class_init(ObjectClass *oc, vo= id *data) cc->gdb_write_register =3D superh_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D superh_cpu_get_phys_page_debug; + dc->vmsd =3D &vmstate_sh_cpu; #endif cc->disas_set_info =3D superh_cpu_disas_set_info; =20 cc->gdb_num_core_regs =3D 59; - - dc->vmsd =3D &vmstate_sh_cpu; cc->tcg_ops =3D &superh_tcg_ops; } =20 diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index 0258884f845..a74ac7b6140 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -115,10 +115,12 @@ static void uc32_cpu_initfn(Object *obj) #endif } =20 +#ifndef CONFIG_USER_ONLY static const VMStateDescription vmstate_uc32_cpu =3D { .name =3D "cpu", .unmigratable =3D 1, }; +#endif =20 #include "hw/core/tcg-cpu-ops.h" =20 @@ -146,7 +148,9 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *= data) cc->dump_state =3D uc32_cpu_dump_state; cc->set_pc =3D uc32_cpu_set_pc; cc->get_phys_page_debug =3D uc32_cpu_get_phys_page_debug; +#ifndef CONFIG_USER_ONLY dc->vmsd =3D &vmstate_uc32_cpu; +#endif cc->tcg_ops =3D &uc32_tcg_ops; } =20 diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index e2b2c7a71c1..a66527e2d45 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -176,10 +176,12 @@ static void xtensa_cpu_initfn(Object *obj) #endif } =20 +#ifndef CONFIG_USER_ONLY static const VMStateDescription vmstate_xtensa_cpu =3D { .name =3D "cpu", .unmigratable =3D 1, }; +#endif =20 #include "hw/core/tcg-cpu-ops.h" =20 @@ -216,9 +218,9 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void= *data) cc->gdb_stop_before_watchpoint =3D true; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D xtensa_cpu_get_phys_page_debug; + dc->vmsd =3D &vmstate_xtensa_cpu; #endif cc->disas_set_info =3D xtensa_cpu_disas_set_info; - dc->vmsd =3D &vmstate_xtensa_cpu; cc->tcg_ops =3D &xtensa_tcg_ops; } =20 --=20 2.26.3