#994172 grub2 cutmem not working propertly

Package:
grub2
Source:
grub2
Description:
GRand Unified Bootloader, version 2 (dummy package)
Submitter:
Alexey Kuznetsov
Date:
2021-09-16 07:00:03 UTC
Severity:
normal
#994172#5
Date:
2021-09-13 08:14:36 UTC
From:
To:
Dear Maintainer,

Hello!

My old notebook has memory issues and requires to cut last 20M memory
region to work propertly (no matter how much installed 1G or 2G I had to
cut last 20M)

From kernel perspective it looks like this:

[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000007f73ffff] usable
[ 0.000000] BIOS-e820: [mem 0x000000007f740000-0x000000007f74ffff] ACPI data
[ 0.000000] BIOS-e820: [mem 0x000000007f750000-0x000000007f7fffff] ACPI NVS
[ 0.000000] e820: remove [mem 0x7e400000-0xfffffffffffffffe] usable
[ 0.000000] Notice: NX (Execute Disable) protection missing in CPU!
[ 0.000000] user-defined physical RAM map:
[ 0.000000] user: [mem 0x0000000000000000-0x000000000009fbff] usable
[ 0.000000] user: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[ 0.000000] user: [mem 0x00000000000e0000-0x00000000000fffff] reserved
[ 0.000000] user: [mem 0x0000000000100000-0x000000007e3fffff] usable
[ 0.000000] user: [mem 0x000000007f740000-0x000000007f74ffff] ACPI data
[ 0.000000] user: [mem 0x000000007f750000-0x000000007f7fffff] ACPI NVS

If this region is not removed my notebook works SUPER slow and every
click takes few seconds to process. Same affects grub2. If region in use
grub2 takes 2 minutes to boot into kernel. I recorded youtube video:

https://youtu.be/BlTii6QL5oY

I know grub2 has a 'cutmem' command which is not working propertly. When
I issue a:

'cutmem 0x7e40000 0x7f73ffff'

grub2 reports no change in 'lsmmap' output, which is not correct! I
tested 'cutmem' on my second notebook with efi loader, and cutmem
affects 'lsmmap' output with 'BADRAM regions' printed out.

fast logs:

https://linux-hardware.org/?probe=59b41381ed

slow logs:

https://linux-hardware.org/?probe=28a5b48a05

'grub-legacy' works fine, no slow downs!

I report it on grub2 bug tracker with no response:

https://savannah.gnu.org/bugs/index.php?61148

#994172#10
Date:
2021-09-13 08:21:46 UTC
From:
To:
-- AK
#994172#15
Date:
2021-09-16 06:57:40 UTC
From:
To:
My guess was to limit the memory map returned by e820 by size of 20M
manually. So, I did patch grub source code with following:


diff --git a/grub-core/kern/i386/pc/mmap.old b/grub-core/kern/i386/pc/mmap.c
index c0c3c35..0eb76d9 100644
--- a/grub-core/kern/i386/pc/mmap.old
+++ b/grub-core/kern/i386/pc/mmap.c
@@ -134,6 +134,10 @@ grub_get_mmap_entry (struct grub_machine_mmap_entry
*entry,
   else
     entry->size = regs.ecx;

+  if (entry->addr == 0x0000000000100000) {
+    entry->len -= 0x1340000;
+  }
+
   /* return the continuation value */
   return regs.ebx;
 }


But that did not succeed. Grub still works slowly. Does anyone know why
kernel with 'mem=2020M' argument works fast, and the same memory map does
not fix grub 'slow down' issue?