{"id":292,"date":"2007-11-02T07:43:32","date_gmt":"2007-11-02T11:43:32","guid":{"rendered":"http:\/\/journal2.alanv.org\/?p=292"},"modified":"2012-10-09T21:39:32","modified_gmt":"2012-10-10T01:39:32","slug":"more-os-2","status":"publish","type":"post","link":"https:\/\/journal2.alanv.org\/?p=292","title":{"rendered":"More OS"},"content":{"rendered":"<p>Don&#8217;t you love that sense of satisfaction you get after you fix a rather annoying bug?<\/p>\n<p>8 finished the VM rewrite for our kernel (and it looks *much* nicer now, and the PM can also magically keep track of free physical pages without needing an internal data structure [and hence, won&#8217;t use more memory if we ever happen to get more than 256MB of ram]) and we had a remarkably easy time integrating it into our main branch (although I&#8217;m still of the opinion that Subversion merging is horrific and painful).<\/p>\n<p>Then the fun started. Things started out ok and init and idle started and the shell started and readline worked.<br \/>\nThen, when we tried to execute a task from the shell, things exploded.<br \/>\nAfter about an hour, I tracked down the problem to fork&#8217;s page-directory-and-table copying function&#8230; odd though, since that hadn&#8217;t changed since before the VM rewrite, and it was working fine before.<br \/>\nAfter poking at it some more, I determined that, for some unknown reason, one of the page tables in the newly-forked task contained garbage data. Garbage data that happened to look a lot like a kernel stack. Hmmm&#8230;<br \/>\nA bunch of breakpoints and plenty of <code>x%cr3 4096<\/code> and <code>psym \"pcb->esp0\"<\/code> later, I discovered that, somehow, the same physical page was being mapped as both a kernel stack page and as a page table page. Very odd.<br \/>\nPoked at it for another couple hours until I managed to isolate the problem to one function&#8230; a function that destroys the current mappings in the page directory\/tables to prepare a task for exec. Turns out it was a mistake with freeing pages&#8230; for some reason, the code was freeing a page *after* the desired page (<code>PTR_ADD(page_loc, PAGE_SIZE)<\/code>). Oops. Fixing that fixed the immediate bug but tripped an assertion.<br \/>\nThat one turned out to be simpler&#8230; the wrong virtual address was being passed into the freeing function (<code>*entry<\/code> instead of <code>entry<\/code>). Whee.<\/p>\n<p>So yeah, it appears that we are back in the same state that we were yesterday as far as runnability and such goes, except we have a shiny new VM that appears to be much happier (and much cleaner) than before.<\/p>\n<p>I should probably go sleep, as it is 7:30&#8230; but it might make more sense to just stay up until class and then sleep afterward. Meh.<\/p>\n<p>All we have left to do is finish vanish and write wait and we will be kernel code-complete (at least, theoretically&#8230; we&#8217;ll probably end up doing more rewrites and such). Awesomeness.<\/p>\n<p>There has been much ITG lately. I need to get back into 11s&#8230; maybe I&#8217;ll manage to pass a 12 before I leave CMU. Wheee.<br \/>\n<img src='http:\/\/journal2.alanv.org\/wp-content\/uploads\/110107itg.jpg' alt='110107itg.jpg' \/><br \/>\n<img src='http:\/\/journal2.alanv.org\/wp-content\/uploads\/110107itg2.jpg' alt='110107itg2.jpg' \/><br \/>\n<img src='http:\/\/journal2.alanv.org\/wp-content\/uploads\/110107itg3.jpg' alt='110107itg3.jpg' \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Don&#8217;t you love that sense of satisfaction you get after you fix a rather annoying bug? 8 finished the VM rewrite for our kernel (and it looks *much* nicer now, and the PM can also magically keep track of free &hellip; <a href=\"https:\/\/journal2.alanv.org\/?p=292\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,10],"tags":[],"class_list":["post-292","post","type-post","status-publish","format-standard","hentry","category-dancing-games","category-os"],"_links":{"self":[{"href":"https:\/\/journal2.alanv.org\/index.php?rest_route=\/wp\/v2\/posts\/292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/journal2.alanv.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/journal2.alanv.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/journal2.alanv.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/journal2.alanv.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=292"}],"version-history":[{"count":0,"href":"https:\/\/journal2.alanv.org\/index.php?rest_route=\/wp\/v2\/posts\/292\/revisions"}],"wp:attachment":[{"href":"https:\/\/journal2.alanv.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/journal2.alanv.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/journal2.alanv.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}