summaryrefslogtreecommitdiff
path: root/sys/src/9/pc/mmu.c
AgeCommit message (Collapse)Author
2025-05-14kernel: get rid of Proc.kstackglenda
The kernel stack is now above the Proc structure, so the explicit kstack pointer can be eliminated.
2021-11-26kernel: support large 64-bit pci membars, increase pc64 VMAPSIZE to 1TBcinap_lenrek
This makes vmap()/vunmap() take a vlong size argument, and change the type of Pci.mem[].size to vlong as well. Even if vmap() wont support large mappings, it is nice to get the original unruncated value for error checking. pc64 needs a bigger VMAP window, as system76 pangolin puts the framebuffer at a physical address > 512GB.
2020-12-22kernel: avoid palloc lock during mmurelease()cinap_lenrek
Previously, mmurelease() was always called with palloc spinlock held. This is unneccesary for some mmurelease() implementations as they wont release pages to the palloc pool. This change removes pagechainhead() and pagechaindone() and replaces them with just freepages() call, which aquires the palloc lock internally as needed. freepages() avoids holding the palloc lock while walking the linked list of pages, avoding some lock contention.
2020-06-06pc, pc64: use 64-bit physical addresses for vmap() and upaalloc()cinap_lenrek
2020-05-22pc, pc64: do page attribute table (PAT) init early in cpuidentify()cinap_lenrek
the page attribute table was initialized in mmuinit(), which is too late for bootscreen(). So now we check for PAT support and insert the write-combine entry early in cpuidentify(). this might have been the cause of some slow EFI framebuffers on machines with overlapping or insufficient MTRR entries.
2020-04-06pc: zero rampage() memory (thanks LordCreepity)cinap_lenrek
memory returned by rampage() is not zeroed, so we have to zero it ourselfs. apparently, this bug didnt show up as we where zeroing conventional low memory before the new memory map code. also rampage() never returns nil.
2020-04-04pc, pc64: new memory map codecinap_lenrek
This replaces the memory map code for both pc and pc64 kernels with a unified implementation using the new portable memory map code. The main motivation is to be robust against broken e820 memory maps by the bios and delay the Conf.mem[] allocation after archinit(), so mp and acpi tables can be reserved and excluded from user memory. There are a few changes: new memreserve() function has been added for archinit() to reserve bios and acpi tables. upareserve() has been replaced by upaalloc(), which now has an address argument. umbrwmalloc() and umbmalloc() have been replaced by umballoc(). both upaalloc() and umballoc() return physical addresses or -1 on error. the physical address -1 is now used as a sentinel value instead of 0 when dealing with physical addresses. archmp and archacpi now always use vmap() to access the bios tables and reserve the ranges. more overflow checks have been added. ramscan() has been rewritten using vmap(). to handle the population of kernel memory, pc and pc64 now have pmap() and punmap() functions to do permanent mappings.
2019-12-07pc: replace duplicated and broken mmu flush code in vunmap()cinap_lenrek
comparing m with MACHP() is wrong as m is a constant on 386. add procflushothers(), which flushes all processes except up using common procflushmmu() routine.
2019-10-02pc: move low-level allocation details out of mmu.c into memory.c rampage() ↵cinap_lenrek
function
2019-05-03pc kernel: remove countpagerefs() (thanks BurnZeZ)cinap_lenrek
forgot to commit this...
2018-07-11pc kernel: get rid of ugly and partially broken cpuid macrosaiju
2017-06-13pc/pc64: keep shadow copy of DR7 in Mach and use that to check whether we ↵aiju
need to reset DR7 in procsave(); remove superfluous reset of DR7 in mmurelease()
2017-06-12pc/pc64: reset DR7 in mmureleaseaiju
2017-03-11pc kernel: don't use active.thunderbirdsargo in vunmap() tlb flush codecinap_lenrek
2016-12-17pc: modify cpu0 page tables in patwc() instead of current cpu onescinap_lenrek
on 386 kernel, each processor has its own pdb where the primary pdb for kernel mappings is on cpu0 and other cpu's lazily pull pdb entries from cpu0 when they fault in vmapsync(). so we have to edit the table tables in the pdb of cpu0 and not the current processor.
2016-12-17pat write combinding support for 386 kernel, honor cpuid bitscinap_lenrek
2016-12-15pc64: implement simple write combining for framebuffers with the PATcinap_lenrek
on some modern machines like the x250, the bios arranges the mtrr's and the framebuffer membar in a way that doesnt allow us to mark the framebuffer pages as write combining, leading to slow graphics. since the pentium III, the processor interprets the page table bit combinations of the WT, CD and bit7 bits as an index into the page attribute table (PAT). to not change the semantics of the WT and CD bits, we preserve the bit patterns 0-3 and use the last entry 7 for write combining. (done in mmuinit() for each core). the new patwc() function takes virtual address range and changes the page table marking the range as write combining. no attempt is made on invalidating tlb's. doesnt matter in our case as the following mtrr() call in screen.c does it for us.
2016-01-05kernel: change active.machs from bitmap to char array to support up to 64 ↵cinap_lenrek
cpus on pc64
2015-06-15kernel: add pagechaindone() to wakeup processes waiting for memorycinap_lenrek
we keep the details about palloc in page.c, providing pagechaindone() for mmu code to be called after a series of pagechainhead() calls.
2014-12-18pc: remove mmuinit0()cinap_lenrek
all mmuinit0() does is initialize m->gdt, but this isnt neccesary as this is done by mmuinit() anyway before loading the gdt.
2014-10-18pc, pc64: allow passing RSDT pointer in *acpi= boot parameter, early ↵cinap_lenrek
bootscreeninit(), fix rampage() usage rampage() cannot be used after meminit(), so test for conf.mem[0].npage != 0 and use xalloc()/mallocalign() instead. this allows us to use vmap() early before mmuinit() which is needed for bootscreeninit() and acpi. to get memory for page tables, pc64 needs a lowraminit(). with EFI, the RSDT pointer is passed in *acpi= parameter from the efi loader. as the RSDT is ususally at the end of the physical address space (and not to be found in bios areas), we cannot KMAP() it so we need to vmap().
2014-08-07pc, pc64: make pc kaddr() check reject -KZERO address (thanks aiju)cinap_lenrek
2014-06-22kernel: new pagecache, remove Lock from page, use cmpswap for Ref instead of ↵cinap_lenrek
Lock make the Page stucture less than half its original size by getting rid of the Lock and the lru. The Lock was required to coordinate the unchaining of pages that where both cached and on the lru freelist. now pages have a single next pointer that is used for palloc.head freelist xor for page cache hash chains in Image.pghash[]. cached pages are not on the freelist anymore, but will be reclaimed from images by the pager when the freelist runs out of pages. each Image has its own 512 hash chains for cached page lookup. That is 2MB worth of pages and there should be no collisions for most text images. page reclaiming can be done without holding palloc.lock as the Image is the owner of the page hash chains protected by the Image's lock. reclaiming Image structures can be done quickly by only reclaiming pages from inactive images, that is images which are not currently in use by segments. the Ref structure has no Lock anymore. Only a single long that is atomically incremented or decremnted using cmpswap(). there are various other changes as a consequence code. and lots of pikeshedding, sorry.
2014-01-20kernel: convert putmmu() to uintptr for va and pacinap_lenrek
2014-01-20kernel: apply uintptr for ulong when a pointer is storedcinap_lenrek
this change is in preparation for amd64. the systab calling convention was also changed to return uintptr (as segattach returns a pointer) and the arguments are now passed as va_list which handles amd64 arguments properly (all arguments are passed in 64bit quantities on the stack, tho the upper part will not be initialized when the element is smaller than 8 bytes). this is partial. xalloc needs to be converted in the future.
2012-08-17pckernel: use constants instead of hardcoding cpuid bits in various placescinap_lenrek
2012-03-28panic: trailing newlinescinap_lenrek
2011-12-13kernel: more alloc stuffcinap_lenrek
2011-12-12kernel: fix inproper use of malloc/smalloccinap_lenrek
2011-07-12segdesc: add /dev/^(ldt gdt) supportcinap_lenrek
2011-06-27kernel: fix issue #62 (vunmap bug) reported from ↵cinap_lenrek
http://9fans.net/archive/2011/06/262
2011-03-30Import sources from 2011-03-30 iso image - libTaru Karttunen
2011-03-30Import sources from 2011-03-30 iso imageTaru Karttunen