Commit 9a717b55df29b2b0dd0553ccfa656671bad043d1
1 parent
9043b62d
Add BIOS fixes from KVM tree
See each patch for individual Signed-off-by's/commit logs git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6392 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
12 changed files
with
695 additions
and
1 deletions
pc-bios/bios-pq/0002_kvm-bios-update-smbios-table-to-report-memory-above-4g.patch
0 → 100644
1 | +update SMBIOS table to report memory above 4G (Alex Williamson) | |
2 | + | |
3 | +Signed-off-by: Alex Williamson <alex.williamson@hp.com> | |
4 | +Signed-off-by: Avi Kivity <avi@redhat.com> | |
5 | +Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> | |
6 | + | |
7 | +Index: bochs/bios/rombios32.c | |
8 | +=================================================================== | |
9 | +--- bochs.orig/bios/rombios32.c | |
10 | ++++ bochs/bios/rombios32.c | |
11 | +@@ -2081,7 +2081,8 @@ void smbios_init(void) | |
12 | + { | |
13 | + unsigned cpu_num, nr_structs = 0, max_struct_size = 0; | |
14 | + char *start, *p, *q; | |
15 | +- int memsize = ram_size / (1024 * 1024); | |
16 | ++ int memsize = (ram_end == ram_size) ? ram_size / (1024 * 1024) : | |
17 | ++ (ram_end - (1ull << 32) + ram_size) / (1024 * 1024); | |
18 | + | |
19 | + #ifdef BX_USE_EBDA_TABLES | |
20 | + ebda_cur_addr = align(ebda_cur_addr, 16); | |
21 | +@@ -2108,8 +2109,8 @@ void smbios_init(void) | |
22 | + add_struct(smbios_type_4_init(p, cpu_num)); | |
23 | + add_struct(smbios_type_16_init(p, memsize)); | |
24 | + add_struct(smbios_type_17_init(p, memsize)); | |
25 | +- add_struct(smbios_type_19_init(p, memsize)); | |
26 | +- add_struct(smbios_type_20_init(p, memsize)); | |
27 | ++ add_struct(smbios_type_19_init(p, ram_end / (1024 * 1024))); | |
28 | ++ add_struct(smbios_type_20_init(p, ram_end / (1024 * 1024))); | |
29 | + add_struct(smbios_type_32_init(p)); | |
30 | + add_struct(smbios_type_127_init(p)); | |
31 | + | |
32 | + | |
33 | + | ... | ... |
pc-bios/bios-pq/0003_kvm-bios-generate-mptable-unconditionally.patch
0 → 100644
1 | +generate mptable unconditionally (Avi Kivity) | |
2 | + | |
3 | +VMware ESX requires an mptable even for uniprocessor guests. | |
4 | + | |
5 | +Signed-off-by: Avi Kivity <avi@qumranet.com> | |
6 | +Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> | |
7 | + | |
8 | +Index: bochs/bios/rombios32.c | |
9 | +=================================================================== | |
10 | +--- bochs.orig/bios/rombios32.c | |
11 | ++++ bochs/bios/rombios32.c | |
12 | +@@ -970,11 +970,6 @@ static void mptable_init(void) | |
13 | + int ioapic_id, i, len; | |
14 | + int mp_config_table_size; | |
15 | + | |
16 | +-#ifdef BX_QEMU | |
17 | +- if (smp_cpus <= 1) | |
18 | +- return; | |
19 | +-#endif | |
20 | +- | |
21 | + #ifdef BX_USE_EBDA_TABLES | |
22 | + mp_config_table = (uint8_t *)(ram_size - ACPI_DATA_SIZE - MPTABLE_MAX_SIZE); | |
23 | + #else | |
24 | + | |
25 | + | ... | ... |
pc-bios/bios-pq/0004_kvm-bios-add-mtrr-support.patch
0 → 100644
1 | +add mtrr support (Avi Kivity) | |
2 | + | |
3 | +program mtrrs for cpu 0. Doesn't support >=4G at the moment. | |
4 | + | |
5 | +Signed-off-by: Avi Kivity <avi@qumranet.com> | |
6 | +Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> | |
7 | + | |
8 | +Index: bochs/bios/rombios32.c | |
9 | +=================================================================== | |
10 | +--- bochs.orig/bios/rombios32.c | |
11 | ++++ bochs/bios/rombios32.c | |
12 | +@@ -64,6 +64,23 @@ typedef unsigned long long uint64_t; | |
13 | + | |
14 | + #define BIOS_TMP_STORAGE 0x00030000 /* 64 KB used to copy the BIOS to shadow RAM */ | |
15 | + | |
16 | ++#define MSR_MTRRcap 0x000000fe | |
17 | ++#define MSR_MTRRfix64K_00000 0x00000250 | |
18 | ++#define MSR_MTRRfix16K_80000 0x00000258 | |
19 | ++#define MSR_MTRRfix16K_A0000 0x00000259 | |
20 | ++#define MSR_MTRRfix4K_C0000 0x00000268 | |
21 | ++#define MSR_MTRRfix4K_C8000 0x00000269 | |
22 | ++#define MSR_MTRRfix4K_D0000 0x0000026a | |
23 | ++#define MSR_MTRRfix4K_D8000 0x0000026b | |
24 | ++#define MSR_MTRRfix4K_E0000 0x0000026c | |
25 | ++#define MSR_MTRRfix4K_E8000 0x0000026d | |
26 | ++#define MSR_MTRRfix4K_F0000 0x0000026e | |
27 | ++#define MSR_MTRRfix4K_F8000 0x0000026f | |
28 | ++#define MSR_MTRRdefType 0x000002ff | |
29 | ++ | |
30 | ++#define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg)) | |
31 | ++#define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1) | |
32 | ++ | |
33 | + static inline void outl(int addr, int val) | |
34 | + { | |
35 | + asm volatile ("outl %1, %w0" : : "d" (addr), "a" (val)); | |
36 | +@@ -135,6 +152,19 @@ static inline void putc(int c) | |
37 | + outb(INFO_PORT, c); | |
38 | + } | |
39 | + | |
40 | ++static uint64_t rdmsr(unsigned index) | |
41 | ++{ | |
42 | ++ unsigned long long ret; | |
43 | ++ | |
44 | ++ asm ("rdmsr" : "=A"(ret) : "c"(index)); | |
45 | ++ return ret; | |
46 | ++} | |
47 | ++ | |
48 | ++static void wrmsr(unsigned index, uint64_t val) | |
49 | ++{ | |
50 | ++ asm volatile ("wrmsr" : : "c"(index), "A"(val)); | |
51 | ++} | |
52 | ++ | |
53 | + static inline int isdigit(int c) | |
54 | + { | |
55 | + return c >= '0' && c <= '9'; | |
56 | +@@ -469,6 +499,54 @@ static int cmos_readb(int addr) | |
57 | + return inb(0x71); | |
58 | + } | |
59 | + | |
60 | ++void setup_mtrr(void) | |
61 | ++{ | |
62 | ++ int i, vcnt, fix, wc; | |
63 | ++ uint32_t mtrr_cap; | |
64 | ++ union { | |
65 | ++ uint8_t valb[8]; | |
66 | ++ uint64_t val; | |
67 | ++ } u; | |
68 | ++ uint64_t vbase, vmask; | |
69 | ++ | |
70 | ++ mtrr_cap = rdmsr(MSR_MTRRcap); | |
71 | ++ vcnt = mtrr_cap & 0xff; | |
72 | ++ fix = mtrr_cap & 0x100; | |
73 | ++ wc = mtrr_cap & 0x400; | |
74 | ++ if (!vcnt || !fix) | |
75 | ++ return; | |
76 | ++ u.val = 0; | |
77 | ++ for (i = 0; i < 8; ++i) | |
78 | ++ if (ram_size >= 65536 * (i + 1)) | |
79 | ++ u.valb[i] = 6; | |
80 | ++ wrmsr(MSR_MTRRfix64K_00000, u.val); | |
81 | ++ u.val = 0; | |
82 | ++ for (i = 0; i < 8; ++i) | |
83 | ++ if (ram_size >= 65536 * 8 + 16384 * (i + 1)) | |
84 | ++ u.valb[i] = 6; | |
85 | ++ wrmsr(MSR_MTRRfix16K_80000, u.val); | |
86 | ++ wrmsr(MSR_MTRRfix16K_A0000, 0); | |
87 | ++ wrmsr(MSR_MTRRfix4K_C0000, 0); | |
88 | ++ wrmsr(MSR_MTRRfix4K_C8000, 0); | |
89 | ++ wrmsr(MSR_MTRRfix4K_D0000, 0); | |
90 | ++ wrmsr(MSR_MTRRfix4K_D8000, 0); | |
91 | ++ wrmsr(MSR_MTRRfix4K_E0000, 0); | |
92 | ++ wrmsr(MSR_MTRRfix4K_E8000, 0); | |
93 | ++ wrmsr(MSR_MTRRfix4K_F0000, 0); | |
94 | ++ wrmsr(MSR_MTRRfix4K_F8000, 0); | |
95 | ++ vbase = 0; | |
96 | ++ --vcnt; /* leave one mtrr for VRAM */ | |
97 | ++ for (i = 0; i < vcnt && vbase < ram_size; ++i) { | |
98 | ++ vmask = (1ull << 40) - 1; | |
99 | ++ while (vbase + vmask + 1 > ram_size) | |
100 | ++ vmask >>= 1; | |
101 | ++ wrmsr(MTRRphysBase_MSR(i), vbase | 6); | |
102 | ++ wrmsr(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800); | |
103 | ++ vbase += vmask + 1; | |
104 | ++ } | |
105 | ++ wrmsr(MSR_MTRRdefType, 0xc00); | |
106 | ++} | |
107 | ++ | |
108 | + void ram_probe(void) | |
109 | + { | |
110 | + if (cmos_readb(0x34) | cmos_readb(0x35)) | |
111 | +@@ -482,6 +560,7 @@ void ram_probe(void) | |
112 | + ebda_cur_addr = ((*(uint16_t *)(0x40e)) << 4) + 0x380; | |
113 | + BX_INFO("ebda_cur_addr: 0x%08lx\n", ebda_cur_addr); | |
114 | + #endif | |
115 | ++ setup_mtrr(); | |
116 | + } | |
117 | + | |
118 | + /****************************************************/ | |
119 | + | |
120 | + | ... | ... |
pc-bios/bios-pq/0005_kvm-bios-smp-mtrr-support.patch
0 → 100644
1 | +smp mtrr support (Avi Kivity) | |
2 | + | |
3 | +Signed-off-by: Avi Kivity <avi@qumranet.com> | |
4 | +Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> | |
5 | + | |
6 | +Index: bochs/bios/rombios.h | |
7 | +=================================================================== | |
8 | +--- bochs.orig/bios/rombios.h | |
9 | ++++ bochs/bios/rombios.h | |
10 | +@@ -56,6 +56,7 @@ | |
11 | + #define ACPI_DATA_SIZE 0x00010000L | |
12 | + #define PM_IO_BASE 0xb000 | |
13 | + #define SMB_IO_BASE 0xb100 | |
14 | ++#define SMP_MSR_ADDR 0xf010 | |
15 | + | |
16 | + // Define the application NAME | |
17 | + #if defined(BX_QEMU) | |
18 | +Index: bochs/bios/rombios32.c | |
19 | +=================================================================== | |
20 | +--- bochs.orig/bios/rombios32.c | |
21 | ++++ bochs/bios/rombios32.c | |
22 | +@@ -472,6 +472,23 @@ void qemu_cfg_read(uint8_t *buf, int len | |
23 | + } | |
24 | + #endif | |
25 | + | |
26 | ++void init_smp_msrs(void) | |
27 | ++{ | |
28 | ++ *(uint32_t *)SMP_MSR_ADDR = 0; | |
29 | ++} | |
30 | ++ | |
31 | ++void wrmsr_smp(uint32_t index, uint64_t val) | |
32 | ++{ | |
33 | ++ static struct { uint32_t ecx, eax, edx; } *p = (void *)SMP_MSR_ADDR; | |
34 | ++ | |
35 | ++ wrmsr(index, val); | |
36 | ++ p->ecx = index; | |
37 | ++ p->eax = val; | |
38 | ++ p->edx = val >> 32; | |
39 | ++ ++p; | |
40 | ++ p->ecx = 0; | |
41 | ++} | |
42 | ++ | |
43 | + void uuid_probe(void) | |
44 | + { | |
45 | + #ifdef BX_QEMU | |
46 | +@@ -519,32 +536,32 @@ void setup_mtrr(void) | |
47 | + for (i = 0; i < 8; ++i) | |
48 | + if (ram_size >= 65536 * (i + 1)) | |
49 | + u.valb[i] = 6; | |
50 | +- wrmsr(MSR_MTRRfix64K_00000, u.val); | |
51 | ++ wrmsr_smp(MSR_MTRRfix64K_00000, u.val); | |
52 | + u.val = 0; | |
53 | + for (i = 0; i < 8; ++i) | |
54 | + if (ram_size >= 65536 * 8 + 16384 * (i + 1)) | |
55 | + u.valb[i] = 6; | |
56 | +- wrmsr(MSR_MTRRfix16K_80000, u.val); | |
57 | +- wrmsr(MSR_MTRRfix16K_A0000, 0); | |
58 | +- wrmsr(MSR_MTRRfix4K_C0000, 0); | |
59 | +- wrmsr(MSR_MTRRfix4K_C8000, 0); | |
60 | +- wrmsr(MSR_MTRRfix4K_D0000, 0); | |
61 | +- wrmsr(MSR_MTRRfix4K_D8000, 0); | |
62 | +- wrmsr(MSR_MTRRfix4K_E0000, 0); | |
63 | +- wrmsr(MSR_MTRRfix4K_E8000, 0); | |
64 | +- wrmsr(MSR_MTRRfix4K_F0000, 0); | |
65 | +- wrmsr(MSR_MTRRfix4K_F8000, 0); | |
66 | ++ wrmsr_smp(MSR_MTRRfix16K_80000, u.val); | |
67 | ++ wrmsr_smp(MSR_MTRRfix16K_A0000, 0); | |
68 | ++ wrmsr_smp(MSR_MTRRfix4K_C0000, 0); | |
69 | ++ wrmsr_smp(MSR_MTRRfix4K_C8000, 0); | |
70 | ++ wrmsr_smp(MSR_MTRRfix4K_D0000, 0); | |
71 | ++ wrmsr_smp(MSR_MTRRfix4K_D8000, 0); | |
72 | ++ wrmsr_smp(MSR_MTRRfix4K_E0000, 0); | |
73 | ++ wrmsr_smp(MSR_MTRRfix4K_E8000, 0); | |
74 | ++ wrmsr_smp(MSR_MTRRfix4K_F0000, 0); | |
75 | ++ wrmsr_smp(MSR_MTRRfix4K_F8000, 0); | |
76 | + vbase = 0; | |
77 | + --vcnt; /* leave one mtrr for VRAM */ | |
78 | + for (i = 0; i < vcnt && vbase < ram_size; ++i) { | |
79 | + vmask = (1ull << 40) - 1; | |
80 | + while (vbase + vmask + 1 > ram_size) | |
81 | + vmask >>= 1; | |
82 | +- wrmsr(MTRRphysBase_MSR(i), vbase | 6); | |
83 | +- wrmsr(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800); | |
84 | ++ wrmsr_smp(MTRRphysBase_MSR(i), vbase | 6); | |
85 | ++ wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800); | |
86 | + vbase += vmask + 1; | |
87 | + } | |
88 | +- wrmsr(MSR_MTRRdefType, 0xc00); | |
89 | ++ wrmsr_smp(MSR_MTRRdefType, 0xc00); | |
90 | + } | |
91 | + | |
92 | + void ram_probe(void) | |
93 | +@@ -2263,6 +2280,8 @@ void rombios32_init(uint32_t *s3_resume_ | |
94 | + qemu_cfg_port = qemu_cfg_port_probe(); | |
95 | + #endif | |
96 | + | |
97 | ++ init_smp_msrs(); | |
98 | ++ | |
99 | + ram_probe(); | |
100 | + | |
101 | + cpu_probe(); | |
102 | +Index: bochs/bios/rombios32start.S | |
103 | +=================================================================== | |
104 | +--- bochs.orig/bios/rombios32start.S | |
105 | ++++ bochs/bios/rombios32start.S | |
106 | +@@ -49,6 +49,18 @@ _start: | |
107 | + smp_ap_boot_code_start: | |
108 | + xor %ax, %ax | |
109 | + mov %ax, %ds | |
110 | ++ | |
111 | ++ mov $SMP_MSR_ADDR, %ebx | |
112 | ++11: | |
113 | ++ mov 0(%ebx), %ecx | |
114 | ++ test %ecx, %ecx | |
115 | ++ jz 12f | |
116 | ++ mov 4(%ebx), %eax | |
117 | ++ mov 8(%ebx), %edx | |
118 | ++ wrmsr | |
119 | ++ add $12, %ebx | |
120 | ++ jmp 11b | |
121 | ++12: | |
122 | + lock incw smp_cpus | |
123 | + 1: | |
124 | + hlt | |
125 | + | |
126 | + | ... | ... |
pc-bios/bios-pq/0006_kvm-bios-extend-mtrrs-to-above-4g.patch
0 → 100644
1 | +extend MTRRs to above 4G (Alex Williamson) | |
2 | + | |
3 | +When I try to boot guests using a recent Linux kernel (2.6.26+), memory | |
4 | +above 3.5G gets thrown away with an error like this: | |
5 | + | |
6 | +WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing 4608MB of RAM | |
7 | + | |
8 | +This extends MTRRs to cover all of memory. | |
9 | + | |
10 | +Signed-off-by: Alex Williamson <alex.williamson@hp.com> | |
11 | +Signed-off-by: Avi Kivity <avi@redhat.com> | |
12 | +Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> | |
13 | + | |
14 | +Index: bochs/bios/rombios32.c | |
15 | +=================================================================== | |
16 | +--- bochs.orig/bios/rombios32.c | |
17 | ++++ bochs/bios/rombios32.c | |
18 | +@@ -427,6 +427,7 @@ uint32_t cpuid_signature; | |
19 | + uint32_t cpuid_features; | |
20 | + uint32_t cpuid_ext_features; | |
21 | + unsigned long ram_size; | |
22 | ++uint64_t above4g_ram_size; | |
23 | + uint8_t bios_uuid[16]; | |
24 | + #ifdef BX_USE_EBDA_TABLES | |
25 | + unsigned long ebda_cur_addr; | |
26 | +@@ -561,6 +562,14 @@ void setup_mtrr(void) | |
27 | + wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800); | |
28 | + vbase += vmask + 1; | |
29 | + } | |
30 | ++ for (vbase = 1ull << 32; i < vcnt && vbase < above4g_ram_size; ++i) { | |
31 | ++ vmask = (1ull << 40) - 1; | |
32 | ++ while (vbase + vmask + 1 > above4g_ram_size) | |
33 | ++ vmask >>= 1; | |
34 | ++ wrmsr_smp(MTRRphysBase_MSR(i), vbase | 6); | |
35 | ++ wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800); | |
36 | ++ vbase += vmask + 1; | |
37 | ++ } | |
38 | + wrmsr_smp(MSR_MTRRdefType, 0xc00); | |
39 | + } | |
40 | + | |
41 | +@@ -572,11 +581,19 @@ void ram_probe(void) | |
42 | + else | |
43 | + ram_size = (cmos_readb(0x30) | (cmos_readb(0x31) << 8)) * 1024 + | |
44 | + 1 * 1024 * 1024; | |
45 | ++ if (cmos_readb(0x5b) | cmos_readb(0x5c) | cmos_readb(0x5d)) | |
46 | ++ above4g_ram_size = ((uint64_t)cmos_readb(0x5b) << 16) | | |
47 | ++ ((uint64_t)cmos_readb(0x5c) << 24) | ((uint64_t)cmos_readb(0x5d) << 32); | |
48 | ++ | |
49 | ++ if (above4g_ram_size) | |
50 | ++ above4g_ram_size += 1ull << 32; | |
51 | ++ | |
52 | + BX_INFO("ram_size=0x%08lx\n", ram_size); | |
53 | + #ifdef BX_USE_EBDA_TABLES | |
54 | + ebda_cur_addr = ((*(uint16_t *)(0x40e)) << 4) + 0x380; | |
55 | + BX_INFO("ebda_cur_addr: 0x%08lx\n", ebda_cur_addr); | |
56 | + #endif | |
57 | ++ BX_INFO("top of ram %ldMB\n", above4g_ram_size >> 20); | |
58 | + setup_mtrr(); | |
59 | + } | |
60 | + | |
61 | + | |
62 | + | ... | ... |
pc-bios/bios-pq/0007_kvm-bios-cleanup-consolidate-above-4g-memory-parsing.patch
0 → 100644
1 | +cleanup/consolidate above 4G memory parsing (Alex Williamson) | |
2 | + | |
3 | +Signed-off-by: Alex Williamson <alex.williamson@hp.com> | |
4 | +Signed-off-by: Avi Kivity <avi@redhat.com> | |
5 | +Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> | |
6 | + | |
7 | +Index: bochs/bios/rombios32.c | |
8 | +=================================================================== | |
9 | +--- bochs.orig/bios/rombios32.c | |
10 | ++++ bochs/bios/rombios32.c | |
11 | +@@ -427,7 +427,7 @@ uint32_t cpuid_signature; | |
12 | + uint32_t cpuid_features; | |
13 | + uint32_t cpuid_ext_features; | |
14 | + unsigned long ram_size; | |
15 | +-uint64_t above4g_ram_size; | |
16 | ++uint64_t ram_end; | |
17 | + uint8_t bios_uuid[16]; | |
18 | + #ifdef BX_USE_EBDA_TABLES | |
19 | + unsigned long ebda_cur_addr; | |
20 | +@@ -562,9 +562,9 @@ void setup_mtrr(void) | |
21 | + wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800); | |
22 | + vbase += vmask + 1; | |
23 | + } | |
24 | +- for (vbase = 1ull << 32; i < vcnt && vbase < above4g_ram_size; ++i) { | |
25 | ++ for (vbase = 1ull << 32; i < vcnt && vbase < ram_end; ++i) { | |
26 | + vmask = (1ull << 40) - 1; | |
27 | +- while (vbase + vmask + 1 > above4g_ram_size) | |
28 | ++ while (vbase + vmask + 1 > ram_end) | |
29 | + vmask >>= 1; | |
30 | + wrmsr_smp(MTRRphysBase_MSR(i), vbase | 6); | |
31 | + wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800); | |
32 | +@@ -582,18 +582,19 @@ void ram_probe(void) | |
33 | + ram_size = (cmos_readb(0x30) | (cmos_readb(0x31) << 8)) * 1024 + | |
34 | + 1 * 1024 * 1024; | |
35 | + if (cmos_readb(0x5b) | cmos_readb(0x5c) | cmos_readb(0x5d)) | |
36 | +- above4g_ram_size = ((uint64_t)cmos_readb(0x5b) << 16) | | |
37 | +- ((uint64_t)cmos_readb(0x5c) << 24) | ((uint64_t)cmos_readb(0x5d) << 32); | |
38 | ++ ram_end = (((uint64_t)cmos_readb(0x5b) << 16) | | |
39 | ++ ((uint64_t)cmos_readb(0x5c) << 24) | | |
40 | ++ ((uint64_t)cmos_readb(0x5d) << 32)) + (1ull << 32); | |
41 | ++ else | |
42 | ++ ram_end = ram_size; | |
43 | + | |
44 | +- if (above4g_ram_size) | |
45 | +- above4g_ram_size += 1ull << 32; | |
46 | ++ BX_INFO("end of ram=%ldMB\n", ram_end >> 20); | |
47 | + | |
48 | + BX_INFO("ram_size=0x%08lx\n", ram_size); | |
49 | + #ifdef BX_USE_EBDA_TABLES | |
50 | + ebda_cur_addr = ((*(uint16_t *)(0x40e)) << 4) + 0x380; | |
51 | + BX_INFO("ebda_cur_addr: 0x%08lx\n", ebda_cur_addr); | |
52 | + #endif | |
53 | +- BX_INFO("top of ram %ldMB\n", above4g_ram_size >> 20); | |
54 | + setup_mtrr(); | |
55 | + } | |
56 | + | |
57 | + | |
58 | + | ... | ... |
pc-bios/bios-pq/0008_kvm-bios-switch-mtrrs-to-cover-only-the-pci-range-and--default-to-wb.patch
0 → 100644
1 | +switch MTRRs to cover only the PCI range and default to WB (Alex Williamson) | |
2 | + | |
3 | +This matches how some bare metal machines report MTRRs and avoids | |
4 | +the problem of running out of MTRRs to cover all of RAM. | |
5 | + | |
6 | +Signed-off-by: Alex Williamson <alex.williamson@hp.com> | |
7 | +Signed-off-by: Avi Kivity <avi@redhat.com> | |
8 | +Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> | |
9 | + | |
10 | +Index: bochs/bios/rombios32.c | |
11 | +=================================================================== | |
12 | +--- bochs.orig/bios/rombios32.c | |
13 | ++++ bochs/bios/rombios32.c | |
14 | +@@ -525,7 +525,6 @@ void setup_mtrr(void) | |
15 | + uint8_t valb[8]; | |
16 | + uint64_t val; | |
17 | + } u; | |
18 | +- uint64_t vbase, vmask; | |
19 | + | |
20 | + mtrr_cap = rdmsr(MSR_MTRRcap); | |
21 | + vcnt = mtrr_cap & 0xff; | |
22 | +@@ -552,25 +551,10 @@ void setup_mtrr(void) | |
23 | + wrmsr_smp(MSR_MTRRfix4K_E8000, 0); | |
24 | + wrmsr_smp(MSR_MTRRfix4K_F0000, 0); | |
25 | + wrmsr_smp(MSR_MTRRfix4K_F8000, 0); | |
26 | +- vbase = 0; | |
27 | +- --vcnt; /* leave one mtrr for VRAM */ | |
28 | +- for (i = 0; i < vcnt && vbase < ram_size; ++i) { | |
29 | +- vmask = (1ull << 40) - 1; | |
30 | +- while (vbase + vmask + 1 > ram_size) | |
31 | +- vmask >>= 1; | |
32 | +- wrmsr_smp(MTRRphysBase_MSR(i), vbase | 6); | |
33 | +- wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800); | |
34 | +- vbase += vmask + 1; | |
35 | +- } | |
36 | +- for (vbase = 1ull << 32; i < vcnt && vbase < ram_end; ++i) { | |
37 | +- vmask = (1ull << 40) - 1; | |
38 | +- while (vbase + vmask + 1 > ram_end) | |
39 | +- vmask >>= 1; | |
40 | +- wrmsr_smp(MTRRphysBase_MSR(i), vbase | 6); | |
41 | +- wrmsr_smp(MTRRphysMask_MSR(i), (~vmask & 0xfffffff000ull) | 0x800); | |
42 | +- vbase += vmask + 1; | |
43 | +- } | |
44 | +- wrmsr_smp(MSR_MTRRdefType, 0xc00); | |
45 | ++ /* Mark 3.5-4GB as UC, anything not specified defaults to WB */ | |
46 | ++ wrmsr_smp(MTRRphysBase_MSR(0), 0xe0000000ull | 0); | |
47 | ++ wrmsr_smp(MTRRphysMask_MSR(0), ~(0x20000000ull - 1) | 0x800); | |
48 | ++ wrmsr_smp(MSR_MTRRdefType, 0xc06); | |
49 | + } | |
50 | + | |
51 | + void ram_probe(void) | |
52 | + | |
53 | + | |
54 | + | ... | ... |
pc-bios/bios-pq/0009_kvm-bios-resolve-memory-device-roll-over-reporting--issues-with-32g-guests.patch
0 → 100644
1 | +resolve memory device roll over reporting issues with >32G guests (Bill Rieske) | |
2 | + | |
3 | +The field within the Memory Device type 17 is only a word with the MSB being | |
4 | +used to report MB/KB. Thereby, a guest with 32G and greater would report | |
5 | +incorrect memory device information rolling over to 0. | |
6 | + | |
7 | +This presents more than one memory device and associated memory structures | |
8 | +if the memory is larger than 16G | |
9 | + | |
10 | +Signed-off-by: Bill Rieske <brieske@novell.com> | |
11 | +Signed-off-by: Avi Kivity <avi@redhat.com> | |
12 | +Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> | |
13 | + | |
14 | +Index: bochs/bios/rombios32.c | |
15 | +=================================================================== | |
16 | +--- bochs.orig/bios/rombios32.c | |
17 | ++++ bochs/bios/rombios32.c | |
18 | +@@ -381,6 +381,17 @@ int vsnprintf(char *buf, int buflen, con | |
19 | + return buf - buf0; | |
20 | + } | |
21 | + | |
22 | ++int snprintf(char * buf, size_t size, const char *fmt, ...) | |
23 | ++{ | |
24 | ++ va_list args; | |
25 | ++ int i; | |
26 | ++ | |
27 | ++ va_start(args, fmt); | |
28 | ++ i=vsnprintf(buf,size,fmt,args); | |
29 | ++ va_end(args); | |
30 | ++ return i; | |
31 | ++} | |
32 | ++ | |
33 | + void bios_printf(int flags, const char *fmt, ...) | |
34 | + { | |
35 | + va_list ap; | |
36 | +@@ -2039,7 +2050,7 @@ smbios_type_4_init(void *start, unsigned | |
37 | + | |
38 | + /* Type 16 -- Physical Memory Array */ | |
39 | + static void * | |
40 | +-smbios_type_16_init(void *start, uint32_t memsize) | |
41 | ++smbios_type_16_init(void *start, uint32_t memsize, int nr_mem_devs) | |
42 | + { | |
43 | + struct smbios_type_16 *p = (struct smbios_type_16*)start; | |
44 | + | |
45 | +@@ -2052,7 +2063,7 @@ smbios_type_16_init(void *start, uint32_ | |
46 | + p->error_correction = 0x01; /* other */ | |
47 | + p->maximum_capacity = memsize * 1024; | |
48 | + p->memory_error_information_handle = 0xfffe; /* none provided */ | |
49 | +- p->number_of_memory_devices = 1; | |
50 | ++ p->number_of_memory_devices = nr_mem_devs; | |
51 | + | |
52 | + start += sizeof(struct smbios_type_16); | |
53 | + *((uint16_t *)start) = 0; | |
54 | +@@ -2062,20 +2073,19 @@ smbios_type_16_init(void *start, uint32_ | |
55 | + | |
56 | + /* Type 17 -- Memory Device */ | |
57 | + static void * | |
58 | +-smbios_type_17_init(void *start, uint32_t memory_size_mb) | |
59 | ++smbios_type_17_init(void *start, uint32_t memory_size_mb, int instance) | |
60 | + { | |
61 | + struct smbios_type_17 *p = (struct smbios_type_17 *)start; | |
62 | + | |
63 | + p->header.type = 17; | |
64 | + p->header.length = sizeof(struct smbios_type_17); | |
65 | +- p->header.handle = 0x1100; | |
66 | ++ p->header.handle = 0x1100 + instance; | |
67 | + | |
68 | + p->physical_memory_array_handle = 0x1000; | |
69 | + p->total_width = 64; | |
70 | + p->data_width = 64; | |
71 | +- /* truncate memory_size_mb to 16 bits and clear most significant | |
72 | +- bit [indicates size in MB] */ | |
73 | +- p->size = (uint16_t) memory_size_mb & 0x7fff; | |
74 | ++/* TODO: should assert in case something is wrong ASSERT((memory_size_mb & ~0x7fff) == 0); */ | |
75 | ++ p->size = memory_size_mb; | |
76 | + p->form_factor = 0x09; /* DIMM */ | |
77 | + p->device_set = 0; | |
78 | + p->device_locator_str = 1; | |
79 | +@@ -2084,8 +2094,8 @@ smbios_type_17_init(void *start, uint32_ | |
80 | + p->type_detail = 0; | |
81 | + | |
82 | + start += sizeof(struct smbios_type_17); | |
83 | +- memcpy((char *)start, "DIMM 1", 7); | |
84 | +- start += 7; | |
85 | ++ snprintf(start, 8, "DIMM %d", instance); | |
86 | ++ start += strlen(start) + 1; | |
87 | + *((uint8_t *)start) = 0; | |
88 | + | |
89 | + return start+1; | |
90 | +@@ -2093,16 +2103,16 @@ smbios_type_17_init(void *start, uint32_ | |
91 | + | |
92 | + /* Type 19 -- Memory Array Mapped Address */ | |
93 | + static void * | |
94 | +-smbios_type_19_init(void *start, uint32_t memory_size_mb) | |
95 | ++smbios_type_19_init(void *start, uint32_t memory_size_mb, int instance) | |
96 | + { | |
97 | + struct smbios_type_19 *p = (struct smbios_type_19 *)start; | |
98 | + | |
99 | + p->header.type = 19; | |
100 | + p->header.length = sizeof(struct smbios_type_19); | |
101 | +- p->header.handle = 0x1300; | |
102 | ++ p->header.handle = 0x1300 + instance; | |
103 | + | |
104 | +- p->starting_address = 0; | |
105 | +- p->ending_address = (memory_size_mb * 1024) - 1; | |
106 | ++ p->starting_address = instance << 24; | |
107 | ++ p->ending_address = p->starting_address + (memory_size_mb << 10) - 1; | |
108 | + p->memory_array_handle = 0x1000; | |
109 | + p->partition_width = 1; | |
110 | + | |
111 | +@@ -2114,18 +2124,18 @@ smbios_type_19_init(void *start, uint32_ | |
112 | + | |
113 | + /* Type 20 -- Memory Device Mapped Address */ | |
114 | + static void * | |
115 | +-smbios_type_20_init(void *start, uint32_t memory_size_mb) | |
116 | ++smbios_type_20_init(void *start, uint32_t memory_size_mb, int instance) | |
117 | + { | |
118 | + struct smbios_type_20 *p = (struct smbios_type_20 *)start; | |
119 | + | |
120 | + p->header.type = 20; | |
121 | + p->header.length = sizeof(struct smbios_type_20); | |
122 | +- p->header.handle = 0x1400; | |
123 | ++ p->header.handle = 0x1400 + instance; | |
124 | + | |
125 | +- p->starting_address = 0; | |
126 | +- p->ending_address = (memory_size_mb * 1024) - 1; | |
127 | +- p->memory_device_handle = 0x1100; | |
128 | +- p->memory_array_mapped_address_handle = 0x1300; | |
129 | ++ p->starting_address = instance << 24; | |
130 | ++ p->ending_address = p->starting_address + (memory_size_mb << 10) - 1; | |
131 | ++ p->memory_device_handle = 0x1100 + instance; | |
132 | ++ p->memory_array_mapped_address_handle = 0x1300 + instance; | |
133 | + p->partition_row_position = 1; | |
134 | + p->interleave_position = 0; | |
135 | + p->interleaved_data_depth = 0; | |
136 | +@@ -2176,6 +2186,7 @@ void smbios_init(void) | |
137 | + char *start, *p, *q; | |
138 | + int memsize = (ram_end == ram_size) ? ram_size / (1024 * 1024) : | |
139 | + (ram_end - (1ull << 32) + ram_size) / (1024 * 1024); | |
140 | ++ int i, nr_mem_devs; | |
141 | + | |
142 | + #ifdef BX_USE_EBDA_TABLES | |
143 | + ebda_cur_addr = align(ebda_cur_addr, 16); | |
144 | +@@ -2187,23 +2198,32 @@ void smbios_init(void) | |
145 | + | |
146 | + p = (char *)start + sizeof(struct smbios_entry_point); | |
147 | + | |
148 | +-#define add_struct(fn) { \ | |
149 | ++#define add_struct(fn) do{ \ | |
150 | + q = (fn); \ | |
151 | + nr_structs++; \ | |
152 | + if ((q - p) > max_struct_size) \ | |
153 | + max_struct_size = q - p; \ | |
154 | + p = q; \ | |
155 | +-} | |
156 | ++}while (0) | |
157 | + | |
158 | + add_struct(smbios_type_0_init(p)); | |
159 | + add_struct(smbios_type_1_init(p)); | |
160 | + add_struct(smbios_type_3_init(p)); | |
161 | + for (cpu_num = 1; cpu_num <= smp_cpus; cpu_num++) | |
162 | + add_struct(smbios_type_4_init(p, cpu_num)); | |
163 | +- add_struct(smbios_type_16_init(p, memsize)); | |
164 | +- add_struct(smbios_type_17_init(p, memsize)); | |
165 | +- add_struct(smbios_type_19_init(p, ram_end / (1024 * 1024))); | |
166 | +- add_struct(smbios_type_20_init(p, ram_end / (1024 * 1024))); | |
167 | ++ | |
168 | ++ /* Each 'memory device' covers up to 16GB of address space. */ | |
169 | ++ nr_mem_devs = (memsize + 0x3fff) >> 14; | |
170 | ++ add_struct(smbios_type_16_init(p, memsize, nr_mem_devs)); | |
171 | ++ for ( i = 0; i < nr_mem_devs; i++ ) | |
172 | ++ { | |
173 | ++ uint32_t dev_memsize = ((i == (nr_mem_devs - 1)) | |
174 | ++ ? (memsize & 0x3fff) : 0x4000); | |
175 | ++ add_struct(smbios_type_17_init(p, dev_memsize, i)); | |
176 | ++ add_struct(smbios_type_19_init(p, dev_memsize, i)); | |
177 | ++ add_struct(smbios_type_20_init(p, dev_memsize, i)); | |
178 | ++ } | |
179 | ++ | |
180 | + add_struct(smbios_type_32_init(p)); | |
181 | + add_struct(smbios_type_127_init(p)); | |
182 | + | |
183 | + | |
184 | + | ... | ... |
pc-bios/bios-pq/0010_kvm-bios-fix-smbios-memory-device-length-boundary--condition.patch
0 → 100644
1 | +fix smbios memory device length boundary condition (Bill Rieske) | |
2 | + | |
3 | +dev_memsize ends up 0 when it shouldn't be on 16G boundary conditions. | |
4 | + | |
5 | +Signed-off-by: Bill Rieske <brieske@novell.com> | |
6 | +Signed-off-by: Avi Kivity <avi@redhat.com> | |
7 | +Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> | |
8 | + | |
9 | +Index: bochs/bios/rombios32.c | |
10 | +=================================================================== | |
11 | +--- bochs.orig/bios/rombios32.c | |
12 | ++++ bochs/bios/rombios32.c | |
13 | +@@ -2218,7 +2218,7 @@ void smbios_init(void) | |
14 | + for ( i = 0; i < nr_mem_devs; i++ ) | |
15 | + { | |
16 | + uint32_t dev_memsize = ((i == (nr_mem_devs - 1)) | |
17 | +- ? (memsize & 0x3fff) : 0x4000); | |
18 | ++ ? (((memsize-1) & 0x3fff)+1) : 0x4000); | |
19 | + add_struct(smbios_type_17_init(p, dev_memsize, i)); | |
20 | + add_struct(smbios_type_19_init(p, dev_memsize, i)); | |
21 | + add_struct(smbios_type_20_init(p, dev_memsize, i)); | |
22 | + | |
23 | + | ... | ... |
pc-bios/bios-pq/HEAD
pc-bios/bios-pq/series
1 | 1 | 0001_bx-qemu.patch |
2 | +0002_kvm-bios-update-smbios-table-to-report-memory-above-4g.patch | |
3 | +0003_kvm-bios-generate-mptable-unconditionally.patch | |
4 | +0004_kvm-bios-add-mtrr-support.patch | |
5 | +0005_kvm-bios-smp-mtrr-support.patch | |
6 | +0006_kvm-bios-extend-mtrrs-to-above-4g.patch | |
7 | +0007_kvm-bios-cleanup-consolidate-above-4g-memory-parsing.patch | |
8 | +0008_kvm-bios-switch-mtrrs-to-cover-only-the-pci-range-and--default-to-wb.patch | |
9 | +0009_kvm-bios-resolve-memory-device-roll-over-reporting--issues-with-32g-guests.patch | |
10 | +0010_kvm-bios-fix-smbios-memory-device-length-boundary--condition.patch | ... | ... |
pc-bios/bios.bin
No preview for this file type