From nobody Wed Feb 11 04:06:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.43 as permitted sender) client-ip=209.85.221.43; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f43.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1621248757; cv=none; d=zohomail.com; s=zohoarc; b=nmi8ZV/dtwCGIINSMsfj6MG7K62F5blq7px0d1fcCpA6gttea5Fj1evZ7AtEeeZ7868ejHHoVJ68AzoZBz+pSEJi8hxDpEwc5ZNpSKvE40KsP5xZOF3kg6LJn89mqM+Evz+rq9GH+MOAFc3820Tn2/9RGRt/MzPhunyTFbaKxG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621248757; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=62bRjuN6Hv82DBcOqLhZSxPlLlMeXZkMX2kFXTADKa8=; b=DMaRNRBf/wL4+YtwU3FeWeKuY6mYC3Q3JdTe/x0LjY7CRvNBN5PU0s7Cqzbr5g02vWGQ9hj9pGeegcMHUZNch9zeKbz36DNzRCRnDVgEw0XVCk8nbfBn8TSagS79OteTkh/TKB2caWroP/TQ1Y83aDPN1WSaDUbmRjMEF0PZ4NI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by mx.zohomail.com with SMTPS id 1621248757816886.8305770879027; Mon, 17 May 2021 03:52:37 -0700 (PDT) Received: by mail-wr1-f43.google.com with SMTP id x8so5864701wrq.9 for ; Mon, 17 May 2021 03:52:37 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id n7sm16178413wri.14.2021.05.17.03.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 03:52: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=62bRjuN6Hv82DBcOqLhZSxPlLlMeXZkMX2kFXTADKa8=; b=WRR9/ZTGXumMwQZEBcx5Hs6N/5Olc0JagEXe+Tmnno2wD6IAr3o7LfKMfRoqj4pqSe yiYcxf6JAJYranESSCijaJ+stNpiHhYTIMTWKPa1DqEHM+0e9lzTPw0bUv/42NB8g2la DW7YEx32YzsytDjFXT0EyWGnXPz2+wQhlfKeujlrH0Ciqu03oo7d9eAhXaF8xKa4aCoT +kP6v92Sd4auYTQraXwNYBW3jwnIWsgfhxL3Vzz8T8mbu1XuER/Qxdrb626CH15f9DLk Edd73Er13ctIL3c7dY9ogD/Sk84sJn0mJMk1mx6jvbk4z5yS6UIDnrkx/RIcxU4+U53Y KZEw== 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=62bRjuN6Hv82DBcOqLhZSxPlLlMeXZkMX2kFXTADKa8=; b=MPpp4L73MrTfa9dHSHe9vzt2qHsZBtcbyzLSAqZKqXvYm4a/VcgCSoTSeW0FkVb79c i6fXixFYSmoxFg/O2ZyuZssJ3CMbdXNd4wB0JPiAL4XFXjBbdJAcPrdfhpl7MAIFJnvC iZC7eTo+JVyFPiwgk1CPPA4P4qXVU7uigCavihGgN97Q3tGjAoOU5HPa+/Y5pani6ODx P3K8O3QUY6W2nR+vkOyuNLGzvf3yDt50S0/IuZmW/a7kQGwt8dXL4cYzajibsKpKBvBn 6fRYE/jUxBAAdvJmm65xXhYwcLUvUEoSTSntA5w6Oy7ANrMPIiyDSU7Z8WarcWObML+G ws6g== X-Gm-Message-State: AOAM530pHLRelR6rh8aslS0eHf0MHessdSpWkr4S6mk0uN46sBGSReis lZfHsLaTmLt1ER6RNwvkLOs= X-Google-Smtp-Source: ABdhPJxuGh9k7KDPLVkU7UAl8Q8bHZEURJ6FKu4cwawa4wjyB94cF4Ev29l3JvoZfhva4rx3vPJsrw== X-Received: by 2002:adf:f14d:: with SMTP id y13mr2556205wro.261.1621248755997; Mon, 17 May 2021 03:52: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: qemu-s390x@nongnu.org, Richard Henderson , qemu-arm@nongnu.org, Laurent Vivier , Paolo Bonzini , qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v7 11/23] cpu: Assert DeviceClass::vmsd is NULL on user emulation Date: Mon, 17 May 2021 12:51:28 +0200 Message-Id: <20210517105140.1062037-12-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210517105140.1062037-1-f4bug@amsat.org> References: <20210517105140.1062037-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. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- v7: Check vmsd->unmigratable (David) --- cpu.c | 2 ++ target/sh4/cpu.c | 5 +++-- target/xtensa/cpu.c | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cpu.c b/cpu.c index 34a0484bf41..6fe4af27975 100644 --- a/cpu.c +++ b/cpu.c @@ -141,6 +141,8 @@ 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 || + qdev_get_vmsd(DEVICE(cpu))->unmigratable); 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/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