From nobody Sat Nov 23 18:38:59 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1732209189; cv=none; d=zohomail.com; s=zohoarc; b=VV4xScV+AKMW426P5SzDSSjcRISdUO2rfxEZXZ0MAHGfwTfas1nk2E9VGi1q5nYYkS4eP+bADpyXmVNN2QOhH5WwZ+2LCYfYRQ8WZkYMoO4vF/F5zath9BmoGseXGtOMgidVOL0F+Vh2T7KTM4TZqMwaVdZPc/3g+VIbOmOtV84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732209189; 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=ZYyjcmwGZcc7NttBsBYoWNTe7fj51f/J/c4PbwCrSW0=; b=RoZwf41hnM1Ahs+rTfLHIdSr63e78KHU3wIM3EZmumU9a9/337axgZoD57b0BbxRBJf1+9YDpWJ5FXlbGaX4xSVy0bIv3dRzuDUppgRhI6fkHWcKpnXdMXoDlR3qT1krakPcPimWiV9PLt7Br1vDfHwIR7lQ+TL+JSM0SF9NCds= 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; 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 1732209189293358.4336497519947; Thu, 21 Nov 2024 09:13:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tEAg5-0005Rs-PS; Thu, 21 Nov 2024 12:09:13 -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 1tEAe1-00012r-3y for qemu-devel@nongnu.org; Thu, 21 Nov 2024 12:07:09 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tEAdY-0001iS-NN for qemu-devel@nongnu.org; Thu, 21 Nov 2024 12:07:04 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-38248b810ffso805676f8f.0 for ; Thu, 21 Nov 2024 09:06:36 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fafeceesm53837f8f.37.2024.11.21.09.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 09:06:30 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id DDBC660500; Thu, 21 Nov 2024 16:58:09 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732208795; x=1732813595; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZYyjcmwGZcc7NttBsBYoWNTe7fj51f/J/c4PbwCrSW0=; b=PejqfVPoBL4glanT7r79oYFDkwi83yLvILxohLx52bggyI+zXGpqzjtgwTjhKhpp4e F/JqLn5dCkHIGKnc05ZbvulOxcj/Z6KEu7CHypxrUAyytEkoxBcHfEkpvE4Yf0vZ/vE9 QM18a9JuEce3i8Jr6E5QiPVxNLpI3Zrr7grkJK2Tw2HO6ia4jqOMDbG/ujGd79iEDOUQ H1wHM8tj9erRBAiJvClN7nncj9uudY6UqMioSqhahUT1yci3jVScS5eAPT8nYvKsk7tL 8V97O2n0mFEy+UQolA09RFwcwjCFeZGM6lXx+22qRv+cGF0InEml8WNlRRcWQm8bnfiK lnQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732208795; x=1732813595; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZYyjcmwGZcc7NttBsBYoWNTe7fj51f/J/c4PbwCrSW0=; b=XrQfdUNoiHunzl82qOPQTucQttFLUohn3h0Y+YcnS+Z34a66r4ghJ2lLE+hFaUbjlO 9Tx6pOpRZrQWLXMFYnppujxWs2waM9mT2ppcqqmJKKqwZQgQHdPl7s9LP7DcvQdC79lV kQL6wmhat1mbRIYqtyqo0TfjmYPyjmEOoRjaEznvktyxXoWkNNT8pBxXH/KOFsf80Uoc zHt5c+awaNQSBmebIst9QTj5t/QZl2OygBoPgGl4F/5oi4DDmFGYVgQF7fHBTBvPWsva aVlMLdE+m81xKAWrdZDRhzGGFD3ay2o6fO7huphfK65d2xnZ+DV8ehWupfbUzpNOAqTs AEWQ== X-Gm-Message-State: AOJu0YwclQDg3mGCc+AoCOLM7pu26EjR/7jmhiY6SXIhFVTfvbvQsxCB CYuroa1802n6yahKMpRNN/rjT+ffsqT90MOOa7+R2URBUVfyhVuFC769HDTx3wI= X-Gm-Gg: ASbGncuO00Cb0/FmVvVD2nd3WkOR3qZrFWpirhCdFXjj8qGZhTG1yRjigiR5cdkHI2d i7NO57WkoWpEJ42t1XAFFPjICtsGQt4GdE22Iky8CNPVyrWPjmSEuqchiWW9HAMrwcuNiSWmKCz u9wQHujzBjI/U1kvD1FAMxNNjExl3Vjv7qusibQc4Kd9RXz4nDbN7U3l73hBuSsXSUKk6jTPTAg LnludLe3iqljd1bdiGX9nKDXgR5b/7ztYSrlZBSr0edRvUe X-Google-Smtp-Source: AGHT+IEzMrGkl+YSMzaGV8afQzDZmynkhbb/zDv35PnZsmLYJaYum1VwMogQ8i2Vgpj+WEtSs5JrcQ== X-Received: by 2002:a05:6000:2a7:b0:382:4b69:9c75 with SMTP id ffacd0b85a97d-38254b17f80mr6364450f8f.43.1732208793832; Thu, 21 Nov 2024 09:06:33 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Daniel Henrique Barboza , Pierrick Bouvier , Harsh Prateek Bora , Marcel Apfelbaum , Jiaxun Yang , Halil Pasic , Christian Borntraeger , qemu-ppc@nongnu.org, Daniel Henrique Barboza , Alexandre Iooss , qemu-riscv@nongnu.org, Thomas Huth , Bernhard Beschow , Thomas Huth , Eric Farman , Bin Meng , qemu-s390x@nongnu.org, Niek Linnenbank , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , John Snow , Wainer dos Santos Moschetta , Cleber Rosa , qemu-rust@nongnu.org, Nicholas Piggin , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Palmer Dabbelt , Markus Armbruster , Weiwei Li , Mahmoud Mandour , Mark Cave-Ayland , Liu Zhiwei , Aurelien Jarno , Ani Sinha , Alistair Francis , Junjie Mao , Manos Pitsidianakis Subject: [PATCH 38/39] rust/pl011: Fix range checks for device ID accesses Date: Thu, 21 Nov 2024 16:58:05 +0000 Message-Id: <20241121165806.476008-39-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241121165806.476008-1-alex.bennee@linaro.org> References: <20241121165806.476008-1-alex.bennee@linaro.org> 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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.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, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1732209191195116600 From: Junjie Mao 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 Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Message-Id: Signed-off-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.39.5