2

I was looking for an answer for this question but didn't find any clear answer. When calling a sys call such as getpid(), while returning from kernel mode to user mode, does the TLB get flushed?

My "logic" says yes, in order to prevent the user to invades kernel's address space. I am not very convinced with that answer because of the hardware protection which can protect the kernel's virtual space and save flushing time.

Would love to get this straight,

Thanks.

Asurii
  • 69
  • 6
  • 1
    There certainly is such hardware protection - there's a user/supervisor bit in every page table entry, so kernel memory can be left mapped without making it accessible to the user. However I seem to recall that as part of the Meltdown/Spectre mitigations, the user now gets a separate page table with kernel memory not mapped at all, and switching between those tables on entry/exit to the kernel would certainly entail a TLB flush. I'll have to look it up. – Nate Eldredge Sep 20 '21 at 12:49
  • 1
    @NateEldredge yep, that's called Page Table Isolation aka PTI, usually enabled by default. – Marco Bonelli Sep 20 '21 at 13:00

0 Answers0