UPSTREAM: intelmetool: handle failures to mmap MEI memory

Fixes crashes when there is an error mapping memory.

    Error mapping physical memory 0x0000004275159040 [0x4000] ERRNO=1
    Segmentation fault (core dumped)

BUG=none
BRANCH=none
TEST=none

Change-Id: I89bacbb2ff0e0c00cdb9c768efb9fa04f9470e5c
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: e311f94279
Original-Change-Id: I5becc0c2870dd97297c4e8d1b101b95b31792ca7
Original-Signed-off-by: Paul Wise <pabs3@bonedaddy.net>
Original-Reviewed-on: https://review.coreboot.org/19562
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Original-Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-on: https://chromium-review.googlesource.com/497402
This commit is contained in:
Paul Wise 2017-05-04 14:13:38 +08:00 committed by chrome-bot
parent dab89ffba1
commit 3633751908
2 changed files with 14 additions and 0 deletions

View file

@ -83,6 +83,10 @@ static void dump_me_memory() {
uint8_t *dump;
dump = map_physical_exact((off_t)me_clone, (void *)me_clone, 0x2000000);
if (dump == NULL) {
printf("Could not map ME memory\n");
return;
}
zeroit(dump, 0x2000000);
printf("Send magic command for memory clone\n");
@ -210,6 +214,12 @@ static int activate_me() {
rcba_phys = pci_read_long(sb, 0xf0) & 0xfffffffe;
rcba = map_physical((off_t)rcba_phys, size);
if (rcba == NULL) {
printf("Could not map MEI PCI device memory\n");
pci_free_dev(sb);
pci_cleanup(pacc);
return 1;
}
//printf("RCBA at 0x%08" PRIx32 "\n", (uint32_t)rcba_phys);
fd2 = *(uint32_t *)(rcba + FD2);

View file

@ -581,6 +581,10 @@ uint32_t intel_mei_setup(struct pci_dev *dev)
mei_base_address = dev->base_addr[0] & ~0xf;
pagerounded = mei_base_address & ~0xfff;
mei_mmap = map_physical(pagerounded, 0x2000) + mei_base_address - pagerounded;
if (mei_mmap == NULL) {
printf("Could not map ME setup memory\n");
return 1;
}
/* Ensure Memory and Bus Master bits are set */
reg32 = pci_read_long(dev, PCI_COMMAND);