diff --git a/me_cleaner.py b/me_cleaner.py index 8c0dac4..1b35f8d 100755 --- a/me_cleaner.py +++ b/me_cleaner.py @@ -27,6 +27,7 @@ min_ftpr_offset = 0x400 spared_blocks = 4 unremovable_modules = ("ROMP", "BUP") unremovable_modules_me11 = ("rbe", "kernel", "syslib", "bup") +unremovable_partitions = ["FTPR"] class OutOfRegionException(Exception): @@ -457,6 +458,11 @@ if __name__ == "__main__": action="store_true") parser.add_argument("-k", "--keep-modules", help="don't remove the FTPR " "modules, even when possible", action="store_true") + parser.add_argument("-w", "--whitelist", metavar="whitelist", + help="Comma separated list of extra partitions to keep" + "in the final image. This can be used to specify the " + "MFS partition for example, which stores PCIe and " + "clock settings") parser.add_argument("-d", "--descriptor", help="remove the ME/TXE " "Read/Write permissions to the other regions on the " "flash from the Intel Flash Descriptor (requires a " @@ -603,13 +609,51 @@ if __name__ == "__main__": if not args.check: if not args.soft_disable_only: - print("Removing extra partitions...") - mef.fill_range(me_start + 0x30, ftpr_offset, b"\xff") - mef.fill_range(ftpr_offset + ftpr_length, me_end, b"\xff") + print("Reading partitions list...") + unremovable_part = [] + unremovable_part_fpt = b"" - print("Removing extra partition entries in FPT...") - mef.write_to(me_start + 0x30, ftpr_header) - mef.write_to(me_start + 0x14, pack(" me_end: + print(" {:<4} ({:^23}, 0x{:08x} total bytes): nothing to " + "remove" + .format(part_name, "no data here", part_length)) + else: + sys.stdout.write(" {:<4} (0x{:08x} - 0x{:08x}, 0x{:08x} " + "total bytes): ".format(part_name, + part_start, + part_end, + part_length)) + if part_name in unremovable_part: + unremovable_part_fpt += partition + print("NOT removed") + else: + mef.fill_range(me_start + part_start, + me_start + part_end, b"\xff") + print("removed") + + print("Removing partition entries in FPT...") + mef.write_to(me_start + 0x30, unremovable_part_fpt) + mef.write_to(me_start + 0x14, + pack("