Skip to contentSkip to conversation

Wrong machtype argument passed for fuloong-2f

bug David Kuehling 3 participants 12 messages Oct 29, 2011 – Oct 30, 2011

lore
Share & tools
lore
#0 lore raw

hi,

according to my /proc/cmdline grub passes machtype=lemote-fuloong-2f-unknown as first argument to the linux kernel.

This is determined in linux.c:

http://bzr.savannah.gnu.org/lh/grub/trunk/grub/annotate/head:/grub-core/loader/mips/linux.c

however, Linux only understands lemote-fuloong-2f-box, according to:

http://git.linux-mips.org/?p=linux.git;a=blob;f=arch/mips/loongson/common/machtype.c;h=2efd5d9dee27192f8a0da79698eb79b5c6e9828c;hb=linux-3.0-stable

cheers,

David

Signature · 2 lines
GnuPG public key: http://dvdkhlng.users.sourceforge.net/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205  D016 7DEF 5323 C174 7D40
#1 lore raw
Quoted 3 lines · * David Kuehling ([email protected]) [111029 11:37]:

according to my /proc/cmdline grub passes machtype=lemote-fuloong-2f-unknown as first argument to the linux kernel.

Did you see any issues because of that in Linux? Fallback within linux is MACH_LEMOTE_FL2F which is the one used with the argument "lemote-fuloong-2f-box" (not saying this bug shouldn't be fixed, but ...). Also I think grub should just forward the parameters added by pmon, but not adding them itself (except for the parameters via the grub configuration, e.g. root=...).

Andi

#2 lore raw
Quoted 10 lines · Andreas Barth
Quoted 3 lines · * David Kuehling ([email protected]) [111029 11:37]:

according to my /proc/cmdline grub passes machtype=lemote-fuloong-2f-unknown as first argument to the linux kernel.

Did you see any issues because of that in Linux? Fallback within linux is MACH_LEMOTE_FL2F which is the one used with the argument "lemote-fuloong-2f-box" (not saying this bug shouldn't be fixed, but ...). Also I think grub should just forward the parameters added by pmon, but not adding them itself (except for the parameters via the grub configuration, e.g. root=...).

GRUB isn't restricted ot pmon environments so this argument makes little sense to me.

Quoted 8 lines

Andi

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#3 lore raw
Quoted 12 lines · * Vladimir 'φ-coder/phcoder' Serbinenko ([email protected]) [111029 12:42]:
Quoted 10 lines · Andreas Barth
Quoted 3 lines · * David Kuehling ([email protected]) [111029 11:37]:

according to my /proc/cmdline grub passes machtype=lemote-fuloong-2f-unknown as first argument to the linux kernel.

Did you see any issues because of that in Linux? Fallback within linux is MACH_LEMOTE_FL2F which is the one used with the argument "lemote-fuloong-2f-box" (not saying this bug shouldn't be fixed, but ...). Also I think grub should just forward the parameters added by pmon, but not adding them itself (except for the parameters via the grub configuration, e.g. root=...).

Quoted 2 lines

GRUB isn't restricted ot pmon environments so this argument makes little sense to me.

Isn't there a way to detect pmon environments in run time? Basically that's more like "is there a pmon configuration, and if so, just forward parameters"? I personally don't see how we could correctly find out the different variants the linux kernel detects without using the information the kernel uses, i.e. the command line. And if we use the command line, we could as well just forward it.

(The optimal case would be device trees everywhere, but well. We are today.)

Andi

#4 lore raw
Quoted 12 lines · Andreas Barth
Quoted 11 lines · * Vladimir 'φ-coder/phcoder' Serbinenko ([email protected]) [111029 12:42]:
Quoted 10 lines · Andreas Barth
Quoted 3 lines · * David Kuehling ([email protected]) [111029 11:37]:

according to my /proc/cmdline grub passes machtype=lemote-fuloong-2f-unknown as first argument to the linux kernel.

Did you see any issues because of that in Linux? Fallback within linux is MACH_LEMOTE_FL2F which is the one used with the argument "lemote-fuloong-2f-box" (not saying this bug shouldn't be fixed, but ...). Also I think grub should just forward the parameters added by pmon, but not adding them itself (except for the parameters via the grub configuration, e.g. root=...).

Quoted 9 lines
Quoted 2 lines

GRUB isn't restricted ot pmon environments so this argument makes little sense to me.

Isn't there a way to detect pmon environments in run time? Basically that's more like "is there a pmon configuration, and if so, just forward parameters"? I personally don't see how we could correctly find out the different variants the linux kernel detects without using the information the kernel uses, i.e. the command line. And if we use the command line, we could as well just forward it.

Which creates a separate codepath uselessly. If GRUB is firmware it uses the information available on mkimage time, if loaded by pmon or another GRUB, use command line.

Quoted 3 lines

(The optimal case would be device trees everywhere, but well. We are today.)

Device trees have some nonsensical devices, like commandline which I couldn't find inside of any of my chips.

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#6 lore raw
In reply to Andreas Barth
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Andreas" == Andreas Barth <[email protected]> writes:

Quoted 3 lines · * David Kuehling ([email protected]) [111029 11:37]:

according to my /proc/cmdline grub passes machtype=lemote-fuloong-2f-unknown as first argument to the linux kernel.

Did you see any issues because of that in Linux?

No, don't think so. (Well, there are some issues with the fuloong box, but they don't seem to be fixed after patching fuloong's boot argument)

Quoted 3 lines

Fallback within linux is MACH_LEMOTE_FL2F which is the one used with the argument "lemote-fuloong-2f-box" (not saying this bug shouldn't be fixed, but ...).

I didn't find a method to make linux report the actual mach type that it is running with, so I don't know what it fell back to, and I just went the safe route of patching my version of grub.

cheers,

David

Signature · 2 lines
GnuPG public key: http://dvdkhlng.users.sourceforge.net/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205  D016 7DEF 5323 C174 7D40
#7 lore raw
Quoted 3 lines · * David Kuehling ([email protected]) [111029 13:43]:

I didn't find a method to make linux report the actual mach type that it is running with, so I don't know what it fell back to, and I just went the safe route of patching my version of grub.

It's displayed as part of /proc/cpuinfo.

Andi

#5 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · * Vladimir 'φ-coder/phcoder' Serbinenko ([email protected]) [111029 12:55]:
Quoted 4 lines · Andreas Barth

I personally don't see how we could correctly
find out the different variants the linux kernel detects without using the information the kernel uses, i.e. the command line. And if we use the command line, we could as well just forward it.

Which creates a separate codepath uselessly. If GRUB is firmware it uses the information available on mkimage time, if loaded by pmon or another GRUB, use command line.

I don't think we disagree here. Sorry if I wrote that wrong.

Andi

#8 lore raw
In reply to Andreas Barth
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Andreas" == Andreas Barth <[email protected]> writes:

Quoted 3 lines · * David Kuehling ([email protected]) [111029 11:37]:

according to my /proc/cmdline grub passes machtype=lemote-fuloong-2f-unknown as first argument to the linux kernel.

Quoted 6 lines

Did you see any issues because of that in Linux? Fallback within linux is MACH_LEMOTE_FL2F which is the one used with the argument "lemote-fuloong-2f-box" (not saying this bug shouldn't be fixed, but ...). Also I think grub should just forward the parameters added by pmon, but not adding them itself (except for the parameters via the grub configuration, e.g. root=...).

BTW it looks like it is impossible to override machtype= parameter from the kernel command line configured in boot/grub/grub.cfg, since linux code in loongson/common/machtype.c uses the first occurence of "machtype=" in arcs_cmdline[]. Is this behaviour by design or by accident? Is this linux' fault or grub's fault? One could change grub to append machtype= rather than prepend it to the command line...

cheers,

David

Signature · 2 lines
GnuPG public key: http://dvdkhlng.users.sourceforge.net/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205  D016 7DEF 5323 C174 7D40
#9 lore raw
Quoted 6 lines · * David Kuehling ([email protected]) [111029 22:46]:

BTW it looks like it is impossible to override machtype= parameter from the kernel command line configured in boot/grub/grub.cfg, since linux code in loongson/common/machtype.c uses the first occurence of "machtype=" in arcs_cmdline[]. Is this behaviour by design or by accident? Is this linux' fault or grub's fault? One could change grub to append machtype= rather than prepend it to the command line...

I would consider it more appropriate to add a flag "suppress pmon command line" to the grub configuration - if you want to overwrite it, it should fully disappear, and not just be not parsed because there is another one first.

Andi

#10 lore raw
Quoted 7 lines · Andreas Barth
Quoted 6 lines · * David Kuehling ([email protected]) [111029 22:46]:

BTW it looks like it is impossible to override machtype= parameter from the kernel command line configured in boot/grub/grub.cfg, since linux code in loongson/common/machtype.c uses the first occurence of "machtype=" in arcs_cmdline[]. Is this behaviour by design or by accident? Is this linux' fault or grub's fault? One could change grub to append machtype= rather than prepend it to the command line...

Quoted 5 lines

I would consider it more appropriate to add a flag "suppress pmon command line" to the grub configuration - if you want to overwrite it, it should fully disappear, and not just be not parsed because there is another one first.

As I already said: machtype isn't only about pmon. And I consider it as part of protocol on loongson so no, it won't be overrideable. Moreover it's fundamentally wrong to make bugs configurable (bugs=on). Please try the following patch:
=== modified file 'grub-core/loader/mips/linux.c'

loader/mips/linux.c 2011-10-30 03:28:36 +0000 renamed from loader/mips/linux.c 2011-08-19 20:46:11 +0000 +1 -1
@@ -41,7 +41,7 @@
 const char loongson_machtypes[][60] =
   {
     [GRUB_ARCH_MACHINE_YEELOONG] = "machtype=lemote-yeeloong-2f-8.9inches",
-    [GRUB_ARCH_MACHINE_FULOONG2F]  = "machtype=lemote-fuloong-2f-unknown",
+    [GRUB_ARCH_MACHINE_FULOONG2F]  = "machtype=lemote-fuloong-2f-box",
     [GRUB_ARCH_MACHINE_FULOONG2E]  = "machtype=lemote-fuloong-2e-unknown"
   };
 #endif
Quoted 7 lines

Andi

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#11 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Vladimir" == Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> writes:

[..]

Quoted 5 lines

As I already said: machtype isn't only about pmon. And I consider it as part of protocol on loongson so no, it won't be overrideable. Moreover it's fundamentally wrong to make bugs configurable (bugs=on). Please try the following patch: === modified file 'grub-core/loader/mips/linux.c' --- grub-core/loader/mips/linux.c

Quoted 8 lines
2011-08-19 20:46:11 +0000 +++ grub-core/loader/mips/linux.c 2011-10-30

03:28:36 +0000 @@ -41,7 +41,7 @@ const char loongson_machtypes[][60] = { [GRUB_ARCH_MACHINE_YEELOONG] = "machtype=lemote-yeeloong-2f-8.9inches", - [GRUB_ARCH_MACHINE_FULOONG2F] = "machtype=lemote-fuloong-2f-unknown",
+ [GRUB_ARCH_MACHINE_FULOONG2F] = "machtype=lemote-fuloong-2f-box", [GRUB_ARCH_MACHINE_FULOONG2E] = "machtype=lemote-fuloong-2e-unknown" }; #endif

Already have exactly that change applied to the version of grub installed.

$ cat /proc/cmdline 
machtype=lemote-fuloong-2f-box root=/dev/mapper/world-root ro
console=tty rd_start=0x80eb0000 rd_size=0x68f0d9 
$ cat /proc/cpuinfo |grep system
system type		: lemote-fuloong-2f-box

cheers,

David

Signature · 2 lines
GnuPG public key: http://dvdkhlng.users.sourceforge.net/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205  D016 7DEF 5323 C174 7D40