From patchwork Wed May 26 23:46:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 448686 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp26085jac; Wed, 26 May 2021 17:14:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRuRVNxgOZZ75kuUX48b/oO5kjU8Jk/31MYNGDpukEwwxTnWfp8U2vNYIaeXu7rLPn14H0 X-Received: by 2002:a6b:d103:: with SMTP id l3mr659614iob.159.1622074467838; Wed, 26 May 2021 17:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622074467; cv=none; d=google.com; s=arc-20160816; b=Lfr3Dnvx7XOwGXG7WgLZnfqOaelYPRD4g2JiOKZpDJpK7BJqajJJJcK+h8bHKoUzvy plImTnoKG+NTVbS34v5jyX2mvIUMGG8s3Jfx1jdOQoO2oY0Mv4yWj8cZSEd/KVkGOxX7 uaS4/8xY2/rgJa6wNg++vHNboGV0U9Y7cLFWznI2nJ6ksAdVBFvFjUjRboHAlv/BaJ2k 1hOnxMFYrUUUtZ/VS1IcIB/qakNC9dndI2qXXxhD7lN0H4w/k9BFEriyEXGzuDSz/pS3 oYvJq2p7pq4aJH/Fq6atK9+U7aSnhchvMLuw7iUCq+NBspTR2+v9dAqQoeqBa0nAClMG +vnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=e6BEiCbeKFz5loqZtzxI2JeaF9i9lMWYWU5RWY4z+jo=; b=bTsfXn8tozej1X1GcOoROzrb+88CkTn163aBPejrvkQKndGbpf8+Hi33iSPl9lY+iV 98qpqHOPkgAeV/NqvyKDEudOolbFeCwQINO8fT8i3lWFFxjgbFYvw8ybRcG3pg7s1KOC J8QipucIvVdfFQGVIITgu4DXVCZO8vNxFCF50DyQvZkj9ik4aRe1pClcmNzco5ZFaf3N ez+mVDklGoZfwF37zBm0250u9+wsitGuf+uo9amwNl4aHhb2YSdmRnu3X/FCj886+cFX SuNwfFq41wk+OrueqLdurifviSUyr9FogCYFRGWmvy6n4y3oHygu3cQNF4+vTkxaCtL2 l4mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s0ePgidF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l11si894555jak.61.2021.05.26.17.14.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 May 2021 17:14:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s0ePgidF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lm3fP-0004AG-7p for patch@linaro.org; Wed, 26 May 2021 20:14:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lm3FO-0005kq-KO for qemu-devel@nongnu.org; Wed, 26 May 2021 19:47:34 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:38899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lm3FI-0004Vz-Kd for qemu-devel@nongnu.org; Wed, 26 May 2021 19:47:34 -0400 Received: by mail-pl1-x62b.google.com with SMTP id 69so1422329plc.5 for ; Wed, 26 May 2021 16:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e6BEiCbeKFz5loqZtzxI2JeaF9i9lMWYWU5RWY4z+jo=; b=s0ePgidFtxmL/mVzo3BVldMMiwsrS76yEBmP2pYhvhZ5B6b1RbTeN3cx2Xyhu7c3Je MGzid/cWrutbXFCDzXDfu0xhnp6vBioRA0t9CHVMkywaBEAPlujNKNUdMIGgydN2ZOxm yRjdsMPCp+mEf5YFLdoJuev0bQvZDN7YrslHKATtCtJMoFIE2dFBN4lUT5LPkXl4WgwA /vyfF8IEnroT2IXi4vjEqo3eLQibcq8cXINQNErmzTIdKEQeZn5RvSIPB9SNmCDI86Ei 7b3mYh97+/UnPgFdvXHqWdb0CfQAvKpPw4BWPGF0s34sD+wigFxyG9CQB/OYeTfdwprs TUHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e6BEiCbeKFz5loqZtzxI2JeaF9i9lMWYWU5RWY4z+jo=; b=giKPYGV61S/qcJWburHxYD0FsU0YjgyQk5LEFTTiADc6CDMLk4flw5jJOIYtXLBqUh hxhMvcMu/YQqQzwhi2rT0kLNGaHewghAPfXN3KhVLdNm22CFsoiC69oD4BXGmaybvZr0 /AFHYje4L9h98+r9AACwo3Yjgfbe+5hord4rbwC5KiEHEYUkaRmH9SP20nomZlMFda/c 8HcIPYRkubZqZqgHl3/ZdYUlzqEkTp1TuLxxaww+NrzdpNprCiEP0o+dKQ8ITj97lBCj a82AeYDPyeTKXXX1DeEUZuK4sF6840/pEUuVfttZPrfwNs3qRXNRSWMk9aSOxtVcBHqD e1VQ== X-Gm-Message-State: AOAM531xigTNOI08S7Eq6dsnR6fYSTThcS6rMXDH2jEeAL9Jj0/DCFkz BYKtwjSUYBpklxfOFWFwPVIOaWBxOtks4A== X-Received: by 2002:a17:90a:fa6:: with SMTP id 35mr685681pjz.186.1622072847280; Wed, 26 May 2021 16:47:27 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id g13sm285355pfi.18.2021.05.26.16.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 16:47:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 18/31] cpu: Assert DeviceClass::vmsd is NULL on user emulation Date: Wed, 26 May 2021 16:46:57 -0700 Message-Id: <20210526234710.125396-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210526234710.125396-1-richard.henderson@linaro.org> References: <20210526234710.125396-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé 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é Reviewed-by: Richard Henderson Message-Id: <20210517105140.1062037-12-f4bug@amsat.org> Signed-off-by: Richard Henderson --- cpu.c | 2 ++ target/sh4/cpu.c | 5 +++-- target/xtensa/cpu.c | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) -- 2.25.1 diff --git a/cpu.c b/cpu.c index 34a0484bf4..6fe4af2797 100644 --- a/cpu.c +++ b/cpu.c @@ -141,6 +141,8 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) #endif /* CONFIG_TCG */ #ifdef CONFIG_USER_ONLY + assert(qdev_get_vmsd(DEVICE(cpu)) == NULL || + qdev_get_vmsd(DEVICE(cpu))->unmigratable); assert(cc->vmsd == NULL); #else if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index ac65c88f1f..35d4251aaf 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 = &(env->movcal_backup); } +#ifndef CONFIG_USER_ONLY static const VMStateDescription vmstate_sh_cpu = { .name = "cpu", .unmigratable = 1, }; +#endif #include "hw/core/tcg-cpu-ops.h" @@ -257,12 +259,11 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = superh_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = superh_cpu_get_phys_page_debug; + dc->vmsd = &vmstate_sh_cpu; #endif cc->disas_set_info = superh_cpu_disas_set_info; cc->gdb_num_core_regs = 59; - - dc->vmsd = &vmstate_sh_cpu; cc->tcg_ops = &superh_tcg_ops; } diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 210ef80092..0267571fbd 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -175,10 +175,12 @@ static void xtensa_cpu_initfn(Object *obj) #endif } +#ifndef CONFIG_USER_ONLY static const VMStateDescription vmstate_xtensa_cpu = { .name = "cpu", .unmigratable = 1, }; +#endif #include "hw/core/tcg-cpu-ops.h" @@ -215,9 +217,9 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug; + dc->vmsd = &vmstate_xtensa_cpu; #endif cc->disas_set_info = xtensa_cpu_disas_set_info; - dc->vmsd = &vmstate_xtensa_cpu; cc->tcg_ops = &xtensa_tcg_ops; }