From nobody Sat May 4 20:35:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.67 as permitted sender) client-ip=209.85.128.67; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f67.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1604878969; cv=none; d=zohomail.com; s=zohoarc; b=IrnkCmudCXpAYnofJfaYWHgVgAQoxKZbRBcXe2GuilOOve4SWzEmdcQ2m34DK60dGIQqODps96qDGmKDTITSQ3WZC3FHUzNs2hrkKIBDtfKuVKM59zJ0LWb3MCmbgqDu8DpPS+OcEBVgOMscmWU4cTz7cIc/Pr8frn2JcOecAEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604878969; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MxQ+pwW2m0VYMWrMPbB6LNqF9/H+1tHtQq2Dtg175Wo=; b=R+7l9RW9+mKhziutePpa3z6B0dQmy2x9dkIi9HjHSRWDeoZ6WwAtrcVjvLmniS93Yy1KYM6T1ZKe2UyA0QjRaadwsPp/owM0t4rW6Vi7+PAHBrtDAoOAnvPdyD/Pqf2Y0WpAEKNzPM9FN19TPA0C8bjvJNvknnhlfRmsHYgDIeY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.zohomail.com with SMTPS id 1604878969219587.7290349052913; Sun, 8 Nov 2020 15:42:49 -0800 (PST) Received: by mail-wm1-f67.google.com with SMTP id t67so2021290wmt.5 for ; Sun, 08 Nov 2020 15:42:48 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (234.red-83-42-66.dynamicip.rima-tde.net. [83.42.66.234]) by smtp.gmail.com with ESMTPSA id x18sm12028207wrg.4.2020.11.08.15.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Nov 2020 15:42:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MxQ+pwW2m0VYMWrMPbB6LNqF9/H+1tHtQq2Dtg175Wo=; b=I/poudOctBmDkEHg4dD0EKUZ7wv8ti6n9O0DPgCgLDfOpw7UtDnmxpSfIdC2rtunVv AVrLP2oK6KaFUY9RimyvjHP59C6P9PImP3XLuPxM7DwDKx9GmzA3eKSpLVmuhUwkiWUf cjwyKekPristMZi8BmYVRT4xjLd/eLxYBd1XBIWdwidNm1fKNADwGatpnvzh6gGZmbMn knXsR3SAF1XE61j2umOctIv41LtD2RDkvj3/7+783l27NoGEEMo36yDDpyaaNXJBL3hi CP8jjQHPr9DLyOeCtw5wp6C/gz2G1F4IqTp+fX8AAtFtTO1FoyMVwvPL44q3MpfHmPLP 768A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=MxQ+pwW2m0VYMWrMPbB6LNqF9/H+1tHtQq2Dtg175Wo=; b=tgC0++sv1bgZl7iZkZtg3uUg8dWQg2z5GPPVYp+78+s7ievrV088nIBWj4bEDezdLN YqEUYEJpU4GMQkoxu63h44W9Cy+eb/16iW3tB47TyFp8UGX8hg6MWZwz1N+0Ysqfedzh kujzJDNDRLY+ActUFiSDWMP9nf52hO+i016MnBz8fOC1r26LLPUMwOaiJ3DGMdsFRQol 1SkeCM8X9Wfb8OeGrXxWWSvIary/5gzJrwvbVpUEQHnJUvVkLShUXOH+X9qwRSbgYURq r8x3EsGKugQ56WfbzGIkyVmHrqIb92NsIfEfbF4TcuVVeCUoZDuBKrhJ8RUJIVY1RuzC fqMw== X-Gm-Message-State: AOAM532nei4xsaR4kv6MjlO84SLaZ3nk6hOm5Is1W0reaiktYdzySpWN kj5qQBPe/fdZ5tHi7s4egkw= X-Google-Smtp-Source: ABdhPJwqyXrN/wAAMFgOHJ4GtWCk2RGhFfzTnNsn6e5rlp9WoW8UTQNAfVfPVuKKEuytU2XTkjDa3A== X-Received: by 2002:a1c:98cd:: with SMTP id a196mr10942949wme.42.1604878967195; Sun, 08 Nov 2020 15:42:47 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paul Burton , libvir-list@redhat.com, Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Aleksandar Rikalo , Richard Henderson Subject: [PULL 1/3] target/mips: Deprecate nanoMIPS ISA Date: Mon, 9 Nov 2020 00:42:32 +0100 Message-Id: <20201108234234.2389789-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201108234234.2389789-1-f4bug@amsat.org> References: <20201108234234.2389789-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The nanoMIPS ISA has been announced in 2018 for various projects: GCC: https://gcc.gnu.org/legacy-ml/gcc/2018-05/msg00012.html Linux: https://lwn.net/Articles/753605/ QEMU: https://www.mail-archive.com/qemu-devel@nongnu.org/msg530721.html Unfortunately the links referenced doesn't work anymore (www.mips.com). From this Wayback machine link [1] we can get to a working place to download a toolchain (a more recent release than the one referenced in the announcement mails): http://codescape.mips.com/components/toolchain/nanomips/2018.04-02/download= s.html The toolchain page mention LLVM but simply links http://llvm.org/ where there is no reference on nanoMIPS. The only reference in the GCC mailing list, is the nanoMIPS announcement: https://gcc.gnu.org/pipermail/gcc/2018-May.txt The developer who authored the announcements have been emailed [2] to ask for more information but all their emails are now bouncing: - Your message to Stefan.Markovic@mips.com couldn't be delivered. - Your message to smarkovic@wavecomp.com couldn't be delivered. - Couldn't deliver the message to the following recipients: Robert.Suchanek@mips.com, matthew.fortune@mips.com, marcin.nowakowski@mips.com Our deprecation policy do not allow feature removal before 2 release, therefore declare the nanoMIPS ISA code deprecated as of QEMU 5.2. This gives time to developers to update the QEMU community, or interested parties to step in to maintain this code. [1] https://web.archive.org/web/20180904044530/https://www.mips.com/develop= /tools/compilers/ [2] https://www.mail-archive.com/qemu-devel@nongnu.org/msg756392.html Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Richard Henderson Message-Id: <20201102202710.2224691-1-f4bug@amsat.org> --- docs/system/deprecated.rst | 23 +++++++++++++++++++++++ MAINTAINERS | 6 +++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst index 8c1dc7645d7..bbaae0d97c3 100644 --- a/docs/system/deprecated.rst +++ b/docs/system/deprecated.rst @@ -310,6 +310,13 @@ to build binaries for it. ``Icelake-Client`` CPU Models are deprecated. Use ``Icelake-Server`` CPU Models instead. =20 +MIPS ``I7200`` CPU Model (since 5.2) +'''''''''''''''''''''''''''''''''''' + +The ``I7200`` guest CPU relies on the nanoMIPS ISA, which is deprecated +(the ISA has never been upstreamed to a compiler toolchain). Therefore +this CPU is also deprecated. + System emulator devices ----------------------- =20 @@ -407,6 +414,13 @@ The ``ppc64abi32`` architecture has a number of issues= which regularly trip up our CI testing and is suspected to be quite broken. For that reason the maintainers strongly suspect no one actually uses it. =20 +MIPS ``I7200`` CPU (since 5.2) +'''''''''''''''''''''''''''''' + +The ``I7200`` guest CPU relies on the nanoMIPS ISA, which is deprecated +(the ISA has never been upstreamed to a compiler toolchain). Therefore +this CPU is also deprecated. + Related binaries ---------------- =20 @@ -471,6 +485,15 @@ versions, aliases will point to newer CPU model versio= ns depending on the machine type, so management software must resolve CPU model aliases before starting a virtual machine. =20 +Guest Emulator ISAs +------------------- + +nanoMIPS ISA +'''''''''''' + +The ``nanoMIPS`` ISA has never been upstreamed to any compiler toolchain. +As it is hard to generate binaries for it, declare it deprecated. + =20 Recently removed features =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D diff --git a/MAINTAINERS b/MAINTAINERS index 63223e1183d..16aace05624 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -227,7 +227,7 @@ R: Aleksandar Rikalo S: Odd Fixes F: target/mips/ F: default-configs/*mips* -F: disas/*mips* +F: disas/mips.c F: docs/system/cpu-models-mips.rst.inc F: hw/intc/mips_gic.c F: hw/mips/ @@ -240,6 +240,10 @@ F: include/hw/timer/mips_gictimer.h F: tests/tcg/mips/ K: ^Subject:.*(?i)mips =20 +MIPS TCG CPUs (nanoMIPS ISA) +S: Orphan +F: disas/nanomips.* + Moxie TCG CPUs M: Anthony Green S: Maintained --=20 2.26.2 From nobody Sat May 4 20:35:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604878989; cv=none; d=zohomail.com; s=zohoarc; b=hBIqxnYj5Qkzsx9sZ+8Xsiy/OhvwHtO4a83S/N+ghy83TYyUTOcwFwADWpI0pYrkVsqKhdivqFjQuhDcfBD9TjrfmrygFFctZJ8RERu9oTlN2i1IG9NB9aaPOTDwq2JedUstM/RctwO0ldhsBv6ZwbMYkuAxYTIDsJJ7fj32lZ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604878989; 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=MOQKSfuZ3WXnJIf1iQq//Z2ISnKXo6hb+zOBO4CmoII=; b=b7GNnHDq0cWbOWpskGsJO/lCktyo5EhN8WifBmC8D+kgkuXhB1nYVrPBcEGUyPgxmX8viU387XrnPsvn3nPJcz56QFKnKCkGOc+eqjGEa2zrLIkCnF957bAhAXj3Kc51sqBDy3cyosVAAh73BGr0t2KMUkGTH6JDejzlVendWHA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604878989850125.64629538296776; Sun, 8 Nov 2020 15:43:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-163-qBxKC2INOsqkH6fiEdTUUg-1; Sun, 08 Nov 2020 18:43:06 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6193757097; Sun, 8 Nov 2020 23:43:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E5915B4AD; Sun, 8 Nov 2020 23:43:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 06AD7922F1; Sun, 8 Nov 2020 23:43:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A8NgvaN031628 for ; Sun, 8 Nov 2020 18:42:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9EC922166B44; Sun, 8 Nov 2020 23:42:57 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 998F32166B28 for ; Sun, 8 Nov 2020 23:42:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D7BE185A790 for ; Sun, 8 Nov 2020 23:42:55 +0000 (UTC) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-517-x3bbHquFNJ6q91bDfCvjPw-1; Sun, 08 Nov 2020 18:42:53 -0500 Received: by mail-wr1-f47.google.com with SMTP id 23so6897616wrc.8 for ; Sun, 08 Nov 2020 15:42:53 -0800 (PST) Received: from localhost.localdomain (234.red-83-42-66.dynamicip.rima-tde.net. [83.42.66.234]) by smtp.gmail.com with ESMTPSA id v12sm11741425wro.72.2020.11.08.15.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Nov 2020 15:42:51 -0800 (PST) X-MC-Unique: qBxKC2INOsqkH6fiEdTUUg-1 X-MC-Unique: x3bbHquFNJ6q91bDfCvjPw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=MOQKSfuZ3WXnJIf1iQq//Z2ISnKXo6hb+zOBO4CmoII=; b=SXA7yTI3iwZxs7R1Zw1lKpgimawg9tI4ppixFSJpoOyDASV9GMh6DGsEGBS6Qj/DAV x4SBUHp9Ibj8f28pQ8yKooedvPto49KANQjtuPQ/iFafyBOtmL1MNHqvWpESRxHIjg/D UGyBrPos8Yi4kTnp0gJTPbJs/f/tpc3xcwFAC2AgHIYpPWcMnmO9zc4dsP8vvzKWQRYD Jdi0M/fc2A/9dtCoPP0XGtLs/GC7Y0GS0zyNh5hcFEB6VTn956uZ+oKaA+NnP7OoVWD1 bDQQE5WmeSbNlwv9L7+afS1TvhgONZennps/qOyrrfkq67NXeqitFWsBzISWF+POxDH3 uGBA== X-Gm-Message-State: AOAM531Pzr4eUy9+CwRXJ4q7e5+xEpmwJ+Xu49liIZ7MviHHsiKvxoh7 oMsGERRo667bgI634O+NCMo= X-Google-Smtp-Source: ABdhPJwzmHuRWarpqHSrSBEOhOltq46x1N6ScvGfqN92q/FNHpKaiS4CDh+/jYo2eMCBzw2NabMwSQ== X-Received: by 2002:adf:9461:: with SMTP id 88mr14332374wrq.171.1604878972170; Sun, 08 Nov 2020 15:42:52 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 2/3] target/mips: Fix PageMask with variable page size Date: Mon, 9 Nov 2020 00:42:33 +0100 Message-Id: <20201108234234.2389789-3-f4bug@amsat.org> In-Reply-To: <20201108234234.2389789-1-f4bug@amsat.org> References: <20201108234234.2389789-1-f4bug@amsat.org> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Aleksandar Rikalo , Paul Burton , libvir-list@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jiaxun Yang , Huacai Chen , Aurelien Jarno X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Jiaxun Yang Our current code assumed the target page size is always 4k when handling PageMask and VPN2, however, variable page size was just added to mips target and that's no longer true. Fixes: ee3863b9d414 ("target/mips: Support variable page size") Signed-off-by: Jiaxun Yang Signed-off-by: Huacai Chen Message-Id: <1604636510-8347-2-git-send-email-chenhc@lemote.com> Tested-by: Philippe Mathieu-Daud=C3=A9 [PMD: Replaced find_first_zero_bit() by cto32()] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/cpu.h | 1 + target/mips/cp0_helper.c | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index d41579d44ae..23f8c6f96cd 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -619,6 +619,7 @@ struct CPUMIPSState { * CP0 Register 5 */ int32_t CP0_PageMask; +#define CP0PM_MASK 13 int32_t CP0_PageGrain_rw_bitmask; int32_t CP0_PageGrain; #define CP0PG_RIE 31 diff --git a/target/mips/cp0_helper.c b/target/mips/cp0_helper.c index 709cc9a7e3d..a1b5140ccaf 100644 --- a/target/mips/cp0_helper.c +++ b/target/mips/cp0_helper.c @@ -892,13 +892,28 @@ void helper_mtc0_memorymapid(CPUMIPSState *env, targe= t_ulong arg1) =20 void update_pagemask(CPUMIPSState *env, target_ulong arg1, int32_t *pagema= sk) { - uint64_t mask =3D arg1 >> (TARGET_PAGE_BITS + 1); - if (!(env->insn_flags & ISA_MIPS32R6) || (arg1 =3D=3D ~0) || - (mask =3D=3D 0x0000 || mask =3D=3D 0x0003 || mask =3D=3D 0x000F || - mask =3D=3D 0x003F || mask =3D=3D 0x00FF || mask =3D=3D 0x03FF || - mask =3D=3D 0x0FFF || mask =3D=3D 0x3FFF || mask =3D=3D 0xFFFF)) { - env->CP0_PageMask =3D arg1 & (0x1FFFFFFF & (TARGET_PAGE_MASK << 1)= ); + uint32_t mask; + int maskbits; + + /* Don't care MASKX as we don't support 1KB page */ + mask =3D extract32((uint32_t)arg1, CP0PM_MASK, 16); + maskbits =3D cto32(mask); + + /* Ensure no more set bit after first zero */ + if ((mask >> maskbits) !=3D 0) { + goto invalid; } + /* We don't support VTLB entry smaller than target page */ + if ((maskbits + 12) < TARGET_PAGE_BITS) { + goto invalid; + } + env->CP0_PageMask =3D mask << CP0PM_MASK; + + return; + +invalid: + /* When invalid, set to default target page size. */ + env->CP0_PageMask =3D (~TARGET_PAGE_MASK >> 12) << CP0PM_MASK; } =20 void helper_mtc0_pagemask(CPUMIPSState *env, target_ulong arg1) --=20 2.26.2 From nobody Sat May 4 20:35:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.53 as permitted sender) client-ip=209.85.128.53; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f53.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.53 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1604878979; cv=none; d=zohomail.com; s=zohoarc; b=d8U1kerKxyCJ6c9XjvKW8gyc9V/RHCzIm+JXrzHMttlhwITQ256Iqj5uSHd+pPfVlqGVQ8/pfurGAxR0sPJl1aUFPot59L1G+Tnr7Frvfww1LlFrWwZyF7E2mEhf2V7L/3MBCeOkYWx5QDGfCRPl+6BMOUfiR/JewIXEkbyw10U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604878979; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pZ7rBipTKKb/oioa2rrfZq9jThonQF//eO/4l0XoKyI=; b=dvxbfx+OA5O2hq6+IC1YVYwVB2FDnoiJsfmXp994VPf2E6x/h9gf8LWLe+enumzART8S4R3wXkmr3057zyxIhChelCHmTWo1+ZS/Td57aD87Qc79Q+VZgkJOKvAaGtErpLYWhV8sKLyFy28dzNsNxeSHbAvqvCKNkh4rLxfO2zc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.53 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by mx.zohomail.com with SMTPS id 1604878979224480.7205720995812; Sun, 8 Nov 2020 15:42:59 -0800 (PST) Received: by mail-wm1-f53.google.com with SMTP id v5so6439274wmh.1 for ; Sun, 08 Nov 2020 15:42:58 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (234.red-83-42-66.dynamicip.rima-tde.net. [83.42.66.234]) by smtp.gmail.com with ESMTPSA id q2sm5431060wru.76.2020.11.08.15.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Nov 2020 15:42:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pZ7rBipTKKb/oioa2rrfZq9jThonQF//eO/4l0XoKyI=; b=TAWB74L0iPa1+/0eZO3xVYo4Ak2YBrRNlxxjJeeAQF9q3e0TvAO2t5Zhia5UjxKtPo 2CL/b9nHG+wyqEjpv5norwzGWYYmi+AE7fExHc/0M/k8wW0ewjJkAe624Nx4GQg4N4S8 vDv3pVwFtAPFXluckxZy7LiSmhz+c1Ry0VR4WszDWngUzuZgwKGuxgV1Vh2/BWZ1PvV5 XVSbaeTI2DM3+EFjsXuzPMUAEm20fllwNvu/dpXDtnKzRhar5u8Dn0vLbUmQzqvnAtM3 qPFcs95yYKrDPRr0GxZuLeZObyCjaLqXWXdssCTqstvFFMadHEGCVW8XvrQTJ1cSV/Kx xHSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=pZ7rBipTKKb/oioa2rrfZq9jThonQF//eO/4l0XoKyI=; b=DvwHMT+eDL1JJiZmufE3L3qjCQgCVbnjxeRfLeEfDmNomZQiLiGBnnN7EnagFSs3f5 OhCFsIcoOWb06MjpKxfRawt5L1qQbUR5LtSKLkjPkvxOuOs2dMfkXt7YCDHAxsjSVhlH /RlUpo8+AE6wue5DquG+yi7Y0lni7Sm/VKWBl9qNiZAyfo3dKnjMgnjKhMuFx7Pu1Eaq NWpKhmLQmuBhNjE7ZSlNSSmWFGwjF8AidsrNB+6lQprgBZvnbnPe13O/TLTTjkYBg3xc J4ARw7CFpxqYJlv1e/rvSiYw81AJDvJrkw5nqJn5bM9br2viGGlPJLESNKGQtid5omjT iw/w== X-Gm-Message-State: AOAM533daG2i+C8DbwYgS+E/e8b/6Dx876Qtkgurz1PIKKNnE5ZjGnoZ FrbCBE8lhuiTV1IONEAJSFY= X-Google-Smtp-Source: ABdhPJxHHmCXqtltdovTPDMCeJbKlBppRVSYDARDsf2gPmzuZ1H5zmVkXLEkjGwCD2HHYK8FYPnHDQ== X-Received: by 2002:a1c:1c3:: with SMTP id 186mr11409605wmb.39.1604878977356; Sun, 08 Nov 2020 15:42:57 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paul Burton , libvir-list@redhat.com, Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Aleksandar Rikalo , Peter Maydell Subject: [PULL 3/3] hw/mips/boston: Fix memory leak in boston_fdt_filter() error-handling paths Date: Mon, 9 Nov 2020 00:42:34 +0100 Message-Id: <20201108234234.2389789-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201108234234.2389789-1-f4bug@amsat.org> References: <20201108234234.2389789-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) From: Peter Maydell Coverity points out that the error-handling paths in the boston_fdt_filter() function don't free the fdt that was allocated. Fix the leak by using g_autofree. Fixes: Coverity CID 1432275 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20201106175823.1650-1-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/boston.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 3356d7a6814..3d40867dc4c 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -349,11 +349,9 @@ static const void *boston_fdt_filter(void *opaque, con= st void *fdt_orig, MachineState *machine =3D s->mach; const char *cmdline; int err; - void *fdt; - size_t fdt_sz, ram_low_sz, ram_high_sz; - - fdt_sz =3D fdt_totalsize(fdt_orig) * 2; - fdt =3D g_malloc0(fdt_sz); + size_t ram_low_sz, ram_high_sz; + size_t fdt_sz =3D fdt_totalsize(fdt_orig) * 2; + g_autofree void *fdt =3D g_malloc0(fdt_sz); =20 err =3D fdt_open_into(fdt_orig, fdt, fdt_sz); if (err) { @@ -380,7 +378,7 @@ static const void *boston_fdt_filter(void *opaque, cons= t void *fdt_orig, =20 s->fdt_base =3D *load_addr; =20 - return fdt; + return g_steal_pointer(&fdt); } =20 static const void *boston_kernel_filter(void *opaque, const void *kernel, --=20 2.26.2