Hi Christoffer, On 10/12/2018 10:03, Christoffer Dall wrote: > On Thu, Dec 06, 2018 at 05:31:19PM +0000, Marc Zyngier wrote: >> Contrary to the non-VHE version of the TLB invalidation helpers, the VHE >> code has interrupts enabled, meaning that we can take an interrupt in >> the middle of such a sequence, and start running something else with >> HCR_EL2.TGE cleared. > > Do we have to clear TGE to perform the TLB invalidation, or is that just > a side-effect of re-using code? We really do need to clear TGE. From the description of TLBI VMALLE1IS: <quote> When EL2 is implemented and enabled in the current Security state: — If HCR_EL2.{E2H, TGE} is not {1, 1}, the entry would be used with the current VMID and would be required to translate the specified VA using the EL1&0 translation regime. — If HCR_EL2.{E2H, TGE} is {1, 1}, the entry would be required to translate the specified VA using the EL2&0 translation regime. </quote> > Also, do we generally perform TLB invalidations in the kernel with > interrupts disabled, or is this just a result of clearing TGE? That's definitely a result of clearing TGE. We could be taking an interrupt here, and execute a user access on the back of it (perf will happily walk a user-space stack in that context, for example). Having TGE clear in that context. An alternative solution would be to save/restore TGE on interrupt entry/exit, but that's a bit overkill when you consider how rarely we issue such TLB invalidation. > Somehow I feel like this should look more like just another TLB > invalidation in the kernel, but if there's a good reason why it can't > then this is fine. The rest of the TLB invalidation in the kernel doesn't need to save/restore any context. They apply to a set of parameters that are already loaded on the CPU. What we have here is substantially different. Thanks, M. -- Jazz is not dead. It just smells funny...