Skip to content

fast-get: fix a recent regression: write before mapping RO#10731

Merged
kv2019i merged 1 commit intothesofproject:mainfrom
lyakh:fastget
Apr 28, 2026
Merged

fast-get: fix a recent regression: write before mapping RO#10731
kv2019i merged 1 commit intothesofproject:mainfrom
lyakh:fastget

Conversation

@lyakh
Copy link
Copy Markdown
Collaborator

@lyakh lyakh commented Apr 28, 2026

A recent commit introduced a regression: it moved writing data to a buffer after the call, mapping the target buffer as read-only. Fix it by moving the copy operation back up.

Fixes commit cfa5f02 ("fast-get: don't corrupt entries when failing")

A recent commit introduced a regression: it moved writing data to a
buffer after the call, mapping the target buffer as read-only. Fix it
by moving the copy operation back up.

Fixes commit cfa5f02 ("fast-get: don't corrupt entries when failing")

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Copilot AI review requested due to automatic review settings April 28, 2026 13:26
Copy link
Copy Markdown
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not very obvious that fast_get_access_grant() actually limits the access here, but alas, fixes the regression...

@lyakh
Copy link
Copy Markdown
Collaborator Author

lyakh commented Apr 28, 2026

It is not very obvious that fast_get_access_grant() actually limits the access here, but alas, fixes the regression...

@kv2019i why isn't it obvious?

.attr = K_MEM_PARTITION_P_RO_U_RO | XTENSA_MMU_CACHED_WB,
clearly maps the memory read-only for kernel and userspace

@kv2019i
Copy link
Copy Markdown
Collaborator

kv2019i commented Apr 28, 2026

@lyakh wrote:

It is not very obvious that fast_get_access_grant() actually limits the access here, but alas, fixes the regression...
@kv2019i why isn't it obvious?
[...]
clearly maps the memory read-only for kernel and userspace

You have to look inside the grant function implementation to see that. And even then, the function name is surprising. Usually when you grant something, you allow something more, not remove something you already had.

@lyakh
Copy link
Copy Markdown
Collaborator Author

lyakh commented Apr 28, 2026

It is not very obvious that fast_get_access_grant() actually limits the access here, but alas, fixes the regression...
@kv2019i why isn't it obvious?
[...]
clearly maps the memory read-only for kernel and userspace

You have to look inside the grant function implementation to see that. And even then, the function name is surprising. Usually when you grant something, you allow something more, not remove something you already had.

it grants it to userspace. As for the kernel - well, the kernel mode might not need that access at all (after having written to it once). But yes, it isn't immediately obvious without reading the code :-)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression in fast_get() where the newly allocated SRAM buffer could be mapped read-only before the data copy occurred, causing the subsequent write to fail.

Changes:

  • Move the memcpy_s() into the newly allocated SRAM buffer earlier in fast_get().
  • Perform dcache_writeback_region() before any read-only memory-domain mapping occurs.

@kv2019i kv2019i merged commit 0a87dc3 into thesofproject:main Apr 28, 2026
44 of 45 checks passed
@lyakh lyakh deleted the fastget branch April 29, 2026 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants