Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\cpu\mtrr\cleanup.c Create Date:2022-07-28 08:06:42
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:mtrr_trim_uncached_memory - trim RAM not covered by MTRRs*@end_pfn: ending page frame number* Some buggy BIOSes don't setup the MTRRs properly for systems with certain* memory configurations

Proto:int __init mtrr_trim_uncached_memory(unsigned long end_pfn)

Type:int

Parameter:

TypeParameterName
unsigned longend_pfn
879  highest_pfn = 0
889  If Not is_cpu(INTEL) || disable_mtrr_trim Then Return 0
892  Access to machine-specific registers (available on 586 and better only)* Note: the rd* operations modify the parameters directly (without using* pointer indirection), this allows gcc to optimize better(MSR_MTRRdefType, def, dummy)
893  def &= 0xff
894  If def != MTRR memory types, which are defined in SDM Then Return 0
898  memset(range_state, 0, size of range_state )
899  When i < num_var_ranges cycle
900  get(i, & base, & size, & type)
901  base_pfn = base
902  size_pfn = size
903  type = type
907  When i < num_var_ranges cycle
908  type = type
909  If type != MTRR_TYPE_WRBACK Then Continue
911  base = base_pfn
912  size = size_pfn
913  If highest_pfn < base + size Then highest_pfn = base + size
918  If Not highest_pfn Then
919  pr_info("CPU MTRRs all blank - virtualized system.\n")
920  Return 0
924  memset(num, 0, size of num )
925  When i < num_var_ranges cycle
926  type = type
927  If type >= MTRR_NUM_TYPES Then Continue
929  size = size_pfn
930  If Not size Then type = MTRR_NUM_TYPES
932  num[type]++
936  If Not num[MTRR_TYPE_WRBACK] Then Return 0
940  If num[MTRR_TYPE_WRBACK] + num[MTRR memory types, which are defined in SDM ] != num_var_ranges - num[MTRR_NUM_TYPES] Then Return 0
944  memset(range, 0, size of range )
945  nr_range = 0
946  If mtrr_tom2 Then
947  start = 1ULL << 32 - PAGE_SHIFT determines the page size
948  end = mtrr_tom2 >> PAGE_SHIFT determines the page size
949  If highest_pfn < end Then highest_pfn = end
951  nr_range++
953  nr_range = x86_get_mtrr_mem_range(range, nr_range, 0, 0)
956  total_trim_size = 0
957  If start Then total_trim_size += real_trim_memory(0, start)
961  When i < nr_range - 1 cycle
962  If end < start Then total_trim_size += real_trim_memory(end, start)
968  i = nr_range - 1
969  If end < end_pfn Then total_trim_size += real_trim_memory(end, end_pfn)
973  If total_trim_size Then
974  pr_warn("WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing %lluMB of RAM.\n", total_trim_size >> 20)
977  If Not changed_by_mtrr_cleanup Then WARN_ON(1)
980  pr_info("update e820 for mtrr\n")
981  e820__update_table_print()
983  Return 1
986  Return 0