James Kenney wrote:
> It would be helpful if there was an explicit statement saying
> something like in implementations with separate G and VS stage
> TLB caches, there is no requirement that execution of HFENCE.GVMA
> invalidate any VS stage TLB entries, or something like that (as Anup
> stated, I think) - or the opposite, if that is what is required.
>
> I can see that Kelvin's TPCs would definitely have to be flushed,
> because otherwise there is a risk that a subsequent page table lookup
> would be short-circuited and use stale data. But the situation for
> cached VS-stage entries is not clear. For context, we have customers
> who have conflicting opinions about this: one is sure that all
> VS-stage entries must be flushed by HFENCE.GVMA, and one is equally
> sure that they must not!
I'm starting to realize I didn't read James's message well enough, and
I then wrote a long treatise yesterday addressing the wrong question.
Sorry! (Although maybe it will prove helpful to some people anyway.)
I'll try to do better this time.
James Robinson:
> What you are describing seems very (and unnecessarily) punitive for
> implementations which are caching VS stage translations separately
> from G stage translations. As someone working on an implementation
> which does, this, I would like to check whether this is the right
> thing to be specifying.
>
> This is not what Anup, who I believe is at the forefront of
> implementing relevant software, had understood (from his first
> response to the thread on Sep 22).
>
> The net effect of what you describe is that whenever the hypervisor
> makes any modification to the guest mappings, all VS-stage
> translations must be invalidated, whereas it seems to me that there
> are a number of situations where the hypervisor might change G-stage
> mappings but the VS-stage mappings can (even must, see the example
> below) be considered to remain valid.
The Privileged ISA manual tries to say that HFENCE.GVMA applies only
to the address translation data structures (page tables) pointed to by
hgatp, not those pointed to by satp or vsatp. Although I didn't say
so explicitly, I meant my statements yesterday in that context. An
HFENCE.GVMA need not affect an address translation cache (TLB) that
caches only VS-stage translations.
I assume that answers the concerns of both of you, correct?
Even so, if you still believe the document is unclear as currently
written, please review the existing GitHub issues here:
https://github.com/riscv/riscv-isa-manual/issuesand if there isn't one already for this topic, add it.
Best,
- John Hauser