<div dir="ltr"><div>Thank you</div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Georgii Ekserdzhian</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">пн, 14 дек. 2020 г. в 16:11, Petr Tuma <<a href="mailto:petr.tuma@d3s.mff.cuni.cz">petr.tuma@d3s.mff.cuni.cz</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Georgii,<br>
<br>
> One more question. I did look through the assembly code and through MIPS manual and as far as I understand when we get a TLB miss CPU should go to tlb refill handler directly, but for some reason our code goes to general_exception_handler. Is that correct or do we have a problem?<br>
<br>
There are three different TLB exceptions on the MIPS CPU, TLB Refill, TLB Invalid and TLB Modified.<br>
<br>
- TLB Refill is called when there is no TLB entry matching the virtual address used (no entry where `VA & mask == VPN` and either `ASID == entry ASID` or `entry global`). This is the exception you should focus on in your assignments.<br>
<br>
- TLB Invalid is called when there is a TLB entry matching the virtual address used, but the `valid` bit is zero. This is an exception that you might see when working on your assignments, in particular if you leave current ASID at zero and use the initial TLB content, which is also all zeros, so it happens to match all addresses. If you assign ASID to your threads correctly (and do not start with the zero ASID), you should not need to handle this exception I think.<br>
<br>
- TLB Modified is called when there is a TLB entry matching the virtual address used, but the `dirty` bit is zero and the access is a write. This is intended for swapping so that the kernel can remember what pages are dirty. Since you do not have swapping, just set the dirty bit in the TLB entries to one from the start and you should never see this exception.<br>
<br>
Only TLB Refill has its own handler. Both TLB Invalid and TLB Modified are delivered to the general exception handler and can be recognized by looking at the CP0 registers.<br>
<br>
Petr<br>
</blockquote></div>