Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Avoid strict-aliasing related issues when compiling with optimization
[palacios.git] / bios / seabios / palacios_fixes.patch
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
10
11 ---
12  src/acpi.c    |   44 +++++++++++++++++++++++++++++---------------
13  src/pciinit.c |    2 +-
14  src/smp.c     |    5 ++++-
15  3 files changed, 34 insertions(+), 17 deletions(-)
16
17 diff --git a/src/acpi.c b/src/acpi.c
18 index 3d8b7c8..7d50990 100644
19 --- a/src/acpi.c
20 +++ b/src/acpi.c
21 @@ -262,18 +262,32 @@ build_fadt(struct pci_device *pci)
22      fadt->dsdt = cpu_to_le32((u32)dsdt);
23      fadt->model = 1;
24      fadt->reserved1 = 0;
25 -    int pm_sci_int = pci_config_readb(pci->bdf, PCI_INTERRUPT_LINE);
26 +    int pm_sci_int;
27 +    if (pci)
28 +        pci_config_readb(pci->bdf, PCI_INTERRUPT_LINE);
29 +    else
30 +        pm_sci_int = 0;
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;
39 +    if (pci) {
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);
48 +    } else {
49 +        fadt->smi_cmd = 0;
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;
56 +    }
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));
62  
63 @@ -516,6 +530,7 @@ build_srat(void)
64      if (nb_numa_nodes == 0)
65          return NULL;
66  
67 +
68      u64 *numadata = malloc_tmphigh(sizeof(u64) * (MaxCountCPUs + nb_numa_nodes));
69      if (!numadata) {
70          warn_noalloc();
71 @@ -577,7 +592,7 @@ build_srat(void)
72          next_base = mem_base + mem_len;
73  
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;
78              if (mem_len > 0) {
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;
84 -        }
85 +        }*/
86          acpi_build_srat_memory(numamem, mem_base, mem_len, i-1, 1);
87          numamem++;
88          slots++;
89 @@ -623,9 +638,7 @@ acpi_bios_init(void)
90  
91      // This code is hardcoded for PIIX4 Power Management device.
92      struct pci_device *pci = pci_find_init_device(acpi_find_tbl, NULL);
93 -    if (!pci)
94 -        // Device not found
95 -        return;
96 +    // If no PIIX4 is found we will not build certain structures and init it.
97  
98      // Build ACPI tables
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());
105 +    if(pci)
106 +        ACPI_INIT_TABLE(build_hpet());
107      ACPI_INIT_TABLE(build_srat());
108  
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
112 --- a/src/pciinit.c
113 +++ b/src/pciinit.c
114 @@ -575,7 +575,7 @@ static int pci_bios_init_root_regions(u32 start, u32 end)
115  void
116  pci_setup(void)
117  {
118 -    if (CONFIG_COREBOOT || usingXen()) {
119 +    if (1 || CONFIG_COREBOOT || usingXen()) {
120          // PCI setup already done by coreboot or Xen - just do probe.
121          pci_probe_devices();
122          return;
123 diff --git a/src/smp.c b/src/smp.c
124 index 8c077a1..21e7437 100644
125 --- a/src/smp.c
126 +++ b/src/smp.c
127 @@ -81,7 +81,7 @@ smp_probe(void)
128          MaxCountCPUs = 1;
129          return;
130      }
131 -
132 +#if 0
133      // Init the counter.
134      writel(&CountCPUs, 1);
135  
136 @@ -121,6 +121,9 @@ smp_probe(void)
137  
138      // Restore memory.
139      *(u64*)BUILD_AP_BOOT_ADDR = old;
140 +#endif
141
142 +    CountCPUs = inb_cmos(CMOS_BIOS_SMP_COUNT) + 1; // Fix for Palacios
143  
144      MaxCountCPUs = qemu_cfg_get_max_cpus();
145      if (!MaxCountCPUs || MaxCountCPUs < CountCPUs)
146 -- 
147 1.7.5.4