Bug 857464

Summary: grub2 and memmap cause kernel hang
Product: [openSUSE] openSUSE 13.1 Reporter: Pi Ny <piny>
Component: BootloaderAssignee: Michael Chang <mchang>
Status: RESOLVED DUPLICATE QA Contact: Jiri Srain <jsrain>
Severity: Critical    
Priority: P5 - None CC: arvidjaar
Version: Final   
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE 13.1   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: insert '$'-esacping hint to 'memmap' description
insert '$'-esacping hint into /etc/default/grub
insert '$'-esacping hint into /boot/grub2/grub.cfg

Description Pi Ny 2014-01-06 01:53:17 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0

Issue:
Using the kernel parameter memmap with grub2 boot loader causes kernel hang during boot. The systems freezes directly after issuing
[CODE]
Loading initial ramdisk ...
[/CODE]

Cause:
The root cause is that the "$" character needs to be escaped even in /boot/grub2/grub.cfg.
Multiple escaping is necessary when using the "official" configuration files due to several bash sourcing and $-sign "interpretations".
This is documented e.g. in
* http://forums.fedoraforum.org/showthread.php?t=285588
* https://groups.google.com/forum/#!msg/jailhouse-dev/sttVUtTYLlk/ax2CrrAUMtwJ

Note:
This error is very hard to detect and I spend "a lot of time" chasing a non existent graphics issue (KVM, nomodeset, etc).
Eventually, trying to install a fresh OS12.3 (this bug applies here too!) and fiddling with a very specific "vga=0x0361" setting, the screen switched mode and displayed
[CODE]
PANIC: early exception 08 rip 246:10 error 8158c98c cr2 0
[/CODE]
This error message does not appear "usually"!
Chasing this error message (e.g. [SOLVED] PANIC: early exception 08 rip 246:10 after upgrading from 2 to 4GB RAM) I finally tracked it down to the "$-escaping" issue.

To do:
Escape the $-sign in all grub2 configurati files acc.
* http://forums.fedoraforum.org/showthread.php?t=285588
* https://groups.google.com/forum/#!msg/jailhouse-dev/sttVUtTYLlk/ax2CrrAUMtwJ


Reproducible: Always

Steps to Reproduce:
1. Insert kernel boot parameter memmap=64K$0K into /boot/grub2/grub.cfg
2. Boot

Actual Results:  
Boot process hangs with last message "Loading initial ramdisk ..."

Expected Results:  
System booting successfully

This error is hard to detect!
All info available directs towards graphics issues!

This is reproduced with a fresh, minimum install (text mode)
Comment 1 Pi Ny 2014-01-06 01:54:17 UTC
I know this is an grub2 issue - but seems to be a feature!
So ALL openSUSE docu is affected!
Comment 2 Pi Ny 2014-01-06 02:13:21 UTC
This issue also affects the installation of openSUSE with YAST!
Entering the additional boot option "memmap=64K$0K" leads to an "$0"-expansion resulting in an entry (reproduced from my mind) like
"memmap=64K/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg"

This probably should be a separate bug concerning the YAST installer!
Comment 3 Andrei Borzenkov 2014-01-06 06:08:17 UTC
(In reply to comment #1)
> I know this is an grub2 issue - but seems to be a feature!

I do not see where it is grub2 problem. It is perfectly legal to add parameters that would be expanded at boot time to kernel command line in grub.cfg. This feature is very useful.

I agree that it is worth to mention it in documentation. Care to provide a patch?

May be YaST could special case memmap and additionally escape it. Do you have list of other kernel parameters that are using $ as part of value?
Comment 4 Pi Ny 2014-01-06 14:31:55 UTC
(In reply to comment #3)
> I do not see where it is grub2 problem. It is perfectly legal to add parameters
> that would be expanded at boot time to kernel command line in grub.cfg. This
> feature is very useful.
> 
> I agree that it is worth to mention it in documentation. Care to provide a
> patch?
> 
> May be YaST could special case memmap and additionally escape it. Do you have
> list of other kernel parameters that are using $ as part of value?

I checked 
https://www.kernel.org/doc/Documentation/kernel-parameters.txt

There is seems that memmap is the only "true" kernel parameter using the "$"-character.

I propose at least 3 documents that should be updated:

1) In https://www.kernel.org/doc/Documentation/kernel-parameters.txt:
   A note should be added to the memmap entry.
   -> see attached kernel-parameters.txt.2014-01-08_grub2-dollar.diff
   (based on kernel-parameters.txt as of 2013-12-30)

2) In the config files of grub:
   I apologize for surrendering in the face of the data structure of grub-2.00.tar.gz as available from ftp://ftp.gnu.org/gnu/grub/.
   I could not really identify the places to propose following changes:

   2a) /etc/default/grub
   A note should be added before the entries GRUB_CMDLINE_LINUX_DEFAULT,
   GRUB_CMDLINE_LINUX_RECOVERY, and GRUB_CMDLINE_LINUX
   -> see attached _etc_default_grub_2014-01-08_dollar-escape.diff
   (based on current installation)

   2b) /boot/grub2/grub.cfg
   A note should be added in the file header
   -> see attached _boot_grub2_grub.cfg_2014-01-08_dollar-escape.diff
   (based on a current installation)
   Yes, there is a warning not to edit this file directly but in emergency cases people go there...


I strongly agree that YAST should escape it (three-fold!), because YAST is meant for users (like me) who don't know too much about internals.
Should I file a bug concerning YAST related to this one?
Comment 5 Pi Ny 2014-01-06 14:34:20 UTC
Created attachment 573370 [details]
insert '$'-esacping hint to 'memmap' description

cf. https://bugzilla.novell.com/show_bug.cgi?id=857464#c4
Comment 6 Pi Ny 2014-01-06 14:35:47 UTC
Created attachment 573372 [details]
insert '$'-esacping hint into /etc/default/grub

https://bugzilla.novell.com/show_bug.cgi?id=857464#c4
Comment 7 Pi Ny 2014-01-06 14:36:56 UTC
Created attachment 573373 [details]
insert '$'-esacping hint into /boot/grub2/grub.cfg

cf. https://bugzilla.novell.com/show_bug.cgi?id=857464#c4
Comment 8 Pi Ny 2014-01-06 16:08:42 UTC
(In reply to comment #4)
 
> I strongly agree that YAST should escape it (three-fold!), because YAST is
> meant for users (like me) who don't know too much about internals.
> Should I file a bug concerning YAST related to this one?

Meanwhile I decided to file a separate bug https://bugzilla.novell.com/show_bug.cgi?id=857556 concerning YAST.
Comment 9 Michael Chang 2014-01-07 03:12:44 UTC
(In reply to comment #8)

> Meanwhile I decided to file a separate bug
> https://bugzilla.novell.com/show_bug.cgi?id=857556 concerning YAST.

Thanks for report. I will look after it.
Comment 10 Michael Chang 2015-12-21 04:52:28 UTC
The memmap escaping problem has fixed by YaST, thanks.

*** This bug has been marked as a duplicate of bug 857556 ***