Skip to content

better tb cache handling for hook add and del#2279

Open
PhilippTakacs wants to merge 2 commits intounicorn-engine:devfrom
PhilippTakacs:hook_add_tb
Open

better tb cache handling for hook add and del#2279
PhilippTakacs wants to merge 2 commits intounicorn-engine:devfrom
PhilippTakacs:hook_add_tb

Conversation

@PhilippTakacs
Copy link
Contributor

uc.c Outdated

if (type & UC_HOOK_CODE || type & UC_HOOK_BLOCK) {
if (end <= begin) {
uc_ctl_flush_tb(uc);
Copy link
Member

Choose a reason for hiding this comment

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

One thing on my mind is that this might be dangerous in a hook context.

Assume we have call stack like uc_emu_start -> hook_code -> tb_flush, then the underlying memory of the current tb is invalidated immediately. I'm a bit forgetting details, what's your idea about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can either use break_translation_loop and do the tb clean in the emulation loop or use some invalidation like uc_hook_del is doing. I need some time to test this.

Code and Block hooks are implemented by adding the callback directly
to the translation block. So when a hook is added after the code is
already translated the tb cache needs to be cleared.

see unicorn-engine#2200
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.

2 participants