{"id":15,"date":"2006-06-16T12:44:36","date_gmt":"2006-06-16T20:44:36","guid":{"rendered":"http:\/\/www.pagetable.com\/?p=15"},"modified":"2006-06-16T12:44:36","modified_gmt":"2006-06-16T20:44:36","slug":"vitualization-the-elegant-way-and-the-x86-way","status":"publish","type":"post","link":"https:\/\/www.pagetable.com\/?p=15","title":{"rendered":"Virtualization: The elegant way and the x86 way"},"content":{"rendered":"<p>Virtualization means running one or more complete operating systems (at the same time) on one machine, possibly on top of another operating system. VMware, VirtualPC, Parallels etc. support, for example, running a complete GNU\/Linux OS on top of Windows. For virtualization, the Virtual Machine Monitor (VMM) must be more powerful than kernel mode code of the guest: The guest&#8217;s kernel mode code must not be allowed to change the global state of the machine, but may not notice that its attempts fail, as it was designed for kernel mode. The VMM as the arbiter must be able to control the guest completely.<\/p>\n<p>Architectures like the PowerPC made virtualization easy from the beginning. There are no assembly instructions that work differently in kernel mode than in user mode. An instruction either works the same in both modes, or it throws an exception when used in user mode. In order to virtualize an operating system, it is as easy as running the kernel mode part of the guest in user mode and emulate all instructions that throw exceptions. When the guest OS wants to set up a page table, the VMM notices this, intercepts the instruction, and changes its own page tables, so that the guest OS works as it is supposed to, but the VMM and other guests cannot be affected.<\/p>\n<p>On the x86 platform, there are several instructions that just behave differently in kernel mode and in user mode. If we run kernel mode code in user mode, some sensitive instructions might not throw exceptions, but instead return incorrect (compared to kernel mode) results. VMware, VirtualPC, Parallels and friends therefore have to scan all kernel mode code and replace these sensitive instructions with explicit calls to the VMM. This effectively steals about 100 MHz of computing power per VM running.<\/p>\n<p>Intel fixed it with its &#8220;Virtualization Technology&#8221; (VT), formerly known as &#8220;Vanderpool&#8221;, but not by adding a global switch that makes all sensitive instructions throw exceptions in user mode &#8211; but by adding yet another mode of execution. The new &#8220;root mode&#8221; is more powerful than standard kernel mode. The host OS and the VMM run in root mode, and the VMM switches to &#8220;non-root&#8221; mode into the guest OS, after telling the CPU which instructions and events should make it leave non-root mode and return to the VMM. This sounds complex &#8211; but it therefore fits nicely into the x86 architecture. \ud83d\ude09<\/p>\n<p>Although AMD&#8217;s Pacifica is incompatible, it&#8217;s the same design. But it&#8217;s more powerful: Pacifica allows 16 Bit as well as non-paged applications in non-root mode, whereas VT restricts the VM to 32\/64 bit paged mode.<\/p>\n<p>I know that I simplified the whole issue a lot, but if you have corrections or any other comments, please do add them.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Virtualization means running one or more complete operating systems (at the same time) on one machine, possibly on top of another operating system. VMware, VirtualPC, Parallels etc. support, for example, running a complete GNU\/Linux OS on top of Windows. For virtualization, the Virtual Machine Monitor (VMM) must be more powerful than kernel mode code of &#8230; <a title=\"Virtualization: The elegant way and the x86 way\" class=\"read-more\" href=\"https:\/\/www.pagetable.com\/?p=15\" aria-label=\"Read more about Virtualization: The elegant way and the x86 way\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,35,36,38],"tags":[],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-trivia","category-virtualization","category-whines","category-x86"],"_links":{"self":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15"}],"version-history":[{"count":0,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts\/15\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}