From 392004124f627c7b99024b92e320cdd2355f9eea Mon Sep 17 00:00:00 2001 From: acevest Date: Wed, 24 Nov 2021 21:57:31 +0800 Subject: [PATCH] =?utf8?q?fix=E5=9C=A8x86=5F64=E7=9A=84=E6=9C=BA=E5=99=A8?= =?utf8?q?=E4=B8=8A=E5=8F=AF=E7=94=A8=E7=9A=84=E5=86=85=E5=AD=98=E5=9C=B0?= =?utf8?q?=E5=9D=80=E7=9A=84=E4=BD=8E32bit=E5=8F=AF=E8=83=BD=E5=87=BA?= =?utf8?q?=E7=8E=B0=E5=9B=9E=E7=BB=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- mm/bootmem.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mm/bootmem.c b/mm/bootmem.c index 8f3088c..9c2d7d5 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c @@ -99,6 +99,14 @@ void e820_init_bootmem_data() { unsigned long bgn_pfn = PFN_UP(p->addr); unsigned long end_pfn = PFN_DW(p->addr + p->size); + // 在x86_64的机器上低32bit可能出现回绕的情况 + // 就算物理内存小于4G也可能出现 + // 这种情况直接忽略 + if (bgn_pfn < bootmem_data.max_pfn) { + break; + } + + if (bootmem_data.min_pfn > bgn_pfn) { bootmem_data.min_pfn = bgn_pfn; } @@ -122,6 +130,7 @@ void e820_init_bootmem_data() { } void register_bootmem_pages() { + unsigned long max_pfn = 0; for (unsigned int i = 0; i < boot_params.e820map.map_cnt; ++i) { struct e820_entry *p = boot_params.e820map.map + i; @@ -132,6 +141,16 @@ void register_bootmem_pages() { unsigned long bgn_pfn = PFN_UP(p->addr); unsigned long end_pfn = PFN_DW(p->addr + p->size); + // 在x86_64的机器上低32bit可能出现回绕的情况 + // 就算物理内存小于4G也可能出现 + // 这种情况直接忽略 + if (bgn_pfn < max_pfn) { + break; + } + max_pfn = end_pfn; + + + #if 1 // 用一个相对快的方式 fast_init_bootmem_bitmap(bgn_pfn, end_pfn, 0); -- 2.44.0