def display_vendor_error_type_extension(): with ttypager.page(): entry = get_action(SET_ERROR_TYPE_WITH_ADDRESS) set_err = acpi.set_error_type_with_addr.from_address(entry.register_region.address) vendor_err_addr = entry.register_region.address + set_err.vendor_error_type_extension_structure_offset vendor_err = acpi.vendor_error_type_extension.from_address(vendor_err_addr) print(vendor_err)
def show_autodemotion(): with ttypager.page(): if bitfields.getbits(bits.rdmsr(bits.bsp_apicid(), 0xe2), 26, 25) == 0x3: print("C1 and C3 autodemotion are enabled") else: print("C1 and C3 autodemotion are disabled")
def variable_mtrrs(apicid=bits.bsp_apicid()): assert apicid in bits.cpus() ia32_mtrrcap_msr = IA32_MTRRCAP( bits.rdmsr(apicid, IA32_MTRRCAP_REG) ) ia32_mtrr_def_type_msr = IA32_MTRR_DEF_TYPE(bits.rdmsr(apicid, IA32_MTRR_DEF_TYPE_REG)) with ttypager.page(): print("Summary:") print("Default memory type: {}".format(_memory_type_str(ia32_mtrr_def_type_msr.type))) for i in range(ia32_mtrrcap_msr.VCNT): ia32_mtrr_physbase_msr = IA32_MTRR_PHYSBASE(bits.rdmsr(apicid, IA32_MTRR_PHYSBASEn_REG(i))) ia32_mtrr_physmask_msr = IA32_MTRR_PHYSMASK(bits.rdmsr(apicid, IA32_MTRR_PHYSMASKn_REG(i))) if (ia32_mtrr_physmask_msr.V): print("MTRR{}: type={:20} base={:10} size={:10}".format(i, _memory_type_str(ia32_mtrr_physbase_msr.Type), _physbase_str(ia32_mtrr_physbase_msr.PhysBase), _physmask_str(ia32_mtrr_physmask_msr.PhysMask))) print() print(ia32_mtrrcap_msr, end='\n\n') print(ia32_mtrr_def_type_msr, end='\n\n') for i in range(ia32_mtrrcap_msr.VCNT): msr_num = IA32_MTRR_PHYSBASEn_REG(i) ia32_mtrr_physbase_msr = IA32_MTRR_PHYSBASE( bits.rdmsr(apicid, msr_num) ) print("IA32_MTRR_PHYSBASE[{}] MSR {:#x}".format(i, msr_num)) print(ia32_mtrr_physbase_msr, end='\n\n') msr_num = IA32_MTRR_PHYSMASKn_REG(i) ia32_mtrr_physmask_msr = IA32_MTRR_PHYSMASK( bits.rdmsr(apicid, msr_num) ) print("IA32_MTRR_PHYSMASK[{}] MSR {:#x}".format(i, msr_num)) print(ia32_mtrr_physmask_msr, end='\n\n')
def print_fields(cls): with ttypager.page(): print("{}".format(cls.__name__)) print("{:20s} {:6} {:6}".format('field', 'length', 'offset')) for f in cls._fields_: a = getattr(cls, f[0]) print("{:20s} {:6} {:6}".format(f[0], a.size, a.offset))
def mwait_callback(use_mwait, name="", hint=0): for cpu in bits.cpus(): bits.set_mwait(cpu, use_mwait, hint, int_break_event) with ttypager.page(): if use_mwait: print("MWAIT enabled: {}".format(name)) else: print("MWAIT disabled")
def dump(): with ttypager.page(): for num, apicid in enumerate(bits.cpus()): heading = "Processor {} -- APIC ID {:#x}".format(num, apicid) cpu = cpus[apicid] print "{}\n{}".format(heading, "="*len(heading)) print "\n\n{}\n".format("".join(str(cpuid) for cpuid in cpu.cpuids)) print "\n\n{}\n".format("".join(str(msr) for msr in cpu.msrs))
def dump(): with ttypager.page(): for num, apicid in enumerate(bits.cpus()): heading = "Processor {} -- APIC ID {:#x}".format(num, apicid) cpu = cpus[apicid] print "{}\n{}".format(heading, "=" * len(heading)) print "\n\n{}\n".format("".join( str(cpuid) for cpuid in cpu.cpuids)) print "\n\n{}\n".format("".join(str(msr) for msr in cpu.msrs))
def callback(): with ttypager.page(): print(bits.brandstring()) if cpulib.__name__ == "cpu_gen": print("No processor-specific test exists!") print("Menu entries will only include generic tests that apply to all processors.") else: print("Detected as CPU codename: {}".format(cpulib.name)) print("Menu entries have been tailored to target this specific processor")
def display_vendor_error_type_extension(): with ttypager.page(): entry = get_action(SET_ERROR_TYPE_WITH_ADDRESS) set_err = acpi.set_error_type_with_addr.from_address( entry.register_region.address) vendor_err_addr = entry.register_region.address + set_err.vendor_error_type_extension_structure_offset vendor_err = acpi.vendor_error_type_extension.from_address( vendor_err_addr) print(vendor_err)
def display(): """Print processor topology to the screen via pager.""" with ttypager.page(): socket_dict = topology() for socket, core_dict in socket_dict.iteritems(): print 'socket {}'.format(_display_apicid(socket)) for core, threads in core_dict.iteritems(): print '| core {}'.format(_display_apicid(core)) for thread in threads: print '| | thread {}'.format(_display_apicid(thread)) print
def test_latency(count=0x10000): start = time.time() cpu_ping(count) stop = time.time() elapsed_ms = int((stop - start) * 1000) try: itermsg = "with {0} iteration/ms".format(int(round(count / elapsed_ms))) except ZeroDivisionError: itermsg = "cannot compute iterations/ms" with ttypager.page(): print("elapsed time = {} ms; {}".format(elapsed_ms, itermsg))
def callback(): with ttypager.page(): print(bits.brandstring()) if cpulib.__name__ == "cpu_gen": print("No processor-specific test exists!") print( "Menu entries will only include generic tests that apply to all processors." ) else: print("Detected as CPU codename: {}".format(cpulib.name)) print( "Menu entries have been tailored to target this specific processor" )
def demo(): unc_methods = [ inject_memory_unc_nonfatal_err, inject_memory_unc_fatal_err, inject_processor_unc_nonfatal_err, inject_processor_unc_fatal_err, inject_pcie_unc_nonfatal_err, inject_pcie_unc_fatal_err, inject_platform_unc_nonfatal_err, inject_platform_unc_fatal_err, ] corr_methods = [ inject_memory_correctable_err, inject_processor_correctable_err, inject_pcie_correctable_err, inject_platform_correctable_err, ] display_methods = [ display_einj, display_einj_address, display_supported_errors, display_triggers, display_vendor_error_type_extension, ] with ttypager.page(): for item in display_methods: print("\n\n\nMethod name: {}".format(item.__name__)) print("Method doc:\n{}\n\n".format( item.__doc__ if item. __doc__ else "No documentation for this method")) item() for item in corr_methods: print("\n\nMethod name: {}".format(item.__name__)) print("Method doc: {}".format(item.__doc__ if item.__doc__ else "No documentation for this method")) item() for item in unc_methods: print("\n\n\nMethod name: {}".format(item.__name__)) print("Method doc: {}\n\n".format( item.__doc__ if item. __doc__ else "No documentation for this method")) print( "Based on the name and documentation of this item, it is likely to be fatal." ) print("Execute it directly from the python command line.") print( "Your mileage may vary and if it breaks, you get to keep all the pieces." )
def demo(): unc_methods = [ inject_memory_unc_nonfatal_err, inject_memory_unc_fatal_err, inject_processor_unc_nonfatal_err, inject_processor_unc_fatal_err, inject_pcie_unc_nonfatal_err, inject_pcie_unc_fatal_err, inject_platform_unc_nonfatal_err, inject_platform_unc_fatal_err, ] corr_methods = [ inject_memory_correctable_err, inject_processor_correctable_err, inject_pcie_correctable_err, inject_platform_correctable_err, ] display_methods = [ display_einj, display_einj_address, display_supported_errors, display_triggers, display_vendor_error_type_extension, ] with ttypager.page(): for item in display_methods: print("\n\n\nMethod name: {}".format(item.__name__)) print("Method doc:\n{}\n\n".format(item.__doc__ if item.__doc__ else "No documentation for this method")) item() for item in corr_methods: print("\n\nMethod name: {}".format(item.__name__)) print("Method doc: {}".format(item.__doc__ if item.__doc__ else "No documentation for this method")) item() for item in unc_methods: print("\n\n\nMethod name: {}".format(item.__name__)) print("Method doc: {}\n\n".format(item.__doc__ if item.__doc__ else "No documentation for this method")) print("Based on the name and documentation of this item, it is likely to be fatal.") print("Execute it directly from the python command line.") print("Your mileage may vary and if it breaks, you get to keep all the pieces.")
def display_einj(): with ttypager.page(): einj = acpi.parse_einj() if einj is None: raise RuntimeError("No ACPI EINJ table found") print(einj)
def display_triggers(): with ttypager.page(): print(get_trigger_action_table_op())
def show_interrupt_break_event(): with ttypager.page(): if int_break_event: print("Interrupt Break Event is enabled") else: print("Interrupt Break Event is disabled")
def callback(): with ttypager.page(): print("{} boot detected".format(boot_str)) print("Tests and other menu entries tailored for this environment")