On 11/30/22 14:50, Nada Lachtar wrote:
Hello,
I’m trying to understand the structure of TLB in QEMU/tcg, in order to extract
the physical address from the CPUTLBEntry. Would this be possible without
having the virtual address and use tlb_lookup? For example, I would like to
read all the physical addresses that are recorded in the TLB table without the
need for a virtual address to translate the entry.
I would appreciate your help in directing me to what functions/structures to
use to achieve this.
The virtual address of the CPUTLBEntry is recorded as the page-address bits in each of the
three comparators: addr_read, addr_write, addr_code. This is documented in the comment
right there with CPUTLBEntry (TARGET_LONG_BITS to TARGET_PAGE_BITS).
Bits below TARGET_PAGE_BITS are TLB flags, e.g. TLB_MMIO.
If TLB_INVALID_MASK is set in addr_{read,write,code}, the entry is not
readable/writable/executable. If TLB_INVALID_MASK is set in all three, the entry is unused.
If CPUTLBEntry is valid, there is also a CPUTLBEntryFull structure in parallel, which
contains (among other things), CPUTLBEntryFull.phys_addr, containing the cpu-side physical
address for the address space given by CPUTLBEntryFull.attrs.
r~