{"id":2229264,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229264/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260427232116.50586-2-scottjgo@gmail.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260427232116.50586-2-scottjgo@gmail.com>","date":"2026-04-27T23:21:15","name":"[1/2] target/arm/hvf, target/i386/hvf: Pass MR-relative offset to memory_region_set_dirty()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"69566f18efecb6933f6dddffddf3cf354e395997","submitter":{"id":93060,"url":"http://patchwork.ozlabs.org/api/1.1/people/93060/?format=json","name":"Scott J. Goldman","email":"scottjgo@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260427232116.50586-2-scottjgo@gmail.com/mbox/","series":[{"id":501742,"url":"http://patchwork.ozlabs.org/api/1.1/series/501742/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=501742","date":"2026-04-27T23:21:14","name":"target/{arm,i386}/hvf: Fix HVF migration","version":1,"mbox":"http://patchwork.ozlabs.org/series/501742/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229264/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229264/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=Th9XeWhY;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4KQh109Nz1yHX\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 09:24:28 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wHVIz-0000yR-Lr; Mon, 27 Apr 2026 19:23:57 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <scottjgo@gmail.com>)\n id 1wHVIs-0000xK-S6\n for qemu-devel@nongnu.org; Mon, 27 Apr 2026 19:23:51 -0400","from mail-dl1-x1234.google.com ([2607:f8b0:4864:20::1234])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <scottjgo@gmail.com>)\n id 1wHVIq-0004rs-A9\n for qemu-devel@nongnu.org; Mon, 27 Apr 2026 19:23:50 -0400","by mail-dl1-x1234.google.com with SMTP id\n a92af1059eb24-12c1a170a50so13599046c88.0\n for <qemu-devel@nongnu.org>; Mon, 27 Apr 2026 16:23:47 -0700 (PDT)","from localhost.localdomain ([2601:645:8200:47:f4a5:bd04:3ca7:5727])\n by smtp.gmail.com with ESMTPSA id\n 5a478bee46e88-2ed0a0ce710sm849973eec.19.2026.04.27.16.23.44\n (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);\n Mon, 27 Apr 2026 16:23:44 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1777332225; x=1777937025; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=odA0IPTIBedM8iKPBA7J9zqBhAg6a99RkWB/Bh7jxvE=;\n b=Th9XeWhYxSSoV9oKO2GCX1OvUcS05ZEekmoaC0rk8KaKQBXu04nhvTZtd7kpipDvm0\n 7BHMTgDV6A0SCWb4wXBfty6eV8qi0BazZalkmFZh9dqOw0aYiH1KK4r6Vsvwkg5saGnc\n Bra4a+ktaPHWsFh4N0r6RFT/iKwi+UrKFPftVOZhs3XiQtOqdkTkC3yl56PPcfb9CFlS\n w4ntFTg83F3hpx2Q5hwX2R5dRdrv3pdZ+BhC1XZ5tbMqzCzbB2K1C/1Imn1zrVoKUdfb\n PEdtLeIN9u2w+xAl9wXmwYk+117uTVRtQ0XfXf5OVHLZGPTMhZEPQIe7u4uNE0tusvMn\n NLbQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777332225; x=1777937025;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=odA0IPTIBedM8iKPBA7J9zqBhAg6a99RkWB/Bh7jxvE=;\n b=QnlW0QMN4hS3nbyKDLbekQEbS2X6bEmbKZL/VWmTndTiTJkJ+pi9i0Fs5suzxablfY\n 5/RuWNXqdCiwkgZDVulfZBhFBkhNrvYzRBvcrkZ0GzzKncNi5tbgp8q4hIg6ZxZ3lZtm\n jmtHTgMcOJ/E1HHo/yfD4K+VMHPNQK/za+boHjCXIsNBSw20OQKzhzLC6D44mfJq0wZ1\n rolcuSQojNYt/c4oV2X2Kg9rDuxTD2jgkfnc3dp7uYH7NO/0qOXc0g0nVF28p98WJbwY\n rhANzi9NnLAslh1pPrYtt2Z/VgAXa8gywsBtcYtEVoSi2k/eLkdAVJWMNJTOvkC+VHG+\n zkuA==","X-Gm-Message-State":"AOJu0YxpGF7mlwYna6mUWNTA4Ua52wocGVl8QydrM//G2ixbDyPBCmXy\n Ay8+LDlyaOhqSeoxdFp+Pi7MhVsr4LXCmMg0oPTPh7qoSosw3Uuvtq/SN8dO7B7zaHw=","X-Gm-Gg":"AeBDietuTggAjcFGBOWMlM7jm9p9HgzAVU9L3kh2ZBTkVBfT9aEF8hoox0p88xlJtFa\n m5qFLeGv2L2AeiOHqNPW1WdAVVPQC4QtCJSwYI/fnhwjpFTkW5qXs6+eOyRHzkRK2hiA5IjJTsx\n 9C/ijlcnfN34mLoHqm8ZwJjV6RQcNr3LGVa5R/cA0xHOin4MknMxqS2cRKxFkeOpsupWUGwTSn8\n U5e8ulv0OImO9TDR2ZdT3n+tlRVsj0AXPX83B9f6FzbA9ITGcw/hDj/RW3DiFZScNK2y1xmNmBh\n U051lEDT7Y0sFiVjOy6kA5Ba6jeknbsQgoSQVjv025Yg0T/OnGOJ9zW1OYUP2mQdUn2dAgwxKXO\n CgqAA0yjB0H5UBBHbUd5kTIfm50ITTfYiqdoXjZvKNYRd3MVJkGtyK1abzhzVIAtrh89Y5X2Yan\n R14yDXfaUo3A3NzF679G2OpOK0MdSStd0wfLS8zc7KeedIQtloDTf21AyQ7BQ7BocvJtrbXCqFj\n LRtfo5+RAbns18eFf3tMCu1YWYAeJwrutG6QA==","X-Received":"by 2002:a05:7022:2385:b0:12c:8b9:71d9 with SMTP id\n a92af1059eb24-12ddd9b5758mr395647c88.27.1777332225460;\n Mon, 27 Apr 2026 16:23:45 -0700 (PDT)","From":"\"Scott J. Goldman\" <scottjgo@gmail.com>","To":"qemu-devel@nongnu.org","Cc":"qemu-arm@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,\n Alexander Graf <agraf@csgraf.de>, Roman Bolshakov <rbolshakov@ddn.com>,\n Phil Dennis-Jordan <phil@philjordan.eu>,\n Richard Henderson <richard.henderson@linaro.org>, =?utf-8?q?Philippe_Mathie?=\n\t=?utf-8?q?u-Daud=C3=A9?= <philmd@linaro.org>,\n Eric Auger <eric.auger@redhat.com>, \"Scott J. Goldman\" <scottjgo@gmail.com>","Subject":"[PATCH 1/2] target/arm/hvf,\n target/i386/hvf: Pass MR-relative offset to memory_region_set_dirty()","Date":"Mon, 27 Apr 2026 16:21:15 -0700","Message-ID":"<20260427232116.50586-2-scottjgo@gmail.com>","X-Mailer":"git-send-email 2.50.1","In-Reply-To":"<20260427232116.50586-1-scottjgo@gmail.com>","References":"<20260427232116.50586-1-scottjgo@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2607:f8b0:4864:20::1234;\n envelope-from=scottjgo@gmail.com; helo=mail-dl1-x1234.google.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, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Both the arm and i386 hvf accelerators have the same bug in their\ndirty-page logging path: the address fed to memory_region_set_dirty()\nis computed as \"<ipa,gpa>_page + xlat\", but memory_region_set_dirty()\nexpects an offset relative to the start of the resolved MemoryRegion.\naddress_space_translate() already returns that offset in xlat, while\nipa_page / gpa_page is the guest-physical (system address space)\naddress.\n\nAdding the two together produces a bogus offset that for any non-\ntrivial RAM size walks well past the end of the MemoryRegion's dirty\nbitmap. With dirty logging active (e.g. live migration on a guest\nwith several GB of RAM), this triggers an out-of-bounds atomic write\ninside bitmap_set_atomic() and crashes the source QEMU as soon as the\nguest writes to RAM:\n\n    Thread .. 'CPU N/HVF', stop reason = EXC_BAD_ACCESS ...\n      bitmap_set_atomic at bitmap.c:213\n      physical_memory_set_dirty_range at physmem.c:1038\n      memory_region_set_dirty at memory.c:2191\n      hvf_handle_exception at hvf.c\n\nFix it by passing only the MR-relative offset xlat. ipa_page /\ngpa_page is still the right argument to hvf_unprotect_dirty_range(),\nwhich works on the guest-physical address space.\n\nSigned-off-by: Scott J. Goldman <scottjgo@gmail.com>\n---\n target/arm/hvf/hvf.c  | 2 +-\n target/i386/hvf/hvf.c | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)","diff":"diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c\nindex a19d7a5e1f..a36c634423 100644\n--- a/target/arm/hvf/hvf.c\n+++ b/target/arm/hvf/hvf.c\n@@ -2243,7 +2243,7 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp)\n                 assert(!mr->readonly);\n \n                 if (memory_region_get_dirty_log_mask(mr)) {\n-                    memory_region_set_dirty(mr, ipa_page + xlat, page_size);\n+                    memory_region_set_dirty(mr, xlat, page_size);\n                     hvf_unprotect_dirty_range(ipa_page, page_size);\n                 }\n \ndiff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c\nindex c0d028b147..cdc8bd1950 100644\n--- a/target/i386/hvf/hvf.c\n+++ b/target/i386/hvf/hvf.c\n@@ -146,7 +146,7 @@ static bool ept_emulation_fault(CPUState *cs, uint64_t gpa, uint64_t ept_qual)\n     if (write && memory_region_get_dirty_log_mask(mr)) {\n         uintptr_t page_size = qemu_real_host_page_size();\n \n-        memory_region_set_dirty(mr, gpa_page + xlat, page_size);\n+        memory_region_set_dirty(mr, xlat, page_size);\n         hvf_unprotect_dirty_range(gpa_page, page_size);\n     }\n \n","prefixes":["1/2"]}