Advertisement
Guest User

slic 2.1 in xen + kvm howto

a guest
May 3rd, 2011
3,113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.85 KB | None | 0 0
  1. https://github.com/ghuntley/seaslic.git
  2.  
  3. git://gitorious.org/seabios/seabios.git
  4.  
  5.  
  6. Which modification is needed for the patch to work on xen-4.0.0 ? Im on Debian Squeeze, the first hunk fails, probably because slic.h is missing?
  7. Fixed it.
  8. You grab the xen sources, like
  9.  
  10. apt-get source xen-tools
  11. whichever version you use.
  12.  
  13. Then get all the dependencies:
  14.  
  15. apt-get build-dep xen-tools
  16. so you can actually build the thing.
  17.  
  18. Next, get the build stuff if you don't have it. Theese are always good to have:
  19.  
  20. apt-get install kernel-package build-essential
  21.  
  22. Then get to ur xen source, xen-4.0.0/tools/firmware/hvmloader/acpi/ and start messing with inserting a slic the REAL way.
  23.  
  24. Start with slic.h.
  25.  
  26. slic.h is a file, consisting of a simple c data file, with the slic bin inside it. The BIN is a regular BIOS modding bin, as it just contains the SLIC.
  27.  
  28. xxd -i ~/HPQOEM.SLIC-CPC.bin | grep -v len | sed 's/unsigned char.*/unsigned char SLIC[] = {/' > slic.h
  29. This created the slic file for make.
  30.  
  31. Next, you need to set the marker etc in the acpi2 file, in the OEM fields
  32.  
  33. sed -i -e 's/#define ACPI_OEM_ID.*"Xen"/#define ACPI_OEM_ID "HPQOEM"/' acpi2_0.h
  34. sed -i -e 's/#define ACPI_OEM_TABLE_ID.*"HVM"/#define ACPI_OEM_TABLE_ID "SLIC-CPC"/' acpi2_0.h
  35. #this will work, but manual editing will work too - mind this, you might need to set the creator too, if you take a slic with creator data
  36.  
  37.  
  38. So get a bunch of bins from the pages on this forum, stick it in the slic.h header file, and make sure to edit the acpi2_0.h header as well.
  39. Next, create the function that actually creates the table;
  40.  
  41.  
  42.  
  43. /* SLIC */
  44. memcpy(&buf[offset], SLIC, sizeof(SLIC));
  45. table_ptrs[nr_tables++] = (unsigned long)&buf[offset];
  46. offset += align16(sizeof(SLIC));
  47.  
  48.  
  49. Which is in build.c and as such file is just a source file, you can edit it by hand. Patch files are nice, manual handiwork is better.
  50. The code is supposed to be inside the function "construct_secondary_tables" at the end, just before:
  51.  
  52.  
  53. table_ptrs[nr_tables] = 0;
  54. return align16(offset);
  55.  
  56.  
  57. Now, this is simple, just go to the xen source root of your distro, and do a 'make tools'. For me that failed after xc couldn't build something python related, but that doesn't matter, you only need the hvmloader.
  58. It's in dist/install/usr/lib/xen-/boot. Copy it somewhere, and load your HVM guests up with it, and you have a BIOS with a SLIC 2.1. !
  59.  
  60. []hxxp://image.bayimg.com/mabehaadd.jpg[]
  61.  
  62. I actually had some information found on a random italian forum [hxxp://forum.italianzone.eu/software-sistemi-operativi-programmazione-36/howto-adding-slic-table-xenserver-hvms-12778/?langid=1] which explained a few of the manual actions. Now, I don't speak italian, and I can't translate, but you can see from the code how it works.
  63.  
  64.  
  65. If I find the time, or if someone has a question, I can make a more elaborate how-to.
  66. apt-cache search xen-hypervisor-4.1-amd64
  67.  
  68. apt-cache search xen-tools
  69.  
  70. DISCLAIMER: guide for educational purposes, all the appropriate disclaimers are believed to be applicable the text that follows
  71.  
  72. Purpose: use OEM activation of Windows operating system that came with our hardware (server, notebook or whatever it is) through XenServer virtualized hardware.
  73.  
  74. In summary: Activation of recent operating systems oem ms works by making the matching between the installed certificate, serial, and this slice table between tables acpi bios of our system.
  75. If we decide to install a hypervisor on our hardware and then install the OS on a virtual machine oem activation will not work because the bios exposed by the virtual machine will be emulated without slic tables.
  76.  
  77. How to fix: dump the original slic table and make sure that the BIOS is loaded virtual machines.
  78.  
  79. Requirements:
  80. - A working installation of [Dear Guest / Member you can not see link reply beforeclick here to register]
  81. - The [Dear Guest / Member you can not see link reply beforeclick here to register]
  82. - The [Dear Guest / Member you can not see link reply beforeclick here to register]
  83. - The [Dear Guest / Member you can not see link reply beforeclick here to register] by centos repository
  84.  
  85. Step by step
  86.  
  87. 1. Dump the slic table (using, for example Slic Toolkit)
  88.  
  89. 2. We import the virtual machine with pre-configured development environment on the server
  90.  
  91. 3. Start them, configure the password and, if the network and install gettext (needed later to complete the compilation)
  92.  
  93. 4. Install the source package from the iso XenServer-5.6.0-source-1.iso (/ xen/xen-3.4.2-5.6.0.597.20014.src.rpm)
  94.  
  95. 5. The program in charge of creating the virtual bios hvmloader, reading / xen-3.4.2/tools/firmware/hvmloader/acpi/build.c we see that we can inject the slic table in a similar way to the TPM. To do this we must create a header file that contains the slice, include it in build.c, copy the code to create the table and rebuild everything.
  96.  
  97. 5a.
  98. Code:
  99.  
  100. xxd -i SLIC_DUMP.BIN | sed 's/unsigned char.*/unsigned char SLIC[] = {/' | grep -v _len > slic.h
  101.  
  102. This will generate the h file that suits our case, converting the binary dump of the slice in an array of unsigned char, replacing the name derived from the course by xxd in SLIC, by removing the final line on the length hanging from the writing and xxd everything inside slic.h
  103. Before we open the file in a text editor and verify that there are no anomalies
  104.  
  105. 5b. we edit build.c inserting between slic.h include:
  106. Code:
  107.  
  108. #include "slic.h"
  109.  
  110. and adding the code shown in construct_secondary_tables
  111.  
  112. Code:
  113.  
  114. static int construct_secondary_tables(uint8_t *buf, unsigned long *table_ptrs)
  115. {
  116. int offset = 0, nr_tables = 0;
  117. struct acpi_20_madt *madt;
  118. struct acpi_20_hpet *hpet;
  119. struct acpi_20_tcpa *tcpa;
  120. static const uint16_t tis_signature[] = {0x0001, 0x0001, 0x0001};
  121. uint16_t *tis_hdr;
  122. void *lasa;
  123.  
  124. /* MADT. */
  125. if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
  126. {
  127. madt = (struct acpi_20_madt *)&buf[offset];
  128. offset += construct_madt(madt);
  129. table_ptrs[nr_tables++] = (unsigned long)madt;
  130. }
  131.  
  132. /* HPET. */
  133. if ( hpet_exists(ACPI_HPET_ADDRESS) )
  134. {
  135. hpet = (struct acpi_20_hpet *)&buf[offset];
  136. offset += construct_hpet(hpet);
  137. table_ptrs[nr_tables++] = (unsigned long)hpet;
  138. }
  139.  
  140. if ( battery_port_exists() )
  141. {
  142. table_ptrs[nr_tables++] = (unsigned long)&buf[offset];
  143. memcpy(&buf[offset], AmlCode_PM, sizeof(AmlCode_PM));
  144. offset += align16(sizeof(AmlCode_PM));
  145. }
  146.  
  147. /* TPM TCPA and SSDT. */
  148. tis_hdr = (uint16_t *)0xFED40F00;
  149. if ( (tis_hdr[0] == tis_signature[0]) &&
  150. (tis_hdr[1] == tis_signature[1]) &&
  151. (tis_hdr[2] == tis_signature[2]) )
  152. {
  153. memcpy(&buf[offset], AmlCode_TPM, sizeof(AmlCode_TPM));
  154. table_ptrs[nr_tables++] = (unsigned long)&buf[offset];
  155. offset += align16(sizeof(AmlCode_TPM));
  156.  
  157. tcpa = (struct acpi_20_tcpa *)&buf[offset];
  158. memset(tcpa, 0, sizeof(*tcpa));
  159. offset += align16(sizeof(*tcpa));
  160. table_ptrs[nr_tables++] = (unsigned long)tcpa;
  161.  
  162. tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
  163. tcpa->header.length = sizeof(*tcpa);
  164. tcpa->header.revision = ACPI_2_0_TCPA_REVISION;
  165. fixed_strcpy(tcpa->header.oem_id, ACPI_OEM_ID);
  166. fixed_strcpy(tcpa->header.oem_table_id, ACPI_OEM_TABLE_ID);
  167. tcpa->header.oem_revision = ACPI_OEM_REVISION;
  168. tcpa->header.creator_id = ACPI_CREATOR_ID;
  169. tcpa->header.creator_revision = ACPI_CREATOR_REVISION;
  170. if ( (lasa = mem_alloc(ACPI_2_0_TCPA_LAML_SIZE, 0)) != NULL )
  171. {
  172. tcpa->lasa = virt_to_phys(lasa);
  173. tcpa->laml = ACPI_2_0_TCPA_LAML_SIZE;
  174. memset(lasa, 0, tcpa->laml);
  175. set_checksum(tcpa,
  176. offsetof(struct acpi_header, checksum),
  177. tcpa->header.length);
  178. }
  179. }
  180.  
  181. /* SLIC TABLE */
  182. memcpy(&buf[offset], SLIC, sizeof(SLIC));
  183. table_ptrs[nr_tables++] = (unsigned long)&buf[offset];
  184. offset += align16(sizeof(SLIC));
  185.  
  186. table_ptrs[nr_tables] = 0;
  187. return align16(offset);
  188. }
  189.  
  190. 5c. Because the activation function is necessary for the OEM ID and OEM Table ID acpi correspond to the slice, we will therefore be amended by changing the following define in acpi2_0.h and taking care not to forget any whitespace at the beginning or at the end of the string
  191.  
  192. Code:
  193.  
  194. #define ACPI_OEM_ID "Xen"
  195. #define ACPI_OEM_TABLE_ID "HVM"
  196.  
  197. 5d. Launch
  198. Code:
  199.  
  200. make tools
  201.  
  202. and we await the end of compilation
  203.  
  204. 6. At this point we can replace the original hvmloader the loader and start the installation from iso vm windows oem disk.
  205. If everything goes well the operating system should be activated as if they were real hardware.
  206. If the activation does not work we can verify the contents of the ACPI tables on the virtual machine with a utility type RW-Everything.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement