From: Richard Henderson <richard.henderson@linaro.org>
To: Mikhail Tyutin <m.tyutin@yadro.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, alex.bennee@linaro.org,
Dmitriy Solovev <d.solovev@yadro.com>
Subject: Re: [PATCH v2] Fix SEGFAULT on getting physical address of MMIO region.
Date: Thu, 3 Aug 2023 07:57:15 -0700 [thread overview]
Message-ID: <7e58cf18-b1c0-c15d-dbf0-8b858dab2d9c@linaro.org> (raw)
In-Reply-To: <20230803105830.8722-1-m.tyutin@yadro.com>
On 8/3/23 03:58, Mikhail Tyutin wrote:
> Apply save_iotlb_data() to io_readx() as well as to io_writex().
>
> Signed-off-by: Dmitriy Solovev <d.solovev@yadro.com>
> Signed-off-by: Mikhail Tyutin <m.tyutin@yadro.com>
> ---
> accel/tcg/cputlb.c | 36 +++++++++++++++++++++---------------
> 1 file changed, 21 insertions(+), 15 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
>
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index ba44501a7c..addce3be38 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -1363,6 +1363,21 @@ static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr,
> }
> }
>
> +/*
> + * Save a potentially trashed CPUTLBEntryFull for later lookup by plugin.
> + * This is read by tlb_plugin_lookup if the fulltlb entry doesn't match
> + * because of the side effect of io_writex changing memory layout.
> + */
> +static void save_iotlb_data(CPUState *cs, MemoryRegionSection *section,
> + hwaddr mr_offset)
> +{
> +#ifdef CONFIG_PLUGIN
> + SavedIOTLB *saved = &cs->saved_iotlb;
> + saved->section = section;
> + saved->mr_offset = mr_offset;
> +#endif
> +}
> +
> static uint64_t io_readx(CPUArchState *env, CPUTLBEntryFull *full,
> int mmu_idx, vaddr addr, uintptr_t retaddr,
> MMUAccessType access_type, MemOp op)
> @@ -1382,6 +1397,12 @@ static uint64_t io_readx(CPUArchState *env, CPUTLBEntryFull *full,
> cpu_io_recompile(cpu, retaddr);
> }
>
> + /*
> + * The memory_region_dispatch may trigger a flush/resize
> + * so for plugins we save the iotlb_data just in case.
> + */
> + save_iotlb_data(cpu, section, mr_offset);
> +
> {
> QEMU_IOTHREAD_LOCK_GUARD();
> r = memory_region_dispatch_read(mr, mr_offset, &val, op, full->attrs);
> @@ -1398,21 +1419,6 @@ static uint64_t io_readx(CPUArchState *env, CPUTLBEntryFull *full,
> return val;
> }
>
> -/*
> - * Save a potentially trashed CPUTLBEntryFull for later lookup by plugin.
> - * This is read by tlb_plugin_lookup if the fulltlb entry doesn't match
> - * because of the side effect of io_writex changing memory layout.
> - */
> -static void save_iotlb_data(CPUState *cs, MemoryRegionSection *section,
> - hwaddr mr_offset)
> -{
> -#ifdef CONFIG_PLUGIN
> - SavedIOTLB *saved = &cs->saved_iotlb;
> - saved->section = section;
> - saved->mr_offset = mr_offset;
> -#endif
> -}
> -
> static void io_writex(CPUArchState *env, CPUTLBEntryFull *full,
> int mmu_idx, uint64_t val, vaddr addr,
> uintptr_t retaddr, MemOp op)
next prev parent reply other threads:[~2023-08-03 14:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-03 10:58 [PATCH v2] Fix SEGFAULT on getting physical address of MMIO region Mikhail Tyutin
2023-08-03 14:57 ` Richard Henderson [this message]
2023-08-03 15:15 ` Peter Maydell
2023-08-03 16:07 ` Mikhail Tyutin
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=7e58cf18-b1c0-c15d-dbf0-8b858dab2d9c@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=d.solovev@yadro.com \
--cc=m.tyutin@yadro.com \
--cc=pbonzini@redhat.com \
--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 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).