From: Jonathan Cameron via qemu development <qemu-devel@nongnu.org>
To: Alireza Sanaee <alireza.sanaee@huawei.com>
Cc: Gregory Price <gourry@gourry.net>, <qemu-devel@nongnu.org>,
<anisa.su887@gmail.com>, <armbru@redhat.com>, <david@kernel.org>,
<imammedo@redhat.com>, <linuxarm@huawei.com>,
<lizhijian@fujitsu.com>, <mst@redhat.com>, <nifan.cxl@gmail.com>,
<peterx@redhat.com>, <philmd@linaro.org>, <ppbonzini@redhat.com>,
<venkataravis@micron.com>, <xiaoguangrong.eric@gmail.com>
Subject: Re: [PATCH v5 3/3] hw/cxl: Add a performant (and correct) path for the non interleaved cases
Date: Fri, 27 Feb 2026 10:36:20 +0000 [thread overview]
Message-ID: <20260227103620.0000612b@huawei.com> (raw)
In-Reply-To: <20260226001405.00005b6b.alireza.sanaee@huawei.com>
On Thu, 26 Feb 2026 00:14:05 +0000
Alireza Sanaee <alireza.sanaee@huawei.com> wrote:
> On Wed, 25 Feb 2026 15:34:27 -0500
> Gregory Price <gourry@gourry.net> wrote:
>
> Hi Gregory,
>
> > On Wed, Feb 25, 2026 at 06:07:18PM +0000, Alireza Sanaee via qemu development wrote:
> > > +static void cxl_fmws_direct_passthrough_remove(CXLType3Dev *ct3d,
> > > + uint64_t decoder_base,
> > > + unsigned int idx)
> > > +{
> > > + CXLFixedWindow *owner_fw = ct3d->direct_mr_fw[idx];
> > > + MemoryRegion *direct_mr = &ct3d->direct_mr[idx];
> > > +
> > > + if (!owner_fw) {
> > > + return;
> > > + }
> > > +
> > > + if (!memory_region_is_mapped(direct_mr)) {
> > > + return;
> > > + }
> > > +
> > > + if (cxl_cfmws_find_device(owner_fw, decoder_base, false)) {
> > > + return;
> > > + }
> > > +
> > > + memory_region_del_subregion(&owner_fw->mr, direct_mr);
> > > + ct3d->direct_mr_fw[idx] = NULL;
> > > +}
> > > +
> >
> > kreview flagged this, seems reasonable given other examples in the tree
> >
> > The other commits looked ok, I'll try to get around to testing this soon.
> >
> > ~Gregory
> >
> > ---
> >
> > Reported-by: kreview-8842242
> >
> > The alias parameters (target MR, offset, size) are all guest-controlled
> > and can change between cycles -- the guest can reprogram DPA skip, decoder
> > size, or decoder base before recommitting. There is no API to change the
> > alias target (mr->alias) after init, so an init-once approach would not
> > work here.
> >
> > The VGA chain4_alias in hw/display/vga.c handles the same situation
> > (embedded MR alias rebuilt with different parameters on guest register
> > writes) using object_unparent():
> >
> > vga_update_memory_access() {
> > memory_region_del_subregion(s->legacy_address_space, &s->chain4_alias);
> > object_unparent(OBJECT(&s->chain4_alias));
> > ...
> > memory_region_init_alias(&s->chain4_alias, ...);
> > memory_region_add_subregion_overlap(..., &s->chain4_alias, 2);
> > }
> >
> > Adding object_unparent() in remove() should fix this:
> >
> > memory_region_del_subregion(&owner_fw->mr, direct_mr);
> > object_unparent(OBJECT(direct_mr));
> > ct3d->direct_mr_fw[idx] = NULL;
> >
>
> This was actually my question as well, but I tested with a scenario in which I
> created a region with its alias. Then I torn down that region so that the alias
> goes away, and finally reinitialized the same region to reuse the deleted alias
> object. It worked, but still it does not mean it is correct. I can send another
> revision using unparent API.
It is more elegant (and keeps the introspection stuff reporting correctly)
to unparent the object on delete. To test this you'd need to bring it up in a different
cfmws so the parent changes. So this is good feedback.
There is a secondary issue that around the HBM decoder registers being modified at random
points that don't make sense from an OS flow point of view, but which could lead to
mismatch. For that one we'd need to snapshot the decoders at commit time and use
that snapshot as the valid settings.
Note that form a spec viewpoint I think it's undefined what happens if the OS messes
with these registers at inappropriate moments. Snap shot should be a valid
implementation choice though.
Given we aren't currently that defensive against the OS doing crazy things I don't
mind pushing that snapshot thing to a follow up patch. Maybe merge into this once
it's ready.
Jonathan
prev parent reply other threads:[~2026-02-27 10:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 18:07 [PATCH v5 0/3] hw/cxl: Add a performant (and correct) path for the non interleaved cases Alireza Sanaee via qemu development
2026-02-25 18:07 ` [PATCH v5 1/3] hw/cxl: Use HPA in cxl_cfmws_find_device() rather than offset in window Alireza Sanaee via qemu development
2026-02-25 18:07 ` [PATCH v5 2/3] hw/cxl: Allow cxl_cfmws_find_device() to filter on whether interleaved paths are accepted Alireza Sanaee via qemu development
2026-02-25 18:07 ` [PATCH v5 3/3] hw/cxl: Add a performant (and correct) path for the non interleaved cases Alireza Sanaee via qemu development
2026-02-25 20:34 ` Gregory Price
2026-02-26 0:14 ` Alireza Sanaee via qemu development
2026-02-27 10:36 ` Jonathan Cameron via qemu development [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=20260227103620.0000612b@huawei.com \
--to=qemu-devel@nongnu.org \
--cc=alireza.sanaee@huawei.com \
--cc=anisa.su887@gmail.com \
--cc=armbru@redhat.com \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=imammedo@redhat.com \
--cc=jonathan.cameron@huawei.com \
--cc=linuxarm@huawei.com \
--cc=lizhijian@fujitsu.com \
--cc=mst@redhat.com \
--cc=nifan.cxl@gmail.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=ppbonzini@redhat.com \
--cc=venkataravis@micron.com \
--cc=xiaoguangrong.eric@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.