From patchwork Tue Apr 7 04:35:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 185221 Delivered-To: patch@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp4434267ilr; Mon, 6 Apr 2020 21:36:41 -0700 (PDT) X-Google-Smtp-Source: APiQypLaX1w30NSfeM8ldMJUDPVleXgncokEoP7/CcGZEzKg5Gmyc5NHgFyO1Y9tmLBlnI7J95Fu X-Received: by 2002:ac8:514c:: with SMTP id h12mr613745qtn.268.1586234201068; Mon, 06 Apr 2020 21:36:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586234201; cv=none; d=google.com; s=arc-20160816; b=OgSK/KiLu5r1B3yAajoNzC7iGSovSs1KgK6D4VnXIvR8pUw7fMCfPFh8MhYIoP/XZC 18usex4eJnrATo/8qHeJdM9PxHTO7JVECecLdvOkxaIKxi9cmGhjH0N0zBdQFeSE6YI5 bMFOU9RmFQSxQFDiLlhBEz9FKr72bkgQCDhMebucllZGFVFzZTWG/oJJSdpnnuZM+9Np JOu/Op3CXL6xjEDdOuGHEKMWy/UZGZUs3DQxgW9gbA5ahQBQVrRPsHqyDMbnTwQn0gSY Rj9lR4GA1LiTzWR/+xRpWJXJZKkRDi2/yFg9xl8w0+odfxR27Zssi+IbZulL2P/4lDAZ s1fw== 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=HS3oFe4drWUjptxn2eG6bAMW+766RKu9wS0DwWeWdNE=; b=X1kOVmES600ZZbmsH1NnST2BUnK288hPVmwfnHRAgw0WxYZB0x5EBm3YH79zZI8Nzr 798rTorAM01Au6d6sD6zntuIZXYQhniIyv/5M8Y8I+xkWZ6omU+Bp3l8ssxYMP8FEvoZ jlaMvZFuY8SouExE57fSC7ItholrEMHA8QUqX7CTLgi3/bgFjMLJUT2n1oroaC44MJYh Gxgscm27YjqiXIn+s9k9OIsz8OkpJVuFUWLSh809SU0FRu3oTqjF2m+4GjlMR7PyQByK SA2AfMUa8wyF078evbaCcDdTCz17ZD16iBcGSze8ctmZq8svkBKcTzq5ZYF0gOOa0m22 0Y3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gibson.dropbear.id.au header.s=201602 header.b=cmFL7lc1; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h196si1179638qke.275.2020.04.06.21.36.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Apr 2020 21:36:41 -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=neutral (body hash did not verify) header.i=@gibson.dropbear.id.au header.s=201602 header.b=cmFL7lc1; 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" Received: from localhost ([::1]:40988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLfyZ-0007yT-Hi for patch@linaro.org; Tue, 07 Apr 2020 00:36:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52272) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLfyK-0007xs-DF for qemu-devel@nongnu.org; Tue, 07 Apr 2020 00:36:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLfyJ-0004Aq-EG for qemu-devel@nongnu.org; Tue, 07 Apr 2020 00:36:24 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:48261) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLfyH-00045Q-QU; Tue, 07 Apr 2020 00:36:23 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 48xF3K0Dqfz9sR4; Tue, 7 Apr 2020 14:36:12 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1586234173; bh=hHIGRjoFYCwEG4FYc0AkcpQkI4ODTreh/O1iHm8vwyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cmFL7lc1mD/Ev/HAAS8Te0JtMPNiB4gyeL05NMdvX8DMYMmLXQwtfFmpCKXqaUXJ7 Q7rS24JdyHnETg3XLJxYIm8bEotBhCU+CDo8eiPnDPegp1QTkQvrrJzoVXDoSzh/zR SvS/yuqOPfBCD7rWs0F+4zfcxdmxF6tYFqQPAH+A= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 01/10] hw/ppc/e500.c: Handle qemu_find_file() failure Date: Tue, 7 Apr 2020 14:35:57 +1000 Message-Id: <20200407043606.291546-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200407043606.291546-1-david@gibson.dropbear.id.au> References: <20200407043606.291546-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 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: aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell If qemu_find_file() doesn't find the BIOS it returns NULL; we were passing that unchecked through to load_elf(), which assumes a non-NULL pointer and may misbehave. In practice it fails with a weird message: $ qemu-system-ppc -M ppce500 -display none -kernel nonesuch Bad address qemu-system-ppc: could not load firmware '(null)' Handle the failure case better: $ qemu-system-ppc -M ppce500 -display none -kernel nonesuch qemu-system-ppc: could not find firmware/kernel file 'nonesuch' Spotted by Coverity (CID 1238954). Signed-off-by: Peter Maydell Message-Id: <20200324121216.23899-1-peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: David Gibson --- hw/ppc/e500.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.25.2 diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 854cd3ac46..0d1f41197c 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -1047,6 +1047,10 @@ void ppce500_init(MachineState *machine) } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, payload_name); + if (!filename) { + error_report("could not find firmware/kernel file '%s'", payload_name); + exit(1); + } payload_size = load_elf(filename, NULL, NULL, NULL, &bios_entry, &loadaddr, NULL, NULL, From patchwork Tue Apr 7 04:36:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 185222 Delivered-To: patch@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp4436755ilr; Mon, 6 Apr 2020 21:40:47 -0700 (PDT) X-Google-Smtp-Source: APiQypKk2eEmlCgBXxxrGngvZHNx6zssq6I/5dOuDz9uegp/l3XBGzsb3npg7zo/IB0T3f3YGvU1 X-Received: by 2002:ad4:45ae:: with SMTP id y14mr446080qvu.119.1586234447591; Mon, 06 Apr 2020 21:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586234447; cv=none; d=google.com; s=arc-20160816; b=P+8RtAJhyrPhS4yBLqgSDPNTrLOjWFEThZw6wr8vxwN+5We1XumGoJWjx8x93i6iNt bZXTi3JK++jFMl8ZX1lkihog860LrychToVtt8vVIv+acjQ9s8/fKgisxX2uUWYJmusF VDrth3+WjUYIO2DC4K+3mvNSytcosEglf5zBQ9p+cdPuRQ5ifVM8t5tiogF5dVtgjD1D 2I1fk3gx98Dn4HTafoHSTYrhEiQd8C5KtZvibW5JE/WyCTp2lQdyyPvyyru3tU4BnaNK 7nkZYRJahbZpl7wZG3H828U6NRTc30uG2//h0pACTVjkRhhe0WCtfZIRq32Wq0aBU47e 5FSw== 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=FEaZvFMdMwAf7q8+5VIIDlbsijbQ6me7uRcEqwO5pRE=; b=h00ZYxtE5p1p0Jd4kydnVs75sYxCo/OzA0Cr9tl4UBvpS/SyiEAMzSQr2RCobdnmx4 Jo4ukhGpoCScZVf9s+wSQaS5XaHTo5JVlAYWTbSrgGw6SeuCO6d97SjOsGSIbJpzaBRs /Reja8ZRUIqknt4fuRZ3JX6kF4w+xwFaJ08VHYFgImvgIiN7e8Y4FO9L+wzREnB1MIxZ SrdAXCCEsoCtVcDaK3qQiP568Q4eL/1VU++ujSoKcM7HEC+bSdpRXLo5UFMo8rZPxqWH vLjGJWt7jy3fZwFFqVJT/rO5UYtwZJsARD0i0f7OY4vq4FsXci8UgMerCvcpg7zXpl18 PqvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gibson.dropbear.id.au header.s=201602 header.b=UKlNeUrS; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i2si1040143qtc.82.2020.04.06.21.40.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Apr 2020 21:40:47 -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=neutral (body hash did not verify) header.i=@gibson.dropbear.id.au header.s=201602 header.b=UKlNeUrS; 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" Received: from localhost ([::1]:41056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLg2Z-0006xx-4j for patch@linaro.org; Tue, 07 Apr 2020 00:40:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52340) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLfyM-0007yQ-Fd for qemu-devel@nongnu.org; Tue, 07 Apr 2020 00:36:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLfyL-0004Cn-9F for qemu-devel@nongnu.org; Tue, 07 Apr 2020 00:36:26 -0400 Received: from bilbo.ozlabs.org ([203.11.71.1]:40711 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLfyK-0004Al-UH; Tue, 07 Apr 2020 00:36:25 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 48xF3K4Hptz9sSk; Tue, 7 Apr 2020 14:36:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1586234173; bh=EYxcaKAJK6jtK2yRfiXyVNG0eInMoSPB/jy3Zpie/2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UKlNeUrSEksUbGIyc8O6geQ/NhgpCdKvaAsM3Ar5+gjtxzq6LIdMPqAr5yiZ/tf9z jxB7zxacvQUGeF27BTJB5qwEkS5JsssIt4E6GMVrv7YmCrPYTThtz2GFT7Dx5v/PIY EKsJcpZEMkxC8fAX/gt7Z7dpSg1ep+/KBKLgIDq4= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 08/10] hw/ppc/ppc440_uc.c: Remove incorrect iothread locking from dcr_write_pcie() Date: Tue, 7 Apr 2020 14:36:04 +1000 Message-Id: <20200407043606.291546-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200407043606.291546-1-david@gibson.dropbear.id.au> References: <20200407043606.291546-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 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: aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In dcr_write_pcie() we take the iothread lock around a call to pcie_host_mmcfg_udpate(). This is an incorrect attempt to deal with the bug fixed in commit 235352ee6e73d7716, where we were not taking the iothread lock before calling device dcr read/write functions. (It's not sufficient locking, because although the other cases in the switch statement won't assert, there is no locking which prevents multiple guest CPUs from trying to access the PPC460EXPCIEState struct at the same time and corrupting data.) Unfortunately with commit 235352ee6e73d7716 we are now trying to recursively take the iothread lock, which will assert: $ qemu-system-ppc -M sam460ex --display none ** ERROR:/home/petmay01/linaro/qemu-from-laptop/qemu/cpus.c:1830:qemu_mutex_lock_iothread_impl: assertion failed: (!qemu_mutex_iothread_locked()) Aborted (core dumped) Remove the locking within dcr_write_pcie(). Fixes: 235352ee6e73d7716 Signed-off-by: Peter Maydell Message-Id: <20200330125228.24994-1-peter.maydell@linaro.org> Tested-by: BALATON Zoltan Signed-off-by: David Gibson --- hw/ppc/ppc440_uc.c | 3 --- 1 file changed, 3 deletions(-) -- 2.25.2 diff --git a/hw/ppc/ppc440_uc.c b/hw/ppc/ppc440_uc.c index d5ea962249..b30e093cbb 100644 --- a/hw/ppc/ppc440_uc.c +++ b/hw/ppc/ppc440_uc.c @@ -13,7 +13,6 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "qemu/log.h" -#include "qemu/main-loop.h" #include "qemu/module.h" #include "cpu.h" #include "hw/irq.h" @@ -1183,9 +1182,7 @@ static void dcr_write_pcie(void *opaque, int dcrn, uint32_t val) case PEGPL_CFGMSK: s->cfg_mask = val; size = ~(val & 0xfffffffe) + 1; - qemu_mutex_lock_iothread(); pcie_host_mmcfg_update(PCIE_HOST_BRIDGE(s), val & 1, s->cfg_base, size); - qemu_mutex_unlock_iothread(); break; case PEGPL_MSGBAH: s->msg_base = ((uint64_t)val << 32) | (s->msg_base & 0xffffffff);