From nobody Mon Dec 23 19:53:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=zabka.it ARC-Seal: i=1; a=rsa-sha256; t=1734724880; cv=none; d=zohomail.com; s=zohoarc; b=SvUVqS+GQFZ6uqsfIXIUrGqPIM98NLgR4XNnXB1mUuV7d+XqybFSL7rA9/D5ZqXd6xVAnftPOL9BhIyqobVnezfDfZMBq0gQp8VkiGg34PH5ysbd0T97qOTsQEqR2GlKKf9aIMJrp6+52eXQ0/ALjNSknA6P4CiyEuzxWRizAtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734724880; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OjaYxAUwgyfdD+Xfgs2+sV3Nc5IIljcSjw6TPoGngUk=; b=aFyZcE//NpuaqWCMlIhpDR89HaNiE3JFs/FdqtKseNTP+R8Lp5oGobTb0EsWInq56Uz/bCV4xgiUsb3qPbUszHUVwRbN0iKikHCCUdmJE8t/qkB55tq9A1iON3+oXGuQfzuL5v9m0ZM4ybYZJKZK3p456dy3W5+1wTvb/N7GBw8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734724879661613.1343388414977; Fri, 20 Dec 2024 12:01:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOjAl-00030D-8x; Fri, 20 Dec 2024 15:00:31 -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 1tOjAc-0002zl-Ae for qemu-devel@nongnu.org; Fri, 20 Dec 2024 15:00:29 -0500 Received: from out-181.mta1.migadu.com ([95.215.58.181]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOjAY-0007YV-6h for qemu-devel@nongnu.org; Fri, 20 Dec 2024 15:00:21 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zabka.it; s=key1; t=1734724814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=OjaYxAUwgyfdD+Xfgs2+sV3Nc5IIljcSjw6TPoGngUk=; b=ppd+cplc+rST5LwoZ4zM1y9EZYuEef/b9LM9rEszolmeGuUzD9Iqu1K5dbDBVZwjGTriul 81oPIdCMF/x27DCYylQovHAy9fHO6hjHLdtlYO0zaOv7qHTJRwZWFU5pdyFuw8j5xuPe/p MsM8xwIqfcGC6IbBqzfg9kq8mLJB+Tc= From: Stefan Zabka To: qemu-devel@nongnu.org Cc: Stefan Zabka , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2] physmem: allow cpu_memory_rw_debug to write to MMIO devices Date: Fri, 20 Dec 2024 20:49:41 +0100 Message-ID: <20241220195923.314208-1-git@zabka.it> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=95.215.58.181; envelope-from=git@zabka.it; helo=out-181.mta1.migadu.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_SBL_A=0.1 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @zabka.it) X-ZM-MESSAGEID: 1734724882432116600 Content-Type: text/plain; charset="utf-8" Resolves: https://gitlab.com/qemu-project/qemu/-/issues/213 Signed-off-by: Stefan Zabka --- Addressed initial review by David Hildenbrand The other change made more sense to me, so I'd like to write a test to verify that an AddressSpace like 0x00..0x0F MMIO Device A 0x10..0x1F ROM 0x20..0x2F MMIO Device B and a debug write from 0x00-0x2F still writes to MMIO Device B and that there isn't an early exit in address_space_rw when it encounters a ROM region. How would I go about doing that? --- system/physmem.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index dc1db3a384..623f41ae06 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3573,12 +3573,13 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, if (l > len) l =3D len; phys_addr +=3D (addr & ~TARGET_PAGE_MASK); - if (is_write) { - res =3D address_space_write_rom(cpu->cpu_ases[asidx].as, phys_= addr, - attrs, buf, l); - } else { - res =3D address_space_read(cpu->cpu_ases[asidx].as, phys_addr, - attrs, buf, l); + res =3D address_space_rw(cpu->cpu_ases[asidx].as, phys_addr, + attrs, buf, l, is_write); + if (res !=3D MEMTX_OK && is_write) { + /* Fallback since it might be a ROM region*/ + /* TODO verify that this works as expected*/ + res =3D address_space_write_rom(cpu->cpu_ases[asidx].as, + phys_addr, attrs, buf, l); } if (res !=3D MEMTX_OK) { return -1; --=20 2.47.1