I'm currently developing a hypervisor feature.
I'm confused about what to do with TLB Invalidation when EPT Violation occurs
I'm developing on Linux, using an i7 CPU. My implementation:
- VPID and EPT Enabled
- Initially, every EPT entries' write access is cleared (read and execution access is set)
- If EPT Violation occurs(when tries to write), set write access and change entry to point another page(another hpa)
According to Intel Manual,
"An EPT Violation invalidates any guest-physical mappings (associated with the current EP4TA) that would be used to translate the guest-physical address that caused the EPT Violation. And also invalidates any combined mappings too"
I'm confused with this part.
Does it ensures that EPT Violation invalidates corresponding TLB Entry not only in the current core's TLB cache but also other core's TLB Cache?
If so, is it OK just setting write access and allocating new hpa without tlb shootdown?
I think you need to worry about clearing other core's TLB cache.
If you read above the part of Intel manual you quoted, you will find that the paragraph applys to a single logical core:
FYI the SDM I am using has Order Number 325384-075US, released in June 2021
Also, I feel that if EPT violation handles TLB shootdown for you, it will be very inefficient, or Intel should provide hardware support for traditional TLB shootdown (i.e. TLB shootdown that has nothing to do with virtual machines).