From nobody Sun Sep 28 16:28:06 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1756273191; cv=none; d=zohomail.com; s=zohoarc; b=Ga06KNo06dVoN663GcoQz7QZ1npghsT0V9qevJnSgPDc6U3WK4AR8w5HGNWNN6kCRjGkkqe6Pz9F3wBAlYCndg3uLEdUd4BF21d0XM9GYVsERVOU2eoNDGLwZ9dGXkQWeJjsFuxVi6CM0mYKJhXWeVw/JMsYo6cso0wTk0vXB1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756273191; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YdMhIp1+hv+APs6iwmimqvUCk8niLvWTzzjevOU/ip4=; b=F5tkiqeKHxf2hIdndmmrpsmO+XtlR44VWVjBwCzCipO6tbaKUcAoojoLxyTZTvcKa/SVq6Y1LpuCCF/pN6nYGop/K0334HiphTP7KZtUfLyC9MK+H13bdvq9oIBfknnBG4w/xleo2sfxco0hcC55huN7RyCORpYHBDd84JWa1mM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756273191213144.14483740732578; Tue, 26 Aug 2025 22:39:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ur8s0-0005MY-HE; Wed, 27 Aug 2025 01:38:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ur8rx-0005Lq-9C for qemu-devel@nongnu.org; Wed, 27 Aug 2025 01:38:49 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ur8rs-0006kw-JU for qemu-devel@nongnu.org; Wed, 27 Aug 2025 01:38:48 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-771ff6f117aso1147080b3a.2 for ; Tue, 26 Aug 2025 22:38:43 -0700 (PDT) Received: from stoup.. ([144.6.121.55]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-770401af6b2sm12071868b3a.56.2025.08.26.22.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Aug 2025 22:38:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756273120; x=1756877920; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YdMhIp1+hv+APs6iwmimqvUCk8niLvWTzzjevOU/ip4=; b=WavaqESygPtZ+T1M4bOuVFkSxzKC5OVC4B4c9W+ZDfMLPeJbXZNBTfXQLKTSCAzjmA 8UJpgEoxk09DZx6fWuItFwgXculqmI0Aj7NOI8vR8s4Kxfw0Vg6eGqx6VzfDzusC5Gjo o6UrlL80jC0isYMdmrR19y4aDJpoJKyZICxSZ9emQOXVD7GHgMT4QM7AoggE63qznPPF bqddggJhmUJv1BPbY1lUyPulUl3/eh+C1U8ksmmNnZPiZEEM2qftCsHQMTdAPtttJW67 OiewMPSDQ1D7f5AdUBze2ZSEw8C9VeCjVczDmXBtUjhBD2m6WS1mHRHvpG/CAYPaJcxk 7FfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756273120; x=1756877920; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YdMhIp1+hv+APs6iwmimqvUCk8niLvWTzzjevOU/ip4=; b=oyUJYiIMjlFlO9LOPY4sWQ0LHwXSyD91+vJZqfbPczrH7UFgK/iBh/FQWWOWbaRl2w MyXopFHs9tL+VnFdS4hiN9qRVdwICZJywE1c6kSFATH92xtVTQibdEnwGNLSSW63mWvs g8FFg43LojGzIuq9qUhG2fMDxuzkdsFnWWIorxIaLvAz2J5vH4gmqjsltWxPIneKY5fk qvYOXbQS9Z2qdtOIHc2R2vy2722r/qRopbWU1cjuIgdNX+7BXs/p7El4N3HrrFtSgf6p HaEv0B5XApEZvew/jAH4/Ey5YBEzWi4sfPAGIPCeMTPs+kFzX4UfWsTl2HKqRpZk68ab G19g== X-Gm-Message-State: AOJu0YwX7p7aN1rzvfk2/443jPM8A7xyAP/nMeK0cYwXwCYjTyu26e0S jOuXJlJ8G1T2arTcYNwDS5oExomNG9IYAKIQUvJu1aJhRHbHBqwGp+OVHvY5r8p97jeu8xkpSga 6yHpbgC8= X-Gm-Gg: ASbGncu7Ce97f1hMfzcSg0t8RhWMDk6FqY87LbdfWE8gSgeFnLZDexlCGXAlLaoBUdC uIuIGAQcmIlHyD5I6tgGZ/jnIWeZhRGfSdzVZUzJ/Ts3xYFqdknYJojYgwOhQ11pzUYFZbdEed8 D6G7/7VNMzscSnbb7qEHYO1Bg2cWylvMiFh1q12W5+EVKvDnzM4jD9fmt4HCfz52Pg6SJlba02Z +o/iRYOJChTvkDOm1ad0gC0F2+mlqR/BExgaJq4KDIUCj7HpptZ+DlEBMx6UbawIZ9PwXwnzSLz YVlUjraUTF0OAArjW/y0F28Iqzsdd04usLKuSyu8KYHL+yvzTBDW5ho4aDa6nG4P5vUZqKWyxDY QXKSOf/B4US16DbcDxUx22PK2lQ== X-Google-Smtp-Source: AGHT+IH7MUhEFcCtXhNNqHuq7YiIUPCOE4bVyQOXMM3kexrPkIf9QycSXIm4LYOUzKnbbZkHm4ggbA== X-Received: by 2002:a05:6a00:80f:b0:771:fd05:d376 with SMTP id d2e1a72fcca58-771fd05dad5mr4796989b3a.0.1756273120390; Tue, 26 Aug 2025 22:38:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Henk van der Laak Subject: [PATCH 1/2] hw/core: Dump cpu_reset in the reset.exit phase Date: Wed, 27 Aug 2025 15:38:21 +1000 Message-ID: <20250827053822.4094239-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250827053822.4094239-1-richard.henderson@linaro.org> References: <20250827053822.4094239-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1756273192440116600 Content-Type: text/plain; charset="utf-8" During reset.hold, the cpu is in an inconsistent state, where the leaf class has not had a chance to initialize state at all. This is visible as a SIGSEGV in "qemu-system-sparc64 -d cpu_reset". Move the dump to the exit phase, where all initialization is certain to be complete. Reported-by: Henk van der Laak Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/cpu-common.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 39e674aca2..26321be785 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -119,11 +119,6 @@ static void cpu_common_reset_hold(Object *obj, ResetTy= pe type) { CPUState *cpu =3D CPU(obj); =20 - if (qemu_loglevel_mask(CPU_LOG_RESET)) { - qemu_log("CPU Reset (CPU %d)\n", cpu->cpu_index); - log_cpu_state(cpu, cpu->cc->reset_dump_flags); - } - cpu->interrupt_request =3D 0; cpu->halted =3D cpu->start_powered_off; cpu->mem_io_pc =3D 0; @@ -137,6 +132,16 @@ static void cpu_common_reset_hold(Object *obj, ResetTy= pe type) cpu_exec_reset_hold(cpu); } =20 +static void cpu_common_reset_exit(Object *obj, ResetType type) +{ + if (qemu_loglevel_mask(CPU_LOG_RESET)) { + CPUState *cpu =3D CPU(obj); + + qemu_log("CPU Reset (CPU %d)\n", cpu->cpu_index); + log_cpu_state(cpu, cpu->cc->reset_dump_flags); + } +} + ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model) { ObjectClass *oc; @@ -380,6 +385,7 @@ static void cpu_common_class_init(ObjectClass *klass, c= onst void *data) dc->realize =3D cpu_common_realizefn; dc->unrealize =3D cpu_common_unrealizefn; rc->phases.hold =3D cpu_common_reset_hold; + rc->phases.exit =3D cpu_common_reset_exit; cpu_class_init_props(dc); /* * Reason: CPUs still need special care by board code: wiring up --=20 2.43.0 From nobody Sun Sep 28 16:28:06 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1756273188; cv=none; d=zohomail.com; s=zohoarc; b=QsqFjqVEmNT8A0QonVYxEpzNiD9qzgDaFDQUp3OUViV6qilu2UCKN1DZd71P1cbqAVk2oQ7z+bTFnZn2w6RPpganW6aIYcIDc397/xQKD2TC5iJ+GR4otNiuFN9Hh5RNSgArQXUCVE4BzNPisbwWPi/qYqpzlZU7JWORCefGQMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756273188; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=P/LENQOxma9sLlNHQfVZiYtvAKkgBC0iDr3UdZUm5Y4=; b=hEI+6gLyyD2rc8xkQPbQxJJ0+qTbdd8lv665rddxo1LdH3WTrqfkkWvkPQwLkPyyPTF7GrWNIF0tnyO+2A0jhzKhzIqfvu8GoQMyg6yE4BZURuKmyqDAzIHSdClm7ldJYw64P/dfPtbhh4ekBdDKEvgPxiWBFTvtlAhhLCg3YWA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756273188025678.16960355034; Tue, 26 Aug 2025 22:39:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ur8s0-0005MU-HJ; Wed, 27 Aug 2025 01:38:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ur8rx-0005Lr-CE for qemu-devel@nongnu.org; Wed, 27 Aug 2025 01:38:49 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ur8rv-0006lD-7M for qemu-devel@nongnu.org; Wed, 27 Aug 2025 01:38:49 -0400 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-323266cdf64so4720520a91.0 for ; Tue, 26 Aug 2025 22:38:44 -0700 (PDT) Received: from stoup.. ([144.6.121.55]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-770401af6b2sm12071868b3a.56.2025.08.26.22.38.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Aug 2025 22:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756273123; x=1756877923; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=P/LENQOxma9sLlNHQfVZiYtvAKkgBC0iDr3UdZUm5Y4=; b=LHoXPT428Lg8fQigWkbS7zULZE/Asjy2rJoD+cFBIb734/ssTWYO/Z0XvV2KB/AtQd SoukstMrZd1exKk63OkjtBt4I3e3dnL1A6dtZDhLGX05AZnYYAIMqhnE2wugBHlOD190 UN3YghvbrqFFoXaLntKAqcwT4kKf1IRspbQTDgsPeU7mDSZEzaHyG2CziZpuQGWGFj8S EbZv7lqkgxxFS85mhhP4Dql9efuG7SmbvOYfrO68WaWsCUnS6OqvkhwqRkNbi0WoNG/s XJqH6CcipEBbKmeuojpOJ5YuRpCLRM6nFAF5b1M2PZ7nqwh8SWviMoVxQ0bl0NajLmAx NdPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756273123; x=1756877923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P/LENQOxma9sLlNHQfVZiYtvAKkgBC0iDr3UdZUm5Y4=; b=Sx4XCJQte5+8/TShNaid8f+yIPeGUipZUHDFykivPuRvSvIeOeAQRC22obdMvcTYu7 y4T9lkQZWiaJA4A9bhBR0PBi3VRi5vZP43lXX9miT9bVNW1hKDRJcC8MW+aMR3cpdzE/ CAEzylEGIBispOKkSkG/8GUIucRzZU5gPIjElfuV0NNnIMMVe6JQj7q/1ho2C3+Ohh4g TOMyTGZw7TUWofCfFeWGAVjJysbsNg+ZmDQtdT/vh1DgwyyQYeFQZdDsz3opJCVFCeHO WJWosAAZ6wQRljRL3D8vFl7GF/okbbbAbg3su4921Yu3mbrFjyt2s5DWgsNLb1L6InO3 1+iA== X-Gm-Message-State: AOJu0Yyc9xig+xftbYRmt0/Qo2BWK0H9wsHUdXFCMbkHd+WCr1tqR1kg aYy7Hb8iXgqG/gEN0DnfMAO5HRE2CmfrtQajmq/KQHK1Pye+S9zW78DK7/Rb1/igLnR4GiK/mnf 6jPNdb2E= X-Gm-Gg: ASbGnctYdj3ZLBNbf969sOdlVGX5fovTdABbvFwALR6kf82+1IGZJxIRo8/8jBxF4JD CqlD2R1MG6ozE7RtewJ+Mt9MkgNE6qS4Gl4Xr+/i8a+fgpmGqEJr6DI6nsUlXDU7dDsquuHxIbz +ArH/0og1G9yK/5TF6SeVW6fwuDTaucHMpWACWPZnVbJ18RPIldIaqFeJe9PxDBt3EW/Y9wXlfy zr/c/9EUNp+O0ufrh0ZEPK58BTCVu8dt8ckqKhHvZ5vL7oksBpWmwf8WCCeHBA6Lfvxw8AruOs/ O7MFJva/TG82QRc2PTB+RBVEBqrotXY1r8kNzzLDosQhSKc6S2H6EVPst5MdJcypTxFnGAvGvmU 8aQeJMkdMPPI+ycGeo+3niWsnSSxRoFjj3Qqa X-Google-Smtp-Source: AGHT+IHgsvwyHEG/8HvYpL/s4U3LtwfWQC+ywYEPdOfVkBHS9Ow+Kpo0Xj/EgHd/uB/a7ILDGD7TdA== X-Received: by 2002:a17:90b:58ce:b0:323:7e80:8819 with SMTP id 98e67ed59e1d1-32518b825b3mr21057154a91.36.1756273122933; Tue, 26 Aug 2025 22:38:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/2] hw/core: Use qemu_log_trylock/unlock in cpu_common_reset_exit Date: Wed, 27 Aug 2025 15:38:22 +1000 Message-ID: <20250827053822.4094239-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250827053822.4094239-1-richard.henderson@linaro.org> References: <20250827053822.4094239-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1756273189767124100 Content-Type: text/plain; charset="utf-8" Ensure that the "CPU Reset" message won't be separated from the cpu_dump_state output. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/cpu-common.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 26321be785..259cf2a3c3 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -135,10 +135,15 @@ static void cpu_common_reset_hold(Object *obj, ResetT= ype type) static void cpu_common_reset_exit(Object *obj, ResetType type) { if (qemu_loglevel_mask(CPU_LOG_RESET)) { - CPUState *cpu =3D CPU(obj); + FILE *f =3D qemu_log_trylock(); =20 - qemu_log("CPU Reset (CPU %d)\n", cpu->cpu_index); - log_cpu_state(cpu, cpu->cc->reset_dump_flags); + if (f) { + CPUState *cpu =3D CPU(obj); + + fprintf(f, "CPU Reset (CPU %d)\n", cpu->cpu_index); + cpu_dump_state(cpu, f, cpu->cc->reset_dump_flags); + qemu_log_unlock(f); + } } } =20 --=20 2.43.0