From nobody Sat Nov 23 21:47:51 2024 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=pass (i=1 dmarc=pass fromdomain=hotmail.com); dmarc=pass(p=none dis=none) header.from=hotmail.com ARC-Seal: i=2; a=rsa-sha256; t=1730960382; cv=pass; d=zohomail.com; s=zohoarc; b=e/dYiXARXrTCyPGpC+ZK4n7s6u0ZQ1oeH1m6VuxRFDKxhCWAmAKBqcomviwtVuS0aSQhkfEvzVvH7PNhdjA5+gwdbTqvQrquj3/7ISUmyHow+pKupbEXlyI1cI0ykScacgOk/x3Fvuxx3Z6wCkNT+as9rnzsINJlT6DwVbq9Gu0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730960382; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jZW6/8nAN+mVmljO7sMbKac8QVuSaZP+8nzheJNdr8A=; b=Qe6GCHUfL21Cq3lYHxj317Mn6bPWVTm+DAD+y+7a9Iz2SpZqQxoPEjeWl0lYodSHuhuN4MKl3+Ey9w1rh2oOvb3s3xnbmym9mTH/CAel9yTkTraQj+axF11yl5hh+wAVAYEFt0sJUadQMexW3vZ6exPpwOPYzNYAvLFX3K5K0uk= ARC-Authentication-Results: i=2; 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=pass (i=1 dmarc=pass fromdomain=hotmail.com); 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 1730960382183603.6793245228912; Wed, 6 Nov 2024 22:19:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8vrC-00030a-5I; Thu, 07 Nov 2024 01:19:03 -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 1t8vr4-00030G-NV for qemu-devel@nongnu.org; Thu, 07 Nov 2024 01:18:54 -0500 Received: from mail-me3aus01olkn2055.outbound.protection.outlook.com ([40.92.63.55] helo=AUS01-ME3-obe.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 1t8vr3-0005pQ-3v for qemu-devel@nongnu.org; Thu, 07 Nov 2024 01:18:54 -0500 Received: from SY0P300MB1026.AUSP300.PROD.OUTLOOK.COM (2603:10c6:10:282::22) by SY8P300MB0308.AUSP300.PROD.OUTLOOK.COM (2603:10c6:10:260::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 06:13:41 +0000 Received: from SY0P300MB1026.AUSP300.PROD.OUTLOOK.COM ([fe80::aea3:2365:f9e8:5bd]) by SY0P300MB1026.AUSP300.PROD.OUTLOOK.COM ([fe80::aea3:2365:f9e8:5bd%2]) with mapi id 15.20.8137.019; Thu, 7 Nov 2024 06:13:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rI3hIXeuZJ1uHoNe1wKqqKTx920Ru5CNgpf3ztvzbf29Vdh7Gc5DvAtJWowp6eIRJ39ZhLGgDFbfKXLavWItGMuqMNC9kBZG0IoqG/NFIAyBFDcFeeV0xAiuoaiZ2QESs//fvEfG1bZXXi2nT6xf7Vc7/fXg3fV8RgL4rAIRNCyUajiev8QoB6asF96Xetb/QCvqB4TeJM7EJcNC9nlHEypD1TZBG3tMxHrkZQpbwNe+QcOm4AogRY+LZynSz9QT3VQJdV7NXBui+m4YR5v0syO2vzjojfx8WVS6gPNSekCC0+nLxBMxSgs53lkQuBlSaN6GvQDaoqbgg1VvgP9noQ== 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=jZW6/8nAN+mVmljO7sMbKac8QVuSaZP+8nzheJNdr8A=; b=tE7edk7AHLC04E8XG1oJmfyIk7Z1orD2eEZNdtowOsz0x1jBFWpjcNEah0FK3BfNkcGUt5I4QOk1A1kraxwLR4hWIzdAtu0U+R/WlxcE2r/59Y9vLTgGtVqeH5uY31u1yfYnEcAU6lWN/UYSMNT51GY12CvESOQ7c41LqUh0eBGPsvbQdR4mVylwZj4QSZBOoqSVSaOwglnHwZ7nci+eK3EoE9rxZTfOqWQ4HGO5mklY2pE6FIz1iALIq1SbQw7E9MecxUFyHDa5JUN5ZDY0Z9R5LF7ensGWEWPYdomCmV4sBgDSrHIOq4RH2LSluMwEGDCCaKAtuJWWkkfhjWiKzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jZW6/8nAN+mVmljO7sMbKac8QVuSaZP+8nzheJNdr8A=; b=KWTV47EaqwrRggqmtaWly65XBfKKHK/R3+6GjDgFTJjRJCCniTydFRzbm2V+BVJu6PuHpolrR7U6sO9az/WtcA4Pu92EBXUQ4fVTczBddHes4Zz9D5+WVEHojISWbH3VWRJj6crsGlLNo6l1NK+hQb621FYe/zs7xpJkieRsnbwfDCA4OCnVUt61o/4Uc8idIYNWUrqLjui1fBGZvGG2uJ5FOqnC7l7KSOk2TgmjFBH74zLMhtXtOpq2iw6p54VC3sCwBPWg3iV83viCnp0kW1D6Ob80Akll6ldKDtHw13pFBfMyKxOJgpkY7F0zGUi3D4Y/uYCZ9ttD07nWik0hkw== From: Junjie Mao To: Manos Pitsidianakis , Paolo Bonzini Cc: qemu-devel@nongnu.org, Junjie Mao , Peter Maydell Subject: [PATCH] rust/pl011: Fix range checks for device ID accesses Date: Thu, 7 Nov 2024 14:13:07 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI1PR02CA0010.apcprd02.prod.outlook.com (2603:1096:4:1f7::17) To SY0P300MB1026.AUSP300.PROD.OUTLOOK.COM (2603:10c6:10:282::22) X-Microsoft-Original-Message-ID: <20241107061307.13276-1-junjie.mao@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SY0P300MB1026:EE_|SY8P300MB0308:EE_ X-MS-Office365-Filtering-Correlation-Id: b64e253b-9851-4874-6fbe-08dcfef352ef X-Microsoft-Antispam: BCL:0; ARA:14566002|7092599003|8060799006|461199028|5062599005|5072599009|19110799003|15080799006|440099028|3412199025|1710799026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?UHEC4N6FcSkwZM+L00i503ypPugZmjOs7u/0mRS9SQD2M6y1bTveqddSZuql?= =?us-ascii?Q?5fg58R3gYwRdn2zR000kCwZj5zCWSEW/29eJy9sWrCIi0lWtFTJdxbZHQ8Kk?= =?us-ascii?Q?lM0vn8nA0kDoA9UxqrTmc7XCvXZX6XJsCCWhyk6+OPs90iMEF/7OR3LoLh+p?= =?us-ascii?Q?eAW5p/GkXAp/pGak4T2hMaYmfrDzWBTLYBzazbZ0XQdUdMS8NeE2Q1xjL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7KE6xl/QGFrQVr+yqWJKy1tUpSxVNEFI=3D?= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?S2LmWA7ZzFXADv1HrwLIofOyHT2FDsELoY2jiQmExwqPTqV2aXuJUpcXluaf?= =?us-ascii?Q?CCoThyBsBsksVKDPmpEd6t1ObQGA4++LXGQzakO3fidxIR69y4/Ol4lHFWRo?= =?us-ascii?Q?PpMPalB3BBaWg4QQhSimZFrLwZwrtrxGcXq3ZpCt3IMQTvTL31t5eXxwSvrs?= =?us-ascii?Q?1CQcpWDtzRratfhrkTMA+dPMIV5R40AD7RNuYAaE4PFnGZH13YDnbENO5bzX?= =?us-ascii?Q?P40Az1ixHYJkSOIEULGCKXgForLr0SAGkdRiwbRoHseVKlgiQz/hpx5SqkLO?= =?us-ascii?Q?tDgnMYDHMIKRvRuSeqEEvvgjFgGJL0ukCMHcOYbCLTSWG8UHZVoQukD86Hqa?= =?us-ascii?Q?BI9iJZwfpKGEHwx7gv8DaabSJrm6R/YOm2OAlW0H3LBWkZSDBXiXAHhefAvN?= =?us-ascii?Q?e5LfEd519R7W5p73HQYja4momJDpaQRRskLRYAvBLQK5VdtGS26elWxxX/Ds?= =?us-ascii?Q?zanIWL+uquBC+WT/l12HfUD0zuIJhk7T9/ID4Hiw1yNBtgkUQrWZy0njRw7Y?= =?us-ascii?Q?J8mA+HhbuLm+Yst5M615mYBkOVqH+H9IUEgid9e+nILSqYt9iydBKSC88opF?= =?us-ascii?Q?LDZ3umrkmFYp02ee0CmmRY1HHnbRMp62BFYm4vkIJljhn+N+/UZ1Goobl2nQ?= =?us-ascii?Q?N7lcAp/AdNRtxDzpTI/0C8tT0+H5JmTM7fyYl6HTrPnZOyfilAQulTmBUtFg?= =?us-ascii?Q?ikZhbEqBHluhClVqFh8+9i5k6pYKdKmFf6c4RHJzlhc4YYmlWrcXvYD8045O?= =?us-ascii?Q?y0E2sApdmSX4F6NtDs7/W4DlGmJWDrGBdWPCMpMu1hRYux66jF/E7IX7yOpZ?= =?us-ascii?Q?1LdxIcaLM+yXFo7ChlrW3s/lGVTCvYLGP4cZzWD0w63DSPKXaJere9mVMrR1?= =?us-ascii?Q?i5yQBdvP3VabxM63DabCeLR1qN6hDNt1eTU5Lnj5dvDEwLTbBehjpZPOZRlj?= =?us-ascii?Q?mJhEwRnWC0uM7524l4vRCrYwNgJDsGDHulOcmA/gx+DmGKuivCjMA4z0vfvh?= =?us-ascii?Q?2UxiAzHChTTBmrsNKaJAEBGZ1Uw60BKSO5tJyWxKVgnPSmiV+B5vOjEpqXMM?= =?us-ascii?Q?k3+ivB0eF5Xg6dCtfIA2S5ZWKuUMoDv7w09yFf9jwmH2TZDdLALaiDRKr+f4?= =?us-ascii?Q?NJ4eHIs2jVf1bGwDDY4QC0iHCoTxXjx6o+2XSJr91+5sjShJfz/muvu4Vkig?= =?us-ascii?Q?/B+705eDTciPUKMhXv+QgKyLI+2lPgpzGLe4uFbX6nTmG3vg0sGD2+eXVww?= =?us-ascii?Q?=3D?= X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-448bf.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: b64e253b-9851-4874-6fbe-08dcfef352ef X-MS-Exchange-CrossTenant-AuthSource: SY0P300MB1026.AUSP300.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:13:40.4255 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SY8P300MB0308 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=40.92.63.55; envelope-from=junjie.mao@hotmail.com; helo=AUS01-ME3-obe.outbound.protection.outlook.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, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @hotmail.com) X-ZM-MESSAGEID: 1730960382549116600 Content-Type: text/plain; charset="utf-8" The peripheral and PrimeCell identification registers of pl011 are located = at offset 0xFE0 - 0xFFC. To check if a read falls to such registers, the C implementation checks if the offset-shifted-by-2 (not the offset itself) is= in the range 0x3F8 - 0x3FF. Use the same check in the Rust implementation. This fixes the timeout of the following avocado tests: * tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_virt * tests/avocado/replay_kernel.py:ReplayKernelNormal.test_arm_virt * tests/avocado/replay_kernel.py:ReplayKernelNormal.test_arm_vexpressa9 Reported-by: Peter Maydell Signed-off-by: Junjie Mao Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- rust/hw/char/pl011/src/device.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 2a85960b81..476cacc844 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -182,7 +182,7 @@ pub fn read(&mut self, offset: hwaddr, _size: c_uint) -= > std::ops::ControlFlow { + Err(v) if (0x3f8..0x400).contains(&(v >> 2)) =3D> { u64::from(self.device_id[(offset - 0xfe0) >> 2]) } Err(_) =3D> { --=20 2.34.1