Skip to content

Commit

Permalink
hw/cxl/cxl-host: Fix segmentation fault when getting cxl-fmw property
Browse files Browse the repository at this point in the history
QEMU 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: 03b39fc ("hw/cxl: Make the CXL fixed memory window setup a machine parameter.")
Signed-off-by: Zhao Liu <[email protected]>
Reviewed-by: Li Zhijian <[email protected]>
Reviewed-by: Xingtao Yao <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jonathan Cameron <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
  • Loading branch information
trueptolemy authored and mstsirkin committed Jul 21, 2024
1 parent 9de2049 commit a207d5f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hw/cxl/cxl-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit a207d5f

Please sign in to comment.