TLB Question
Hi,
I'm trying to understand the MMU operations & am wondering where is the kernel code where the kernel interfaces with the this piece of hardware?
Can some one help me in understanding that what all are the responsibilities of the kernel, and what is it the hardware takes care of automatically? E.g. who fills, flushes & refills the TLB entries? What all initializations need to be performed by kernel (And where is the code?)
TIA,
Rick
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 1 line
E.g. who fills, flushes & refills the TLB entries?
TLB entries are filled by H/W and not explicitly by kernel. Whenever MMU translates VA to PA it caches that translation into TLB. If TLB is full then MMU uses its own algorithms to replace some entry in TLB e.g. MMU might consider TLB as circular buffer and replace first entry once TLB is full.
Quoted 2 lines
What all initializations need to be performed by kernel (And where is the code?)
Kernel bascially has to set up the page tables and set the Page Table Base register and enbale MMU.
Regards
- A.
Quoted 23 lines · Rick Brown
Hi,
I'm trying to understand the MMU operations & am wondering where is the kernel code where the kernel interfaces with the this piece of hardware?
Can some one help me in understanding that what all are the responsibilities of the kernel, and what is it the hardware takes care of automatically? E.g. who fills, flushes & refills the TLB entries? What all initializations need to be performed by kernel (And where is the code?)
TIA,
Rick
--
To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to [email protected] Please read the FAQ at http://kernelnewbies.org/FAQ
Hi...
Quoted 4 lines · sahlot arvind
TLB entries are filled by H/W and not explicitly by kernel. Whenever MMU translates VA to PA it caches that translation into TLB. If TLB is full then MMU uses its own algorithms to replace some entry in TLB e.g. MMU might consider TLB as circular buffer and replace first entry once TLB is full.
AFAIK, by using certain instructions...you can manually insert entry/entries to TLB. Same thing to deleting TLB entries. This kind of technique is used for example on security related software such as PaX/grsecurity
regards,
Mulyadi.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 2 lines
AFAIK, by using certain instructions...you can manually insert entry/entries to TLB. Same thing to deleting TLB entries.
Yes you can insert/delete entries in TLB manually. Though I am not sure but AFAIK, linux kernel does do this.
Please correct if I am wrong.
Regards
Quoted 21 lines · Mulyadi Santosa
Hi...
Quoted 2 lines · sahlot arvind
TLB entries are filled by H/W and not explicitly by kernel. Whenever MMU translates VA to PA it caches that translation into TLB. If TLB is full
then
Quoted 2 lines
MMU uses its own algorithms to replace some entry in TLB e.g. MMU might consider TLB as circular buffer and replace first entry once TLB is
full.
AFAIK, by using certain instructions...you can manually insert entry/entries to TLB. Same thing to deleting TLB entries. This kind of technique is used for example on security related software such as PaX/grsecurity
regards,
Mulyadi.
hadling tlb is architecture specific thing, so its better to search the manuals of corresponding processor to find out appropriate instructions to manipulate TLB entries.
AFAI can recall INVLPG is used to invalidate specific pte in TLB.
regards,
mahaveer darade
Quoted 33 lines · sahlot arvind
Quoted 2 lines
AFAIK, by using certain instructions...you can manually insert entry/entries to TLB. Same thing to deleting TLB entries.
Yes you can insert/delete entries in TLB manually. Though I am not sure but AFAIK, linux kernel does do this.
Please correct if I am wrong.Regards
Quoted 21 lines · Mulyadi Santosa
Hi...
Quoted 2 lines · sahlot arvind
TLB entries are filled by H/W and not explicitly by kernel. Whenever MMU translates VA to PA it caches that translation into TLB. If TLB is full
then
Quoted 2 lines
MMU uses its own algorithms to replace some entry in TLB e.g. MMU might consider TLB as circular buffer and replace first entry once TLB is
full.
AFAIK, by using certain instructions...you can manually insert entry/entries to TLB. Same thing to deleting TLB entries. This kind of technique is used for example on security related software such as PaX/grsecurity
regards,
Mulyadi.
Signature · 15 lines
--------------------------- Thanks & Regards, Mahaveer Darade [email protected] Mobile - 9970365267 --- Dream it , Code it. ---The "silly question" is the first intimation of some totally new development - To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs
I found one header file for x86 that implement the TLB flushing - include/asm-x86/tlbflush.h (the different implementation are used are used because of the diff generation of x86:
static inline void __native_flush_tlb(void)
{
write_cr3(read_cr3());
}(my questions: WHAT IS THE DIFF BETWEEN FLUSH VIA flush_tlb() above
vs flush_tlb_global() below?)
static inline void __native_flush_tlb_global(void)
{
unsigned long cr4 = read_cr4();
/* clear PGE */
write_cr4(cr4 & ~X86_CR4_PGE);
/* write old PGE again and flush TLBs */
write_cr4(cr4);
}(question: what is this single - does it flush only ONE SINGLE ENTRY
IN THE TLB that map this particular addr value?)
static inline void __native_flush_tlb_single(unsigned long addr)
{
__asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory");
}-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 11 lines · Peter Teoh
I found one header file for x86 that implement the TLB flushing -
include/asm-x86/tlbflush.h(the different implementation are used are used because of the diff generation of x86:static inline void
__native_flush_tlb(void){ write_cr3(read_cr3()); }(my questions: WHAT IS THE DIFF BETWEEN FLUSH VIA
flush_tlb()above
vsflush_tlb_global()below?)
below function is used to handle tlb entires of global pages as they do not get flushed from TLB on task switch or writing to cr3
Quoted 11 lines
static inline void
__native_flush_tlb_global(void){ unsigned long cr4 = read_cr4(); /* clear PGE */ write_cr4(cr4 & ~X86_CR4_PGE); /* write old PGE again and flush TLBs */ write_cr4(cr4); }
Quoted 2 lines
(question: what is this single - does it flush only ONE SINGLE ENTRY
IN THE TLB that map this particular addr value?)
yes thats right !! its used to invalidate particular PTE entry in TLB.
Quoted 7 lines
static inline void
__native_flush_tlb_single(unsigned long addr){ __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory"); }
Signature · 11 lines
--------------------------- Thanks & Regards, Mahaveer Darade [email protected] Mobile - 9970365267 --- Dream it , Code it. ---The "silly question" is the first intimation of some totally new development