1 From 83f115d2f7f26dddcbbffe89aa8a7a97b28a6228 Mon Sep 17 00:00:00 2001
2 From: Alexander Kudryavtsev <alexk@ispras.ru>
3 Date: Mon, 12 Mar 2012 13:07:07 +0400
4 Subject: [PATCH] Fixes needed to launch SEABIOS inside Palacios's VM: 1.
5 Allow to build ACPI tables without PIIX4 PM device 2.
6 Disable HPET table generation 3. Do not perform PCI setup
7 since it breaks Palacios 4. Do not initialize AP cores
8 since it breaks Palacios 5. Fix SRAT generation - do not
9 cut PCI hole since it is already cut off by Palacios
12 src/acpi.c | 44 +++++++++++++++++++++++++++++---------------
15 3 files changed, 34 insertions(+), 17 deletions(-)
17 diff --git a/src/acpi.c b/src/acpi.c
18 index 3d8b7c8..7d50990 100644
21 @@ -262,18 +262,32 @@ build_fadt(struct pci_device *pci)
22 fadt->dsdt = cpu_to_le32((u32)dsdt);
25 - int pm_sci_int = pci_config_readb(pci->bdf, PCI_INTERRUPT_LINE);
28 + pci_config_readb(pci->bdf, PCI_INTERRUPT_LINE);
31 fadt->sci_int = cpu_to_le16(pm_sci_int);
32 - fadt->smi_cmd = cpu_to_le32(PORT_SMI_CMD);
33 - fadt->pm1a_evt_blk = cpu_to_le32(PORT_ACPI_PM_BASE);
34 - fadt->pm1a_cnt_blk = cpu_to_le32(PORT_ACPI_PM_BASE + 0x04);
35 - fadt->pm_tmr_blk = cpu_to_le32(PORT_ACPI_PM_BASE + 0x08);
36 - fadt->pm1_evt_len = 4;
37 - fadt->pm1_cnt_len = 2;
38 - fadt->pm_tmr_len = 4;
40 + fadt->smi_cmd = cpu_to_le32(PORT_SMI_CMD);
41 + fadt->pm1a_evt_blk = cpu_to_le32(PORT_ACPI_PM_BASE);
42 + fadt->pm1a_cnt_blk = cpu_to_le32(PORT_ACPI_PM_BASE + 0x04);
43 + fadt->pm_tmr_blk = cpu_to_le32(PORT_ACPI_PM_BASE + 0x08);
44 + fadt->pm1_evt_len = 4;
45 + fadt->pm1_cnt_len = 2;
46 + fadt->pm_tmr_len = 4;
47 + pci_init_device(fadt_init_tbl, pci, fadt);
50 + fadt->pm1a_evt_blk = 0;
51 + fadt->pm1a_cnt_blk = 0;
52 + fadt->pm_tmr_blk = 0;
53 + fadt->pm1_evt_len = 0;
54 + fadt->pm1_cnt_len = 0;
55 + fadt->pm_tmr_len = 0;
57 fadt->plvl2_lat = cpu_to_le16(0xfff); // C2 state not supported
58 fadt->plvl3_lat = cpu_to_le16(0xfff); // C3 state not supported
59 - pci_init_device(fadt_init_tbl, pci, fadt);
60 /* WBINVD + PROC_C1 + SLP_BUTTON + FIX_RTC + RTC_S4 */
61 fadt->flags = cpu_to_le32((1 << 0) | (1 << 2) | (1 << 5) | (1 << 6) | (1 << 7));
63 @@ -516,6 +530,7 @@ build_srat(void)
64 if (nb_numa_nodes == 0)
68 u64 *numadata = malloc_tmphigh(sizeof(u64) * (MaxCountCPUs + nb_numa_nodes));
71 @@ -577,7 +592,7 @@ build_srat(void)
72 next_base = mem_base + mem_len;
74 /* Cut out the PCI hole */
75 - if (mem_base <= RamSize && next_base > RamSize) {
76 + /*if (mem_base <= RamSize && next_base > RamSize) {
77 mem_len -= next_base - RamSize;
79 acpi_build_srat_memory(numamem, mem_base, mem_len, i-1, 1);
80 @@ -587,7 +602,7 @@ build_srat(void)
81 mem_base = 1ULL << 32;
82 mem_len = next_base - RamSize;
83 next_base += (1ULL << 32) - RamSize;
86 acpi_build_srat_memory(numamem, mem_base, mem_len, i-1, 1);
89 @@ -623,9 +638,7 @@ acpi_bios_init(void)
91 // This code is hardcoded for PIIX4 Power Management device.
92 struct pci_device *pci = pci_find_init_device(acpi_find_tbl, NULL);
96 + // If no PIIX4 is found we will not build certain structures and init it.
99 u32 tables[MAX_ACPI_TABLES], tbl_idx = 0;
100 @@ -640,7 +653,8 @@ acpi_bios_init(void)
101 ACPI_INIT_TABLE(build_fadt(pci));
102 ACPI_INIT_TABLE(build_ssdt());
103 ACPI_INIT_TABLE(build_madt());
104 - ACPI_INIT_TABLE(build_hpet());
106 + ACPI_INIT_TABLE(build_hpet());
107 ACPI_INIT_TABLE(build_srat());
109 u16 i, external_tables = qemu_cfg_acpi_additional_tables();
110 diff --git a/src/pciinit.c b/src/pciinit.c
111 index 0d8758e..ef8ccda 100644
114 @@ -575,7 +575,7 @@ static int pci_bios_init_root_regions(u32 start, u32 end)
118 - if (CONFIG_COREBOOT || usingXen()) {
119 + if (1 || CONFIG_COREBOOT || usingXen()) {
120 // PCI setup already done by coreboot or Xen - just do probe.
123 diff --git a/src/smp.c b/src/smp.c
124 index 8c077a1..21e7437 100644
127 @@ -81,7 +81,7 @@ smp_probe(void)
134 writel(&CountCPUs, 1);
136 @@ -121,6 +121,9 @@ smp_probe(void)
139 *(u64*)BUILD_AP_BOOT_ADDR = old;
142 + CountCPUs = inb_cmos(CMOS_BIOS_SMP_COUNT) + 1; // Fix for Palacios
144 MaxCountCPUs = qemu_cfg_get_max_cpus();
145 if (!MaxCountCPUs || MaxCountCPUs < CountCPUs)