On 10/14/19 3:49 AM, Alex Bennée wrote:
> +bool tlb_plugin_lookup(CPUState *cpu, target_ulong addr, int mmu_idx,
> +                       bool is_store, struct qemu_plugin_hwaddr *data)
> +{
> +    CPUArchState *env = cpu->env_ptr;
> +    CPUTLBEntry *tlbe = tlb_entry(env, mmu_idx, addr);
> +    target_ulong tlb_addr = is_store ? tlb_addr_write(tlbe) : 
> tlbe->addr_read;
> +
> +    if (likely(tlb_hit(tlb_addr, addr))) {
> +        if (tlb_addr & TLB_MMIO) {
> +            data->hostaddr = 0;
> +            data->is_io = true;
> +            /* XXX: lookup device */
> +        } else {
> +            data->hostaddr = addr + tlbe->addend;
> +            data->is_io = false;

...

>  uint64_t qemu_plugin_hwaddr_to_raddr(const struct qemu_plugin_hwaddr *haddr)
>  {
> +#ifdef CONFIG_SOFTMMU
> +    ram_addr_t ram_addr = 0;
> +
> +    if (haddr && !haddr->is_io) {
> +        ram_addr = qemu_ram_addr_from_host((void *) haddr->hostaddr);
> +        if (ram_addr == RAM_ADDR_INVALID) {

So, did you want the host address or the ram_addr?

If you really only want the ram_addr then you can get
that directly from the (io)tlb:

    uintptr_t index = tlb_index(env, mmu_idx, addr);
    CPUTLB *tlb = &cpu_neg(cpu)->tlb;
    CPUIOTLBEntry *iotlbentry = &tlb->d[mmu_idx].iotlb[index];

    data->raddr = addr + iotlbentry->addr;

That said, what you have works.
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>


r~

Reply via email to