From nobody Sun Dec 6 20:46:09 2026 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; arc=fail (Bad Signature); dmarc=pass(p=reject dis=none) header.from=nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179621855174139.63940204233279; Wed, 2 Dec 2026 05:35:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xYkUb-0005yX-J0; Wed, 02 Dec 2026 08:35:29 -0500 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 1xYkLA-000318-Of for qemu-devel@nongnu.org; Wed, 02 Dec 2026 08:25:44 -0500 Received: from mail-southindiaazon11021081.outbound.protection.outlook.com ([40.107.57.81] helo=MA0PR01CU012.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xYkL8-00053v-St for qemu-devel@nongnu.org; Wed, 02 Dec 2026 08:25:44 -0500 Received: from PN3P287MB1189.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:196::14) by PN2P287MB1197.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:1b5::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 13:20:34 +0000 Received: from PN3P287MB1189.INDP287.PROD.OUTLOOK.COM ([fe80::edbd:4f01:ca92:72c3]) by PN3P287MB1189.INDP287.PROD.OUTLOOK.COM ([fe80::edbd:4f01:ca92:72c3%6]) with mapi id 15.21.0688.009; Wed, 2 Dec 2026 13:20:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nongnu.org; s=lists1p-gnu-org; h=From:MIME-Version:Date:Subject:To:in-reply-to: references; bh=uTT2AkkUgP3MIPjGYp5SGZfdnQWl3h8sL3y6aJV1SMY=; b=IlDpoFBzrE/PWE 7yJ/NRbwXG9QbMKRGhBQLUVGW5JHnGz0rZKBdEGGSvV8p3SE2uw2Rs/Uuy8ExKyx+3JL20U8fTiCa TEdcPn316vNcSdJ9s+ncA2RkqAuSnP95NcyQFw12EypG4eDjEFls+3JvwHRTRT5On1qg0MEOFlKHP F2Fiz1y26/Rrnpar14InzATsAeuJLZAPlDL9qNW/l1MlHdbQm3O6L/jcENJayhZgDdjrUYMhxx4IF QNNc9aMxdtqWZuHC1Haib3/4j3THVoL5oKOIGPNpQJBTqwR6ZdCznNDljNzHS0ruZrzwqnYK03KNc HJfKihqentbxXPxSHFjg==; ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=va8zrQ8iIZlk4uGPYkr07/fRuu+iOPra60gjzExC7XSs1MtoMGMw+XCKfNHa9XyJSZNlElsfICV4EoUExTDFjUvF1Iy6maEMO/vl5SWCeKAEHWzBa9aZUfwdJSGtDKuc/YCoHy5qVLWRfAYkgNXNXGkoZ/Th/xRBrjelQC+mNcRa5ixIqOfEgmzKPLf4NiGALtblLMsWPF3TUpjFCt+tpRYqPYVlga3oVIT4Y2QqdkszL0TKRTSRuNPiaPY0XuQm13Mz7IJ3d6htL8XEkZjCZWQbT5PfnbON7S6Z+0PdiR37vCLDwH/3cXS+h3BgpvSWSsR7nQpozl+BgW0x3AEMrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uTT2AkkUgP3MIPjGYp5SGZfdnQWl3h8sL3y6aJV1SMY=; b=Jmq8WrEJTzy2sj2cFxPM1BBASGB9py2aiByxyAaf9XPUR1m4AToMBzBwnxvI/JRYMxBe30TV8t/EXLKQhxsbH80Op4vsQgAHTshc9V390dTHjfqTeXrITLQbZ6f1cL0skb469/NPR9g/Rfh/1fHrxZ1IYbak8XhnheDHbmIpFb3FrBokUDH5O5EeOWjfbspTZ+Fwa+yKEm/+MPT3qZooTzc+E4qgymRBuGupwFsK5opgDuBzBGOif75Agi5ciQD0wFGDHgG1jjSE0YYda6+A2LwaeBk8Pfw7VnIGI6rfNlMQ9epsNIUaLsl1sdpsYpsb+zgKbprze04AqDHwXbZopg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arivemb.com; dmarc=pass action=none header.from=arivemb.com; dkim=pass header.d=arivemb.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arivemb.com; To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, alex.bennee@linaro.org Subject: [PATCH] replay: split long instruction gaps into several EVENT_INSTRUCTION Date: Wed, 2 Dec 2026 13:20:30 +0000 Message-ID: <20261202132030.7-1-arkadiusz.grzelka@arivemb.com> X-Mailer: git-send-email 2.47.3 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BE1P281CA0400.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:80::13) To PN3P287MB1189.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:196::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN3P287MB1189:EE_|PN2P287MB1197:EE_ X-MS-Office365-Filtering-Correlation-Id: 832e7c91-75b7-40a5-f2b7-08df50770c27 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|376014|23010399003|56012099006|261021123027099003|261026140227099003|261021121427099003|261102123227099003|261028144727099003|10067099003|261022105027099003|261022075727099003|261009223027099003|18002099003|3023799007; X-Microsoft-Antispam-Message-Info: KdauImkmmKTVaPlld3Qg8MVnBd7cQrGKl9U3YOvWKVYib2h4h4TEry0Dr4k/9sBBiV1hT97TWG+fEqkq42BT+qtDTdt3L9MlDxBGGPo8Dy8E1GDfOZJYnDPPS5Jqt2R8yY7LR/5FkDmXFS/bg6cmfkMGoDvJcifnjhcz9AUsCcwK7LE/olxzcVOlYM1QhCYpHaXC2XDdMHntygDn58GnDUPBWVoUPop8lOx1RI6WTJKvcxp23Cb7uWkpnLcnmu5o+wbSIh0dNmSRUgZ88BE7lCnzk5KzQgchKamZ8RpCUrW65WKtQagXhzS3UIl6/NDlNdLNYkj8Swc0RFdfC5gZC+RuY8aPmanDUd+v1JB4VyTCB0eHVQxZmNgU9Ll9xo0Fnaw0sg3dxmis9yagr6sSVm12P4BOCawJ3v/05/g9C4cyparrJU+pPp8lSilq56SXLzES/FZKPp0b+R2N1KOmybxrHEJjueAUG96Hjjq8MsRUxe6xQzRJ8LanQShPDfFdPezjkVv10OFKqgelEYOKmlj+3Hlv9bfx6XJPQ0FmVl2Yviqaz4dp6KjU5Y0Zq2b+B40riKrbjK3vrOotxvHuGkiXkdM7tZj5wIYL4E9Bo32+op+Ihh0pdV8BD/UKhAGXBlK9YjIuJUBHz6OWpdLerIXSxReo1p1VchUuVzSIapA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PN3P287MB1189.INDP287.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(23010399003)(56012099006)(261021123027099003)(261026140227099003)(261021121427099003)(261102123227099003)(261028144727099003)(10067099003)(261022105027099003)(261022075727099003)(261009223027099003)(18002099003)(3023799007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-Chun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l13eJVVig5eVlq05?= =?us-ascii?Q?oU7rmavu+O+xfxFvFRFnALs31O8SS7w=3D?= X-OriginatorOrg: arivemb.com X-MS-Exchange-CrossTenant-Network-Message-Id: 832e7c91-75b7-40a5-f2b7-08df50770c27 X-MS-Exchange-CrossTenant-AuthSource: PN3P287MB1189.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 13:20:34.7537 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0da69f4d-e180-47b8-9ef2-0eda68c86ebf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1jBPONXlKbdUFrtZYoVRS1gXdYLd0zMYRn8CUdDqhE3CuL1IFYXdvIaGHDHTwpysiDsQRBpCoSZJmJKQd0DBwKmZuLRU5B30cH6MiMCHbeM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN2P287MB1197 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=lists1p.gnu.org; Received-SPF: pass client-ip=40.107.57.81; envelope-from=arkadiusz.grzelka@arivemb.com; helo=MA0PR01CU012.outbound.protection.outlook.com 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 02 Dec 2026 08:35:26 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Arkadiusz Grzelka From: Arkadiusz Grzelka via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nongnu.org) X-ZM-MESSAGEID: 1796218552907158501 Content-Type: text/plain; charset="utf-8" In record mode the instruction count is written only when a replay event happens. A guest that spins with no timer, interrupt or I/O (and with -icount sleep=3Doff, so no warp checkpoint is taken) produces no event, and the gap since the last one grows without bound. replay_advance_current_icount() truncates that gap to an int. Past 2^31 instructions the final replay_save_instructions() from replay_finish() sees a negative value and aborts on assert(diff >=3D 0), leaving an empty log. Past 2^32 the value wraps positive again and the log silently holds a count 2^32 too small, so the replay ends early. Compute the gap as int64_t and write it as several EVENT_INSTRUCTION records of at most INT32_MAX each; the reader keeps the count in an int. Replay already consumes consecutive EVENT_INSTRUCTION records: when one is used up, replay_finish_event() fetches the next one. The log format and REPLAY_VERSION are unchanged. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/5067 Fixes: 26bc60ac82f8 ("replay: introduce icount event") Signed-off-by: Arkadiusz Grzelka --- Reproduced: aarch64 -M virt -cpu cortex-a57, guest 00 00 00 14 (b .) as -bios, -icount shift=3D0,sleep=3Doff,rr=3Drecord, stopped past 2^31 + 2^27. Checked after the fix: - SIGTERM and QMP quit: exit 0, logs of 144 and 155 bytes. - Replay with replay-break 2^20 before the end, and on the 2^31 and 2^32 record boundaries: STOP at the exact count. - An unpatched binary replays a split log correctly; log format and REPLAY_VERSION unchanged. - Not tested: snapshots or replay-seek inside a split gap. replay/replay-internal.c | 11 +++++++---- replay/trace-events | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/replay/replay-internal.c b/replay/replay-internal.c index 4839f2b632..89ca98389c 100644 --- a/replay/replay-internal.c +++ b/replay/replay-internal.c @@ -278,17 +278,20 @@ void replay_mutex_unlock(void) =20 void replay_advance_current_icount(uint64_t current_icount) { - int diff =3D (int)(current_icount - replay_state.current_icount); + int64_t diff =3D current_icount - replay_state.current_icount; =20 /* Time can only go forward */ trace_replay_advance_current_icount(replay_state.current_icount, diff); assert(diff >=3D 0); =20 if (replay_mode =3D=3D REPLAY_MODE_RECORD) { - if (diff > 0) { + while (diff > 0) { + int32_t step =3D MIN(diff, INT32_MAX); + replay_put_event(EVENT_INSTRUCTION); - replay_put_dword(diff); - replay_state.current_icount +=3D diff; + replay_put_dword(step); + replay_state.current_icount +=3D step; + diff -=3D step; } } else if (replay_mode =3D=3D REPLAY_MODE_PLAY) { if (diff > 0) { diff --git a/replay/trace-events b/replay/trace-events index e9c887a6c5..290c08809f 100644 --- a/replay/trace-events +++ b/replay/trace-events @@ -9,4 +9,4 @@ replay_get_dword(uint32_t dword) "%08x" replay_get_qword(uint64_t qword) "%016" PRIx64 replay_fetch_data_kind(void) "" replay_get_event(uint32_t current, uint8_t data) "#%u data=3D%02x" -replay_advance_current_icount(uint64_t current_icount, int diff) "current= =3D%" PRIu64 " diff=3D%d" +replay_advance_current_icount(uint64_t current_icount, int64_t diff) "curr= ent=3D%" PRIu64 " diff=3D%" PRId64 base-commit: 3c061218fcf37a98c944ecb88cff56f94f5c0a43 --=20 2.43.0