Пример #1
0
 def run(self):
     t = time()
     try:
         self._cmos = CMOS(self.cs)
     except CmosRuntimeError, msg:
         print msg
         return
Пример #2
0
    def run(self):
        if len(self.argv) < 3:
            print CMOSCommand.__doc__
            return

        try:
            _cmos = CMOS(self.cs)
        except CmosRuntimeError, msg:
            print msg
            return
Пример #3
0
def cmos(argv):
    if 3 > len(argv):
        print usage
        return

    try:
        cmos = CMOS()
    except CmosRuntimeError, msg:
        print msg
        return
Пример #4
0
    def run(self):
        t = time()
        try:
            self._cmos = CMOS(self.cs)
        except CmosRuntimeError as msg:
            print(msg)
            return

        self.func()
        self.logger.log("[CHIPSEC] (cmos) time elapsed {:.3f}".format(time() -
                                                                      t))
Пример #5
0
def cmos(argv):
    """
    >>> chipsec_util cmos dump
    >>> chipsec_util cmos readl|writel|readh|writeh <byte_offset> [byte_val]

    Examples:

    >>> chipsec_util cmos dump
    >>> chipsec_util cmos rl 0x0
    >>> chipsec_util cmos wh 0x0 0xCC
    """
    if 3 > len(argv):
        print cmos.__doc__
        return

    try:
        _cmos = CMOS()
    except CmosRuntimeError, msg:
        print msg
        return
Пример #6
0
 def __init__(self):
     BaseModule.__init__(self)
     self.cmos = CMOS(self.cs)
     self.user_request = False
     self.test_offset = 0x38
     self.test_value = 0xAA
Пример #7
0
class rtclock(BaseModule):
    def __init__(self):
        BaseModule.__init__(self)
        self.cmos = CMOS(self.cs)
        self.user_request = False
        self.test_offset = 0x38
        self.test_value = 0xAA

    def is_supported(self):
        if self.cs.is_core() or (self.cs.get_chipset_code()
                                 == CHIPSET_CODE_AVN):
            return True
        self.logger.log_important('Not a Core platform.  Skipping check.')
        self.res = ModuleResult.NOTAPPLICABLE
        return False

    def check_rtclock(self):
        self.logger.start_test("Protected RTC memory locations")
        ll = ul = 0
        check_config_regs = self.cs.read_register('RC') != 0xFFFFFFFF

        if check_config_regs:
            rc_reg = self.cs.read_register('RC')
            self.cs.print_register('RC', rc_reg)
            ll = self.cs.get_register_field('RC', rc_reg, 'LL')
            ul = self.cs.get_register_field('RC', rc_reg, 'UL')
        elif self.user_request:
            self.logger.warn(
                'Writing to CMOS to determine write protection (original values will be restored)'
            )

            # Try to modify the low RTC memory regions.
            original_val = self.cmos.read_cmos_low(self.test_offset)
            self.cmos.write_cmos_low(self.test_offset,
                                     original_val ^ self.test_value)
            if original_val == self.cmos.read_cmos_low(self.test_offset):
                ll = 1
            else:
                self.logger.warn('Restoring original value')
                self.cmos.write_cmos_low(self.test_offset, original_val)

            # Try to modify the upper RTC memory regions.
            original_val = self.cmos.read_cmos_high(self.test_offset)
            self.cmos.write_cmos_high(self.test_offset,
                                      original_val ^ self.test_value)
            if original_val == self.cmos.read_cmos_high(self.test_offset):
                ul = 1
            else:
                self.logger.warn('Restoring original value')
                self.cmos.write_cmos_high(self.test_offset, original_val)
        else:
            self.logger.warn(
                "Unable to test lock bits without attempting to modify CMOS.")
            self.logger.log(
                "[*] Run chipsec_main manually with the following commandline flags."
            )
            self.logger.log(
                "[*] python chipsec_main -m common.rtclock -a modify")
            return ModuleResult.WARNING

        if ll == 1:
            self.logger.log_good(
                "Protected bytes (0x38-0x3F) in low 128-byte bank of RTC memory are locked"
            )
        else:
            self.logger.log_bad(
                "Protected bytes (0x38-0x3F) in low 128-byte bank of RTC memory are not locked"
            )
        if ul == 1:
            self.logger.log_good(
                "Protected bytes (0x38-0x3F) in high 128-byte bank of RTC memory are locked"
            )
        else:
            self.logger.log_bad(
                "Protected bytes (0x38-0x3F) in high 128-byte bank of RTC memory are not locked"
            )

        if ll == 1 and ul == 1:
            res = ModuleResult.PASSED
            self.logger.log_passed(
                "Protected locations in RTC memory are locked")
        else:
            res = ModuleResult.WARNING
            self.logger.log_warning(
                "Protected locations in RTC memory are accessible (BIOS may not be using them)"
            )

        return res

    # --------------------------------------------------------------------------
    # run( module_argv )
    # Required function: run here all tests from this module
    # --------------------------------------------------------------------------
    def run(self, module_argv):
        if len(module_argv) >= 1:
            if module_argv[0].lower() == 'modify':
                self.user_request = True
        self.res = self.check_rtclock()
        return self.res