--- qemu/roms/seabios/src/acpi.c 2018/04/24 17:36:48 1.1.1.1 +++ qemu/roms/seabios/src/acpi.c 2018/04/24 18:27:43 1.1.1.4 @@ -303,7 +303,7 @@ build_fadt(int bdf) void *dsdt = malloc_high(sizeof(AmlCode)); if (!fadt || !facs || !dsdt) { - dprintf(1, "Not enough memory for fadt!\n"); + warn_noalloc(); return NULL; } @@ -353,7 +353,7 @@ build_madt(void) + sizeof(struct madt_intsrcovr) * 16); struct multiple_apic_table *madt = malloc_high(madt_size); if (!madt) { - dprintf(1, "Not enough memory for madt!\n"); + warn_noalloc(); return NULL; } memset(madt, 0, madt_size); @@ -418,7 +418,7 @@ build_ssdt(void) int length = sizeof(struct acpi_table_header) + 3 + cpu_length; u8 *ssdt = malloc_high(length); if (! ssdt) { - dprintf(1, "No space for ssdt!\n"); + warn_noalloc(); return NULL; } @@ -429,10 +429,12 @@ build_ssdt(void) // build processor scope header *(ssdt_ptr++) = 0x10; // ScopeOp if (cpu_length <= 0x3e) { + /* Handle 1-4 CPUs with one byte encoding */ *(ssdt_ptr++) = cpu_length + 1; } else { - *(ssdt_ptr++) = 0x7F; - *(ssdt_ptr++) = (cpu_length + 2) >> 6; + /* Handle 5-314 CPUs with two byte encoding */ + *(ssdt_ptr++) = 0x40 | ((cpu_length + 2) & 0xf); + *(ssdt_ptr++) = (cpu_length + 2) >> 4; } *(ssdt_ptr++) = '_'; // Name *(ssdt_ptr++) = 'P'; @@ -471,7 +473,7 @@ build_hpet(void) { struct acpi_20_hpet *hpet = malloc_high(sizeof(*hpet)); if (!hpet) { - dprintf(1, "Not enough memory for hpet!\n"); + warn_noalloc(); return NULL; } @@ -512,7 +514,7 @@ build_srat(void) u64 *numadata = malloc_tmphigh(sizeof(u64) * (MaxCountCPUs + nb_numa_nodes)); if (!numadata) { - dprintf(1, "Not enough memory for read numa data from VM!\n"); + warn_noalloc(); return NULL; } @@ -525,7 +527,8 @@ build_srat(void) srat = malloc_high(srat_size); if (!srat) { - dprintf(1, "Not enough memory for srat table!\n"); + warn_noalloc(); + free(numadata); return NULL; } @@ -592,6 +595,7 @@ build_srat(void) build_header((void*)srat, SRAT_SIGNATURE, srat_size, 1); + free(numadata); return srat; } @@ -616,7 +620,7 @@ acpi_bios_init(void) // Create initial rsdt table struct rsdp_descriptor *rsdp = malloc_fseg(sizeof(*rsdp)); if (!rsdp) { - dprintf(1, "Not enough memory for acpi rsdp table!\n"); + warn_noalloc(); return; } @@ -642,13 +646,12 @@ acpi_bios_init(void) u16 len = qemu_cfg_next_acpi_table_len(); void *addr = malloc_high(len); if (!addr) { - dprintf(1, "Not enough memory for ext acpi table of size %d!\n" - , len); + warn_noalloc(); continue; } ACPI_INIT_TABLE(qemu_cfg_next_acpi_table_load(addr, len)); if (tbl_idx == MAX_ACPI_TABLES) { - dprintf(1, "Too many external tables!\n"); + warn_noalloc(); break; } } @@ -658,7 +661,7 @@ acpi_bios_init(void) rsdt = malloc_high(rsdt_len); if (!rsdt) { - dprintf(1, "Not enough memory for acpi rsdt table!\n"); + warn_noalloc(); return; } memset(rsdt, 0, rsdt_len); @@ -677,7 +680,7 @@ acpi_bios_init(void) } u32 -find_resume_vector() +find_resume_vector(void) { dprintf(4, "rsdp=%p\n", RsdpAddr); if (!RsdpAddr || RsdpAddr->signature != RSDP_SIGNATURE)