Exemplo n.º 1
0
    def run(self):
        if len(self.argv) < 3:
            print(UCodeCommand.__doc__)
            return

        ucode_op = self.argv[2]
        t = time.time()

        if ('load' == ucode_op):
            if (4 == len(self.argv)):
                ucode_filename = self.argv[3]
                self.logger.log(
                    "[CHIPSEC] Loading Microcode update on all cores from '{}'"
                    .format(ucode_filename))
                self.cs.ucode.update_ucode_all_cpus(ucode_filename)
            elif (5 == len(self.argv)):
                ucode_filename = self.argv[3]
                cpu_thread_id = int(self.argv[4], 16)
                self.logger.log(
                    "[CHIPSEC] Loading Microcode update on CPU{:d} from '{}'".
                    format(cpu_thread_id, ucode_filename))
                self.cs.ucode.update_ucode(cpu_thread_id, ucode_filename)
            else:
                print(UCodeCommand.__doc__)
                return
        elif ('decode' == ucode_op):
            if (4 == len(self.argv)):
                ucode_filename = self.argv[3]
                if (not ucode_filename.endswith('.pdb')):
                    self.logger.log(
                        "[CHIPSEC] Ucode update file is not PDB file: '{}'".
                        format(ucode_filename))
                    return
                pdb_ucode_buffer = read_file(ucode_filename)
                self.logger.log(
                    "[CHIPSEC] Decoding Microcode Update header of PDB file: '{}'"
                    .format(ucode_filename))
                dump_ucode_update_header(pdb_ucode_buffer)
        elif ('id' == ucode_op):
            if (3 == len(self.argv)):
                for tid in range(self.cs.msr.get_cpu_thread_count()):
                    ucode_update_id = self.cs.ucode.ucode_update_id(tid)
                    self.logger.log(
                        "[CHIPSEC] CPU{:d}: Microcode update ID = 0x{:08X}".
                        format(tid, ucode_update_id))
            elif (4 == len(self.argv)):
                cpu_thread_id = int(self.argv[3], 16)
                ucode_update_id = self.cs.ucode.ucode_update_id(cpu_thread_id)
                self.logger.log(
                    "[CHIPSEC] CPU{:d}: Microcode update ID = 0x{:08X}".format(
                        cpu_thread_id, ucode_update_id))
        else:
            self.logger.error(
                "unknown command-line option '{:32}'".format(ucode_op))
            print(UCodeCommand.__doc__)
            return

        self.logger.log(
            "[CHIPSEC] (ucode) time elapsed {:.3f}".format(time.time() - t))
Exemplo n.º 2
0
def ucode(argv):

    if 3 > len(argv):
        print usage
        return

    ucode_op = argv[2]
    t = time.time()

    if ('load' == ucode_op):
        if (4 == len(argv)):
            ucode_filename = argv[3]
            logger().log(
                "[CHIPSEC] Loading Microcode update on all cores from '%.64s'"
                % ucode_filename)
            chipsec_util._cs.ucode.update_ucode_all_cpus(ucode_filename)
        elif (5 == len(argv)):
            ucode_filename = argv[3]
            cpu_thread_id = int(argv[4], 16)
            logger().log(
                "[CHIPSEC] Loading Microcode update on CPU%d from '%.64s'" %
                (cpu_thread_id, ucode_filename))
            chipsec_util._cs.ucode.update_ucode(cpu_thread_id, ucode_filename)
        else:
            print usage
            return
    elif ('decode' == ucode_op):
        if (4 == len(argv)):
            ucode_filename = argv[3]
            if (not ucode_filename.endswith('.pdb')):
                logger().log(
                    "[CHIPSEC] Ucode update file is not PDB file: '%.256s'" %
                    ucode_filename)
                return
            pdb_ucode_buffer = read_file(ucode_filename)
            logger().log(
                "[CHIPSEC] Decoding Microcode Update header of PDB file: '%.256s'"
                % ucode_filename)
            dump_ucode_update_header(pdb_ucode_buffer)
    elif ('id' == ucode_op):
        if (3 == len(argv)):
            for tid in range(chipsec_util._cs.msr.get_cpu_thread_count()):
                ucode_update_id = chipsec_util._cs.ucode.ucode_update_id(tid)
                logger().log("[CHIPSEC] CPU%d: Microcode update ID = 0x%08X" %
                             (tid, ucode_update_id))
        elif (4 == len(argv)):
            cpu_thread_id = int(argv[3], 16)
            ucode_update_id = chipsec_util._cs.ucode.ucode_update_id(
                cpu_thread_id)
            logger().log("[CHIPSEC] CPU%d: Microcode update ID = 0x%08X" %
                         (cpu_thread_id, ucode_update_id))
    else:
        logger().error("unknown command-line option '%.32s'" % ucode_op)
        print usage
        return

    logger().log("[CHIPSEC] (ucode) time elapsed %.3f" % (time.time() - t))
Exemplo n.º 3
0
 def ucode_decode(self):
     if (not self.ucode_filename.endswith('.pdb')):
         self.logger.log(
             "[CHIPSEC] Ucode update file is not PDB file: '{}'".format(
                 self.ucode_filename))
         return
     pdb_ucode_buffer = read_file(self.ucode_filename)
     self.logger.log(
         "[CHIPSEC] Decoding Microcode Update header of PDB file: '{}'".
         format(self.ucode_filename))
     dump_ucode_update_header(pdb_ucode_buffer)
Exemplo n.º 4
0
def ucode(argv):
    """
    >>> chipsec_util ucode id|load|decode [ucode_update_file (in .PDB or .BIN format)] [cpu_id]

    Examples:

    >>> chipsec_util ucode id
    >>> chipsec_util ucode load ucode.bin 0
    >>> chipsec_util ucode decode ucode.pdb
    """
    if 3 > len(argv):
        print ucode.__doc__
        return

    ucode_op = argv[2]
    t = time.time()

    if ( 'load' == ucode_op ):
        if (4 == len(argv)):
            ucode_filename = argv[3]
            logger().log( "[CHIPSEC] Loading Microcode update on all cores from '%s'" % ucode_filename )
            chipsec_util._cs.ucode.update_ucode_all_cpus( ucode_filename )
        elif (5 == len(argv)):
            ucode_filename = argv[3]
            cpu_thread_id = int(argv[4],16)
            logger().log( "[CHIPSEC] Loading Microcode update on CPU%d from '%s'" % (cpu_thread_id, ucode_filename) )
            chipsec_util._cs.ucode.update_ucode( cpu_thread_id, ucode_filename )
        else:
            print ucode.__doc__
            return
    elif ( 'decode' == ucode_op ):
        if (4 == len(argv)):
            ucode_filename = argv[3]
            if (not ucode_filename.endswith('.pdb')):
                logger().log( "[CHIPSEC] Ucode update file is not PDB file: '%s'" % ucode_filename )
                return
            pdb_ucode_buffer = read_file( ucode_filename )
            logger().log( "[CHIPSEC] Decoding Microcode Update header of PDB file: '%s'" % ucode_filename )
            dump_ucode_update_header( pdb_ucode_buffer )
    elif ( 'id' == ucode_op ):
        if (3 == len(argv)):
            for tid in range(chipsec_util._cs.msr.get_cpu_thread_count()):
                ucode_update_id = chipsec_util._cs.ucode.ucode_update_id( tid )
                logger().log( "[CHIPSEC] CPU%d: Microcode update ID = 0x%08X" % (tid, ucode_update_id) )
        elif (4 == len(argv)):
            cpu_thread_id = int(argv[3],16)
            ucode_update_id = chipsec_util._cs.ucode.ucode_update_id( cpu_thread_id )
            logger().log( "[CHIPSEC] CPU%d: Microcode update ID = 0x%08X" % (cpu_thread_id, ucode_update_id) )
    else:
        logger().error( "unknown command-line option '%.32s'" % ucode_op )
        print ucode.__doc__
        return

    logger().log( "[CHIPSEC] (ucode) time elapsed %.3f" % (time.time()-t) )
Exemplo n.º 5
0
def ucode(argv):

    if 3 > len(argv):
        print usage
        return

    ucode_op = argv[2]
    t = time.time()

    if "load" == ucode_op:
        if 4 == len(argv):
            ucode_filename = argv[3]
            logger().log("[CHIPSEC] Loading Microcode update on all cores from '%.64s'" % ucode_filename)
            _cs.ucode.update_ucode_all_cpus(ucode_filename)
        elif 5 == len(argv):
            ucode_filename = argv[3]
            cpu_thread_id = int(argv[4], 16)
            logger().log("[CHIPSEC] Loading Microcode update on CPU%d from '%.64s'" % (cpu_thread_id, ucode_filename))
            _cs.ucode.update_ucode(cpu_thread_id, ucode_filename)
        else:
            print usage
            return
    elif "decode" == ucode_op:
        if 4 == len(argv):
            ucode_filename = argv[3]
            if not ucode_filename.endswith(".pdb"):
                logger().log("[CHIPSEC] Ucode update file is not PDB file: '%.256s'" % ucode_filename)
                return
            pdb_ucode_buffer = read_file(ucode_filename)
            logger().log("[CHIPSEC] Decoding Microcode Update header of PDB file: '%.256s'" % ucode_filename)
            dump_ucode_update_header(pdb_ucode_buffer)
    elif "id" == ucode_op:
        if 3 == len(argv):
            for tid in range(_cs.msr.get_cpu_thread_count()):
                ucode_update_id = _cs.ucode.ucode_update_id(tid)
                logger().log("[CHIPSEC] CPU%d: Microcode update ID = 0x%08X" % (tid, ucode_update_id))
        elif 4 == len(argv):
            cpu_thread_id = int(argv[3], 16)
            ucode_update_id = _cs.ucode.ucode_update_id(cpu_thread_id)
            logger().log("[CHIPSEC] CPU%d: Microcode update ID = 0x%08X" % (cpu_thread_id, ucode_update_id))
    else:
        logger().error("unknown command-line option '%.32s'" % ucode_op)
        print usage
        return

    logger().log("[CHIPSEC] (ucode) time elapsed %.3f" % (time.time() - t))
Exemplo n.º 6
0
    def run(self):
        if len(self.argv) < 3:
            print UCodeCommand.__doc__
            return

        ucode_op = self.argv[2]
        t = time.time()

        if ( 'load' == ucode_op ):
            if (4 == len(self.argv)):
                ucode_filename = self.argv[3]
                self.logger.log( "[CHIPSEC] Loading Microcode update on all cores from '%s'" % ucode_filename )
                self.cs.ucode.update_ucode_all_cpus( ucode_filename )
            elif (5 == len(self.argv)):
                ucode_filename = self.argv[3]
                cpu_thread_id = int(self.argv[4],16)
                self.logger.log( "[CHIPSEC] Loading Microcode update on CPU%d from '%s'" % (cpu_thread_id, ucode_filename) )
                self.cs.ucode.update_ucode( cpu_thread_id, ucode_filename )
            else:
                print UCodeCommand.__doc__
                return
        elif ( 'decode' == ucode_op ):
            if (4 == len(self.argv)):
                ucode_filename = self.argv[3]
                if (not ucode_filename.endswith('.pdb')):
                    self.logger.log( "[CHIPSEC] Ucode update file is not PDB file: '%s'" % ucode_filename )
                    return
                pdb_ucode_buffer = read_file( ucode_filename )
                self.logger.log( "[CHIPSEC] Decoding Microcode Update header of PDB file: '%s'" % ucode_filename )
                dump_ucode_update_header( pdb_ucode_buffer )
        elif ( 'id' == ucode_op ):
            if (3 == len(self.argv)):
                for tid in range(self.cs.msr.get_cpu_thread_count()):
                    ucode_update_id = self.cs.ucode.ucode_update_id( tid )
                    self.logger.log( "[CHIPSEC] CPU%d: Microcode update ID = 0x%08X" % (tid, ucode_update_id) )
            elif (4 == len(self.argv)):
                cpu_thread_id = int(self.argv[3],16)
                ucode_update_id = self.cs.ucode.ucode_update_id( cpu_thread_id )
                self.logger.log( "[CHIPSEC] CPU%d: Microcode update ID = 0x%08X" % (cpu_thread_id, ucode_update_id) )
        else:
            self.logger.error( "unknown command-line option '%.32s'" % ucode_op )
            print UCodeCommand.__doc__
            return

        self.logger.log( "[CHIPSEC] (ucode) time elapsed %.3f" % (time.time()-t) )