qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org, pbonzini@redhat.com
Subject: Re: [PATCH 1/3] softmmu: Assert data in bounds in iotlb_to_section
Date: Sun, 27 Aug 2023 10:39:23 +0100	[thread overview]
Message-ID: <871qfo6cxb.fsf@linaro.org> (raw)
In-Reply-To: <20230826232415.80233-2-richard.henderson@linaro.org>


Richard Henderson <richard.henderson@linaro.org> writes:

> Suggested-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  softmmu/physmem.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/softmmu/physmem.c b/softmmu/physmem.c
> index 3df73542e1..7597dc1c39 100644
> --- a/softmmu/physmem.c
> +++ b/softmmu/physmem.c
> @@ -2413,9 +2413,15 @@ MemoryRegionSection *iotlb_to_section(CPUState *cpu,
>      int asidx = cpu_asidx_from_attrs(cpu, attrs);
>      CPUAddressSpace *cpuas = &cpu->cpu_ases[asidx];
>      AddressSpaceDispatch *d = qatomic_rcu_read(&cpuas->memory_dispatch);
> -    MemoryRegionSection *sections = d->map.sections;
> +    int section_index = index & ~TARGET_PAGE_MASK;
> +    MemoryRegionSection *ret;

It might be worth a quick comment where section_index comes from because
I was confused initially expecting it to be address like.

>  
> -    return &sections[index & ~TARGET_PAGE_MASK];
> +    assert(section_index < d->map.sections_nb);
> +    ret = d->map.sections + section_index;
> +    assert(ret->mr);
> +    assert(ret->mr->ops);
> +
> +    return ret;
>  }
>  
>  static void io_mem_init(void)

Otherwise:

Acked-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  reply	other threads:[~2023-08-27  9:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-26 23:24 [PATCH 0/3] softmmu: Use async_run_on_cpu in tcg_commit Richard Henderson
2023-08-26 23:24 ` [PATCH 1/3] softmmu: Assert data in bounds in iotlb_to_section Richard Henderson
2023-08-27  9:39   ` Alex Bennée [this message]
2023-08-26 23:24 ` [PATCH 2/3] softmmu: Use async_run_on_cpu in tcg_commit Richard Henderson
2023-08-27  9:58   ` Alex Bennée
2023-08-27 14:54   ` Richard Henderson
2023-08-27 20:17     ` Alex Bennée
2023-08-27 21:16       ` Richard Henderson
2023-08-29 10:50   ` Jonathan Cameron via
2023-08-26 23:24 ` [PATCH 3/3] softmmu: Remove cpu_reloading_memory_map as unused Richard Henderson
2023-08-27  9:59   ` 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=871qfo6cxb.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).