cartesi / machine-emulator

The off-chain implementation of the Cartesi Machine
GNU Lesser General Public License v3.0
58 stars 32 forks source link

feat: add C API to translate virtual address #220

Closed edubart closed 2 months ago

edubart commented 3 months ago

This PR adds a new function to the public C API:

  1. cm_translate_virtual_address - Translates a virtual memory address to its corresponding physical memory address

The use case is to debug address translation from outside, this function was exposed to Lua and JSONRPC.

mpolitzer commented 3 months ago

I would be more explicit with the naming: translate_guest_physical_to_host_ptr (may be a bit overkill, but you get the idea). Also this only makes sense when looking up within page boundaries, do you plan to use this with large pages?

edubart commented 3 months ago

I removed the function about pointers, now this PR is much simpler, it just adds a new function to translate virtual memory from outside using the current satp context.