diff --git a/README.md b/README.md index 216d5f7..ec959e4 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,12 @@ The following command will extract the BIOS firmware and save the image to `bios_image.bin`: ```bash sudo .build/pawn bios_image.bin -``` +``` -You can then use other tools like +Note: When running a Linux kernel > 4.8.4, make sure that either +`CONFIG_IO_DEVMEM=n` is set or that you've booted with the `iomem=relaxed` +boot option. + +After extraction, you can then use other tools like [UEFITool](https://github.com/LongSoft/UEFITool) to process the firmware image further. diff --git a/pawn.cc b/pawn.cc index b693726..3ee95ee 100644 --- a/pawn.cc +++ b/pawn.cc @@ -62,10 +62,20 @@ int PawnMain(const char* dump_filename) { "Mapping 16KiB chipset configuration space at RCBA = 0x%8X, this may " "fail...\n", rcba.base_address); - QCHECK_OK(chipset->MapRootComplex(rcba)); + status = chipset->MapRootComplex(rcba); + if (!status.ok()) { + printf( + "Error: %s\n" + " Check if your kernel was compiled with IO_STRICT_DEVMEM=y.\n" + " On Debian kernels > 4.8.4, boot with iomem=relaxed to\n" + " temporarily disable /dev/mem IO protection.\n", + status.error_message().c_str()); + return EXIT_FAILURE; + } auto gcs = chipset->ReadGcsRegister(); - const char* kBootBiosStrapsDesc[] = {"LPC", "Reserved", "PCI", "SPI"}; + constexpr const char* kBootBiosStrapsDesc[] = {"LPC", "Reserved", "PCI", + "SPI"}; printf("Boot BIOS Straps (BBS): %s\n", kBootBiosStrapsDesc[gcs.boot_bios_straps]); if (gcs.boot_bios_straps != Chipset::kBbsSpi) { diff --git a/physical_memory.cc b/physical_memory.cc index c4b69b5..d583e7d 100644 --- a/physical_memory.cc +++ b/physical_memory.cc @@ -51,6 +51,7 @@ util::Status PhysicalMemory::Init(uintptr_t physical_offset, size_t length) { mem_ = mmap(nullptr /* Address hint */, length_, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd_, physical_offset); if (mem_ == MAP_FAILED) { + mem_ = nullptr; string error(std::strerror(errno)); return util::Status(util::error::FAILED_PRECONDITION, string("Could not map physical memory: ") + error);