From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1CC28C61D97 for ; Wed, 25 Jan 2023 21:13:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKn4X-00063H-4F; Wed, 25 Jan 2023 16:12:45 -0500 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 1pKn4V-000630-88 for qemu-devel@nongnu.org; Wed, 25 Jan 2023 16:12:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKn4Q-0007vB-7t for qemu-devel@nongnu.org; Wed, 25 Jan 2023 16:12:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674681156; 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: in-reply-to:in-reply-to:references:references; bh=VB5Iv7J9O2l7xi/f/zngZZ0KtYCw8ODLzXWR+g0FOlM=; b=Uj/rmSTCCrYYs96qXG3vQSJ8ASSEUd9JcmAcAPEx1srVR5GIDjg3qHg4rg3WYpo5Mku58K RZAXwPcFz7HYmpdX4bB3KfwiI9E6MSy1wYTJyPxCQdyR36kYWMyKgarD06fnrNsrdvlCcz yaIUjvvrn+VKWKI79HkS1zGYgcbrKf8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-312-fi9i7LLkPuOm8cCB2wG2cg-1; Wed, 25 Jan 2023 16:12:33 -0500 X-MC-Unique: fi9i7LLkPuOm8cCB2wG2cg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6E6C229AB3F8; Wed, 25 Jan 2023 21:12:32 +0000 (UTC) Received: from localhost (unknown [10.39.192.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E8C12026D4B; Wed, 25 Jan 2023 21:12:31 +0000 (UTC) Date: Wed, 25 Jan 2023 16:12:29 -0500 From: Stefan Hajnoczi To: Alexander Bulekov Cc: qemu-devel@nongnu.org, Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= , Mauro Matteo Cascella , Peter Xu , Jason Wang , David Hildenbrand , Gerd Hoffmann , Thomas Huth , Laurent Vivier , Bandan Das , "Edgar E . Iglesias" , Darren Kenny , Bin Meng , Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , Daniel P =?iso-8859-1?Q?=2E_Berrang=E9?= , Eduardo Habkost , Jon Maloy , Siqi Chen Subject: Re: [PATCH v4 1/3] memory: prevent dma-reentracy issues Message-ID: References: <20230119070308.321653-1-alxndr@bu.edu> <20230119070308.321653-2-alxndr@bu.edu> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="JEeC1fvID3M/9vOl" Content-Disposition: inline In-Reply-To: <20230119070308.321653-2-alxndr@bu.edu> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org --JEeC1fvID3M/9vOl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 19, 2023 at 02:03:06AM -0500, Alexander Bulekov wrote: > Add a flag to the DeviceState, when a device is engaged in PIO/MMIO/DMA. > This flag is set/checked prior to calling a device's MemoryRegion > handlers, and set when device code initiates DMA. The purpose of this > flag is to prevent two types of DMA-based reentrancy issues: >=20 > 1.) mmio -> dma -> mmio case > 2.) bh -> dma write -> mmio case >=20 > These issues have led to problems such as stack-exhaustion and > use-after-frees. >=20 > Summary of the problem from Peter Maydell: > https://lore.kernel.org/qemu-devel/CAFEAcA_23vc7hE3iaM-JVA6W38LK4hJoWae5K= cknhPRD5fPBZA@mail.gmail.com >=20 > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/62 > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/540 > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/541 > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/556 > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/557 > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/827 > Signed-off-by: Alexander Bulekov > --- > include/hw/qdev-core.h | 7 +++++++ > softmmu/memory.c | 15 +++++++++++++++ > softmmu/trace-events | 1 + > 3 files changed, 23 insertions(+) Reviewed-by: Stefan Hajnoczi --JEeC1fvID3M/9vOl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmPRmz0ACgkQnKSrs4Gr c8ivPgf+Nb8+jf4rYcSSlW97lzn5zM1XYq9sgmGSmST1Zvk7rj3K5q8nuj4aEjDM wluSsfvYQSpxmyKs4y4uADCdxa9m9/jLW6bqN7/L4/A1N2dXaD94Y6HhJnCQJKGg 2DvWuQSlxLa6riMACmisx2ZTwskv/MNBGBC/7Cbd93MA65N8lUKEcyCaGRjBBHD+ BpERawG5Wb8Tt03f3+Me8MtOhNTyjftsMSOgRKSRfdf0X99vOvHc4Fymi4g6bXDI 7UZq8PkJtJCoHAdsT+C9TAQ7CWgLFq4kMHpl9tt8W7cQMJmmt8jizWbg/GdJPnlt HFWQSGXZJpV1dGu21YcYdGea24zCLA== =Z35F -----END PGP SIGNATURE----- --JEeC1fvID3M/9vOl--