Modified Bios for KVM/Qemu/Bochs Bios?

Discussion in 'Virtualization' started by Seb, Nov 9, 2009.

  1. Seb

    Seb MDL Novice

    Nov 9, 2009
    1
    0
    0
    Hello,

    is there a chance to modify the Bochs Bios used by KVM/Qemu virtualization?

    The bios is either available as a binary or as source:

    binary:
    located at
    downloads.sourceforge.net/project/kvm/qemu-kvm/0.11.0/qemu-kvm-0.11.0.tar.gz in the file /pc-bios/bios.bin, the source is also available

    source
    git clone git://git.kernel.org/pub/scm/virt/bochs/bochs.git - (revision 04387139e3b5ac97b5633cd40b3d87cdf45efd6c patched with some patches from the .tar.gz above)
    in the sub-directory "bios" - there you also can find the ACPI tables, probably rombios32.c?:

    /* RSDT */
    memset(rsdt, 0, sizeof(*rsdt));
    rsdt->table_offset_entry[0] = cpu_to_le32(fadt_addr);
    rsdt->table_offset_entry[1] = cpu_to_le32(madt_addr);
    rsdt->table_offset_entry[2] = cpu_to_le32(ssdt_addr);
    rsdt->table_offset_entry[3] = cpu_to_le32(hpet_addr);
    acpi_build_table_header((struct acpi_table_header *)rsdt,
    "RSDT", sizeof(*rsdt), 1);

    Thanks,
    Seb
     
  2. kocoman

    kocoman MDL Senior Member

    May 16, 2007
    328
    4
    10
    For SLP 1.0 ie: for parallels (osx), I can patch one of the file (I forgot which one but it was ~12mb) for the DMI string

    For SLIC 2.0/2.1 not sure about that.
     
  3. sanmaiwashi

    sanmaiwashi MDL Novice

    Nov 10, 2009
    1
    0
    0
    ttp://pages.wazoku.net/bochs_bios_added_HP_SLIC_TABLE.zip
    This archive contains pached binary BIOS and diff.
     
  4. truthinjection

    truthinjection MDL Member

    Aug 27, 2009
    247
    46
    10
    #4 truthinjection, Nov 11, 2009
    Last edited by a moderator: May 23, 2017
    Also, QEMU, at least, will let you load a PCI Option-ROM that can add SLIC tables.

    For example, this thread has a few option roms that you can load to accomplish that:

    http://forums.mydigitallife.net/threads/8727

    The command line is:

    Code:
     qemu -boot n -option-rom <option_rom_file_name>
     
  5. maierg

    maierg MDL Novice

    Dec 1, 2008
    1
    0
    0
    the -option-rom doesn't work for me any new bios files for kvm?
     
  6. arseny

    arseny MDL Novice

    Jun 21, 2010
    2
    0
    0
    Modified BIOS exists and works

    You can try clone this repository
    git://gitorious.org/seabios/seabios.git
     
  7. saugx

    saugx MDL Novice

    Mar 14, 2010
    1
    0
    0
    is there a guide/howto to make this work under lucid?
     
  8. TheFrickler

    TheFrickler MDL Novice

    Aug 2, 2009
    10
    3
    0
    #8 TheFrickler, Dec 9, 2010
    Last edited by a moderator: Apr 20, 2017
    After some research, I have found that you could use qemu's acpitable parameter, like this:

    -acpitable sig=SLIC,oem_id=XXXXXX,oem_table_id=YYYYYYYYY,oem_rev=00000100,asl_compiler_id="INTL",asl_compiler_rev=20051117,data=/usr/share/qemu-kvm/SLIC.BIN

    However, there are two obstacles:

    1. qemu before 0.13 would not adapt OEM_ID and OEM_TABLE_ID for other ACPI tables. Thus, SLP 2.x would fail.
    2. Managing qemu or qemu-kvm with libvirt does not give you the chance to provide the acpitable parameter, so you would have to use a wrapper for qemu-kvm.

    Thus, the best solution is to create a patched bios.bin with SLIC 2.1 (example is for openSUSE 11.3 with kvm 0.12.5):

    1. Get the sources of kvm for your distribution: zypper source-install kvm
    2. Build kvm as provided by your distribution: rpmbuild -bc /usr/src/packages/SPECS/kvm.spec
    3. Go to the source directory for the included Seabios: cd /usr/src/packages/BUILD/qemu-kvm-0.12.5/roms/seabios/src
    4. Create a file slic.h from a binary SLIC file like this: xxd -i /tmp/SLIC.bin | grep -v len | sed 's/unsigned char.*/unsigned char SLIC[] = {/' > slic.h
    5. Patch the source files like this (replacing XXXXXX and YYYYYYYY by your specific OEM_ID and OEM_TABLE_ID, respectively):

    Code:
    --- acpi.c.orig 2010-12-09 15:25:51.022725650 +0100
    +++ acpi.c      2010-12-09 15:45:00.590973992 +0100
    @@ -13,6 +13,8 @@
     #include "pci_regs.h" // PCI_INTERRUPT_LINE
     #include "paravirt.h"
    
    +#include "slic.h" // SLIC
    +
     /****************************************************/
     /* ACPI tables init */
    
    @@ -287,9 +289,9 @@
         h->length = cpu_to_le32(len);
         h->revision = rev;
         memcpy(h->oem_id, CONFIG_APPNAME6, 6);
    -    memcpy(h->oem_table_id, CONFIG_APPNAME4, 4);
    -    memcpy(h->asl_compiler_id, CONFIG_APPNAME4, 4);
    -    memcpy(h->oem_table_id + 4, (void*)&sig, 4);
    +    memcpy(h->oem_table_id, CONFIG_APPNAME8, 8);
    +    memcpy(h->asl_compiler_id, CONFIG_APPNAME8, 4);
    +//    memcpy(h->oem_table_id + 4, (void*)&sig, 4);
         h->oem_revision = cpu_to_le32(1);
         h->asl_compiler_revision = cpu_to_le32(1);
         h->checksum -= checksum(h, len);
    @@ -638,6 +640,8 @@
         ACPI_INIT_TABLE(build_hpet());
         ACPI_INIT_TABLE(build_srat());
    
    +    ACPI_INIT_TABLE(&SLIC);
    +
         u16 i, external_tables = qemu_cfg_acpi_additional_tables();
    
         for(i = 0; i < external_tables; i++) {
    
    
    --- acpi-dsdt.dsl.orig  2010-12-09 15:04:58.930972494 +0100
    +++ acpi-dsdt.dsl       2010-12-09 15:32:38.238723300 +0100
    @@ -20,8 +20,8 @@
         "acpi-dsdt.aml",    // Output Filename
         "DSDT",             // Signature
         0x01,               // DSDT Compliance Revision
    -    "BXPC",             // OEMID
    -    "BXDSDT",           // TABLE ID
    +    "XXXXXX",           // OEMID
    +    "YYYYYYYYY",         // TABLE ID
         0x1                 // OEM Revision
         )
     {
    
     
    --- config.h.orig       2010-12-09 15:25:22.658721692 +0100
    +++ config.h    2010-12-09 15:27:07.194722789 +0100
    @@ -7,10 +7,10 @@
     //#define CONFIG_CPUNAME8 "QEMUCPU "
     //#define CONFIG_APPNAME6 "QEMU  "
     //#define CONFIG_APPNAME4 "QEMU"
    -#define CONFIG_APPNAME  "Bochs"
    +#define CONFIG_APPNAME  "XXXXXX"
     #define CONFIG_CPUNAME8 "BOCHSCPU"
    -#define CONFIG_APPNAME6 "BOCHS "
    -#define CONFIG_APPNAME4 "BXPC"
    +#define CONFIG_APPNAME6 "XXXXXX"
    +#define CONFIG_APPNAME8 "YYYYYYYY"
    
     // Configure as a coreboot payload.
     #define CONFIG_COREBOOT 0
    
    
    6. Build the Seabios again (can take several times before it finishes O.K.): cd ..; make; make
    7. Copy the resulting bios.bin into your kvm installation: cp out/bios.bin /usr/share/qemu-kvm/
    8. Have fun!
     
  9. sebus

    sebus MDL Guru

    Jul 23, 2008
    5,933
    1,801
    180
    Anybody has an idea if this can be done?

    sebus
     
  10. nandinux

    nandinux MDL Novice

    Mar 24, 2011
    1
    0
    0
    I have read the content of this Thread beacause I have to install a windows server 2003 standard r2 oem for HP in a virtual kvm / ubuntu server system on a Dell server.
    At the end i have not realized if is possible to do it so, I ask to TheFrickler:
    if you have a lot of time please tell me something more about this question, thanks in advance, nandinux.
    PS: I have tryed to get a non oem cd from Hp and Microsoft but they say me is not possible and thet I must buy win2003 another time.
     
  11. mikeyspikey2011

    mikeyspikey2011 MDL Novice

    Jun 24, 2011
    2
    2
    0
    Guys thank you all for your helpful instructions using these I successfully created my own ASUS SLIC 2.1 & SLP 1.0 Modded SeaBios for QEMU.

    It beats VMWare for speed hands down.

    Thank you
     
  12. ^Majestic^

    ^Majestic^ MDL Novice

    May 26, 2011
    1
    0
    0
    Hi mikeyspikey2011,

    May I ask, how have you done this? I have tried the instructions which are within this thread and some other by googling but I can't seem to get it to compile nor run. I am using Debian Squeeze (6) with stock KVM out of apt. I can't use the Windows loader solution due to KVM refuses to boot after you apply it. I have also tried the bochs_bios_added_HP_SLIC_TABLE.zip and after replacing the bios on the system, none of the KVM guests will boot not even the linux ones. I assume its not compatible with lastest KVM i.e. missing some key parts which is why I thought building a new one should fix this problem alais I havent managed to yet.

    So would you mind either telling me how you made this to work/compile? or can you give me the replacment bios's to just copy/replace on my host?

    Thanks in advance.

    *UPDATE*

    tracked down what the problem was... compiled sucessfuly now.. just in the middle of testing it all out. If/when it all works, I will provide some howto/instructions so others don't suffer the same pain as I have. hehe.
     
  13. testen

    testen MDL Novice

    Aug 26, 2009
    4
    0
    0
    Thanks for information and patch code.
    I did working seabios 5.1 with dell slic and now server 2008 r2 is activated in KVM.

    I found page ttp://code.coreboot.org/p/seabios/downloads/ where is seabios sources. I also did tried to same with latest 6.2 but could not get in build.
     
  14. jordan.turner1974

    jordan.turner1974 MDL Novice

    Jul 30, 2009
    45
    1
    0
    testen, I am testing Proxmox 1.8 (Debian based) which uses KVM. I see that the guests machines uses SeaBios, but have no clue on how to patch it for testing. I am not an advance Linux person, but can follow instructions. Right now, I just need to understand which file needs to be replaced and where and with what. Any assistance is greatly appreciated.

    FYI, I can't believe the performance on Proxmox is much better than VMWare Hypervisor ESXi 4.1 and Hyper-V R2 SP1!
     
  15. dalco

    dalco MDL Novice

    Apr 26, 2010
    18
    16
    0
    #17 dalco, Aug 20, 2011
    Last edited by a moderator: Apr 20, 2017
    Thanks for the hint!

    I am patched a seabios from the git (v 6.3pre-alpha-bla-bla-bla) and my virtual Win2k8 R2 server was successfully activated.

    P.S. The third hunk from the original patch erroneously patch the wrong place of current seabios from the git. I am not guru in patch format, so I patch original acpi.c by hands and create diff (its working for me).

    Edited patch

    Code:
    --- acpi.c.orig 2011-08-15 22:37:49.000000000 +0700
    +++ acpi.c      2011-08-16 10:26:13.837668295 +0700
    @@ -197,6 +197,11 @@
     
     #include "acpi-dsdt.hex"
     
    +#define CONFIG_OEM_SLIC
    +#ifdef CONFIG_OEM_SLIC
    +#include "acpi-slic.hex"
    +#endif
    +
     static void
     build_header(struct acpi_table_header *h, u32 sig, int len, u8 rev)
     {
    @@ -209,6 +214,10 @@
         memcpy(h->oem_table_id + 4, (void*)&sig, 4);
         h->oem_revision = cpu_to_le32(1);
         h->asl_compiler_revision = cpu_to_le32(1);
    +#ifdef CONFIG_OEM_SLIC
    + if (sig == RSDT_SIGNATURE) // only RSDT is checked by win7 & vista
    + memcpy(h->oem_id, ((struct acpi_table_header*)SLIC)->oem_id, 14);
    +#endif
         h->checksum -= checksum(h, len);
     }
     
    @@ -639,6 +648,17 @@
         ACPI_INIT_TABLE(build_hpet());
         ACPI_INIT_TABLE(build_srat());
     
    +#ifdef CONFIG_OEM_SLIC
    +    {  void *buf = malloc_high(sizeof(SLIC));
    +       if (!buf)
    +           warn_noalloc();
    +       else {
    +           memcpy(buf, SLIC, sizeof(SLIC));
    +           ACPI_INIT_TABLE(buf);                                                                                                                                                                    
    +           }                                                                                                                                                                                        
    +       }                                                                                                                                                                                            
    +#endif                                                                                                                                                                                              
    +                                                                                                                                                                                                    
         u16 i, external_tables = qemu_cfg_acpi_additional_tables();                                                                                                                                     
                                                                                                                                                                                                         
         for(i = 0; i < external_tables; i++) {
    
     
  16. mikeyspikey2011

    mikeyspikey2011 MDL Novice

    Jun 24, 2011
    2
    2
    0
    Hi Majestic,

    Sorry I didn't reply fast enough, I'm glad you figured it out though.

    Also just as a small thank you and to save everyone else the trouble, here it is:

    Asus SLIC 2.1 & SLP 1.0 QEMU SEABIOS

    http: //w w w.mediafire.com/?f86d6u6x5zd0nf0
     
  17. MrTAZ

    MrTAZ MDL Novice

    Dec 22, 2011
    2
    2
    0
    #19 MrTAZ, Dec 24, 2011
    Last edited by a moderator: Apr 20, 2017
    ACPI SLIC HACK Patch for Seabios.

    Hi guys,


    I patched acpi.c for that you don't need any mods to kvm/qemu soft.
    It's a little hack of acpitable's parameters.
    When sig 5L1C is sent, BIOS inserts directly "data" in acpi table but copy oem_id and oem_table_id in RSDT table too.


    Like this : kvm -bios `patched bios` -acpitable sig=5L1C,data=`SLIC dump`


    look my diff n http : / /mrtaz . net / mrtaz / bios . bin

    Code:
    --- acpi.c.orig    2011-12-24 18:03:11.346256959 +0100
    +++ acpi.c    2011-12-24 17:58:07.368750605 +0100
    @@ -628,6 +628,11 @@
     
         u16 i, external_tables = qemu_cfg_acpi_additional_tables();
     
    +    #define SLIC_SIGNATURE 0x43494C53 // SLIC
    +    #define HACK_SLIC_SIGNATURE 0x43314C35 // HACK SLIC
    +    struct acpi_table_header *slic;
    +    slic = 0;
    +
         for(i = 0; i < external_tables; i++) {
             u16 len = qemu_cfg_next_acpi_table_len();
             void *addr = malloc_high(len);
    @@ -635,7 +640,13 @@
                 warn_noalloc();
                 continue;
             }
    -        ACPI_INIT_TABLE(qemu_cfg_next_acpi_table_load(addr, len));
    +        struct acpi_table_header *acpi_ext_table;
    +        acpi_ext_table = qemu_cfg_next_acpi_table_load(addr, len);
    +        if (acpi_ext_table->signature == HACK_SLIC_SIGNATURE) {
    +                acpi_ext_table = acpi_ext_table+1;
    +                slic = acpi_ext_table;
    +        }
    +        ACPI_INIT_TABLE(acpi_ext_table);
             if (tbl_idx == MAX_ACPI_TABLES) {
                 warn_noalloc();
                 break;
    @@ -653,7 +664,19 @@
         memset(rsdt, 0, rsdt_len);
         memcpy(rsdt->table_offset_entry, tables, sizeof(u32) * tbl_idx);
     
    -    build_header((void*)rsdt, RSDT_SIGNATURE, rsdt_len, 1);
    +    if (slic->signature == SLIC_SIGNATURE){
    +        rsdt->signature = RSDT_SIGNATURE;
    +        rsdt->length = cpu_to_le32(rsdt_len);
    +        rsdt->revision = 1;
    +        memcpy(rsdt->oem_id, slic->oem_id, 6);
    +        memcpy(rsdt->oem_table_id, slic->oem_table_id, 8);
    +        memcpy(rsdt->asl_compiler_id, CONFIG_APPNAME4, 4);
    +        rsdt->oem_revision = cpu_to_le32(1);
    +        rsdt->asl_compiler_revision = cpu_to_le32(1);
    +        rsdt->checksum -= checksum(rsdt, rsdt_len);
    +    } else {
    +        build_header((void*)rsdt, RSDT_SIGNATURE, rsdt_len, 1);
    +    }
     
         // Build rsdp pointer table
         memset(rsdp, 0, sizeof(*rsdp));
    
    Thx for comments.
     
  18. kobuki

    kobuki MDL Novice

    Oct 24, 2009
    4
    0
    0
    I tried both methods, from mikeyspikey2011 and from MrTAZ as well. I'm successfully able to install a copy of Windows 7 Ent SP1, but right after the first reboot I get the BSOD as seen on the image. I'm using KVM on a Proxmox test box, the command line contains this extra parameter, where the bios is the one mikeyspikey2011 provided: -bios /path/slic-bios.bin

    View attachment 13122

    Do you have any hints? Do I need some other parameter?