[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 38/39] rust/pl011: Fix range checks for device ID accesses
From: |
Alex Bennée |
Subject: |
[PATCH 38/39] rust/pl011: Fix range checks for device ID accesses |
Date: |
Thu, 21 Nov 2024 16:58:05 +0000 |
From: Junjie Mao <junjie.mao@hotmail.com>
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 <peter.maydell@linaro.org>
Signed-off-by: Junjie Mao <junjie.mao@hotmail.com>
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id:
<SY0P300MB102644C4AC34A3AAD75DC4D5955C2@SY0P300MB1026.AUSP300.PROD.OUTLOOK.COM>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
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/device.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<u
use RegisterOffset::*;
std::ops::ControlFlow::Break(match RegisterOffset::try_from(offset) {
- Err(v) if (0x3f8..0x400).contains(&v) => {
+ Err(v) if (0x3f8..0x400).contains(&(v >> 2)) => {
u64::from(self.device_id[(offset - 0xfe0) >> 2])
}
Err(_) => {
--
2.39.5
- Re: [PATCH 23/39] tests/functional: add a m68k tuxrun tests, (continued)
- [PATCH 25/39] tests/functional: update the mips32el tuxrun tests, Alex Bennée, 2024/11/21
- [PATCH 22/39] tests/functional: update the i386 tuxrun tests, Alex Bennée, 2024/11/21
- [PATCH 37/39] plugins: eradicate qemu-plugins.symbols static file, Alex Bennée, 2024/11/21
- [PATCH 26/39] tests/functional: update the mips64 tuxrun tests, Alex Bennée, 2024/11/21
- [PATCH 15/39] tests/functional: rewrite console handling to be bytewise, Alex Bennée, 2024/11/21
- [PATCH 38/39] rust/pl011: Fix range checks for device ID accesses,
Alex Bennée <=
- [PATCH 27/39] tests/functional: update the mips64el tuxrun tests, Alex Bennée, 2024/11/21
- Re: [PATCH 00/39] maintainer updates for -rc2 pre-PR, Peter Maydell, 2024/11/21
- Re: [PATCH 00/39] maintainer updates for -rc2 pre-PR, Cédric Le Goater, 2024/11/21