From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Gregory Price <gregory.price@memverge.com>,
qemu-devel@nongnu.org, linux-cxl@vger.kernel.org
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [RFC] CXL: TCG/KVM instruction alignment issue discussion default
Date: Tue, 28 Feb 2023 13:42:06 +0100 [thread overview]
Message-ID: <e18377f5-5a8f-20a5-3c32-30f360b0475a@linaro.org> (raw)
In-Reply-To: <Y/Cm5nuJl3G2CG2p@memverge.com>
On 18/2/23 11:22, Gregory Price wrote:
>
> Breaking this off into a separate thread for archival sake.
>
> There's a bug with handling execution of instructions held in CXL
> memory - specifically when an instruction crosses a page boundary.
>
> The result of this is that type-3 devices cannot use KVM at all at the
> moment, and require the attached patch to run in TCG-only mode.
>
>
> CXL memory devices are presently emulated as MMIO, and MMIO has no
> coherency guarantees, so TCG doesn't cache the results of translating
> an instruction, meaning execution is incredibly slow (orders of
> magnitude slower than KVM).
>
>
> Request for comments:
>
>
> First there's the stability issue:
>
> 0) TCG cannot handle instructions across a page boundary spanning ram and
> MMIO. See attached patch for hotfix. This basically solves the page
> boundary issue by reverting the entire block to MMIO-mode if the
> problem is detected.
>
> 1) KVM needs to be investigated. It's likely the same/similar issue,
> but it's not confirmed.
>
>
>
> Second there's the performance issue:
>
> 0) Do we actually care about performance? How likely are users to
> attempt to run software out of CXL memory?
>
> 1) If we do care, is there a potential for converting CXL away from the
> MMIO design? The issue is coherency for shared memory. Emulating
> coherency is a) hard, and b) a ton of work for little gain.
>
> Presently marking CXL memory as MMIO basically enforces coherency by
> preventing caching, though it's unclear how this is enforced
> by KVM (or if it is, i have to imagine it is).
>
>
>
> It might be nice to solve this for non-shared memory regions, but
> testing functionality >>> performance at this point so it might not
> worth the investment.
>
>
> Just tossing this out for discussion
> ~Gregory
>
>
>
>
> diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
> index 061519691f..cd383d7125 100644
> --- a/accel/tcg/translator.c
> +++ b/accel/tcg/translator.c
> @@ -171,8 +171,16 @@ static void *translator_access(CPUArchState *env, DisasContextBase *db,
> if (host == NULL) {
> tb_page_addr_t phys_page =
> get_page_addr_code_hostp(env, base, &db->host_addr[1]);
> - /* We cannot handle MMIO as second page. */
> - assert(phys_page != -1);
> +
> + /*
> + * If the second page is MMIO, treat as if the first page
> + * was MMIO as well, so that we do not cache the TB.
> + */
> + if (unlikely(phys_page == -1)) {
> + tb_set_page_addr0(tb, -1);
> + return NULL;
> + }
> +
> tb_set_page_addr1(tb, phys_page);
> #ifdef CONFIG_USER_ONLY
> page_protect(end);
>
This is:
https://lore.kernel.org/qemu-devel/20230222020023.904232-2-richard.henderson@linaro.org/
prev parent reply other threads:[~2023-02-28 12:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-18 10:22 [RFC] CXL: TCG/KVM instruction alignment issue discussion default Gregory Price
2023-02-27 11:06 ` Jørgen Hansen
2023-02-28 10:49 ` Jonathan Cameron via
2023-03-01 14:51 ` Jørgen Hansen
2023-03-02 1:17 ` Ajay Joshi
2023-02-28 12:42 ` Philippe Mathieu-Daudé [this message]
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=e18377f5-5a8f-20a5-3c32-30f360b0475a@linaro.org \
--to=philmd@linaro.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=gregory.price@memverge.com \
--cc=linux-cxl@vger.kernel.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).