[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 17/55] plugins: implement helpers for resolving hwaddr
From: |
Richard Henderson |
Subject: |
Re: [PATCH v5 17/55] plugins: implement helpers for resolving hwaddr |
Date: |
Mon, 14 Oct 2019 08:45:34 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
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 <address@hidden>
r~
- [PATCH v5 43/55] tests/tcg: drop test-i386-fprem from TESTS when not SLOW, (continued)
- [PATCH v5 43/55] tests/tcg: drop test-i386-fprem from TESTS when not SLOW, Alex Bennée, 2019/10/14
- [PATCH v5 08/55] plugin: add core code, Alex Bennée, 2019/10/14
- [PATCH v5 54/55] plugins: add qemu_plugin_outs and use it, Alex Bennée, 2019/10/14
- [PATCH v5 33/55] target/xtensa: fetch code with translator_ld, Alex Bennée, 2019/10/14
- [PATCH v5 46/55] plugin: add qemu_plugin_insn_disas helper, Alex Bennée, 2019/10/14
- [PATCH v5 52/55] plugins: make howvec plugin more generic, Alex Bennée, 2019/10/14
- [PATCH v5 31/55] target/riscv: fetch code with translator_ld, Alex Bennée, 2019/10/14
- [PATCH v5 17/55] plugins: implement helpers for resolving hwaddr, Alex Bennée, 2019/10/14
- [PATCH v5 32/55] target/sparc: fetch code with translator_ld, Alex Bennée, 2019/10/14
- [PATCH v5 18/55] translate-all: notify plugin code of tb_flush, Alex Bennée, 2019/10/14
- [PATCH v5 30/55] target/alpha: fetch code with translator_ld, Alex Bennée, 2019/10/14
- [PATCH v5 13/55] tcg: add tcg_gen_st_ptr, Alex Bennée, 2019/10/14
- [PATCH v5 42/55] tests/tcg: move "virtual" tests to EXTRA_TESTS, Alex Bennée, 2019/10/14
- [PATCH v5 45/55] tests/plugin: add a hotblocks plugin, Alex Bennée, 2019/10/14