Skip to contentSkip to conversation

[6392] Add BIOS fixes from KVM tree

Qemu-devel Anthony Liguori 4 participants 6 messages Jan 21, 2009 – Jan 22, 2009

lore
Share & tools
lore
#0 lore raw

Revision: 6392

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6392
Author:   aliguori
Date:     2009-01-21 21:46:20 +0000 (Wed, 21 Jan 2009)

Log Message:
-----------
Add BIOS fixes from KVM tree

See each patch for individual Signed-off-by's/commit logs

Modified Paths:
--------------
trunk/pc-bios/bios-pq/HEAD
trunk/pc-bios/bios-pq/series
trunk/pc-bios/bios.bin

Added Paths:
-----------

    trunk/pc-bios/bios-pq/0002_kvm-bios-update-smbios-table-to-report-memory-above-4g.patch
    trunk/pc-bios/bios-pq/0003_kvm-bios-generate-mptable-unconditionally.patch
    trunk/pc-bios/bios-pq/0004_kvm-bios-add-mtrr-support.patch
    trunk/pc-bios/bios-pq/0005_kvm-bios-smp-mtrr-support.patch
    trunk/pc-bios/bios-pq/0006_kvm-bios-extend-mtrrs-to-above-4g.patch
    trunk/pc-bios/bios-pq/0007_kvm-bios-cleanup-consolidate-above-4g-memory-parsing.patch
    trunk/pc-bios/bios-pq/0008_kvm-bios-switch-mtrrs-to-cover-only-the-pci-range-and--default-to-wb.patch
    trunk/pc-bios/bios-pq/0009_kvm-bios-resolve-memory-device-roll-over-reporting--issues-with-32g-guests.patch
    trunk/pc-bios/bios-pq/0010_kvm-bios-fix-smbios-memory-device-length-boundary--condition.patch

Added: trunk/pc-bios/bios-pq/0002_kvm-bios-update-smbios-table-to-report-memory-above-4g.patch
===================================================================

pc-bios/bios-pq/0002_kvm-bios-update-smbios-table-to-report-memory-above-4g.patch +33 -0
@@ -0,0 +1,33 @@
+update SMBIOS table to report memory above 4G (Alex Williamson)
+
+Signed-off-by: Alex Williamson <[email protected]>
+Signed-off-by: Avi Kivity <[email protected]>
+Signed-off-by: Anthony Liguori <[email protected]>
+
+Index: bochs/bios/rombios32.c
+===================================================================
+--- bochs.orig/bios/rombios32.c
++++ bochs/bios/rombios32.c
+@@ -2081,7 +2081,8 @@ void smbios_init(void)
+ {
+     unsigned cpu_num, nr_structs = 0, max_struct_size = 0;
+     char *start, *p, *q;
+-    int memsize = ram_size / (1024 * 1024);
++    int memsize = (ram_end == ram_size) ? ram_size / (1024 * 1024) :
++                  (ram_end - (1ull << 32) + ram_size) / (1024 * 1024);
+
+ #ifdef BX_USE_EBDA_TABLES
+     ebda_cur_addr = align(ebda_cur_addr, 16);
+@@ -2108,8 +2109,8 @@ void smbios_init(void)
+         add_struct(smbios_type_4_init(p, cpu_num));
+     add_struct(smbios_type_16_init(p, memsize));
+     add_struct(smbios_type_17_init(p, memsize));
+-    add_struct(smbios_type_19_init(p, memsize));
+-    add_struct(smbios_type_20_init(p, memsize));
++    add_struct(smbios_type_19_init(p, ram_end / (1024 * 1024)));
++    add_struct(smbios_type_20_init(p, ram_end / (1024 * 1024)));
+     add_struct(smbios_type_32_init(p));
+     add_struct(smbios_type_127_init(p));
+
+
+

Added: trunk/pc-bios/bios-pq/0003_kvm-bios-generate-mptable-unconditionally.patch
===================================================================

pc-bios/bios-pq/0003_kvm-bios-generate-mptable-unconditionally.patch +25 -0
@@ -0,0 +1,25 @@
+generate mptable unconditionally (Avi Kivity)
+
+VMware ESX requires an mptable even for uniprocessor guests.
+
+Signed-off-by: Avi Kivity <[email protected]>
+Signed-off-by: Anthony Liguori <[email protected]>
+
+Index: bochs/bios/rombios32.c
+===================================================================
+--- bochs.orig/bios/rombios32.c
++++ bochs/bios/rombios32.c
+@@ -970,11 +970,6 @@ static void mptable_init(void)
+     int ioapic_id, i, len;
+     int mp_config_table_size;
+
+-#ifdef BX_QEMU
+-    if (smp_cpus <= 1)
+-        return;
+-#endif
+-
+ #ifdef BX_USE_EBDA_TABLES
+     mp_config_table = (uint8_t *)(ram_size - ACPI_DATA_SIZE - MPTABLE_MAX_SIZE);
+ #else
+
+

Added: trunk/pc-bios/bios-pq/0004_kvm-bios-add-mtrr-support.patch
===================================================================

pc-bios/bios-pq/0004_kvm-bios-add-mtrr-support.patch +120 -0

120 lines not on this page · raw message

Added: trunk/pc-bios/bios-pq/0005_kvm-bios-smp-mtrr-support.patch
===================================================================

pc-bios/bios-pq/0005_kvm-bios-smp-mtrr-support.patch +126 -0

126 lines not on this page · raw message

Added: trunk/pc-bios/bios-pq/0006_kvm-bios-extend-mtrrs-to-above-4g.patch
===================================================================

pc-bios/bios-pq/0006_kvm-bios-extend-mtrrs-to-above-4g.patch +62 -0

62 lines not on this page · raw message

Added: trunk/pc-bios/bios-pq/0007_kvm-bios-cleanup-consolidate-above-4g-memory-parsing.patch
===================================================================

pc-bios/bios-pq/0007_kvm-bios-cleanup-consolidate-above-4g-memory-parsing.patch +58 -0

58 lines not on this page · raw message

Added: trunk/pc-bios/bios-pq/0008_kvm-bios-switch-mtrrs-to-cover-only-the-pci-range-and--default-to-wb.patch
===================================================================

pc-bios/bios-pq/0008_kvm-bios-switch-mtrrs-to-cover-only-the-pci-range-and--default-to-wb.patch +54 -0

54 lines not on this page · raw message

Added: trunk/pc-bios/bios-pq/0009_kvm-bios-resolve-memory-device-roll-over-reporting--issues-with-32g-guests.patch
===================================================================

pc-bios/bios-pq/0009_kvm-bios-resolve-memory-device-roll-over-reporting--issues-with-32g-guests.patch +184 -0

184 lines not on this page · raw message

Added: trunk/pc-bios/bios-pq/0010_kvm-bios-fix-smbios-memory-device-length-boundary--condition.patch
===================================================================

pc-bios/bios-pq/0010_kvm-bios-fix-smbios-memory-device-length-boundary--condition.patch +23 -0
@@ -0,0 +1,23 @@
+fix smbios memory device length boundary  condition (Bill Rieske)
+
+dev_memsize ends up 0 when it shouldn't be on 16G boundary conditions.
+    
+Signed-off-by: Bill Rieske <[email protected]>
+Signed-off-by: Avi Kivity <[email protected]>
+Signed-off-by: Anthony Liguori <[email protected]>
+
+Index: bochs/bios/rombios32.c
+===================================================================
+--- bochs.orig/bios/rombios32.c
++++ bochs/bios/rombios32.c
+@@ -2218,7 +2218,7 @@ void smbios_init(void)
+     for ( i = 0; i < nr_mem_devs; i++ )
+     {
+         uint32_t dev_memsize = ((i == (nr_mem_devs - 1))
+-                                ? (memsize & 0x3fff) : 0x4000);
++                                ? (((memsize-1) & 0x3fff)+1) : 0x4000);
+         add_struct(smbios_type_17_init(p, dev_memsize, i));
+         add_struct(smbios_type_19_init(p, dev_memsize, i));
+         add_struct(smbios_type_20_init(p, dev_memsize, i));
+
+

Modified: trunk/pc-bios/bios-pq/HEAD
===================================================================

pc-bios/bios-pq/HEAD +1 -1
@@ -1 +1 @@
-7342176bb0fa9d6cc63b37f6ac239e3f70b74219
+36989b0d2e785ac9e5d6e8a226dbdeb82e876bfd

Modified: trunk/pc-bios/bios-pq/series
===================================================================

pc-bios/bios-pq/series +9 -0
@@ -1 +1,10 @@
 0001_bx-qemu.patch
+0002_kvm-bios-update-smbios-table-to-report-memory-above-4g.patch
+0003_kvm-bios-generate-mptable-unconditionally.patch
+0004_kvm-bios-add-mtrr-support.patch
+0005_kvm-bios-smp-mtrr-support.patch
+0006_kvm-bios-extend-mtrrs-to-above-4g.patch
+0007_kvm-bios-cleanup-consolidate-above-4g-memory-parsing.patch
+0008_kvm-bios-switch-mtrrs-to-cover-only-the-pci-range-and--default-to-wb.patch
+0009_kvm-bios-resolve-memory-device-roll-over-reporting--issues-with-32g-guests.patch
+0010_kvm-bios-fix-smbios-memory-device-length-boundary--condition.patch

Modified: trunk/pc-bios/bios.bin
===================================================================
(Binary files differ)

#1 lore raw

Hi,

I'm sorry to say that, but my tests showed that 0004_kvm-bios-add-mtrr-support.patch is buggy. It reads MSR_MTRRcap unconditionally which is not allowed if the CPUID features do not have CPUID_MTRR set. Real hardware will #GP in that case.
This was found by my MSR access tracing patch.

Please add a check for the CPUID_MTRR feature bit before reading MSR_MTRRcap. Thanks.

Regards,
Carl-Daniel

Quoted 24 lines · Anthony Liguori

Revision: 6392

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6392
Author:   aliguori
Date:     2009-01-21 21:46:20 +0000 (Wed, 21 Jan 2009)

Log Message:
-----------
Add BIOS fixes from KVM tree

See each patch for individual Signed-off-by's/commit logs

[...]
Added Paths:
-----------

    trunk/pc-bios/bios-pq/0002_kvm-bios-update-smbios-table-to-report-memory-above-4g.patch
    trunk/pc-bios/bios-pq/0003_kvm-bios-generate-mptable-unconditionally.patch
    trunk/pc-bios/bios-pq/0004_kvm-bios-add-mtrr-support.patch
    trunk/pc-bios/bios-pq/0005_kvm-bios-smp-mtrr-support.patch
    trunk/pc-bios/bios-pq/0006_kvm-bios-extend-mtrrs-to-above-4g.patch
    trunk/pc-bios/bios-pq/0007_kvm-bios-cleanup-consolidate-above-4g-memory-parsing.patch
    trunk/pc-bios/bios-pq/0008_kvm-bios-switch-mtrrs-to-cover-only-the-pci-range-and--default-to-wb.patch
    trunk/pc-bios/bios-pq/0009_kvm-bios-resolve-memory-device-roll-over-reporting--issues-with-32g-guests.patch
    trunk/pc-bios/bios-pq/0010_kvm-bios-fix-smbios-memory-device-length-boundary--condition.patch
Signature · 1 line
http://www.hailfinger.org/
#2 lore raw
Quoted 10 lines · Carl-Daniel Hailfinger

Hi,

I'm sorry to say that, but my tests showed that 0004_kvm-bios-add-mtrr-support.patch is buggy. It reads MSR_MTRRcap unconditionally which is not allowed if the CPUID features do not have CPUID_MTRR set. Real hardware will #GP in that case.
This was found by my MSR access tracing patch.

Please add a check for the CPUID_MTRR feature bit before reading MSR_MTRRcap. Thanks.

I am in the process of adding this to Bochs. I added checks for CPUID_MTRR and CPUID_MSR and those could go in on next merge.

- Sebastian

#3 lore raw
In reply to Carl-Daniel Hailfinger
Quoted 10 lines · Carl-Daniel Hailfinger

Hi,

I'm sorry to say that, but my tests showed that 0004_kvm-bios-add-mtrr-support.patch is buggy. It reads MSR_MTRRcap unconditionally which is not allowed if the CPUID features do not have CPUID_MTRR set. Real hardware will #GP in that case.
This was found by my MSR access tracing patch.

Please add a check for the CPUID_MTRR feature bit before reading MSR_MTRRcap. Thanks.

Attached, can you confirm it works for you, please?

bios/rombios32.c +6 -2
index 9d2eaaa..3944d25 100755
@@ -48,6 +48,7 @@ typedef unsigned long long uint64_t;
 #define wbinvd() asm volatile("wbinvd")
 
 #define CPUID_APIC (1 << 9)
+#define CPUID_MTRR (1 << 12)
 
 #define APIC_BASE    ((uint8_t *)0xfee00000)
 #define APIC_ICR_LOW 0x300
@@ -540,6 +541,9 @@ void setup_mtrr(void)
         uint64_t val;
     } u;
 
+    if (!(cpuid_features & CPUID_MTRR))
+       return;
+
     mtrr_cap = rdmsr(MSR_MTRRcap);
     vcnt = mtrr_cap & 0xff;
     fix = mtrr_cap & 0x100;
@@ -2201,10 +2205,10 @@ void rombios32_init(uint32_t *s3_resume_vector, uint8_t *shutdown_flag)
 
     init_smp_msrs();
 
-    ram_probe();
-
     cpu_probe();
 
+    ram_probe();
+
     smp_probe();
 
     find_bios_table_area();
#4 lore raw
Quoted 10 lines · Marcelo Tosatti
Quoted 8 lines · Carl-Daniel Hailfinger

Hi,

I'm sorry to say that, but my tests showed that 0004_kvm-bios-add-mtrr-support.patch is buggy. It reads MSR_MTRRcap unconditionally which is not allowed if the CPUID features do not have CPUID_MTRR set. Real hardware will #GP in that case.
This was found by my MSR access tracing patch.

Quoted 6 lines
Quoted 3 lines

Please add a check for the CPUID_MTRR feature bit before reading MSR_MTRRcap. Thanks.

Attached, can you confirm it works for you, please?

Please work with Sebastian on this. I'll just pull this fix in from upstream Bochs once it's all integrated.

Regards,

Anthony Liguori

#5 lore raw
Quoted 11 lines · Anthony Liguori
Quoted 10 lines · Marcelo Tosatti
Quoted 8 lines · Carl-Daniel Hailfinger

Hi,

I'm sorry to say that, but my tests showed that 0004_kvm-bios-add-mtrr-support.patch is buggy. It reads MSR_MTRRcap unconditionally which is not allowed if the CPUID features do not have CPUID_MTRR set. Real hardware will #GP in that case.
This was found by my MSR access tracing patch.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Please add a check for the CPUID_MTRR feature bit before reading MSR_MTRRcap. Thanks.

Attached, can you confirm it works for you, please?

Please work with Sebastian on this. I'll just pull this fix in from upstream Bochs once it's all integrated.

I sent a combined patch to the bochs mailing list. It is also available at [1].

[1] http://article.gmane.org/gmane.comp.emulators.bochs.devel/8256

- Sebastian