All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Junjie Mao <junjie.mao@hotmail.com>
Cc: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	 qemu-devel@nongnu.org,  Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [PATCH] rust/pl011: Fix range checks for device ID accesses
Date: Mon, 18 Nov 2024 09:43:35 +0000	[thread overview]
Message-ID: <87seroubaw.fsf@draig.linaro.org> (raw)
In-Reply-To: <SY0P300MB102644C4AC34A3AAD75DC4D5955C2@SY0P300MB1026.AUSP300.PROD.OUTLOOK.COM> (Junjie Mao's message of "Thu, 7 Nov 2024 14:13:07 +0800")

Junjie Mao <junjie.mao@hotmail.com> writes:

> 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>

This certainly fixes the avocado failures.

Tested-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-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(_) => {

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  reply	other threads:[~2024-11-18  9:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07  6:13 [PATCH] rust/pl011: Fix range checks for device ID accesses Junjie Mao
2024-11-18  9:43 ` Alex Bennée [this message]
2024-11-18  9:54   ` Junjie Mao
2024-11-18 10:38     ` Alex Bennée
2024-11-21 16:47 ` Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87seroubaw.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=junjie.mao@hotmail.com \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.