From nobody Mon Feb 9 05:42:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643899765824829.7284265018193; Thu, 3 Feb 2022 06:49:25 -0800 (PST) Received: from localhost ([::1]:40206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nFdQK-0000wQ-PJ for importer@patchew.org; Thu, 03 Feb 2022 09:49:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nFd1I-00028R-Cv; Thu, 03 Feb 2022 09:23:32 -0500 Received: from mail.csgraf.de ([85.25.223.15]:34076 helo=zulu616.server4you.de) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nFd1G-0007FO-EE; Thu, 03 Feb 2022 09:23:32 -0500 Received: from localhost.localdomain (dynamic-095-114-033-227.95.114.pool.telefonica.de [95.114.33.227]) by csgraf.de (Postfix) with ESMTPSA id 39B4F6080DA9; Thu, 3 Feb 2022 15:23:22 +0100 (CET) From: Alexander Graf To: qemu-devel@nongnu.org Subject: [PATCH] hvf: arm: Add simple dirty bitmap tracking Date: Thu, 3 Feb 2022 15:23:20 +0100 Message-Id: <20220203142320.33022-1-agraf@csgraf.de> X-Mailer: git-send-email 2.32.0 (Apple Git-132) 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=85.25.223.15; envelope-from=agraf@csgraf.de; helo=zulu616.server4you.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: Peter Maydell , Roman Bolshakov , qemu-arm@nongnu.org, Cameron Esfahani Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1643899770924100001 Content-Type: text/plain; charset="utf-8" The actual tracking of dirty bitmap updates is happening in architecture co= de. So far, the aarch64 hvf code has not updated QEMU's dirty bitmap at all. The net result of that is that the VGA device's framebuffer would not update. This patch adds simplistic dirty bitmap updates. Unfortunately hvf can only= set permissions per full region, so we have to mark the complete region as dirty when only a single byte was modified inside. We also handle the write protect update logic before we handle any writes. This allows us to even handle non-ISV instructions on dirty logging enabled memory regions: Once we flip the region to writable again, we just rerun the trapping instruction. Signed-off-by: Alexander Graf --- target/arm/hvf/hvf.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 0dc96560d3..92ad0d29c4 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1163,6 +1163,28 @@ int hvf_vcpu_exec(CPUState *cpu) break; } =20 + /* + * Dirty log updates work without isv as well. We just run the wri= te + * again with write permissions set. So handle them before the ass= ert. + */ + if (iswrite) { + uint64_t gpa =3D hvf_exit->exception.physical_address; + hvf_slot *slot =3D hvf_find_overlap_slot(gpa, 1); + + if (slot && slot->flags & HVF_SLOT_LOG) { + /* + * HVF can only set a full region's permissions, so let's = just + * mark the full region as dirty. + */ + memory_region_set_dirty(slot->region, 0, slot->size); + hv_vm_protect(slot->start, slot->size, HV_MEMORY_READ | + HV_MEMORY_WRITE | HV_MEMORY_EXEC); + + /* Run the same instruction again, without write faulting = */ + break; + } + } + assert(isv); =20 if (iswrite) { --=20 2.32.0 (Apple Git-132)