firmware: scmi: Replace memcpy_from/toio() by memcpy() in scmi_read/write_resp_from_smt()
PATCH 1/1 firmware: scmi: Replace memcpy_from/toio() by memcpy() in scmi_read/write_resp_from_smt()
From: Patrice Chotard <[email protected]>
To avoid "synchronous abort" in AARCH64 in case the "from" address is not aligned, replace memcpy_toio() and memcpy_fromio() by memcpy().
---
drivers/firmware/scmi/smt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/scmi/smt.c +2 -2
@@ -93,7 +93,7 @@ int scmi_write_msg_to_smt(struct udevice *dev, struct scmi_smt *smt,SMT_HEADER_PROTOCOL_ID (msg->protocol_id) |SMT_HEADER_MESSAGE_ID (msg->message_id); -memcpy_toio (hdr->msg_payload, msg->in_msg, msg->in_msg_sz); +memcpy (hdr->msg_payload, msg->in_msg, msg->in_msg_sz);return 0 ; }
@@ -124,7 +124,7 @@ int scmi_read_resp_from_smt(struct udevice *dev, struct scmi_smt *smt,/* Get the data */ msg->out_msg_sz = hdr->length -sizeof (hdr->msg_header); -memcpy_fromio (msg->out_msg, hdr->msg_payload, msg->out_msg_sz); +memcpy (msg->out_msg, hdr->msg_payload, msg->out_msg_sz);return 0 ; }
Signature · 1 line
2.17.1
PATCH 1/1 firmware: scmi: Replace memcpy_from/toio() by memcpy() in scmi_read/write_resp_from_smt()
Quoted 6 lines
From: Patrice Chotard <[email protected]>
Date: Wed, 24 Feb 2021 13:47:55 +0100To avoid "synchronous abort" in AARCH64 in case the "from" address is not aligned, replace
memcpy_toio()andmemcpy_fromio()bymemcpy().
Quoted 6 lines
Signed-off-by Patrice Chotard <[email protected]>Signed-off-by Patrice Chotard <[email protected]>---
drivers/firmware/scmi/smt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
This doesnt really make sense. There is no guarantee that memcpy() doesn't do an unaligned load or store either.
Unaligned loads and stores from/to normal memory should just work on arm64, and memcpy_toio() and memcpy_fromio() make sure they don't do unaligned loads and stores from/to "IO" memory (in this case the shared memory buffer).
Quoted 26 lines
drivers/firmware/scmi/smt.c +2
-2@@ -93,7 +93,7 @@ int scmi_write_msg_to_smt(struct udevice *dev, struct scmi_smt *smt,SMT_HEADER_PROTOCOL_ID (msg->protocol_id) |SMT_HEADER_MESSAGE_ID (msg->message_id); -memcpy_toio (hdr->msg_payload, msg->in_msg, msg->in_msg_sz); +memcpy (hdr->msg_payload, msg->in_msg, msg->in_msg_sz);return 0 ; }@@ -124,7 +124,7 @@ int scmi_read_resp_from_smt(struct udevice *dev, struct scmi_smt *smt,/* Get the data */ msg->out_msg_sz = hdr->length -sizeof (hdr->msg_header); -memcpy_fromio (msg->out_msg, hdr->msg_payload, msg->out_msg_sz); +memcpy (msg->out_msg, hdr->msg_payload, msg->out_msg_sz);return 0 ; }Signature · 1 line
2.17.1
PATCH 1/1 firmware: scmi: Replace memcpy_from/toio() by memcpy() in scmi_read/write_resp_from_smt()
Hi Mark
Quoted 13 lines · Mark Kettenis
Quoted 6 lines
From: Patrice Chotard <[email protected]>
Date: Wed, 24 Feb 2021 13:47:55 +0100To avoid "synchronous abort" in AARCH64 in case the "from" address is not aligned, replace
memcpy_toio()andmemcpy_fromio()bymemcpy().Quoted 6 lines
Signed-off-by Patrice Chotard <[email protected]>Signed-off-by Patrice Chotard <[email protected]>---
drivers/firmware/scmi/smt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 7 lines
This doesnt really make sense. There is no guarantee that
memcpy()doesn't do an unaligned load or store either.Unaligned loads and stores from/to normal memory should just work on arm64, and
memcpy_toio()andmemcpy_fromio()make sure they don't do unaligned loads and stores from/to "IO" memory (in this case the shared memory buffer).
You are right. After further analysis, i understood why the "synchronous abort" occurs. At early stage, before U-Boot relocation, MMU is disabled and then all the "normal" memory space is not yet configured with MT_NORMAL type.
In this situation, all 64bits accesses to a none 64 bits aligned pointer in "normal memory" triggers a synchronous abort.
Same accesses, with MMU configured (after U-Boot relocation), are OK.
I will propose a new patch which will update memcpy_from/toio() and forbid 64bits accesses to non aligned 64bits pointer in case MMU is not yet enabled.
Thanks
Patrice
Quoted 27 lines
Quoted 27 lines
drivers/firmware/scmi/smt.c +2
-2@@ -93,7 +93,7 @@ int scmi_write_msg_to_smt(struct udevice *dev, struct scmi_smt *smt,SMT_HEADER_PROTOCOL_ID (msg->protocol_id) |SMT_HEADER_MESSAGE_ID (msg->message_id); -memcpy_toio (hdr->msg_payload, msg->in_msg, msg->in_msg_sz); +memcpy (hdr->msg_payload, msg->in_msg, msg->in_msg_sz);return 0 ; }@@ -124,7 +124,7 @@ int scmi_read_resp_from_smt(struct udevice *dev, struct scmi_smt *smt,/* Get the data */ msg->out_msg_sz = hdr->length -sizeof (hdr->msg_header); -memcpy_fromio (msg->out_msg, hdr->msg_payload, msg->out_msg_sz); +memcpy (msg->out_msg, hdr->msg_payload, msg->out_msg_sz);return 0 ; }Signature · 1 line
2.17.1