hw/cxl/cxl-host: Fix guest crash when getting cxl-fmw property
PATCH 1/1 hw/cxl/cxl-host: Fix guest crash when getting cxl-fmw property
From: Zhao Liu <[email protected]>
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().
--- hw/cxl/cxl-host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/cxl/cxl-host.c +2 -1
@@ -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); }
Signature · 1 line
2.34.1
Quoted 51 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Zhao Liu
Sent: Thursday, July 4, 2024 5:34 PM
To: Jonathan Cameron <[email protected]>; Fan Ni <[email protected]>
Cc: [email protected]; [email protected]; Zhao Liu <[email protected]>
Subject: [PATCH] hw/cxl/cxl-host: Fix guest crash when getting cxl-fmw propertyFrom: Zhao Liu <[email protected]>
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 asCXLState *type butmachine_get_cfmw()treats the callback asCXLFixedMemoryWindowOptionsList **.Fix this error by casting opaque to
CXLState *type inmachine_get_cfmw().Fixes 03b39fcf64bc ("hw/cxl: Make the CXL fixed memory window setup amachine parameter.")
Signed-off-by Zhao Liu <[email protected]>--- hw/cxl/cxl-host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/cxl/cxl-host.c +2
-1@@ -315,7 +315,8 @@ static void machine_set_cxl(Object *obj, Visitor *v, constchar *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);
Quoted 4 lines
}
--
2.34.1
Quoted 5 lines · Zhao Liu
From: Zhao Liu <[email protected]>
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,
Quoted 32 lines
(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 asCXLState *type butmachine_get_cfmw()treats the callback asCXLFixedMemoryWindowOptionsList **.Fix this error by casting opaque to
CXLState *type inmachine_get_cfmw().Fixes 03b39fcf64bc ("hw/cxl: Make the CXL fixed memory window setup a machine parameter.")Signed-off-by Zhao Liu <[email protected]>--- hw/cxl/cxl-host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/cxl/cxl-host.c +2
-1@@ -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); }
Quoted 10 lines · On Fri, 5 Jul 2024 02:39:51 +0000 "Zhijian Li (Fujitsu)"…
Quoted 5 lines · Zhao Liu
From: Zhao Liu <[email protected]>
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
Quoted 39 lines
Otherwise,
Reviewed-by Li Zhijian <[email protected]>Quoted 32 lines
(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 asCXLState *type butmachine_get_cfmw()treats the callback asCXLFixedMemoryWindowOptionsList **.Fix this error by casting opaque to
CXLState *type inmachine_get_cfmw().Fixes 03b39fcf64bc ("hw/cxl: Make the CXL fixed memory window setup a machine parameter.")Signed-off-by Zhao Liu <[email protected]>--- hw/cxl/cxl-host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/cxl/cxl-host.c +2
-1@@ -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);