From nobody Sat Apr 5 01:04:36 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1739177302; cv=none; d=zohomail.com; s=zohoarc; b=d7TuE1eW1iFV9UGu5BxybYBg3TP/w+s7xlYghBMQHERHsgaCRyyU7Jdoo/fHcHD4fE99Lf682QzbXXIhuQhXthCRcflO+XME33itoJdwfaJFAzGuUxZNWRTB6F2yEKcuo4Pk1j4Es0jL1QlH+dhLoz9eBp0YGyiWEXXAf3mDnvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739177302; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5xxpfU/c7z9d/6ypMxL4FcLhkOjlzksbtn+mi07kcCo=; b=Z78ry1Kl9T6BWzgYzysNBzllCESecn1Ze4jug+IzZvynlSW5FbYpIRVJdeBQM9yL3rAeyEg5VfdN5vXFmvuOmctXco892rV4S4tc3drOJOtFpKPVUY0jsNiSjzQCgp/mS9moPLe2l9oyJAtIV7jtumQMzE8KLXnigznYjjTtohw= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1739177302456127.16727728349872; Mon, 10 Feb 2025 00:48:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thPRx-0006Xv-If; Mon, 10 Feb 2025 03:47:30 -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 1thPRe-0006LI-HF for qemu-devel@nongnu.org; Mon, 10 Feb 2025 03:47:13 -0500 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 1thPRc-00046M-VG for qemu-devel@nongnu.org; Mon, 10 Feb 2025 03:47:10 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-67ewBFQPM5ugh1PKxs2NKA-1; Mon, 10 Feb 2025 03:47:05 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-38dcc9653caso596508f8f.2 for ; Mon, 10 Feb 2025 00:47:05 -0800 (PST) Received: from localhost (p200300cbc734b80012c465cd348aaee6.dip0.t-ipconnect.de. [2003:cb:c734:b800:12c4:65cd:348a:aee6]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-38dc5c8c37esm9933599f8f.2.2025.02.10.00.47.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Feb 2025 00:47:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739177227; 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: in-reply-to:in-reply-to:references:references; bh=5xxpfU/c7z9d/6ypMxL4FcLhkOjlzksbtn+mi07kcCo=; b=CTlnk6eVSveaJbCiHRCq6cwdgEpIbDrD9sC4YL4LWUoZbp6Pj/nCGPOh2T8ADs1HPrPIUq ympp/z+uxpqYgKw71Or4flNiZUdZzItQGEFzmm8r81xhBY9dfYNsWaPTSBPvzuqjkwjojH SGPYtyxYvlcsGVijI+0za0Gc9XWQDaQ= X-MC-Unique: 67ewBFQPM5ugh1PKxs2NKA-1 X-Mimecast-MFC-AGG-ID: 67ewBFQPM5ugh1PKxs2NKA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739177224; x=1739782024; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5xxpfU/c7z9d/6ypMxL4FcLhkOjlzksbtn+mi07kcCo=; b=uBJSZwYdMh/elLKPGlQ/Pl0o3wzlDhvnk15mM8VJF3u+z0MGzZvncPaCTFIViu2rzg MQLgMCs1Rx6ZN5zkhWIEFBJmGW/m97gO1qF9puinXFlX0dduE7w7gTfmkeVc5+KkjTLe 2RH7kxSja+48PXi4KsSJd6IpUH0RoO+R8dhJbjEVgROmdM5hhKCysT1NWVepFOBRD/eb TdeNPLI+ClCiQryRCJ/ya7FfvossWDadMrXlrWF3SNM0SMBzRORXOGyhY9IRfxq/HLQX eYsjNLxgvONhIRFED8QPYSFNSclXkMFQWxuXu1kWvcUHdDw4L9/nMFrv0fll8LClcqnz umNw== X-Gm-Message-State: AOJu0YycXHVDZWSOeweRImJ1Pxs6+ginkq+wwB+TVL/xqmeeavnB2NPc 0YhHszepso4hXdLjbx57upAJvFTUp9D7SRSkrdBXEOCgFKQfopOqcZLQ/jzdxpOkFZfDE8Aawxo BQJk5QKlbpEerGnsEfM0IAjRaqff74bTZV1Ji3AEJ7XuyoAouPqo4H9KCn7zuZ1jgHgE0d3VPJC 2u9kWoNxqFdOU7RGCjnzAuIxr3Vp5km6+3 X-Gm-Gg: ASbGncvbRaVikp//0RPKW1b2ptJ0XQcvLtsV9WyzvXbUhCwx4vCu/0mdRuYm5aUxJNV NqARDCshVxdC7p2zgRC98vUPlUnM7KgwR3zvQ4RFfr1YvY6AZ9QxRKJ+7TsJ3FRqLkREylkd8Oc Ksro9jQOcSj/TBefkRHc0nlAaXriZnsNwgqPZAY2olLaz4yrPwpoebIUpVwau3BJ1PiwAVfdIQ8 gOjX/xxXcw1nV2jiPKSHg9X5UgqOgIPiC9vBT0O31ynsh67qk5kfnYKP8EmCuuFS6ByH2alb6Ve fVyEJvdwaZbr8AulrbEGGSSE5Nhc23pwLGG+zZS/Osy4qFZ1hVyLdnev9serahRGYA== X-Received: by 2002:a5d:4748:0:b0:38a:615b:9ec0 with SMTP id ffacd0b85a97d-38dc935a897mr7523369f8f.54.1739177224238; Mon, 10 Feb 2025 00:47:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgOB7xEm1V5wNJQ3Zv93firtiq/tsaQHHEcpJeSZ2euPV1wlrR7d0KF7QhxhddxrvwuMA3eg== X-Received: by 2002:a5d:4748:0:b0:38a:615b:9ec0 with SMTP id ffacd0b85a97d-38dc935a897mr7523332f8f.54.1739177223801; Mon, 10 Feb 2025 00:47:03 -0800 (PST) From: David Hildenbrand To: qemu-devel@nongnu.org Cc: David Hildenbrand , Paolo Bonzini , Peter Xu , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alex Williamson , Eduardo Habkost , Marcel Apfelbaum , Elena Ufimtseva , Jagannathan Raman , "Dr. David Alan Gilbert" , Stefan Zabka Subject: [PATCH v3 4/7] physmem: disallow direct access to RAM DEVICE in address_space_write_rom() Date: Mon, 10 Feb 2025 09:46:45 +0100 Message-ID: <20250210084648.33798-5-david@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250210084648.33798-1-david@redhat.com> References: <20250210084648.33798-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=dhildenb@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.405, 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_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1739177304082019000 Content-Type: text/plain; charset="utf-8" As documented in commit 4a2e242bbb306 ("memory: Don't use memcpy for ram_device regions"), we disallow direct access to RAM DEVICE regions. This change implies that address_space_write_rom() and cpu_memory_rw_debug() won't be able to write to RAM DEVICE regions. It will also affect cpu_flush_icache_range(), but it's only used by hw/core/loader.c after writing to ROM, so it is expected to not apply here with RAM DEVICE. This fixes direct access to these regions where we don't want direct access. We'll extend cpu_memory_rw_debug() next to also be able to write to these (and IO) regions. This is a preparation for further changes. Cc: Alex Williamson Reviewed-by: Peter Xu Signed-off-by: David Hildenbrand --- system/physmem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 67c9db9daa..7cfcc6cafa 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3137,8 +3137,7 @@ static inline MemTxResult address_space_write_rom_int= ernal(AddressSpace *as, l =3D len; mr =3D address_space_translate(as, addr, &addr1, &l, true, attrs); =20 - if (!(memory_region_is_ram(mr) || - memory_region_is_romd(mr))) { + if (!memory_region_supports_direct_access(mr)) { l =3D memory_access_size(mr, l, addr1); } else { /* ROM/RAM case */ --=20 2.48.1