From patchwork Wed Jul 1 16:47:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <1878645@bugs.launchpad.net> X-Patchwork-Id: 11636945 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE77C60D for ; Wed, 1 Jul 2020 16:56:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF7ED20748 for ; Wed, 1 Jul 2020 16:56:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF7ED20748 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bugs.launchpad.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:43008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqg2R-00034s-1i for patchwork-qemu-devel@patchwork.kernel.org; Wed, 01 Jul 2020 12:56:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqg1f-00025z-2R for qemu-devel@nongnu.org; Wed, 01 Jul 2020 12:55:59 -0400 Received: from indium.canonical.com ([91.189.90.7]:55022) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqg1c-00065h-Q7 for qemu-devel@nongnu.org; Wed, 01 Jul 2020 12:55:58 -0400 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.86_2 #2 (Debian)) id 1jqg1a-0003TR-Et for ; Wed, 01 Jul 2020 16:55:54 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 609232E810D for ; Wed, 1 Jul 2020 16:55:54 +0000 (UTC) MIME-Version: 1.0 Date: Wed, 01 Jul 2020 16:47:05 -0000 From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <1878645@bugs.launchpad.net> To: qemu-devel@nongnu.org X-Launchpad-Notification-Type: bug X-Launchpad-Bug: product=qemu; status=New; importance=Undecided; assignee=None; X-Launchpad-Bug-Information-Type: Public X-Launchpad-Bug-Private: no X-Launchpad-Bug-Security-Vulnerability: no X-Launchpad-Bug-Commenters: a1xndr ajbennee philmd X-Launchpad-Bug-Reporter: Alexander Bulekov (a1xndr) X-Launchpad-Bug-Modifier: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9_=28philmd=29?= References: <158947246472.30762.752698283456022174.malonedeb@chaenomeles.canonical.com> <20200701135652.1366-2-alex.bennee@linaro.org> <85314d31-813a-8c20-7522-5186d5f31884@redhat.com> <87pn9fqjcd.fsf@linaro.org> Message-Id: <838d4d01-cd9e-d74a-5cd2-b23644172c9f@redhat.com> Subject: [Bug 1878645] Re: [PATCH v4 01/40] hw/isa: check for current_cpu before generating IRQ X-Launchpad-Message-Rationale: Subscriber (QEMU) @qemu-devel-ml X-Launchpad-Message-For: qemu-devel-ml Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="1cbd0aa39df153c901321817f9b57cf3f232b507"; Instance="production-secrets-lazr.conf" X-Launchpad-Hash: fead8b426c5d191fdcc66bef7239d05a73b8327f Received-SPF: none client-ip=91.189.90.7; envelope-from=bounces@canonical.com; helo=indium.canonical.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/01 10:05:42 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -58 X-Spam_score: -5.9 X-Spam_bar: ----- X-Spam_report: (-5.9 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Bug 1878645 <1878645@bugs.launchpad.net> Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" On 7/1/20 6:40 PM, Alex Bennée wrote: > > Philippe Mathieu-Daudé writes: > >> On 7/1/20 3:56 PM, Alex Bennée wrote: >>> It's possible to trigger this function from qtest/monitor at which >>> point current_cpu won't point at the right place. Check it and >>> fall back to first_cpu if it's NULL. >>> >>> Signed-off-by: Alex Bennée >>> Cc: Bug 1878645 <1878645@bugs.launchpad.net> >>> --- >>> hw/isa/lpc_ich9.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c >>> index cd6e169d47a..791c878eb0b 100644 >>> --- a/hw/isa/lpc_ich9.c >>> +++ b/hw/isa/lpc_ich9.c >>> @@ -439,7 +439,7 @@ static void ich9_apm_ctrl_changed(uint32_t val, void *arg) >>> cpu_interrupt(cs, CPU_INTERRUPT_SMI); >>> } >>> } else { >>> - cpu_interrupt(current_cpu, CPU_INTERRUPT_SMI); >>> + cpu_interrupt(current_cpu ? current_cpu : first_cpu, CPU_INTERRUPT_SMI); >> >> I'm not sure this change anything, as first_cpu is NULL when using >> qtest accelerator or none-machine, see 508b4ecc39 ("gdbstub.c: fix >> GDB connection segfault caused by empty machines"). > > Good point - anyway feel free to ignore - it shouldn't have been in this > series. It was just some random experimentation I was doing when looking > at that bug. See commit c781a2cc42 ("hw/i386/vmport: Allow QTest use without crashing") for a similar approach, but here I was thinking about a more generic fix, not very intrusive: -- >8 -- } else { diff --git a/hw/isa/apm.c b/hw/isa/apm.c index bce266b957..809afeb3e4 100644 --- a/hw/isa/apm.c +++ b/hw/isa/apm.c @@ -40,7 +40,7 @@ static void apm_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, if (addr == 0) { apm->apmc = val; - if (apm->callback) { + if (apm->callback && !qtest_enabled()) { (apm->callback)(val, apm->arg); }