Skip to content

hooks: change block invalidator callback to PANDA_CB_BEFORE_BLOCK_EXEC_INVALIDATE_OPT#1436

Closed
be32826 wants to merge 1 commit into
devfrom
fix-hooks
Closed

hooks: change block invalidator callback to PANDA_CB_BEFORE_BLOCK_EXEC_INVALIDATE_OPT#1436
be32826 wants to merge 1 commit into
devfrom
fix-hooks

Conversation

@be32826

@be32826 be32826 commented Feb 6, 2024

Copy link
Copy Markdown
Contributor

Previously, the block invalidation function was called on PANDA_CB_BEFORE_BLOCK_TRANSLATE, which is only triggered when both TCG caches miss (i.e. when the block is already invalidated), so I think it is a no-op. It also seems to only invalidate the tb_jmp_cache and not tb_ctx.htable. I think both of these issues exist and that this PR solves them, but I'm not 100% sure.

@AndrewFasano AndrewFasano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think these changes make sense, but I'll defer to @lacraig2 since he wrote it!

@lacraig2

lacraig2 commented Feb 7, 2024

Copy link
Copy Markdown
Member

Previously, the block invalidation function was called on PANDA_CB_BEFORE_BLOCK_TRANSLATE, which is only triggered when both TCG caches miss (i.e. when the block is already invalidated), so I think it is a no-op.

The missing piece here is the context that we're enabling this context so that we can acquire the tb_lock so that we can efficiently handle dropping our block from the tb cache if we fail by other means. The event that generates the block translate is most likely unrelated to the block in question.

It also seems to only invalidate the tb_jmp_cache and not tb_ctx.htable.

Those are hash tables utilized in distinct contexts: translation and runtime. I don't see an issue invalidating the htable, but I'm not convinced it's necessary.

@lacraig2

lacraig2 commented Feb 7, 2024

Copy link
Copy Markdown
Member

FWIW if we're looking for a better implementation of hooks have a look at this PR: #1187

@be32826 be32826 marked this pull request as draft February 7, 2024 17:32
@be32826 be32826 closed this Feb 7, 2024
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.

3 participants