From nobody Fri Nov 14 00:46:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583755943; cv=none; d=zohomail.com; s=zohoarc; b=Msnyx3rGPopUlKRjzofkk/7kMBVDsY//1aN2fP4liKibzNjO74IAZw4//FyEnaqCIC/C3I8dQ2B59ibOkKzTQwsXC1sen6vkESaKS9isyPijlokvDvw1Xqq3LT3RPhTV02+si1VNMeXMDqdl04HTBdicwww8chtwqxu74CAhBi8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583755943; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZXgAGrtPhgvzRQUXqhGwMk2tMOYYjzi9xaVe5yS64Z0=; b=CSPgLIk95TWau/0sLdrIi9AlL5d07VyaizPdlyeEzKEsX9IE+MpKgq6vmLWr8QWaOCc9Fep3b4bwHxTuCqnvjwBHKC7Oz2zE9f503/d3qUUg2btvmAFc5PApfMWIDhnDvX/AIIlWofy4o4Ir8odyowVs7ZF3rK6p0P1Ho/NVLGs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158375594385039.271028425466966; Mon, 9 Mar 2020 05:12:23 -0700 (PDT) Received: from localhost ([::1]:41942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBHGf-0004ga-QO for importer@patchew.org; Mon, 09 Mar 2020 08:12:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55635) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBHFg-0003gS-9l for qemu-devel@nongnu.org; Mon, 09 Mar 2020 08:11:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBHFf-0008Nr-1h for qemu-devel@nongnu.org; Mon, 09 Mar 2020 08:11:20 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:29179 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBHFe-0008MD-U5 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 08:11:18 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-16-gdC24AESNpWBG2KJmuneIA-1; Mon, 09 Mar 2020 08:11:16 -0400 Received: by mail-ed1-f72.google.com with SMTP id p17so2567028edt.20 for ; Mon, 09 Mar 2020 05:11:16 -0700 (PDT) Received: from localhost.localdomain (47.red-88-21-205.staticip.rima-tde.net. [88.21.205.47]) by smtp.gmail.com with ESMTPSA id a22sm2771026edx.25.2020.03.09.05.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2020 05:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583755878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZXgAGrtPhgvzRQUXqhGwMk2tMOYYjzi9xaVe5yS64Z0=; b=Pi0cDb4yQqy1Qi3wpBSrpfm2nq9wd89nhi14hNfl8GH6Srt6F3I+Q3wEZBkkFn4M7aSxls zrme7DoMisYj/FjAhj1c/SPRVXnUPESbt8YWu8ojMzrdxJk43qrfAkwaj//qJkgPwn/yxf n5TVVKFVrZ4/JZ10oZbTIvVM7rmZToA= X-MC-Unique: gdC24AESNpWBG2KJmuneIA-1 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=3ecVRP3opc1bGNljJ0SHMIFQGzksaL6md721N6NDR1Y=; b=h4Sz2mBcHnoataKZnPMgkz/2/iedAeymsrMBtiCd2h7j3ysyYDpFADngYDgmbUIQaM I6YZpQDoMZESxbrBhFEecnHzgRqFvvBq2qn7tbKDjr5hGymYw1oiQMGf/s+zFp8YOyZ0 qzSVubM9s35QuRfUCU04e8+Tw4KOZaBvLCpyFq52DEX/d/w6/UJ3tRBZJDwBrFhgPKzQ tgBfrYwzJKVFcCIFqRaBKOn9hgXlJSwMxc0dNfuTsNNIu/HsmMqeN/eIulBIApbIoIJ2 XMHaXUzLC6J8WJJXvnlxjG6VBMVRLK2JK1GUcinQ1G54O6//qoE8slXULRuZCpyRPqpO ZcDg== X-Gm-Message-State: ANhLgQ0wlbq4h5Uuqj/S9SoXP6dDhjKdzrn8SW5uFJ22ZXbYl/WxUKZz gyeFJtLUbS00/jmVRE8Xnnj77+z4K7kRokpFONywzaF4C7OF26N7jq1siQsAMGjPKgl2abMmLwb wpugqqxp7LhB0njQ= X-Received: by 2002:a50:ff09:: with SMTP id a9mr16288250edu.157.1583755873067; Mon, 09 Mar 2020 05:11:13 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvyaYsutgc3cOXPbr+YH7cJP2+1avA+Vn46vBRKl6DXVkc7BvhXZ9bbg+5ZgN6fdlPIPzzXHg== X-Received: by 2002:a50:ff09:: with SMTP id a9mr16288232edu.157.1583755872882; Mon, 09 Mar 2020 05:11:12 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/2] cpu: Do not reset a vCPU before it is created Date: Mon, 9 Mar 2020 13:11:02 +0100 Message-Id: <20200309121103.20234-2-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200309121103.20234-1-philmd@redhat.com> References: <20200309121103.20234-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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 , Eduardo Habkost , Richard Henderson , "Edgar E. Iglesias" , Laurent Vivier , Aleksandar Markovic , Michael Walle , Paolo Bonzini , Igor Mammedov , Aleksandar Rikalo , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Bastian Koppelmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" cpu_reset() might modify architecture-specific fields allocated by qemu_init_vcpu(). To avoid bugs similar to the one fixed in commit 00d0f7cb66 when introducing new architectures, move the cpu_reset() calls after qemu_init_vcpu(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Vivier --- target/cris/cpu.c | 2 +- target/lm32/cpu.c | 3 +-- target/m68k/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/tricore/cpu.c | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/target/cris/cpu.c b/target/cris/cpu.c index 17c6712e29..9b8b99840d 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -134,8 +134,8 @@ static void cris_cpu_realizefn(DeviceState *dev, Error = **errp) return; } =20 - cpu_reset(cs); qemu_init_vcpu(cs); + cpu_reset(cs); =20 ccc->parent_realize(dev, errp); } diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index 687bf35e65..56f7b97c8f 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -132,9 +132,8 @@ static void lm32_cpu_realizefn(DeviceState *dev, Error = **errp) return; } =20 - cpu_reset(cs); - qemu_init_vcpu(cs); + cpu_reset(cs); =20 lcc->parent_realize(dev, errp); } diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index f0653cda2f..51ca62694e 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -247,8 +247,8 @@ static void m68k_cpu_realizefn(DeviceState *dev, Error = **errp) =20 m68k_cpu_init_gdb(cpu); =20 - cpu_reset(cs); qemu_init_vcpu(cs); + cpu_reset(cs); =20 mcc->parent_realize(dev, errp); } diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 6cd6b9650b..553945005f 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -149,8 +149,8 @@ static void mips_cpu_realizefn(DeviceState *dev, Error = **errp) =20 cpu_mips_realize_env(&cpu->env); =20 - cpu_reset(cs); qemu_init_vcpu(cs); + cpu_reset(cs); =20 mcc->parent_realize(dev, errp); } diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 70c8d8170f..2564436719 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -184,8 +184,8 @@ static void superh_cpu_realizefn(DeviceState *dev, Erro= r **errp) return; } =20 - cpu_reset(cs); qemu_init_vcpu(cs); + cpu_reset(cs); =20 scc->parent_realize(dev, errp); } diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c index cd422a0467..7e9982197f 100644 --- a/target/tilegx/cpu.c +++ b/target/tilegx/cpu.c @@ -91,8 +91,8 @@ static void tilegx_cpu_realizefn(DeviceState *dev, Error = **errp) return; } =20 - cpu_reset(cs); qemu_init_vcpu(cs); + cpu_reset(cs); =20 tcc->parent_realize(dev, errp); } diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 85bc9f03a1..c5a5d54569 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -94,8 +94,8 @@ static void tricore_cpu_realizefn(DeviceState *dev, Error= **errp) if (tricore_feature(env, TRICORE_FEATURE_131)) { set_feature(env, TRICORE_FEATURE_13); } - cpu_reset(cs); qemu_init_vcpu(cs); + cpu_reset(cs); =20 tcc->parent_realize(dev, errp); } --=20 2.21.1