* [PATCH] hw/cxl/cxl-host: Fix guest crash when getting cxl-fmw property
@ 2024-07-04 9:34 Zhao Liu
2024-07-05 0:53 ` Xingtao Yao (Fujitsu) via
2024-07-05 2:39 ` Zhijian Li (Fujitsu) via
0 siblings, 2 replies; 4+ messages in thread
From: Zhao Liu @ 2024-07-04 9:34 UTC (permalink / raw)
To: Jonathan Cameron, Fan Ni; +Cc: qemu-devel, qemu-stable, Zhao Liu
From: Zhao Liu <zhao1.liu@intel.com>
Guest crashes (Segmentation fault) when getting cxl-fmw property via
qmp:
(QEMU) qom-get path=machine property=cxl-fmw
This issue is caused by accessing wrong callback (opaque) type in
machine_get_cfmw().
cxl_machine_init() sets the callback as `CXLState *` type but
machine_get_cfmw() treats the callback as
`CXLFixedMemoryWindowOptionsList **`.
Fix this error by casting opaque to `CXLState *` type in
machine_get_cfmw().
Fixes: 03b39fcf64bc ("hw/cxl: Make the CXL fixed memory window setup a machine parameter.")
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/cxl/cxl-host.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c
index c5f5fcfd64d0..e9f2543c43c6 100644
--- a/hw/cxl/cxl-host.c
+++ b/hw/cxl/cxl-host.c
@@ -315,7 +315,8 @@ static void machine_set_cxl(Object *obj, Visitor *v, const char *name,
static void machine_get_cfmw(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- CXLFixedMemoryWindowOptionsList **list = opaque;
+ CXLState *state = opaque;
+ CXLFixedMemoryWindowOptionsList **list = &state->cfmw_list;
visit_type_CXLFixedMemoryWindowOptionsList(v, name, list, errp);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] hw/cxl/cxl-host: Fix guest crash when getting cxl-fmw property
2024-07-04 9:34 [PATCH] hw/cxl/cxl-host: Fix guest crash when getting cxl-fmw property Zhao Liu
@ 2024-07-05 0:53 ` Xingtao Yao (Fujitsu) via
2024-07-05 2:39 ` Zhijian Li (Fujitsu) via
1 sibling, 0 replies; 4+ messages in thread
From: Xingtao Yao (Fujitsu) via @ 2024-07-05 0:53 UTC (permalink / raw)
To: Zhao Liu, Jonathan Cameron, Fan Ni
Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org, Zhao Liu
> -----Original Message-----
> From: qemu-devel-bounces+yaoxt.fnst=fujitsu.com@nongnu.org
> <qemu-devel-bounces+yaoxt.fnst=fujitsu.com@nongnu.org> On Behalf Of Zhao
> Liu
> Sent: Thursday, July 4, 2024 5:34 PM
> To: Jonathan Cameron <jonathan.cameron@huawei.com>; Fan Ni
> <fan.ni@samsung.com>
> Cc: qemu-devel@nongnu.org; qemu-stable@nongnu.org; Zhao Liu
> <zhao1.liu@intel.com>
> Subject: [PATCH] hw/cxl/cxl-host: Fix guest crash when getting cxl-fmw property
>
> From: Zhao Liu <zhao1.liu@intel.com>
>
> Guest crashes (Segmentation fault) when getting cxl-fmw property via
> qmp:
>
> (QEMU) qom-get path=machine property=cxl-fmw
>
> This issue is caused by accessing wrong callback (opaque) type in
> machine_get_cfmw().
>
> cxl_machine_init() sets the callback as `CXLState *` type but
> machine_get_cfmw() treats the callback as
> `CXLFixedMemoryWindowOptionsList **`.
>
> Fix this error by casting opaque to `CXLState *` type in
> machine_get_cfmw().
>
> Fixes: 03b39fcf64bc ("hw/cxl: Make the CXL fixed memory window setup a
> machine parameter.")
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> hw/cxl/cxl-host.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c
> index c5f5fcfd64d0..e9f2543c43c6 100644
> --- a/hw/cxl/cxl-host.c
> +++ b/hw/cxl/cxl-host.c
> @@ -315,7 +315,8 @@ static void machine_set_cxl(Object *obj, Visitor *v, const
> char *name,
> static void machine_get_cfmw(Object *obj, Visitor *v, const char *name,
> void *opaque, Error **errp)
> {
> - CXLFixedMemoryWindowOptionsList **list = opaque;
> + CXLState *state = opaque;
> + CXLFixedMemoryWindowOptionsList **list = &state->cfmw_list;
>
> visit_type_CXLFixedMemoryWindowOptionsList(v, name, list, errp);
> }
> --
> 2.34.1
>
Reviewed-by: Xingtao Yao <yaoxt.fnst@fujitsu.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/cxl/cxl-host: Fix guest crash when getting cxl-fmw property
2024-07-04 9:34 [PATCH] hw/cxl/cxl-host: Fix guest crash when getting cxl-fmw property Zhao Liu
2024-07-05 0:53 ` Xingtao Yao (Fujitsu) via
@ 2024-07-05 2:39 ` Zhijian Li (Fujitsu) via
2024-07-05 11:40 ` Jonathan Cameron via
1 sibling, 1 reply; 4+ messages in thread
From: Zhijian Li (Fujitsu) via @ 2024-07-05 2:39 UTC (permalink / raw)
To: Zhao Liu, Jonathan Cameron, Fan Ni
Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org, Zhao Liu
On 04/07/2024 17:34, Zhao Liu wrote:
> From: Zhao Liu <zhao1.liu@intel.com>
>
> Guest crashes (Segmentation fault) when getting cxl-fmw property via
> qmp:
>
IMO, it's fair to say "Guest crashes" which generally means the guest kernel panic etc.
I'd prefer the subject like:
hw/cxl/cxl-host: Fix segmentation fault when getting cxl-fmw property
Otherwise,
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
> (QEMU) qom-get path=machine property=cxl-fmw
>
> This issue is caused by accessing wrong callback (opaque) type in
> machine_get_cfmw().
>
> cxl_machine_init() sets the callback as `CXLState *` type but
> machine_get_cfmw() treats the callback as
> `CXLFixedMemoryWindowOptionsList **`.
>
> Fix this error by casting opaque to `CXLState *` type in
> machine_get_cfmw().
>
> Fixes: 03b39fcf64bc ("hw/cxl: Make the CXL fixed memory window setup a machine parameter.")
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> hw/cxl/cxl-host.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c
> index c5f5fcfd64d0..e9f2543c43c6 100644
> --- a/hw/cxl/cxl-host.c
> +++ b/hw/cxl/cxl-host.c
> @@ -315,7 +315,8 @@ static void machine_set_cxl(Object *obj, Visitor *v, const char *name,
> static void machine_get_cfmw(Object *obj, Visitor *v, const char *name,
> void *opaque, Error **errp)
> {
> - CXLFixedMemoryWindowOptionsList **list = opaque;
> + CXLState *state = opaque;
> + CXLFixedMemoryWindowOptionsList **list = &state->cfmw_list;
>
> visit_type_CXLFixedMemoryWindowOptionsList(v, name, list, errp);
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/cxl/cxl-host: Fix guest crash when getting cxl-fmw property
2024-07-05 2:39 ` Zhijian Li (Fujitsu) via
@ 2024-07-05 11:40 ` Jonathan Cameron via
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron via @ 2024-07-05 11:40 UTC (permalink / raw)
To: Zhijian Li (Fujitsu)
Cc: Zhao Liu, Fan Ni, qemu-devel@nongnu.org, qemu-stable@nongnu.org,
Zhao Liu
On Fri, 5 Jul 2024 02:39:51 +0000
"Zhijian Li (Fujitsu)" <lizhijian@fujitsu.com> wrote:
> On 04/07/2024 17:34, Zhao Liu wrote:
> > From: Zhao Liu <zhao1.liu@intel.com>
> >
> > Guest crashes (Segmentation fault) when getting cxl-fmw property via
> > qmp:
> >
>
> IMO, it's fair to say "Guest crashes" which generally means the guest kernel panic etc.
> I'd prefer the subject like:
> hw/cxl/cxl-host: Fix segmentation fault when getting cxl-fmw property
Agreed. I've picked this up and edited the description.
I've just hit send on a v2 of the misc minor fixes series with this
replacing the patch that dropped cfmws_list
Thanks,
Jonathan
>
>
> Otherwise,
>
> Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
>
>
> > (QEMU) qom-get path=machine property=cxl-fmw
> >
> > This issue is caused by accessing wrong callback (opaque) type in
> > machine_get_cfmw().
> >
> > cxl_machine_init() sets the callback as `CXLState *` type but
> > machine_get_cfmw() treats the callback as
> > `CXLFixedMemoryWindowOptionsList **`.
> >
> > Fix this error by casting opaque to `CXLState *` type in
> > machine_get_cfmw().
> >
> > Fixes: 03b39fcf64bc ("hw/cxl: Make the CXL fixed memory window setup a machine parameter.")
> > Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> > ---
> > hw/cxl/cxl-host.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c
> > index c5f5fcfd64d0..e9f2543c43c6 100644
> > --- a/hw/cxl/cxl-host.c
> > +++ b/hw/cxl/cxl-host.c
> > @@ -315,7 +315,8 @@ static void machine_set_cxl(Object *obj, Visitor *v, const char *name,
> > static void machine_get_cfmw(Object *obj, Visitor *v, const char *name,
> > void *opaque, Error **errp)
> > {
> > - CXLFixedMemoryWindowOptionsList **list = opaque;
> > + CXLState *state = opaque;
> > + CXLFixedMemoryWindowOptionsList **list = &state->cfmw_list;
> >
> > visit_type_CXLFixedMemoryWindowOptionsList(v, name, list, errp);
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-05 11:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-04 9:34 [PATCH] hw/cxl/cxl-host: Fix guest crash when getting cxl-fmw property Zhao Liu
2024-07-05 0:53 ` Xingtao Yao (Fujitsu) via
2024-07-05 2:39 ` Zhijian Li (Fujitsu) via
2024-07-05 11:40 ` Jonathan Cameron via
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).