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 lists1p.gnu.org (lists1p.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 46BEFCD98CE for ; Fri, 12 Jun 2026 11:03:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXzfl-0003NA-UN; Fri, 12 Jun 2026 07:03:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXzfk-0003G8-1s for qemu-arm@nongnu.org; Fri, 12 Jun 2026 07:03:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXzfh-0001Bw-Vk for qemu-arm@nongnu.org; Fri, 12 Jun 2026 07:03:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781262212; 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: content-transfer-encoding:content-transfer-encoding; bh=0D5VYBTm+M39AGUV1HBH/FzeUtRKZMMTIMaAxqlpmMg=; b=SIt1gYL8KSlQjGGIhBfnCmNnidudoKYilIP0PGSHufC0VHFkWRFOpVGebdpCGuB8uHH0y5 W0dQ8eHzFCxqOl5eZhrC2e0z29WXH69Z1jR+KFzg9/Qc4+epNKk3/5tlnTh1PkeEGoE9r5 y1DYkyVs33u3AURnhNZ1sQG9OP7wzkw= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-bjnq5cPSOhK-NNiyxYAF4w-1; Fri, 12 Jun 2026 07:03:28 -0400 X-MC-Unique: bjnq5cPSOhK-NNiyxYAF4w-1 X-Mimecast-MFC-AGG-ID: bjnq5cPSOhK-NNiyxYAF4w_1781262207 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 061EA1800A7B; Fri, 12 Jun 2026 11:03:27 +0000 (UTC) Received: from gshan-thinkpadx1nanogen2.rmtau.csb (unknown [10.64.136.3]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9550E1955BC4; Fri, 12 Jun 2026 11:03:20 +0000 (UTC) From: Gavin Shan To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, peterx@redhat.com, mst@redhat.com, peter.maydell@linaro.org, berrange@redhat.com, david@kernel.org, alex@shazbot.org, clg@redhat.com, pbonzini@redhat.com, philmd@mailo.com, phrdina@redhat.com, jugraham@redhat.com, shan.gavin@gmail.com Subject: [PATCH 0/2] system/memory: Make ram device region directly accessible Date: Fri, 12 Jun 2026 21:03:05 +1000 Message-ID: <20260612110307.1264798-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-MFC-PROC-ID: 5i2jtXmcbRMEs9VTxZD0yfIH32Kb2tQSMzx1Su4nEBQ_1781262207 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.129.124; envelope-from=gshan@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@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-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org All ram device regions was turned to be indirectly accessible by commit 4a2e242bbb ("memory: Don't use memcpy for ram_device regions"). This leads to a hanged guest where a NVidia GH100 GPU is passed from host. The memory in its PCI BAR#4 can be allocated as DMA target buffer. qemu has to take DMA bounce buffer in address_space_map() to cover the DMA request. However, the bounce buffer size is 4096 bytes and we're overrunning it easily when the guest has significant disk activities on compiling 'cuda-samples'. The full log and problem description can be found from PATCH[1/2]'s commit log. Try to fix the issue handled in commit 4a2e242bbb by replacing mem{cpy, move} with __builtin_mem{cpy, move} in the accessors to the ram device regions. With this, we can basically revert that commit to make ram device region directly accessible again and bypass the bounce buffer in address_space_map() where the guest hang is caused. PATCH[1] replaces mem{cpy, move} with __builtin_mem{cpy, move} PATCH[2] makes ram device region directly accessible again Changelog ========= RFCv1 -> v1: * https://lists.nongnu.org/archive/html/qemu-arm/2026-06/msg00307.html * Reworked solution based on suggestions from Peter Xu, Peter Maydell and Michael S. Tsirkin Gavin Shan (2): system/memory: Use __builtin_mem{cpy, move} in accessors of ram device region system/memory: Make ram device region directly accessible hw/remote/vfio-user-obj.c | 4 +-- include/system/memory.h | 53 +++++++++++++++++++++++++++++++-------- system/memory.c | 41 +----------------------------- system/physmem.c | 8 +++--- system/trace-events | 2 -- 5 files changed, 50 insertions(+), 58 deletions(-) -- 2.54.0