Hi M-labs, I'm doing a little experiment with LM32 MMU: adding ASID (Address Space ID) support to the TLBs
For now I only implemented it for D-TLB, it is available over there: - https://github.com/fallen/milkymist-mmu ("asid" branch) - lm32 submodule is now pointing to https://github.com/fallen/lm32 ("asid" branch) ASID allows to not flush the TLB during context switch thus improving performance a bit (in theory). When you add/update a TLB entry, you give give it an ASID and therefore the TLB entry is only valid (will produce a MATCH and not a MISS) if its ASID is equal to the current ASID the CPU is in (which is stored in PSW.asid == PSW[16:12]). When you run out of ASID (you assigned all of them to different PIDs), then you need to unassign one and assign it to another process (the next one which will run on the CPU). But then, you need to flush the TLB from its entries belonging to the process who used to own the ASID. This introduces a new TLB operation : LM32_TLB_OP_ASID_FLUSH. This operation iterates over the whole TLB and when it finds an entry of the ASID you specified in the ASID_FLUSH command it will invalidate it. Basic unit tests have been added in the lm32 repository for this new feature. For now I am fighting against an issue when running on the Milkymist One board, I would appreciate if someone could give me some help on finding what's going on :) I don't know yet if it's software or gateware bug, here it is: I'm booting the (modified) Milkymist One BIOS on the gateware with MMU ans ASID enabled in the LM32 config file: BIOS> rcsr psw 00000003 # that's already not normal, should have been 0xC3 since dtlb was activated early in crt0.S BIOS> wcsr psw 0x43 # let's activate it back! BIOS> rcsr psw 000000c3 # OK thats better... BIOS> asid 5 # let's switch ASID from 0 to 5! old PSW: 0x000000C3 switching to ASID 0x00000005 after shifting: asid2 == 0x00005000 new simulated PSW: 0x000050C3 new PSW: 0x000050C3 # OK the PSW is correct at the end of switch_asid() BIOS> rcsr psw 00005003 # damn it! someone turned DTLB off again :-( BIOS> wcsr psw 0x5043 # let's turn it back on! BIOS> rcsr psw 000050c3 # Ok... good... BIOS> help # let's run some stuff! Milkymist(tm) BIOS (bootloader) Don't know what to do? Try 'flashboot'. Available commands: cons - switch console mode flush - flush FML bridge cache mr - read address space mw - write address space mc - copy address space crc - compute CRC32 of a part of the address space rcsr - read processor CSR wcsr - write processor CSR ls - list files on the filesystem load - load a file from the filesystem netboot - boot via TFTP serialboot - boot via SFL fsboot - boot from the filesystem flashboot - boot from flash mdior - read MDIO register mdiow - write MDIO register version - display version reboot - system reset reconf - reload FPGA configuration asid - switch ASID BIOS> rcsr psw 00005003 # Ok there's something going on! DTLB is off again :( BIOS> If you want to try it yourself: $ git clone https://github.com/fallen/milkymist-mmu.git $ cd milkymist-mmu $ git submodule update --init $ make $ source /opt/Xilinx/<whatever_ISE_version>/ISE_DS/settings32.sh $ make bitstream $ cd software/bios && make && cd - flash the BIOS to the M1 board and then run the gateware: $ sudo make load-bitstream Cheers :) -- Yann Sionneau
_______________________________________________ Devel mailing list [email protected] https://ssl.serverraum.org/lists/listinfo/devel
