static int ebda_init(fwts_framework *fw) { if (fw->firmware_type != FWTS_FIRMWARE_BIOS) { fwts_log_info(fw, "Machine is not using traditional BIOS firmware, skipping test."); return FWTS_SKIP; } if ((memory_map = fwts_memory_map_table_load(fw)) == NULL) { fwts_log_error(fw, "Failed to read memory map."); return FWTS_ERROR; } if ((ebda_addr = fwts_ebda_get()) == FWTS_NO_EBDA) { fwts_log_error(fw, "Failed to locate EBDA region."); return FWTS_ERROR; } return FWTS_OK; }
static int memory_mapdump_util(fwts_framework *fw) { fwts_list *memory_mapdump_memory_map_info; if ((memory_mapdump_memory_map_info = fwts_memory_map_table_load(fw)) == NULL) { fwts_log_warning(fw, "Cannot memory map table from /sys/firmware/memmap " "or kernel log."); return FWTS_ERROR; } fwts_memory_map_table_dump(fw, memory_mapdump_memory_map_info); fwts_memory_map_table_free(memory_mapdump_memory_map_info); fwts_infoonly(fw); return FWTS_OK; }
static int mcfg_test1(fwts_framework *fw) { int nr, i; fwts_acpi_table_mcfg *mcfg = (fwts_acpi_table_mcfg*)mcfg_table->data; fwts_acpi_mcfg_configuration *config; bool failed = false; ssize_t mcfg_size; const char *memory_map_name; memory_map_name = fwts_memory_map_name(fw->firmware_type); fwts_log_info(fw, "This test tries to validate the MCFG table by comparing the first " "16 bytes in the MMIO mapped config space with the 'traditional' config " "space of the first PCI device (root bridge). The MCFG data is only " "trusted if it is marked reserved in the %s", memory_map_name); fwts_log_nl(fw); if ((memory_map_list = fwts_memory_map_table_load(fw)) == NULL) { /* Not fatal, just means test will be less comprehensive */ fwts_log_warning(fw, "No memory map table found"); } else { fwts_memory_map_table_dump(fw, memory_map_list); fwts_log_nl(fw); } mcfg_size = mcfg_table->length; mcfg_size -= sizeof(fwts_acpi_table_mcfg); if (mcfg_size < 0) { fwts_failed(fw, LOG_LEVEL_HIGH, "MCFGInvalidSize", "Invalid MCFG ACPI table size: got %zd bytes expecting more", mcfg_size + sizeof(fwts_acpi_table_mcfg)); fwts_advice(fw, "MCFG table must be least %zd bytes (header size) with " "multiples of %zd bytes for each MCFG entry.", sizeof(fwts_acpi_table_mcfg), sizeof(fwts_acpi_mcfg_configuration)); return FWTS_ERROR; } nr = mcfg_size / sizeof(fwts_acpi_mcfg_configuration); if (!nr) { fwts_failed(fw, LOG_LEVEL_MEDIUM, "MCFGNoEntries", "No MCFG ACPI table entries"); return FWTS_ERROR; } if (mcfg_size != (ssize_t)(nr * sizeof(fwts_acpi_mcfg_configuration))) { fwts_failed(fw, LOG_LEVEL_HIGH, "MCFGInvalidSize2", "MCFG table is not a multiple of record size"); return FWTS_ERROR; } fwts_log_info(fw, "MCFG table found, size is %zd bytes (excluding header) (%i entries).", mcfg_size, nr); if (mcfg == NULL) { fwts_failed(fw, LOG_LEVEL_HIGH, "MCFGInvalidTable", "Invalid MCFG ACPI table"); return FWTS_ERROR; } if (memory_map_list == NULL) fwts_failed(fw, LOG_LEVEL_MEDIUM, "MMapUnreadable", "Cannot check MCFG MMIO space against memory map table: could not read memory map table."); config = &mcfg->configuration[0]; for (i = 0; i < nr; i++, config++) { fwts_log_info_verbatim(fw, "Configuration Entry #%d:", i); fwts_log_info_verbatim(fw, " Base Address : 0x%" PRIx64, config->base_address); fwts_log_info_verbatim(fw, " Segment : %" PRIu8, config->pci_segment_group_number); fwts_log_info_verbatim(fw, " Start bus : %" PRIu8, config->start_bus_number); fwts_log_info_verbatim(fw, " End bus : %" PRIu8, config->end_bus_number); if ((memory_map_list != NULL) && (!fwts_memory_map_is_reserved(memory_map_list, config->base_address))) { fwts_failed(fw, LOG_LEVEL_LOW, "MCFGMMIONotReserved", "MCFG MMIO config space at 0x%" PRIx64 " is not reserved in the memory map table", config->base_address); fwts_advice(fw, "The PCI Express specification states that the " "PCI Express configuration space should " "be defined in the MCFG table and *maybe* " "optionally defined in the %s if ACPI MCFG is " "present. Linux checks if the region is reserved " "in the memory map table and will reject the " "MMCONFIG if there is a discrepency between MCFG " "and the memory map table for the PCI Express region. " "[See arch/x86/pci/mmconfig-shared.c pci_mmcfg_reject_broken()]. " "It is recommended that this is defined in the " "%s table for Linux.", memory_map_name, memory_map_name); failed = true; } } if (!failed) fwts_passed(fw, "MCFG MMIO config space is reserved in memory map table."); return FWTS_OK; }