From nobody Tue Aug 25 14:48:21 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-Seal: i=1; a=rsa-sha256; t=1779486862; cv=none; d=zohomail.com; s=zohoarc; b=SojocfQ0S8iMlCz/YXdNHJ1gk6luhCngXC7YmhGKnOhZ11Ne7xWL8xlw6LZTmY37EntTJTmVhYZO4BiT30BLHQVhrebwHi5iWFNzN1arI5ufw/V+nGlNV2TSz1QjLgmZYRNgYX/s97EMO8OfwbdiTWoY+mngaq/DSLAgIrDo6kk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779486862; h=Content-Type: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=lX6xb2HJMJIzIe8BxaeFAgCxrnSe752Vml61AhftVto=; b=JSwZeVgnkXGhLsOOMr9uj4lEBFIKk4Sw221JPcwLntxDHETQQluduJiArB0yUZemF7lRdyXkSKiK7jGddeiAdLM8kKvXuo1PeiBNAn94NVcTL1emHiqDnRY5IOTt3K9jGBltmwdaREQ/l0RPUq7AlXWNJUOlmJGe5+MaE+nzP5k= 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 Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779486862779259.0361483356246; Fri, 22 May 2026 14:54:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQXmu-0003Zo-L2; Fri, 22 May 2026 17:52:12 -0400 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 1wQXmg-0002rP-5K; Fri, 22 May 2026 17:52:00 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQXme-0004EV-1E; Fri, 22 May 2026 17:51:57 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 0514B1AFB77; Sat, 23 May 2026 00:49:21 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 2DA453B71C6; Sat, 23 May 2026 00:49:25 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tls.msk.ru; s=202602; t=1779486561; bh=CBmXxLaye/eE13X9exw7xfw/K70AIPWJmgtC4ZIwDTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eRSPsGvCDZLjvTevoeXj1DlZQhfo456uaa7yR6PV6OxQdLO096Bzam+rYJpsAbGrx kdU2xyhh0udz+IWgi+qHrZr0W/MmP70NG/okywjlpF/Nrg+vkOBZSNRlnurs7a5Xpm quq9IC4dwFxQJwz6/bewcXFcNToxBEUnZow6qy9c/kAkw33Ng6pJ9Vvl+UY+u37ylA D43sluHMKkTN+F0LzohBk9bQIIcAj1yM6eDh02GSvPGecsl+LKlZ1UCzc0H29hN5qf cGx0DXzlaYKKc1UTnhk0lfDE+MsRKXi/gJxCyvxI/Jf45MKufKDzJTO0TWf23Id3RD Z+GAoW3v1GKBA== From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Michael Tokarev Subject: [Stable-10.2.3 129/149] hw/i2c/microbit_i2c: Don't index off end of twi_read_sequence[] Date: Sat, 23 May 2026 00:49:01 +0300 Message-ID: <20260522214923.807017-30-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=lists1p.gnu.org; Received-SPF: pass client-ip=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, 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: qemu development 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 @tls.msk.ru) X-ZM-MESSAGEID: 1779486864240158500 From: Peter Maydell If the guest tries to read more bytes from our fake stub I2C device than we have provided, we incorrectly read one byte beyond the end of this array. Avoid this, and instead keep reporting the RXD register as containing the last byte of the "data transfer". Cc: qemu-stable@nongnu.org Fixes: 9d68bf564ec ("arm: Stub out NRF51 TWI magnetometer/accelerometer det= ection") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3408 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20260501162634.4092394-1-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daud=C3=A9 (cherry picked from commit a824f3531a44cbd19bcd9dd0ca48e5805c781e02) Signed-off-by: Michael Tokarev diff --git a/hw/i2c/microbit_i2c.c b/hw/i2c/microbit_i2c.c index 2291d6370e..d9689b6f1a 100644 --- a/hw/i2c/microbit_i2c.c +++ b/hw/i2c/microbit_i2c.c @@ -41,8 +41,13 @@ static uint64_t microbit_i2c_read(void *opaque, hwaddr a= ddr, unsigned int size) data =3D 0x01; break; case NRF51_TWI_REG_RXD: + /* + * Return the next byte from our fake data sequence. If + * the guest keeps reading the register after that, keep + * returning the same last byte value. + */ data =3D twi_read_sequence[s->read_idx]; - if (s->read_idx < G_N_ELEMENTS(twi_read_sequence)) { + if (s->read_idx + 1 < G_N_ELEMENTS(twi_read_sequence)) { s->read_idx++; } break; --=20 2.47.3