Aaron Lindsay OS <aa...@os.amperecomputing.com> writes:
> On Jun 14 18:11, Alex Bennée wrote: >> From: "Emilio G. Cota" <c...@braap.org> >> >> Here the trickiest feature is passing the host address to >> memory callbacks that request it. Perhaps it would be more >> appropriate to pass a "physical" address to plugins, but since >> in QEMU host addr ~= guest physical, I'm going with that for >> simplicity. > > How much more difficult would it be to get the true physical address (on > the guest)? Previously there was a helper that converted host address (i.e. where QEMU actually stores that value) back to the physical address (ram offset + ram base). However the code for calculating all of this is pretty invasive and requires tweaks to all the softmmu TCG backends as well as hooks into a slew of memory functions. I'm re-working this now so we just have the one memory callback and we provide a helper function that can provide an opaque hwaddr struct which can then be queried. The catch is you can only call this helper during a memory callback. I'm not sure if having this restriction violates our aim of not leaking implementation details to the plugin but it makes the code simpler. Internally what the helper does is simply re-query the SoftMMU TLB. As the TLBs are per-CPU nothing else can have touched the TLB and the cache should be hot so the cost of lookup should be minor. We could also potentially expand the helpers so if you are interested in only IO accesses we can do the full resolution and figure out what device we just accessed. > This is important enough to me that I would be willing to help if > pointed in the right direction. Well I'll certainly CC on the next series (hopefully posted Monday, softfreeze starts Tuesday). I'll welcome any testing and review. Also if you can tell us more about your use case that will help. > > -Aaron -- Alex Bennée