qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron via <qemu-devel@nongnu.org>
To: "Jørgen Hansen" <Jorgen.Hansen@wdc.com>
Cc: Gregory Price <gregory.price@memverge.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>
Subject: Re: [RFC] CXL: TCG/KVM instruction alignment issue discussion default
Date: Tue, 28 Feb 2023 10:49:16 +0000	[thread overview]
Message-ID: <20230228104916.00003d9a@Huawei.com> (raw)
In-Reply-To: <b066510e-8420-26ba-019b-fef2b255634e@wdc.com>

On Mon, 27 Feb 2023 11:06:47 +0000
Jørgen Hansen <Jorgen.Hansen@wdc.com> wrote:

> On 2/18/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.  
> 
> I ran into an issue with KVM as well. However, it wasn't a page boundary 
> spanning issue, since I could hit it when using pure CXL backed memory 
> for a given application. It turned out that (at least) certain AVX 
> instructions didn't handle execution from MMIO when using qemu. This 
> generated an illegal instruction exception for the application. At that 
> point, I switched to tcg, so I didn't investigate if running a non-AVX 
> system would work with KVM.

Short term I'm wondering if we should attempt to error out on KVM
unless some override parameter is used alongside the main cxl=on

> 
> > 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).   
> 
> Having the option of doing device specific processing of accesses to a 
> CXL type 3 device (that the MMIO based access allows) is useful for 
> experimentation with device functionality, so I would be sad to see that 
> option go away. Emulating cache line access to a type 3 device would be 
> interesting, and could potentially be implemented in a way that would 
> allow caching of device memory in a shadow page in RAM, but that it a 
> rather large project.

Absolutely agree.  Can sketch a solution that is entirely in QEMU and
works with KVM on a white board, but it doesn't feel like a small job
to actually implement it and I'm sure there are nasty corners
(persistency is going to be tricky) 

If anyone sees this as a 'fun challenge' and wants to take it on though
that would be great!

Jonathan

> 
> > 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.  
> 
> Thanks,
> Jorgen



  reply	other threads:[~2023-02-28 10:49 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 [this message]
2023-03-01 14:51     ` Jørgen Hansen
2023-03-02  1:17     ` Ajay Joshi
2023-02-28 12:42 ` Philippe Mathieu-Daudé

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=20230228104916.00003d9a@Huawei.com \
    --to=qemu-devel@nongnu.org \
    --cc=Jonathan.Cameron@Huawei.com \
    --cc=Jorgen.Hansen@wdc.com \
    --cc=gregory.price@memverge.com \
    --cc=linux-cxl@vger.kernel.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).