From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
"Gregory Price" <gregory.price@memverge.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Sajjan Rao" <sajjanr@gmail.com>,
"Dimitrios Palyvos" <dimitrios.palyvos@zptcorp.com>,
richard.henderson@linaro.org,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH 3/3] tcg: Avoid double lock if page tables happen to be in mmio memory.
Date: Thu, 15 Feb 2024 16:33:45 +0100 [thread overview]
Message-ID: <bdeb194e-28f6-4dda-bf85-bd1a0b983ecd@linaro.org> (raw)
In-Reply-To: <20240215150133.2088-4-Jonathan.Cameron@huawei.com>
On 15/2/24 16:01, Jonathan Cameron via wrote:
> On i386, after fixing the page walking code to work with pages in
> MMIO memory (specifically CXL emulated interleaved memory),
> a crash was seen in an interrupt handling path.
>
> Useful part of bt
>
> Peter identified this as being due to the BQL already being
> held when the page table walker encounters MMIO memory and attempts
> to take the lock again. There are other examples of similar paths
> TCG, so this follows the approach taken in those of simply checking
> if the lock is already held and if it is, don't take it again.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> accel/tcg/cputlb.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index 047cd2cc0a..3b8d178707 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -2019,6 +2019,7 @@ static uint64_t do_ld_mmio_beN(CPUState *cpu, CPUTLBEntryFull *full,
> int mmu_idx, MMUAccessType type, uintptr_t ra)
> {
> MemoryRegionSection *section;
> + bool locked = bql_locked();
Maybe clearer as:
bool need_lock = !bql_locked();
> MemoryRegion *mr;
> hwaddr mr_offset;
> MemTxAttrs attrs;
> @@ -2030,10 +2031,14 @@ static uint64_t do_ld_mmio_beN(CPUState *cpu, CPUTLBEntryFull *full,
> section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
> mr = section->mr;
>
> - bql_lock();
> + if (!locked) {
if (unlikely(need_lock)) {
> + bql_lock();
> + }
> ret = int_ld_mmio_beN(cpu, full, ret_be, addr, size, mmu_idx,
> type, ra, mr, mr_offset);
> - bql_unlock();
> + if (!locked) {
Ditto.
> + bql_unlock();
> + }
>
> return ret;
> }
next prev parent reply other threads:[~2024-02-15 15:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 15:01 [PATCH 0/3 qemu] tcg/i386: Page tables in MMIO memory fixes (CXL) Jonathan Cameron via
2024-02-15 15:01 ` [PATCH 1/3] accel/tcg: Set can_do_io at at start of lookup_tb_ptr helper Jonathan Cameron via
2024-02-15 15:11 ` Peter Maydell
2024-02-15 16:04 ` Jonathan Cameron via
2024-02-15 19:11 ` Richard Henderson
2024-02-15 15:01 ` [PATCH 2/3] target/i386: Enable page walking from MMIO memory Jonathan Cameron via
2024-02-15 15:31 ` Philippe Mathieu-Daudé
2024-02-15 15:56 ` Jonathan Cameron via
2024-02-15 19:21 ` Richard Henderson
2024-02-15 19:31 ` Richard Henderson
2024-02-15 15:01 ` [PATCH 3/3] tcg: Avoid double lock if page tables happen to be in mmio memory Jonathan Cameron via
2024-02-15 15:33 ` Philippe Mathieu-Daudé [this message]
2024-02-15 16:11 ` Jonathan Cameron via
2024-02-15 16:11 ` Peter Maydell
2024-02-15 17:34 ` Jonathan Cameron via
2024-02-15 19:30 ` Richard Henderson
2024-02-19 12:14 ` Jonathan Cameron via
2024-02-20 11:56 ` 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=bdeb194e-28f6-4dda-bf85-bd1a0b983ecd@linaro.org \
--to=philmd@linaro.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=alex.bennee@linaro.org \
--cc=dimitrios.palyvos@zptcorp.com \
--cc=eduardo@habkost.net \
--cc=gregory.price@memverge.com \
--cc=linux-cxl@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sajjanr@gmail.com \
/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).