<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Abort, Retry, Hack? &#187; intelvt</title>
	<atom:link href="http://marcansoft.com/blog/tag/intelvt/feed/" rel="self" type="application/rss+xml" />
	<link>http://marcansoft.com/blog</link>
	<description>[ marcan&#039;s blog ]</description>
	<lastBuildDate>Tue, 22 Dec 2009 16:26:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Enabling Intel VT on the Aspire 8930G (and other InsydeH2O-based laptops)</title>
		<link>http://marcansoft.com/blog/2009/06/enabling-intel-vt-on-the-aspire-8930g/</link>
		<comments>http://marcansoft.com/blog/2009/06/enabling-intel-vt-on-the-aspire-8930g/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 16:30:49 +0000</pubDate>
		<dc:creator>marcan</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[acer]]></category>
		<category><![CDATA[bios]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[intelvt]]></category>
		<category><![CDATA[reveng]]></category>

		<guid isPermaLink="false">http://marcansoft.com/blog/?p=71</guid>
		<description><![CDATA[It seems the ongoing trend for laptops is to integrate and hide as much as possible from the user. We&#8217;re all used to minimalistic crappy BIOS setups with two or three configuration options. However, things go way too far when OEMs remove options related to features that the hardware is capable of but which are [...]]]></description>
			<content:encoded><![CDATA[<p>It seems the ongoing trend for laptops is to integrate and hide as much as possible from the user. We&#8217;re all used to minimalistic crappy BIOS setups with two or three configuration options. However, things go way too far when OEMs remove options related to features that the hardware is capable of but which are disabled by default. This happens with Intel VT on many laptops &#8211; even if the CPU supports it, you may not be able to find the BIOS setup option to turn it on. </p>
<p>I certainly wanted to use a feature that I <b>paid for</b>, so I started investigating the BIOS and here&#8217;s what I found out.<br />
<span id="more-71"></span></p>
<h3>Under the hood</h3>
<p>The InsydeH2O BIOS is no ordinary old-style BIOS. Instead, it&#8217;s based around the <a href="http://www.uefi.org/">UEFI</a> platform. This goes way beyond the old BIOS paradigm and turns system firmware into practically its own separate OS, that even runs in full 64-bit mode on 64-bit machines. Unfortunately, they make no effort to expose any of this to the user. The firmware has support for booting EFI executables, there&#8217;s an EFI shell, there&#8217;s an EFI boot manager&#8230; but I haven&#8217;t been able to figure out how to access any of this.</p>
<p>If you want to reverse engineer EFI stuff, downloading <a href="https://www.tianocore.org/">TianoCore&#8217;s EDK2</a> is a must. It contains source code for a lot of Intel&#8217;s framework, which is what most vendors use as a base for their EFI support. A lot of the code is exactly the same as what&#8217;s in the Insyde BIOS (read the spec <a href="http://download.intel.com/technology/framework/docs/HII_9_2.pdf">here</a>). </p>
<p>As for the Setup tool, it does indeed have a huge Advanced menu with even more options than your average desktop. There&#8217;s also a hidden Power menu. EFI defines a &#8220;form browser&#8221; protocol and formats for user input, which is what Insyde uses for their setup utility (spec <a href="http://download.intel.com/technology/framework/docs/HII_9_2.pdf">here</a>). I found these tables when disassembling the Setup binary and wrote a little dump utility to turn them into text. The result is a complete dump of the Setup hierarchy, including the Advanced menu, which also includes the offsets in the non-volatile storage corresponding to each setting. Insyde stores this configuration blob into an EFI variable named <code>Setup</code>. <a href="/uploads/insydehacks/setup.txt">Here&#8217;s</a> my dump: the first part is the hierarchy, while at the end I added a rough auto-calculated mapping from configuration offsets to setting names (grep for <code>[0xOFFSET</code> in the top section for better context - the format is <code>[0xOFFSET&lt;FIELD_WIDTH&gt;]</code> for all references to the storage blob). You&#8217;ll find the tools I used <a href="/uploads/insydehacks">here</a>, if you&#8217;re interested, but they&#8217;re rough and need quite a bit of manual help too.</p>
<p>I wasn&#8217;t able to find out how to enable the hidden menus, other than that their form Subclass is 5 instead of 0 (but I haven&#8217;t found what, if anything, checks for this and whether its behavior can be altered). However, manually enabling VT support in the <code>Setup</code> variable is easy enough, now that we have the offset of the VT Enable byte.</p>
<h3>Enabling Intel VT</h3>
<p>The easiest way to enable the setting as far as I can see is to dump out the entire BIOS, patch the setting into the Setup variable (which is part of the data storage section &#8211; we aren&#8217;t modifying any actual BIOS code, as this is the equivalent of changing a CMOS setting on other BIOSes), and then flash the resulting image. These laptops use a weird flash-behind-EC hardware solution for which there is no open flasher, so instead we can just use the normal BIOS flashing tool. In short, we&#8217;ll flash the existing BIOS back on, but in the process also modify a Setup setting.</p>
<p><b>FAIR WARNING:</b> This might apply to other similar laptops, or it might not. It might work, it might do nothing, or it might brick your expensive laptop. Even if you own an Aspire 8930G, I take no responsiblity if your laptop dies, turns into an expensive brick, melts into a pool of slag, blows up, flicks you off, develops self-awareness, or becomes Skynet. You have been warned. I have only tested this on an Aspire 8930G with BIOS Version 1.10. If you want to try this on another system or BIOS you should make sure you understand EXACTLY what is going on and are prepared to spot any problems or fix things yourself.</p>
<p>First, dump the exiting BIOS out. It resides at the top of the 32-bit address space, and is 2MB in size. You can use dd to dump it out of /dev/mem:</p>
<pre>$ dd if=/dev/mem of=original_bios.fd bs=1024 count=2048 skip=4192256</pre>
<p>It is a <i>very</i> good idea to back up this BIOS somewhere safe outside the laptop. Note that it not only contains your existing BIOS code, but also all your settings and manufacturer data (serial number, software license if you run an OEM version of Vista, etc).</p>
<p>Next, run <a href="/uploads/insydehacks/vtenable.py">vtenable.py</a>. This will attempt to locate the <b>Setup</b> EFI variable on the non-volatile storage section and patch the VT byte to one.</p>
<pre>$ python vtenable.py original_bios.fd vt_bios.fd</pre>
<p>You can edit the source code to make other changes to the variable, but make sure you know what you&#8217;re doing. It&#8217;s worth reiterating that <b>this does not patch your BIOS code</b>. It only makes a setting change, just as if you&#8217;d turned on the VT option in the BIOS had it been there. In fact, there are two variables: <code>Setup</code> and <code>Custom</code>, and <code>Setup</code> is the one that changes are committed to when you use the setup utility. Restoring defaults should turn VT back off (untested). It also appears that <code>Custom</code> is probably what the setup defaults are, so changing that should semi-permanently enable VT.</p>
<p>I highly recommend performing a sanity diff between the original and modified images using vbindiff:</p>
<pre>$ vbindiff original_bios.fd vt_bios.fd</pre>
<p>Only two or three bytes should change: one or two adjacent bytes for the checksum (they should be decremented by one when you look at them as a 16-bit unsigned integer), and the VT enable byte should change from <code>00</code> to <code>01</code>. Right after the checksum bytes you should be able to see the <code>Setup</code> name in UTF-16 (something like <code>S.e.t.u.p.</code>).</p>
<p>Finally, flash <code>vt_bios.fd</code> using the vendor-supplied flash utility. I use the DOS version (<code>FLASHIT.EXE</code>) with FreeDOS and a grub menu option so I don&#8217;t need to mess around with external media. Grab a base image <a href="/uploads/insydehacks/freedos_flashit.img.bz2">here</a>, then you can use <a href="http://mtools.linux.lu/">mtools</a> to copy the bios into it:</p>
<pre>$ bunzip2 freedos_flashit.img.bz2
$ mcopy -i freedos_flashit.img vt_bios.fd ::/vt_bios.fd</pre>
<p>To boot it using GRUB, get <a href="http://syslinux.zytor.com/wiki/index.php/MEMDISK">MEMDISK</a>, part of <a href="http://syslinux.zytor.com/wiki/index.php/The_Syslinux_Project">SYSLINUX</a>, and put something like this in your grub.conf:</p>
<pre>title=BIOS Update
root (hd0,0)
kernel (hd0,0)/boot/memdisk
initrd (hd0,0)/boot/freedos_flashit.img</pre>
<p>Of course, copy memdisk and the boot image to your boot partition, and change <code>(hd0,0)</code> to your boot (or root) partition everywhere and remove the <code>/boot</code> part if you have a dedicated boot partition.</p>
<p>Once you&#8217;re in FreeDOS, just type <code>FLASHIT vt&lt;tab&gt;</code> and be happy that FreeDOS supports tab-completion <img src='http://marcansoft.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Caveat: by doing this, you&#8217;re flashing the entire BIOS image. The flash tool makes no attempt to flash only the parts that changed, and the &#8220;flash only variables&#8221; commandline option seems to have no effect. You&#8217;re effectively reflashing your entire BIOS back on, so the usual BIOS flashing caveats apply: don&#8217;t turn the power off, etc. This could be accomplished a lot more cleanly if we had drivers for the flash chip / EC, since then we could use the normal EFI variable store procedure to atomically update the variable, which is completely safe.</p>
<p>You can use the <a href="http://www.linux-kvm.org/page/Enable_VT-X_on_Mac_Pro_(Early_2008)">MSR Magic</a> tool to check whether VT is indeed enabled on your CPU.</p>
<p><b>Update</b>: Several people are working on improved, more general tools to perform this hack across a broader range of InsydeH2O-based BIOSes. Read the comments and check them out, they&#8217;ve done some very good work.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcansoft.com/blog/2009/06/enabling-intel-vt-on-the-aspire-8930g/feed/</wfw:commentRss>
		<slash:comments>387</slash:comments>
		</item>
	</channel>
</rss>
