On 11/17/21 7:37 AM, yangxiaojuan wrote:
+ *physical = (tlb_ppn1 << 12) | (address & ((1 << tlb_ps) - 1));
TARGET_PAGE_SIZE.
Maybe TARGET_PAGE_SIZE is not fit for a huge page. MAKE_64BIT_MASK(0, tlb_ps)
is ok?
I meant the first << 12. But, yes, MAKE_64BIT_MASK is a good improvement.
Bit of a shame to have a linear search. I guess it's ok for a start, but
you'll find that this function is critical to the emulation speed of qemu, so
you should think about other ways to organize the data.
The stlb search by the set, the mtlb uses the linear search, I have no other
idea, do you have some advice?
Well, stlb are all the same page size, and duplicate matches are undefined.
A hash table of the valid entries might be workable, with the virtual page and asid taken
into account. I'd imagine that would get you down from 2048 comparisons to just a few.
The mtlb entries may all have different page size, so I don't immediately know how to
search them more efficiently. But there are only 64 of them.
It might be worth having a couple of bitsets that summarize the valid entries. This could
be used to search less than 64 mtlb entries. It could also be used to influence the
"random" selection of a new tlb entry: always select an empty tlb entry first, then evict
a random entry.
r~