All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zhijian <lizhijian@fujitsu.com>
To: jonathan.cameron@huawei.com, fan.ni@samsung.com
Cc: qemu-devel@nongnu.org, Li Zhijian <lizhijian@fujitsu.com>
Subject: [PATCH] hw/cxl: Fix opaque type interpret wrongly
Date: Fri, 13 Oct 2023 09:55:15 +0800	[thread overview]
Message-ID: <20231013015515.23647-1-lizhijian@fujitsu.com> (raw)

void cxl_component_register_block_init(Object *obj,
                                       CXLComponentState *cxl_cstate,
                                       const char *type)
{
    ComponentRegisters *cregs = &cxl_cstate->crb;
...
    memory_region_init_io(&cregs->cache_mem, obj, &cache_mem_ops, cregs,
                          ".cache_mem", CXL2_COMPONENT_CM_REGION_SIZE);

Obviously, opaque should be pointer to ComponentRegisters.
Fortunately, cregs is the first member of cxl_state, so their values are
the same.

Fixes: 9e58f52d3f8 ("hw/cxl/component: Introduce CXL components (8.1.x, 8.2.5)")
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
 hw/cxl/cxl-component-utils.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c
index f3bbf0fd131..f27a9d3cf60 100644
--- a/hw/cxl/cxl-component-utils.c
+++ b/hw/cxl/cxl-component-utils.c
@@ -64,8 +64,7 @@ hwaddr cxl_decode_ig(int ig)
 static uint64_t cxl_cache_mem_read_reg(void *opaque, hwaddr offset,
                                        unsigned size)
 {
-    CXLComponentState *cxl_cstate = opaque;
-    ComponentRegisters *cregs = &cxl_cstate->crb;
+    ComponentRegisters *cregs = opaque;
 
     if (size == 8) {
         qemu_log_mask(LOG_UNIMP,
@@ -113,8 +112,7 @@ static void dumb_hdm_handler(CXLComponentState *cxl_cstate, hwaddr offset,
 static void cxl_cache_mem_write_reg(void *opaque, hwaddr offset, uint64_t value,
                                     unsigned size)
 {
-    CXLComponentState *cxl_cstate = opaque;
-    ComponentRegisters *cregs = &cxl_cstate->crb;
+    ComponentRegisters *cregs = opaque;
     uint32_t mask;
 
     if (size == 8) {
-- 
2.41.0



             reply	other threads:[~2023-10-13  1:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13  1:55 Li Zhijian [this message]
2023-10-13  8:52 ` [PATCH] hw/cxl: Fix opaque type interpret wrongly Philippe Mathieu-Daudé
2023-10-18  8:27   ` Zhijian Li (Fujitsu)

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=20231013015515.23647-1-lizhijian@fujitsu.com \
    --to=lizhijian@fujitsu.com \
    --cc=fan.ni@samsung.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=qemu-devel@nongnu.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 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.