Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

value passed in write_cb of uc_mmio_map is not a uint64_t, it is really a uint32_t #2074

Open
tesuji opened this issue Dec 30, 2024 · 6 comments
Milestone

Comments

@tesuji
Copy link
Contributor

tesuji commented Dec 30, 2024

The write_cb of uc_mmio_map has definition:

typedef void (*uc_cb_mmio_write_t)(uc_engine *uc, uint64_t offset,
                                   unsigned size, uint64_t value,
                                   void *user_data);

I would expect the value variable has real uint64_t type. But as shown in this diff (with all tests passed),
value (as a u64) is splitted into 2 parts (u32) and passed each with the equivalent offsets.
This is really surprising and I think we should either:

  • don't fix it, and document this behavior.
  • or fix this.
@wtdcode
Copy link
Member

wtdcode commented Dec 30, 2024

Thanks for your interests. Is your issue resolved already?

@tesuji
Copy link
Contributor Author

tesuji commented Dec 30, 2024

I'm sorry I don't understand your question. Could you clarify it?

(In the top post, I made a typo. I mean "this diff" instead of "this PR")

@wtdcode
Copy link
Member

wtdcode commented Dec 30, 2024

@wtdcode
Copy link
Member

wtdcode commented Dec 30, 2024

By the way, a workaround is to play with experimental virtual TLB mode.

@tesuji
Copy link
Contributor Author

tesuji commented Dec 30, 2024

Thanks for the pointer. I got the issue now. My main concern is that
for future users, it could be confusing when debugging this issue again.
Perhaps we could document it in uc_mmio_map document and some functions like that.

(Btw, I changed the written address to be 0x10-aligned, but the mem_write hook still called 2 times.
I just relied on the offset for that.)

@wtdcode
Copy link
Member

wtdcode commented Dec 31, 2024

Thanks for the pointer. I got the issue now. My main concern is that for future users, it could be confusing when debugging this issue again. Perhaps we could document it in uc_mmio_map document and some functions like that.

(Btw, I changed the written address to be 0x10-aligned, but the mem_write hook still called 2 times. I just relied on the offset for that.)

Make sense. I will add a few documents to corresponding APIs (or would you like to contribute?).

@wtdcode wtdcode added this to the Unicorn 2.1.2 milestone Jan 6, 2025
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

No branches or pull requests

2 participants