First Distro-agnostic series taken from Fedora Rawhide
v2 cover First Distro-agnostic series taken from Fedora Rawhide
This is the first patch series, second version, taken from Fedora Rawhide spec [1] that are distro-agnostic. The goal is to merge most of them so all the community/distros would benefit.
Changes since v1:
- deleted 0005-Allow-fallback-to-include-entries-by-title-not-just-.patch
no longer supported (even if doc indicates the contrary)
- deleted 011-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch
similar patch reviewed in a separate thread
- deleted 0014-Don-t-say-GNU-Linux-in-generated-menus.patch
not accepted
- modified patches/0003-Disable-GRUB-video-support-for-IBM-power-machines.patch
included commit description taken from bz
- modified patches/0008-Migrate-PPC-from-Yaboot-to-Grub2.patch
included 'ieee1275' on summary and description and improve description
[1] https://src.fedoraproject.org/rpms/grub2
Fedora Ninjas (2):
Makefile.common: Add .eh_frame to list of relocations stripped normal/main: fw_path prefix when fallback searching for grub config
Mark Hamzy (1):
20_ppc_terminfo.in: Migrate ieee1275/PPC from Yaboot to Grub2
Paulo Flabiano Smorigo (4):
ieee1275/openfw: IBM client architecture (CAS) reboot support term/terminfo: for ppc, reset console display attr when clear screen
ieee1275: Disable GRUB video support for IBM power machines
normal: Add fw_path variable (revised)
Peter Jones (10):
configure.ac: Move bash completion script
misc: Make "exit" take a return code.
efi/init: Make efi machines load an env block from a variable
commands: Pass "\x[[:hex:]][[:hex:]]" straight through unmolested. 10_linux.in: Add devicetree loading
00_header.in: Enable pager by default. (#985860) 10_linux.in: Don't require a password to boot entries generated by
grub-mkconfig.
normal/main: Try mac/guid/etc before grub.cfg on tftp config files. 10_linux.in: Generate OS and CLASS in 10_linux from /etc/os-release normal/main: Try $prefix if $fw_path doesn't work.
Makefile.util.def | 7 ++ conf/Makefile.common | 2 +- configure.ac | 11 +++ grub-core/Makefile.core.def | 1 + grub-core/commands/minicmd.c | 20 ++++- grub-core/commands/wildcard.c | 16 +++- grub-core/kern/efi/efi.c | 9 +- grub-core/kern/efi/init.c | 34 ++++++++ grub-core/kern/emu/main.c | 2 +- grub-core/kern/emu/misc.c | 9 +- grub-core/kern/i386/coreboot/init.c | 2 +- grub-core/kern/i386/qemu/init.c | 2 +- grub-core/kern/ieee1275/cmain.c | 5 +- grub-core/kern/ieee1275/init.c | 30 ++++--- grub-core/kern/ieee1275/openfw.c | 63 ++++++++++++++ grub-core/kern/main.c | 13 ++- grub-core/kern/mips/arc/init.c | 2 +- grub-core/kern/mips/loongson/init.c | 2 +- grub-core/kern/mips/qemu_mips/init.c | 2 +- grub-core/kern/misc.c | 11 ++- grub-core/kern/uboot/init.c | 6 +- grub-core/kern/xen/init.c | 2 +- grub-core/lib/cmdline.c | 25 +++++- grub-core/net/net.c | 2 +- grub-core/normal/main.c | 122 ++++++++++++++++++--------- grub-core/script/execute.c | 50 +++++++++-- grub-core/term/terminfo.c | 2 +- grub-core/video/ieee1275.c | 9 +- include/grub/ieee1275/ieee1275.h | 4 + include/grub/misc.h | 2 +- util/bash-completion.d/Makefile.am | 1 - util/grub-mkconfig.in | 3 +- util/grub.d/00_header.in | 2 + util/grub.d/10_linux.in | 20 ++++- util/grub.d/20_ppc_terminfo.in | 114 +++++++++++++++++++++++++ 35 files changed, 506 insertions(+), 101 deletions(-) create mode 100644 util/grub.d/20_ppc_terminfo.in
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 1/17 ieee1275/openfw: IBM client architecture (CAS) reboot support
From: Paulo Flabiano Smorigo <[email protected]>
This is an implementation of IBM client architecture (CAS) reboot for GRUB.
There are cases where the POWER firmware must reboot in order to support specific features requested by a kernel. The kernel calls ibm,client-architecture-support and it may either return or reboot with the new feature set. eg:
Calling ibm,client-architecture-support.../
Elapsed time since release of system processors: 70959 mins 50 secs Welcome to GRUB!
Instead of return to the GRUB menu, it will check if the flag for CAS reboot is set. If so, grub will automatically boot the last booted kernel using the same parameters
--- grub-core/kern/ieee1275/openfw.c | 63 ++++++++++++++++++++++++++++++++ grub-core/normal/main.c | 19 ++++++++++ grub-core/script/execute.c | 7 ++++ include/grub/ieee1275/ieee1275.h | 2 + 4 files changed, 91 insertions(+)
grub-core/kern/ieee1275/openfw.c +63 -0
@@ -591,3 +591,66 @@ grub_ieee1275_get_boot_dev (void)return bootpath; } + +/* Check if it's a CAS reboot. If so, set the script to be executed. */ +int +grub_ieee1275_cas_reboot (char *script) +{ +grub_uint32_t ibm_ca_support_reboot; +grub_uint32_t ibm_fw_nbr_reboots; +char property_value[10 ]; +grub_ssize_t actual; +grub_ieee1275_ihandle_t options; + +if (grub_ieee1275_finddevice ("/options" , &options) <0 ) +return -1 ; + +/* Check two properties, one is enough to get cas reboot value */ + ibm_ca_support_reboot =0 ; +if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen, +"ibm,client-architecture-support-reboot" , + &ibm_ca_support_reboot, +sizeof (ibm_ca_support_reboot), + &actual) >=0 ) +grub_dprintf ("ieee1275" ,"ibm,client-architecture-support-reboot: %u\n" , + ibm_ca_support_reboot); + + ibm_fw_nbr_reboots =0 ; +if (grub_ieee1275_get_property (options,"ibm,fw-nbr-reboots" , + property_value,sizeof (property_value), + &actual) >=0 ) + { + property_value[sizeof (property_value) -1 ] =0 ; + ibm_fw_nbr_reboots = (grub_uint8_t )grub_strtoul (property_value,0 ,10 ); +grub_dprintf ("ieee1275" ,"ibm,fw-nbr-reboots: %u\n" , ibm_fw_nbr_reboots); + } + +if (ibm_ca_support_reboot || ibm_fw_nbr_reboots) + { +if (!grub_ieee1275_get_property_length (options,"boot-last-label" , &actual)) + { +if (actual >1024 ) + script =grub_realloc (script, actual +1 ); +grub_ieee1275_get_property (options,"boot-last-label" , script, actual, + &actual); +return 0 ; + } + } + +grub_ieee1275_set_boot_last_label ("" ); + +return -1 ; +} + +int grub_ieee1275_set_boot_last_label (const char *text) +{ +grub_ieee1275_ihandle_t options; +grub_ssize_t actual; + +grub_dprintf ("ieee1275" ,"set boot_last_label (size: %u)\n" ,grub_strlen (text)); +if (!grub_ieee1275_finddevice ("/options" , &options) && + options != (grub_ieee1275_ihandle_t) -1 ) +grub_ieee1275_set_property (options,"boot-last-label" , text, +grub_strlen (text), &actual); +return 0 ; +}
grub-core/normal/main.c +19 -0
@@ -34,6 +34,9 @@#include <grub/charset.h> #include <grub/script_sh.h> #include <grub/bufio.h> +#ifdef GRUB_MACHINE_IEEE1275 +#include <grub/ieee1275/ieee1275.h> +#endif GRUB_MOD_LICENSE ("GPLv3+" );
@@ -276,6 +279,22 @@ grub_normal_execute (const char *config, int nested, int batch) { menu =read_config_file (config); +#ifdef GRUB_MACHINE_IEEE1275 +int boot; + boot =0 ; +char *script; + script =grub_malloc (1024 ); +if (!grub_ieee1275_cas_reboot (script)) + { +char *dummy[1 ] = {NULL }; +if (!grub_script_execute_sourcecode (script)) + boot =1 ; + } +grub_free (script); +if (boot) +grub_command_execute ("boot" ,0 ,0 ); +#endif +/* Ignore any error. */ grub_errno =GRUB_ERR_NONE ; }
grub-core/script/execute.c +7 -0
@@ -28,6 +28,9 @@#include <grub/extcmd.h> #include <grub/i18n.h> #include <grub/verify.h> +#ifdef GRUB_MACHINE_IEEE1275 +#include <grub/ieee1275/ieee1275.h> +#endif /* Max digits for a char is 3 (0xFF is 255), similarly for an int it is sizeof (int) * 3, and one extra for a possible -ve sign. */
@@ -883,6 +886,10 @@ grub_script_execute_sourcecode (const char *source)grub_err_t ret =0 ;struct grub_script *parsed_script; +#ifdef GRUB_MACHINE_IEEE1275 +grub_ieee1275_set_boot_last_label (source); +#endif +while (source) {char *line;
include/grub/ieee1275/ieee1275.h +2 -0
@@ -251,6 +251,8 @@ int EXPORT_FUNC(grub_ieee1275_devalias_next) (struct grub_ieee1275_devalias *alivoid EXPORT_FUNC (grub_ieee1275_children_peer ) (struct grub_ieee1275_devalias *alias);void EXPORT_FUNC (grub_ieee1275_children_first ) (const char *devpath,struct grub_ieee1275_devalias *alias); +int EXPORT_FUNC (grub_ieee1275_cas_reboot ) (char *script); +int EXPORT_FUNC (grub_ieee1275_set_boot_last_label ) (const char *text);char *EXPORT_FUNC (grub_ieee1275_get_boot_dev ) (void );
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 2/17 term/terminfo: for ppc, reset console display attr when clear screen
In reply to Leo SandovalFrom: Paulo Flabiano Smorigo <[email protected]>
v2: Also use \x0c instead of a literal ^L to make future patches less awkward.
This should fix this bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=908519
--- grub-core/term/terminfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/term/terminfo.c +1 -1
@@ -151,7 +151,7 @@ grub_terminfo_set_current (struct grub_term_output *term,/* Clear the screen. Using serial console, screen(1) only recognizes the * ANSI escape sequence. Using video console, Apple Open Firmware * (version 3.1.1) only recognizes the literal ^L. So use both. */ - data->cls =grub_strdup ("\e[2J" ); + data->cls =grub_strdup ("\x0c\e[2J\e[m" ); data->reverse_video_on =grub_strdup ("\e[7m" ); data->reverse_video_off =grub_strdup ("\e[m" );if (grub_strcmp ("ieee1275" , str) ==0 )
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 3/17 ieee1275: Disable GRUB video support for IBM power machines
In reply to Leo SandovalFrom: Paulo Flabiano Smorigo <[email protected]>
Disable GRUB Video Support from IBM Power Machines. This patch fixes what is describe above and should fix https://bugzilla.redhat.com/show_bug.cgi?id=973205.
C&P the bz problem's description:
Grub crashes if it tries to run in video mode.
I'm currently testing with grub rpm from f18 in a lpar inside a Power 7R2 machine using a matrox video card attached.
To reproduce you need to redirect the console to the video output.
This will happens:
IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM
IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM STARTING SOFTWARE IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM PLEASE WAIT... IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM
IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM
Welcome to GRUB
DEFAULT CATCH!, exception-handler=fff00300
at %SRR0: 000000000020ac80 %SRR1: 0000000000003002
Open Firmware exception handler entered from non-OF code
Client's Fix Pt Regs:
00 0000000000780c38 0000000001adfc40 0000000000000000 0000000018000000 04 0000000000780850 000000000004afff 00000000001d2bb0 0000000000000000 08 0000000018000000 fffffffffffb5000 000000001804b000 0000000001adfc50 0c 0000000000000008 0000000000000000 0000000000800050 0000000002000066 10 0000000002000065 0000000002000070 000000000200006e 0000000002000067 14 0000000002000063 0000000000000001 00000000001a0000 0000000000000002 18 0000000000000002 0000000000000000 0000000000780dce 00000000ffff8080 1c 0000000000000067 00000000001d3de0 00000000001d2b30 0000000000000002
Special Regs:
%IV: 00000300 %CR: 22002084 %XER: 20000000 %DSISR: 42000000
%SRR0: 000000000020ac80 %SRR1: 0000000000003002
%LR: 0000000000006584 %CTR: 000000000004b000 %DAR: 000000001804afff
Virtual PID = 0
ok
0 >
In Power, GRUB has video support and works fine with PowerMAC.
Theorically it should works with IBM machines as well but, using a Matrox videocard and grub.cfg with the video option enabled, GRUB crashes as we saw above.
Using GRUB debug we saw that the crash happens because GRUB tries to access the video card address:
video/ieee1275.c:236: IEEE1275: keeping current mode 640x480 video/ieee1275.c:266: IEEE1275: initialising FB @ 0x18000000 640x480x8
GRUB gets the address from the display card node from openfirmware. The property is called "address":
0 > dev /pci@80000002000000d/pci@0/display@0 ok
0 > .properties
ibm,loc-code U78AB.001.WZSHS9P-P1-C7-T1 vendor-id 0000102b device-id 00002527 revision-id 00000001 class-code 00030000 interrupts 00000001 min-grant 00000010 max-latency 00000020 subsystem-vendor-id 0000102b subsystem-id 00002300 devsel-speed 00000001
fast-back-to-back
built-in
name display
compatible MTRX,G550
pci102b,2527
pciclass,030000
display
reg 00990000 00000000 00000000 00000000 00000000
02990030 00000000 00000000 00000000 00010000
02990010 00000000 00000000 00000000 04000000
02990014 00000000 00000000 00000000 00800000
02990018 00000000 00000000 00000000 00800000
fcode-rom-offset 00009000
device_type display
character-set ISO8859-1
iso6429-1983-colors
power-consumption 00000000 00000000 007270e0 007270e0 00000000 00000000 007b98a0 007b98a0
ibm,fw-revision-level 00000100
assigned-addresses 82990010 00000000 f8000000 00000000 04000000
82990014 00000000 f7000000 00000000 00800000
82990018 00000000 f7800000 00000000 00800000
82990030 00000000 f6fe0000 00000000 00020000
address 18000000 17000000
width 00000280
height 000001e0
depth 00000008
linebytes 00000280
bios release 01000000 ok
0 >
Kleber Sacilotto sent me the address that linux returned from the probe:
99:00.0 VGA compatible controller: Matrox Electronics Systems Ltd. Millennium G550 (rev 01) (prog-if 00 [VGA controller])
Subsystem: Matrox Electronics Systems Ltd. Millennium G550 LP PCIE
Control: I/O- Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Interrupt: pin A routed to IRQ 0
Region 0: Memory at 3da318000000 (32-bit, prefetchable) [size=64M]
Region 1: Memory at 3da317000000 (32-bit, non-prefetchable) [size=8M]
Region 2: Memory at 3da317800000 (32-bit, non-prefetchable) [size=8M]
Expansion ROM at 3da316fe0000 [disabled] [size=128K]
Capabilities: [dc] Power Management version 2
Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [f0] AGP version 2.0
Status: RQ=32 Iso- ArqSz=0 Cal=0 SBA+ ITACoh- GART64- HTrans- 64bit- FW- AGP3- Rate=x1,x2
Command: RQ=1 ArqSz=0 Cal=0 SBA- AGP- GART64- 64bit- FW- Rate=<none>
Kernel driver in use: matroxfb
The address is 64bit and display property in openfirmware was cut because it's "encode-int" (32bit):
From linux:
Region 0: Memory at 3da318000000 (32-bit, prefetchable) [size=64M] Region 1: Memory at 3da317000000 (32-bit, non-prefetchable) [size=8M]
From openfirmware:
address 18000000 17000000
David Randall confirmed that the linux address is right after getting the full address using other properties from the videocard node.
We talked with Colleen about the address property from the Matrox card and she said that the node is generated from a FCode that is inside the card, owned by Matrox.
Openfirmware works in 32bit mode so GRUB for Power is hotwired in 32bit, even for 64bit machines.
David taught us how to get the full address but, as GRUB is build in 32bit and the value is 64 we need to implement an asm helper in order to access it.
Marcelo Cerri, from ltc security team, helped me writing an asm help to access the address but we still didn't managed to make it work.
We will continue to work in the asm to see if we can access the address.
Besides that, I'm going to implement an address validation in GRUB before it tries to access the address. If the address is invalid it will return an exception and will continue to run in text mode.
--- grub-core/kern/ieee1275/cmain.c | 5 ++++- grub-core/video/ieee1275.c | 9 ++++++--- include/grub/ieee1275/ieee1275.h | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-)
grub-core/kern/ieee1275/cmain.c +4 -1
@@ -89,7 +89,10 @@ grub_ieee1275_find_options (void) }if (rc >=0 &&grub_strncmp (tmp,"IBM" ,3 ) ==0 ) -grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS ); + { +grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS ); +grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT ); + }/* Old Macs have no key repeat, newer ones have fully working one. The ones inbetween when repeated key generates an escaoe sequence
grub-core/video/ieee1275.c +6 -3
@@ -351,9 +351,12 @@ static struct grub_video_adapter grub_video_ieee1275_adapter =GRUB_MOD_INIT (ieee1275_fb) { -find_display (); -if (display) -grub_video_register (&grub_video_ieee1275_adapter); +if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT )) + { +find_display (); +if (display) +grub_video_register (&grub_video_ieee1275_adapter); + } }GRUB_MOD_FINI (ieee1275_fb)
include/grub/ieee1275/ieee1275.h +2 -0
@@ -145,6 +145,8 @@ enum grub_ieee1275_flagGRUB_IEEE1275_FLAG_POWER_VM ,GRUB_IEEE1275_FLAG_POWER_KVM , + + GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT };extern int EXPORT_FUNC (grub_ieee1275_test_flag ) (enum grub_ieee1275_flag flag);
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v2 03/17] ieee1275: Disable GRUB video support for IBM power machines
Can you add a short comment in cmain why it's needed? It should mention 32-bit address truncation. The story in the commit message, on the other hand, is way too long. It needs to be summarized with a link to full story.
Quoted 247 lines · Leo Sandoval
From: Paulo Flabiano Smorigo <[email protected]>
Disable GRUB Video Support from IBM Power Machines. This patch fixes what is describe above and should fix
https://bugzilla.redhat.com/show_bug.cgi?id=973205.
C&P <https://bugzilla.redhat.com/show_bug.cgi?id=973205.C&P> the bz problem's description:Grub crashes if it tries to run in video mode.
I'm currently testing with grub rpm from f18 in a lpar inside a Power 7R2 machine using a matrox video card attached.
To reproduce you need to redirect the console to the video output.
This will happens:
IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM
IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM STARTING SOFTWARE IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM PLEASE WAIT... IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBMIBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM
Welcome to GRUB
DEFAULT CATCH!, exception-handler=fff00300
at %SRR0:000000000020ac80%SRR1: 0000000000003002
Open Firmware exception handler entered from non-OF codeClient's Fix Pt Regs:
000000000000780c380000000001adfc400000000000000000 0000000018000000 04 0000000000780850000000000004afff00000000001d2bb00000000000000000 08 0000000018000000fffffffffffb5000000000001804b0000000000001adfc500c 0000000000000008 0000000000000000 0000000000800050 0000000002000066 10 0000000002000065 0000000002000070000000000200006e0000000002000067 14 0000000002000063 000000000000000100000000001a00000000000000000002 18 0000000000000002 00000000000000000000000000780dce00000000ffff80801c 000000000000006700000000001d3de000000000001d2b300000000000000002
Special Regs:%IV: 00000300 %CR: 22002084 %XER: 20000000 %DSISR: 42000000 %SRR0: 000000000020ac80 %SRR1: 0000000000003002 %LR: 0000000000006584 %CTR: 000000000004b000%DAR:
000000001804afff
Virtual PID = 0
ok
0 >In Power, GRUB has video support and works fine with PowerMAC.
Theorically it should works with IBM machines as well but, using a Matrox videocard and grub.cfg with the video option enabled, GRUB crashes as we saw above.
Using GRUB debug we saw that the crash happens because GRUB tries to access the video card address:
video/ieee1275.c:236: IEEE1275: keeping current mode 640x480video/ieee1275.c:266: IEEE1275: initialising FB @0x18000000640x480x8GRUB gets the address from the display card node from openfirmware. The property is called "address":
0 > dev /pci@80000002000000d/pci@0/display@0 ok
0 > .propertiesibm,loc-code U78AB.001.WZSHS9P-P1-C7-T1 vendor-id 0000102b device-id 00002527 revision-id 00000001 class-code 00030000 interrupts 00000001 min-grant 00000010 max-latency 00000020 subsystem-vendor-id 0000102b subsystem-id 00002300 devsel-speed 00000001fast-back-to-back
built-in
name display
compatible MTRX,G550pci102b,2527 pciclass,030000 display reg 00990000 00000000 00000000 00000000 00000000 02990030 00000000 00000000 00000000 00010000 02990010 00000000 00000000 00000000 04000000 02990014 00000000 00000000 00000000 00800000 02990018 00000000 00000000 00000000 00800000 fcode-rom-offset 00009000 device_type display character-set ISO8859-1iso6429-1983-colors
power-consumption 00000000 00000000007270e0007270e000000000
00000000007b98a0007b98a0
ibm,fw-revision-level 00000100assigned-addresses 82990010 00000000 f8000000 00000000 04000000 82990014 00000000 f7000000 00000000 00800000 82990018 00000000 f7800000 00000000 00800000 82990030 00000000 f6fe0000 00000000 00020000 address 18000000 17000000 width 00000280 height 000001e0 depth 00000008 linebytes 00000280 bios release 01000000ok
0 >Kleber Sacilotto sent me the address that linux returned from the probe:
99:00.0 VGA compatible controller: Matrox Electronics Systems Ltd. Millennium G550 (rev 01) (prog-if 00 [VGA controller])
Subsystem: Matrox Electronics Systems Ltd. Millennium G550 LP PCIE
Control: I/O- Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop-
ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort-
<TAbort- <MAbort- >SERR- <PERR- INTx-Interrupt: pin A routed to IRQ 0 Region 0: Memory at 3da318000000 (32-bit, prefetchable) [size=64M] Region 1: Memory at 3da317000000 (32-bit, non-prefetchable) [size=8M] Region 2: Memory at 3da317800000 (32-bit, non-prefetchable)[size=8M]
Expansion ROM at3da316fe0000[disabled] [size=128K]
Capabilities: [dc] Power Management version 2
Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mAPME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [f0] AGP version 2.0
Status: RQ=32 Iso- ArqSz=0 Cal=0 SBA+ ITACoh- GART64-
HTrans- 64bit- FW- AGP3- Rate=x1,x2Command: RQ=1 ArqSz=0 Cal=0 SBA- AGP- GART64- 64bit- FW-Rate=<none>
Kernel driver in use: matroxfbThe address is 64bit and display property in openfirmware was cut because it's "encode-int" (32bit):
From linux:
Region 0: Memory at3da318000000(32-bit, prefetchable) [size=64M] Region 1: Memory at3da317000000(32-bit, non-prefetchable) [size=8M]From openfirmware:
address 18000000 17000000David Randall confirmed that the linux address is right after getting the full address using other properties from the videocard node.
We talked with Colleen about the address property from the Matrox card and she said that the node is generated from a FCode that is inside the card, owned by Matrox.
Openfirmware works in 32bit mode so GRUB for Power is hotwired in 32bit, even for 64bit machines.
David taught us how to get the full address but, as GRUB is build in 32bit and the value is 64 we need to implement an asm helper in order to access it.
Marcelo Cerri, from ltc security team, helped me writing an asm help to access the address but we still didn't managed to make it work.
We will continue to work in the asm to see if we can access the address.
Besides that, I'm going to implement an address validation in GRUB before it tries to access the address. If the address is invalid it will return an exception and will continue to run in text mode.
Signed-off-by Paulo Flabiano Smorigo <[email protected]>Signed-off-by Robbie Harwood <[email protected]>--- grub-core/kern/ieee1275/cmain.c | 5 ++++- grub-core/video/ieee1275.c | 9 ++++++--- include/grub/ieee1275/ieee1275.h | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-)grub-core/kern/ieee1275/cmain.c +4
-1@@ -89,7 +89,10 @@ grub_ieee1275_find_options (void) }if (rc >=0 &&grub_strncmp (tmp,"IBM" ,3 ) ==0 ) -grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS ); + { +grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS ); +grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT ); + }/* Old Macs have no key repeat, newer ones have fully working one.
The ones inbetween when repeated key generates an escaoe sequencegrub-core/video/ieee1275.c +0
-0@@ -351,9 +351,12 @@ static struct grub_video_adapter
grub_video_ieee1275_adapter=
GRUB_MOD_INIT(ieee1275_fb)
{grub-core/video/ieee1275.c +1
-3-find_display (); -if (display) -grub_video_register (&grub_video_ieee1275_adapter); + if (! grub_ieee1275_test_flag(
GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT))grub-core/video/ieee1275.c +5
-0+ { +find_display (); +if (display) +grub_video_register (&grub_video_ieee1275_adapter); + } }GRUB_MOD_FINI (ieee1275_fb)include/grub/ieee1275/ieee1275.h +2
-0@@ -145,6 +145,8 @@ enum grub_ieee1275_flagGRUB_IEEE1275_FLAG_POWER_VM ,GRUB_IEEE1275_FLAG_POWER_KVM , + +GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flagflag);
--
2.46.2
Quoted 5 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 4/17 configure.ac: Move bash completion script
In reply to Leo SandovalFrom: Peter Jones <[email protected]>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=922997
Apparently these go in a new place now.
--- configure.ac | 11 +++++++++++ util/bash-completion.d/Makefile.am | 1 - 2 files changed, 11 insertions(+), 1 deletion(-)
configure.ac +11 -0
@@ -319,6 +319,14 @@ AC_SUBST(grubdirname) AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname", [Default grub directory name]) +PKG_PROG_PKG_CONFIG +AS_IF([$($PKG_CONFIG --exists bash-completion)], [ + bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion) +] , [ + bashcompletiondir=${datadir}/bash-completion/completions +]) +AC_SUBST(bashcompletiondir) + # # Checks for build programs. #
@@ -534,6 +542,9 @@ HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags" # Check for target programs. # +# This makes sure pkg.m4 is available. +m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config]) + # Find tools for the target. if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then tmp_ac_tool_prefix="$ac_tool_prefix"
util/bash-completion.d/Makefile.am +0 -1
@@ -6,7 +6,6 @@ EXTRA_DIST = $(bash_completion_source) CLEANFILES = $(bash_completion_script) config.log -bashcompletiondir = $(sysconfdir)/bash_completion.d bashcompletion_DATA = $(bash_completion_script) $(bash_completion_script): $(bash_completion_source) $(top_builddir)/config.status
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 5/17 misc: Make "exit" take a return code.
In reply to Leo SandovalFrom: Peter Jones <[email protected]>
This adds "exit" with a return code. With this patch, any "exit" command /may/ include a return code, and on platforms that support returning with an exit status, we will do so. By default we return the same exit status we did before this patch.
--- grub-core/commands/minicmd.c | 20 ++++++++++++++++---- grub-core/kern/efi/efi.c | 9 +++++++-- grub-core/kern/emu/main.c | 2 +- grub-core/kern/emu/misc.c | 9 +++++---- grub-core/kern/i386/coreboot/init.c | 2 +- grub-core/kern/i386/qemu/init.c | 2 +- grub-core/kern/ieee1275/init.c | 2 +- grub-core/kern/mips/arc/init.c | 2 +- grub-core/kern/mips/loongson/init.c | 2 +- grub-core/kern/mips/qemu_mips/init.c | 2 +- grub-core/kern/misc.c | 11 ++++++++++- grub-core/kern/uboot/init.c | 6 +++--- grub-core/kern/xen/init.c | 2 +- include/grub/misc.h | 2 +- 14 files changed, 50 insertions(+), 23 deletions(-)
grub-core/commands/minicmd.c +16 -4
@@ -182,12 +182,24 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)), }/* exit */ -static grub_err_t __attribute__ ((noreturn)) +static grub_err_t grub_mini_cmd_exit (struct grub_command *cmd __attribute__ ((unused)), -int argc __attribute__ ((unused)), -char *argv[] __attribute__ ((unused))) +int argc,char *argv[]) { -grub_exit (); +int retval =-1 ; +unsigned long n; + +if (argc <0 || argc >1 ) +return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("one argument expected" )); + +if (argc ==1 ) + { + n =grub_strtoul (argv[0 ],0 ,10 ); +if (n != ~0UL ) + retval = n; + } + +grub_exit (retval);/* Not reached. */ }
grub-core/kern/efi/efi.c +7 -2
@@ -175,11 +175,16 @@ grub_reboot (void) }void -grub_exit (void ) +grub_exit (int retval) { +int rc =GRUB_EFI_LOAD_ERROR ; + +if (retval ==0 ) + rc =GRUB_EFI_SUCCESS ; +grub_machine_fini (GRUB_LOADER_FLAG_NORETURN ); grub_efi_system_table->boot_services->exit (grub_efi_image_handle, -GRUB_EFI_SUCCESS ,0 ,0 ); + rc,0 ,0 );for (;;) ; }
grub-core/kern/emu/main.c +1 -1
@@ -67,7 +67,7 @@ grub_reboot (void) }void -grub_exit (void ) +grub_exit (int retval __attribute__((unused))) {grub_reboot (); }
grub-core/kern/emu/misc.c +5 -4
@@ -83,7 +83,7 @@ grub_util_error (const char *fmt, ...)vfprintf (stderr, fmt, ap);va_end (ap);fprintf (stderr,".\n" ); -grub_exit (); +grub_exit (1 ); } void *
@@ -152,12 +152,13 @@ xasprintf (const char *fmt, ...)#if !defined (GRUB_MACHINE_EMU ) || defined (GRUB_UTIL )void -grub_exit (void ) +__attribute__ ((noreturn)) +grub_exit (int rc) { -#if defined (GRUB_KERNEL ) +#if defined (GRUB_KERNEL ) && !defined (GRUB_MACHINE_EFI )grub_reboot ();#endif -exit (1 ); +exit (rc <0 ?1 : rc); }#endif
grub-core/kern/i386/coreboot/init.c +1 -1
@@ -41,7 +41,7 @@ extern grub_uint8_t _end[];extern grub_uint8_t _edata[];void __attribute__ ((noreturn)) -grub_exit (void ) +grub_exit (int rc __attribute__((unused))) {/* We can't use grub_fatal() in this function. This would create an infinite loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */
grub-core/kern/i386/qemu/init.c +1 -1
@@ -42,7 +42,7 @@ extern grub_uint8_t _end[];extern grub_uint8_t _edata[];void __attribute__ ((noreturn)) -grub_exit (void ) +grub_exit (int rc __attribute__((unused))) {/* We can't use grub_fatal() in this function. This would create an infinite loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */
grub-core/kern/ieee1275/init.c +1 -1
@@ -114,7 +114,7 @@ grub_addr_t grub_ieee1275_original_stack;#define BYTE22 (DY_MEM_V2 | DRC_INFO)void -grub_exit (void ) +grub_exit (int rc __attribute__((unused))) {grub_ieee1275_exit (); }
grub-core/kern/mips/arc/init.c +1 -1
@@ -276,7 +276,7 @@ grub_halt (void) }void -grub_exit (void ) +grub_exit (int rc __attribute__((unused))) {GRUB_ARC_FIRMWARE_VECTOR ->exit ();
grub-core/kern/mips/loongson/init.c +1 -1
@@ -304,7 +304,7 @@ grub_halt (void) }void -grub_exit (void ) +grub_exit (int rc __attribute__((unused))) {grub_halt (); }
grub-core/kern/mips/qemu_mips/init.c +1 -1
@@ -75,7 +75,7 @@ grub_machine_fini (int flags __attribute__ ((unused))) }void -grub_exit (void ) +grub_exit (int rc __attribute__((unused))) {grub_halt (); }
grub-core/kern/misc.c +10 -1
@@ -1311,9 +1311,18 @@ grub_abort (void)grub_getkey (); } -grub_exit (); +grub_exit (1 ); } +#if defined (__clang__) && !defined (GRUB_UTIL ) +/* clang emits references to abort(). */ +void __attribute__ ((noreturn)) +abort (void ) +{ +grub_abort (); +} +#endif +void grub_fatal (const char *fmt, ...) {
grub-core/kern/uboot/init.c +3 -3
@@ -39,9 +39,9 @@ extern grub_size_t grub_total_module_size;static unsigned long timer_start;void -grub_exit (void ) +grub_exit (int rc) { -grub_uboot_return (0 ); +grub_uboot_return (rc <0 ?1 : rc); } static grub_uint64_t
@@ -78,7 +78,7 @@ grub_machine_init (void)if (!ver) {/* Don't even have a console to log errors to... */ -grub_exit (); +grub_exit (-1 ); }else if (ver >API_SIG_VERSION ) {
grub-core/kern/xen/init.c +1 -1
@@ -584,7 +584,7 @@ grub_machine_init (void) }void -grub_exit (void ) +grub_exit (int rc __attribute__((unused))) {struct sched_shutdown arg;
include/grub/misc.h +1 -1
@@ -385,7 +385,7 @@ char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT;char *EXPORT_FUNC (grub_xvasprintf ) (const char *fmt,va_list args)WARN_UNUSED_RESULT ; -void EXPORT_FUNC (grub_exit ) (void ) __attribute__ ((noreturn)); +void EXPORT_FUNC (grub_exit ) (int rc) __attribute__ ((noreturn));void EXPORT_FUNC (grub_abort ) (void ) __attribute__ ((noreturn)); grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, grub_uint64_t d,
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 6/17 efi/init: Make efi machines load an env block from a variable
In reply to Leo SandovalFrom: Peter Jones <[email protected]>
--- grub-core/Makefile.core.def | 1 + grub-core/kern/efi/init.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+)
grub-core/Makefile.core.def +1 -0
@@ -219,6 +219,7 @@ kernel = { efi = kern/efi/acpi.c; efi = kern/efi/sb.c; efi = kern/lockdown.c; + efi = lib/envblk.c; i386_coreboot = kern/i386/pc/acpi.c; i386_multiboot = kern/i386/pc/acpi.c; i386_coreboot = kern/acpi.c;
grub-core/kern/efi/init.c +34 -0
@@ -28,8 +28,11 @@#include <grub/env.h> #include <grub/mm.h> #include <grub/kernel.h> +#include <grub/stack_protector.h> +#include <grub/lib/envblk.h> +#ifdef GRUB_STACK_PROTECTOR static grub_efi_char16_t stack_chk_fail_msg[] =
@@ -103,6 +106,36 @@ stack_protector_init (void)grub_addr_t grub_modbase; +#define GRUB_EFI_GRUB_VARIABLE_GUID \ + { 0x91376aff, 0xcba6, 0x42be, \ + { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \ + } + +/* Helper for grub_efi_env_init */ +static int +set_var (const char *name,const char *value, +void *whitelist __attribute__((__unused__))) +{ +grub_env_set (name, value); +return 0 ; +} + +static void +grub_efi_env_init (void ) +{ +grub_guid_t efi_grub_guid =GRUB_EFI_GRUB_VARIABLE_GUID ; +struct grub_envblk envblk_s = {NULL ,0 }; +grub_envblk_t envblk = &envblk_s; + +grub_efi_get_variable ("GRUB_ENV" , &efi_grub_guid, &envblk_s.size, + (void **) &envblk_s.buf); +if (!envblk_s.buf || envblk_s.size <1 ) +return ; + +grub_envblk_iterate (envblk,NULL , set_var); +grub_free (envblk_s.buf); +} + __attribute__ ((__optimize__ ("-fno-stack-protector" )))void grub_efi_init (void ) {
@@ -128,6 +161,7 @@ grub_efi_init (void) grub_efi_system_table->boot_services->set_watchdog_timer (0 ,0 ,0 ,NULL ); +grub_efi_env_init ();grub_efidisk_init ();grub_efi_register_debug_commands ();
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 7/17 20_ppc_terminfo.in: Migrate ieee1275/PPC from Yaboot to Grub2
In reply to Leo SandovalFrom: Mark Hamzy <[email protected]>
Add configuration support for ieee1275/PPC ofconsole serial terminal.
--- Makefile.util.def | 7 ++ util/grub.d/20_ppc_terminfo.in | 114 +++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 util/grub.d/20_ppc_terminfo.in
Makefile.util.def +7 -0
@@ -517,6 +517,13 @@ script = { installdir = grubconf; }; +script = { + name = '20_ppc_terminfo'; + common = util/grub.d/20_ppc_terminfo.in; + installdir = grubconf; + condition = COND_HOST_LINUX; +}; + script = { name = '30_os-prober'; common = util/grub.d/30_os-prober.in;
util/grub.d/20_ppc_terminfo.in new file +114 -0
114 lines not on this page · raw message
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 8/17 normal: Add fw_path variable (revised)
In reply to Leo SandovalFrom: Paulo Flabiano Smorigo <[email protected]>
This patch makes grub look for its config file on efi where the app was found. It was originally written by Matthew Garrett, and adapted to fix the "No modules are loaded on grub2 network boot" issue:
https://bugzilla.redhat.com/show_bug.cgi?id=857936
--- grub-core/kern/main.c | 13 ++++++------- grub-core/normal/main.c | 25 ++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 8 deletions(-)
grub-core/kern/main.c +6 -7
@@ -128,16 +128,15 @@ grub_set_prefix_and_root (void)grub_machine_get_bootlocation (&fwdevice, &fwpath); -if (fwdevice) +if (fwdevice && fwpath) { -char *cmdpath; +char *fw_path; - cmdpath =grub_xasprintf ("(%s)%s" , fwdevice, fwpath ? :"" ); -if (cmdpath) + fw_path =grub_xasprintf ("(%s)/%s" , fwdevice, fwpath); +if (fw_path) { -grub_env_set ("cmdpath" , cmdpath); -grub_env_export ("cmdpath" ); -grub_free (cmdpath); +grub_env_set ("fw_path" , fw_path); +grub_free (fw_path); } }
grub-core/normal/main.c +24 -1
@@ -339,7 +339,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),/* Guess the config filename. It is necessary to make CONFIG static, so that it won't get broken by longjmp. */ char *config; -const char *prefix; +const char *prefix, *fw_path; + + fw_path =grub_env_get ("fw_path" ); +if (fw_path) + { + config =grub_xasprintf ("%s/grub.cfg" , fw_path); +if (config) + { +grub_file_t file; + + file =grub_file_open (config,GRUB_FILE_TYPE_CONFIG ); +if (file) + { +grub_file_close (file); +grub_enter_normal_mode (config); + } +else + { +/* Ignore all errors. */ + grub_errno =0 ; + } +grub_free (config); + } + } prefix =grub_env_get ("prefix" );if (prefix)
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 9/17 commands: Pass "\x[[:hex:]][[:hex:]]" straight through unmolested.
In reply to Leo SandovalFrom: Peter Jones <[email protected]>
Don't munge raw spaces when we're doing our cmdline escaping (#923374)
--- grub-core/commands/wildcard.c | 16 ++++++++++++- grub-core/lib/cmdline.c | 25 ++++++++++++++++++-- grub-core/script/execute.c | 43 ++++++++++++++++++++++++++++++----- 3 files changed, 75 insertions(+), 9 deletions(-)
grub-core/commands/wildcard.c +15 -1
@@ -488,6 +488,12 @@ check_file (const char *dir, const char *basename)return ctx.found; } +static int +is_hex (char c) +{ +return ((c >='0' && c <='9' ) || (c >='a' && c <='f' ) || (c >='A' && c <='F' )); +} +static void unescape (char *out,const char *in,const char *end) {
@@ -496,7 +502,15 @@ unescape (char *out, const char *in, const char *end)for (optr = out, iptr = in; iptr < end;) { -if (*iptr =='\\' && iptr +1 < end) +if (*iptr =='\\' && iptr +3 < end && iptr[1 ] =='x' &&is_hex (iptr[2 ]) &&is_hex (iptr[3 ])) + { + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; +continue ; + } +else if (*iptr =='\\' && iptr +1 < end) { *optr++ = iptr[1 ]; iptr +=2 ;
grub-core/lib/cmdline.c +23 -2
@@ -20,6 +20,12 @@#include <grub/lib/cmdline.h> #include <grub/misc.h> +static int +is_hex (char c) +{ +return ((c >='0' && c <='9' ) || (c >='a' && c <='f' ) || (c >='A' && c <='F' )); +} +static unsigned int check_arg (char *c,int *has_space) {int space =0 ;
@@ -27,7 +33,13 @@ static unsigned int check_arg (char *c, int *has_space)while (*c) { -if (*c =='\\' || *c =='\'' || *c =='"' ) +if (*c =='\\' && *(c+1 ) =='x' &&is_hex (*(c+2 )) &&is_hex (*(c+3 ))) + { + size +=4 ; + c +=4 ; +continue ; + } +else if (*c =='\\' || *c =='\'' || *c =='"' ) size++;else if (*c ==' ' ) space =1 ;
@@ -86,7 +98,16 @@ grub_create_loader_cmdline (int argc, char *argv[], char *buf,while (*c) { -if (*c =='\\' || *c =='\'' || *c =='"' ) +if (*c =='\\' && *(c+1 ) =='x' && +is_hex (*(c+2 )) &&is_hex (*(c+3 ))) + { + *buf++ = *c++; + *buf++ = *c++; + *buf++ = *c++; + *buf++ = *c++; +continue ; + } +else if (*c =='\\' || *c =='\'' || *c =='"' ) *buf++ ='\\' ; *buf++ = *c;
grub-core/script/execute.c +37 -6
67 lines not on this page · raw message
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v2 09/17] commands: Pass "\x[[:hex:]][[:hex:]]" straight through unmolested.
Quoted 16 lines · Leo Sandoval
From: Peter Jones <[email protected]>
Don't munge raw spaces when we're doing our cmdline escaping (#923374)
Signed-off-by Peter Jones <[email protected]>--- grub-core/commands/wildcard.c | 16 ++++++++++++- grub-core/lib/cmdline.c | 25 ++++++++++++++++++-- grub-core/script/execute.c | 43 ++++++++++++++++++++++++++++++----- 3 files changed, 75 insertions(+), 9 deletions(-)grub-core/commands/wildcard.c +0
-0
grub-core/commands/wildcard.c check_file (const char *dir, const char *basename) · line 496
Quoted 9 lines
grub-core/commands/wildcard.c +6
-0@@ -488,6 +488,12 @@ check_file (const char *dir, const char *basename)return ctx.found; } +static int +is_hex (char c) +{ +return ((c >='0' && c <='9' ) || (c >='a' && c <='f' ) || (c >='A' && c <='F' )); +} +
Is there a way you can inline a version of this function in some library header to avoid duplicating it elsewhere? Also it seems like a generally useful function. Just a thought.
Thanks
Ross
Quoted 135 lines
grub-core/commands/wildcard.c +9
-1static void unescape (char *out,const char *in,const char *end) {@@ -496,7 +502,15 @@ unescape (char *out, const char *in, const char *end)for (optr = out, iptr = in; iptr < end;) { -if (*iptr =='\\' && iptr +1 < end) +if (*iptr =='\\' && iptr +3 < end && iptr[1 ] =='x' &&is_hex (iptr[2 ]) &&is_hex (iptr[3 ])) + { + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; +continue ; + } +else if (*iptr =='\\' && iptr +1 < end) { *optr++ = iptr[1 ]; iptr +=2 ;grub-core/lib/cmdline.c +23
-2@@ -20,6 +20,12 @@#include <grub/lib/cmdline.h> #include <grub/misc.h> +static int +is_hex (char c) +{ +return ((c >='0' && c <='9' ) || (c >='a' && c <='f' ) || (c >='A' && c <='F' )); +} +static unsigned int check_arg (char *c,int *has_space) {int space =0 ;@@ -27,7 +33,13 @@ static unsigned int check_arg (char *c, int *has_space)while (*c) { -if (*c =='\\' || *c =='\'' || *c =='"' ) +if (*c =='\\' && *(c+1 ) =='x' &&is_hex (*(c+2 )) &&is_hex (*(c+3 ))) + { + size +=4 ; + c +=4 ; +continue ; + } +else if (*c =='\\' || *c =='\'' || *c =='"' ) size++;else if (*c ==' ' ) space =1 ;@@ -86,7 +98,16 @@ grub_create_loader_cmdline (int argc, char *argv[], char *buf,while (*c) { -if (*c =='\\' || *c =='\'' || *c =='"' ) +if (*c =='\\' && *(c+1 ) =='x' && +is_hex (*(c+2 )) &&is_hex (*(c+3 ))) + { + *buf++ = *c++; + *buf++ = *c++; + *buf++ = *c++; + *buf++ = *c++; +continue ; + } +else if (*c =='\\' || *c =='\'' || *c =='"' ) *buf++ ='\\' ; *buf++ = *c;grub-core/script/execute.c +30
-6@@ -56,6 +56,12 @@ static struct grub_script_scope *scope = 0;/* Wildcard translator for GRUB script. */ struct grub_script_wildcard_translator *grub_wildcard_translator; +static int +is_hex (char c) +{ +return ((c >='0' && c <='9' ) || (c >='a' && c <='f' ) || (c >='A' && c <='F' )); +} +static char *wildcard_escape (const char *s) {@@ -72,7 +78,15 @@ wildcard_escape (const char *s) i =0 ;while ((ch = *s++)) { -if (ch =='*' || ch =='\\' || ch =='?' ) +if (ch =='\\' && s[0 ] =='x' &&is_hex (s[1 ]) &&is_hex (s[2 ])) + { + p[i++] = ch; + p[i++] = *s++; + p[i++] = *s++; + p[i++] = *s++; +continue ; + } +else if (ch =='*' || ch =='\\' || ch =='?' ) p[i++] ='\\' ; p[i++] = ch; }@@ -96,7 +110,14 @@ wildcard_unescape (const char *s) i =0 ;while ((ch = *s++)) { -if (ch =='\\' ) +if (ch =='\\' && s[0 ] =='x' &&is_hex (s[1 ]) &&is_hex (s[2 ])) + { + p[i++] ='\\' ; + p[i++] = *s++; + p[i++] = *s++; + p[i++] = *s++; + } +else if (ch =='\\' ) p[i++] = *s++;else p[i++] = ch;@@ -398,10 +419,20 @@ parse_string (const char *str,switch (*ptr) {case '\\' : - escaped = !escaped; -if (!escaped && put) - *(put++) ='\\' ; - ptr++; +if (!escaped && put && *(ptr+1 ) =='x' &&is_hex (*(ptr+2 )) &&is_hex (*(ptr+3 ))) + { + *(put++) = *ptr++; + *(put++) = *ptr++; + *(put++) = *ptr++; + *(put++) = *ptr++; + }
grub-core/script/execute.c parse_string (const char *str, · line 438
Quoted 10 lines
grub-core/script/execute.c +7
-0+else + { + escaped = !escaped; +if (!escaped && put) + *(put++) ='\\' ; + ptr++; + }break ;case '$' :if (escaped)
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v2 09/17] commands: Pass "\x[[:hex:]][[:hex:]]" straight through unmolested.
Quoted 26 lines · On Mon, Oct 7, 2024 at 1:05 PM <[email protected]> wrote:
Quoted 4 lines · Leo Sandoval
From: Peter Jones <[email protected]>
Don't munge raw spaces when we're doing our cmdline escaping (#923374)
Review
Quoted 8 lines
Signed-off-by Peter Jones <[email protected]>--- grub-core/commands/wildcard.c | 16 ++++++++++++- grub-core/lib/cmdline.c | 25 ++++++++++++++++++-- grub-core/script/execute.c | 43 ++++++++++++++++++++++++++++++----- 3 files changed, 75 insertions(+), 9 deletions(-)(quoted diff) +0
-0
b/grub-core/commands/wildcard.cgrub-core/commands/wildcard.c check_file (const char *dir, const char *basename) · line 494
Quoted 11 lines
index
ed6586505..5455242c3100644grub-core/commands/wildcard.c +4
-0@@ -488,6 +488,12 @@ check_file (const char *dir, const char *basename)return ctx.found; } +static int +is_hex (char c) +{ + return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A'&& c <= 'F'));
Quoted 7 lines
grub-core/commands/wildcard.c check_file (const char *dir, const char *basename) · line 496
Quoted 2 lines
grub-core/commands/wildcard.c +2
-0+} +Is there a way you can inline a version of this function in some library header to avoid duplicating it elsewhere? Also it seems like a generally useful function. Just a thought.
Good point. I see identical definitions in other files (grub-core/lib/cmdline.c and grub-core/script/execute.c). I believe this would required
a separated patch to unify all these definitions into one.
Quoted 133 lines
Thanks
Rossgrub-core/commands/wildcard.c unescape (char *out, const char *in, const char
Quoted 4 lines
grub-core/commands/wildcard.c +0
-0static void unescape (char *out,const char *in,const char *end) {@@ -496,7 +502,15 @@ unescape (char *out, const char *in, const char*end)
grub-core/commands/wildcard.c unescape (char *out, const char *in, const char *end)
Quoted 5 lines
grub-core/commands/wildcard.c +1
-1for (optr = out, iptr = in; iptr < end;) { -if (*iptr =='\\' && iptr +1 < end) + if (*iptr == '\\' && iptr + 3 < end && iptr[1] == 'x' &&
is_hex(iptr[2])&&is_hex(iptr[3]))Quoted 16 lines
grub-core/commands/wildcard.c +8
-0+ { + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; +continue ; + } + else if (*iptr == '\\' && iptr + 1 < end) { *optr++ = iptr[1 ]; iptr +=2 ;grub-core/lib/cmdline.c +0
-0grub-core/lib/cmdline.c line 26
Quoted 7 lines
grub-core/lib/cmdline.c +4
-0@@ -20,6 +20,12 @@#include <grub/lib/cmdline.h> #include <grub/misc.h> +static int +is_hex (char c) +{ + return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A'&& c <= 'F'));
grub-core/lib/cmdline.c static unsigned int check_arg (char *c, int
Quoted 6 lines
grub-core/lib/cmdline.c +2
-0+} +static unsigned int check_arg (char *c,int *has_space) {int space =0 ;@@ -27,7 +33,13 @@ static unsigned int check_arg (char *c, int
*has_space)grub-core/lib/cmdline.c static unsigned int check_arg (char *c, int *has_space)
Quoted 5 lines
grub-core/lib/cmdline.c +1
-1while (*c) { -if (*c =='\\' || *c =='\'' || *c =='"' ) + if (*c == '\\' && *(c+1) == 'x' && is_hex(*(c+2)) &&is_hex(*(c+3)))
grub-core/lib/cmdline.c grub_create_loader_cmdline (int argc, char *argv[],
Quoted 10 lines
grub-core/lib/cmdline.c +6
-0+ { + size +=4 ; + c +=4 ; +continue ; + } + else if (*c == '\\' || *c == '\'' || *c == '"') size++; else if (*c == ' ') space =1 ;@@ -86,7 +98,16 @@ grub_create_loader_cmdline (int argc, char *argv[],char *buf,
Quoted 22 lines
grub-core/lib/cmdline.c +10
-1while (*c) { -if (*c =='\\' || *c =='\'' || *c =='"' ) +if (*c =='\\' && *(c+1 ) =='x' && +is_hex (*(c+2 )) &&is_hex (*(c+3 ))) + { + *buf++ = *c++; + *buf++ = *c++; + *buf++ = *c++; + *buf++ = *c++; +continue ; + } +else if (*c =='\\' || *c =='\'' || *c =='"' ) *buf++ ='\\' ; *buf++ = *c;grub-core/script/execute.c +0
-0grub-core/script/execute.c static struct grub_script_scope *scope = 0; · line 62
Quoted 7 lines
grub-core/script/execute.c +4
-0@@ -56,6 +56,12 @@ static struct grub_script_scope *scope = 0;/* Wildcard translator for GRUB script. */ struct grub_script_wildcard_translator *grub_wildcard_translator; +static int +is_hex (char c) +{ + return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A'&& c <= 'F'));
Quoted 40 lines
grub-core/script/execute.c +19
-2+} +static char *wildcard_escape (const char *s) {@@ -72,7 +78,15 @@ wildcard_escape (const char *s) i =0 ;while ((ch = *s++)) { -if (ch =='*' || ch =='\\' || ch =='?' ) +if (ch =='\\' && s[0 ] =='x' &&is_hex (s[1 ]) &&is_hex (s[2 ])) + { + p[i++] = ch; + p[i++] = *s++; + p[i++] = *s++; + p[i++] = *s++; +continue ; + } +else if (ch =='*' || ch =='\\' || ch =='?' ) p[i++] ='\\' ; p[i++] = ch; }@@ -96,7 +110,14 @@ wildcard_unescape (const char *s) i =0 ;while ((ch = *s++)) { -if (ch =='\\' ) +if (ch =='\\' && s[0 ] =='x' &&is_hex (s[1 ]) &&is_hex (s[2 ])) + { + p[i++] ='\\' ; + p[i++] = *s++; + p[i++] = *s++; + p[i++] = *s++; + } +else if (ch =='\\' ) p[i++] = *s++;else p[i++] = ch;@@ -398,10 +419,20 @@ parse_string (const char *str, switch (*ptr)
Quoted 26 lines
grub-core/script/execute.c parse_string (const char *str,
Quoted 7 lines
grub-core/script/execute.c +1
-4{case '\\' : - escaped = !escaped; -if (!escaped && put) - *(put++) ='\\' ; - ptr++; + if (!escaped && put && *(ptr+1) == 'x' && is_hex(*(ptr+2)) &&is_hex(*(ptr+3)))
Quoted 16 lines
grub-core/script/execute.c +13
-0+ { + *(put++) = *ptr++; + *(put++) = *ptr++; + *(put++) = *ptr++; + *(put++) = *ptr++; + } + else + { + escaped = !escaped; +if (!escaped && put) + *(put++) ='\\' ; + ptr++; + }break ;case '$' :if (escaped)
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 10/17 10_linux.in: Add devicetree loading
In reply to Leo SandovalFrom: Peter Jones <[email protected]>
Switch to use APM Mustang device tree, for hardware testing.
Use the default device tree from the grub default file
instead of hardcoding a value.
--- util/grub-mkconfig.in | 3 ++- util/grub.d/10_linux.in | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
util/grub-mkconfig.in +2 -1
@@ -255,7 +255,8 @@ export GRUB_DEFAULT \ GRUB_ENABLE_CRYPTODISK \ GRUB_BADRAM \ GRUB_OS_PROBER_SKIP_LIST \ - GRUB_DISABLE_SUBMENU + GRUB_DISABLE_SUBMENU \ + GRUB_DEFAULT_DTB if test "x${grub_cfg}" != "x"; then rm -f "${grub_cfg}.new"
util/grub.d/10_linux.in +15 -0
@@ -155,6 +155,13 @@ EOF sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' initrd $(echo $initrd_path) +EOF + fi + if test -n "${fdt}" ; then + message="$(gettext_printf "Loading fdt ...")" + sed "s/^/$submenu_indentation/" << EOF + echo '$(echo "$message" | grub_quote)' + devicetree ${rel_dirname}/${fdt} EOF fi sed "s/^/$submenu_indentation/" << EOF
@@ -250,6 +257,14 @@ for linux in ${reverse_sorted_list}; do gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 fi + fdt= + for i in "dtb-${version}" "dtb-${alt_version}"; do + if test -f "${dirname}/${i}/${GRUB_DEFAULT_DTB}" ; then + fdt="${i}/${GRUB_DEFAULT_DTB}" + break + fi + done + config= for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do if test -e "${i}" ; then
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 11/17 00_header.in: Enable pager by default. (#985860)
In reply to Leo SandovalFrom: Peter Jones <[email protected]>
--- util/grub.d/00_header.in | 2 ++ 1 file changed, 2 insertions(+)
util/grub.d/00_header.in +2 -0
@@ -43,6 +43,8 @@ if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_ if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi cat << EOF +set pager=1 + if [ -s \$prefix/grubenv ]; then load_env fi
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v2 11/17] 00_header.in: Enable pager by default. (#985860)
This has a danger of rendering headless systems unbootable while waiting for user input
Quoted 26 lines · Leo Sandoval
From: Peter Jones <[email protected]>
Signed-off-by Peter Jones <[email protected]>--- util/grub.d/00_header.in | 2 ++ 1 file changed, 2 insertions(+)util/grub.d/00_header.in +0
-0@@ -43,6 +43,8 @@ if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; thenGRUB_DEFAULT_BUTTON='${saved_
if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then
GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; ficat << EOF
util/grub.d/00_header.in +2
-1+set pager=1 + if [ -s \$prefix/grubenv ]; then load_env fi --2.46.2
Quoted 5 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 12/17 Makefile.common: Add .eh_frame to list of relocations stripped
In reply to Leo SandovalFrom: Fedora Ninjas <[email protected]>
--- conf/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
conf/Makefile.common +1 -1
@@ -41,7 +41,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) -STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx +STRIPFLAGS_KERNEL = -R .eh_frame -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx if !COND_emu if COND_HAVE_ASM_USCORE LDFLAGS_KERNEL += -Wl,--defsym=_malloc=_grub_malloc -Wl,--defsym=_free=_grub_free
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 13/17 10_linux.in: Don't require a password to boot entries generated by grub-mkconfig.
In reply to Leo SandovalFrom: Peter Jones <[email protected]>
When we set a password, we just want that to mean you can't /edit/ an entry.
Resolves: rhbz#1030176
--- util/grub.d/10_linux.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
util/grub.d/10_linux.in +1 -1
@@ -26,7 +26,7 @@ datarootdir="@datarootdir@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -CLASS="--class gnu-linux --class gnu --class os" +CLASS="--class gnu-linux --class gnu --class os --unrestricted" if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU/Linux
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 14/17 normal/main: fw_path prefix when fallback searching for grub config
In reply to Leo SandovalFrom: Fedora Ninjas <[email protected]>
When PXE booting via UEFI firmware, grub was searching for grub.cfg in the fw_path directory where the grub application was found. If that didn't exist, a fallback search would look for config file names based on MAC and IP address. However, the search would look in the prefix directory which may not be the same fw_path. This patch changes that behavior to use the fw_path directory for the fallback search. Only if fw_path is NULL will the prefix directory be searched.
--- grub-core/normal/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
grub-core/normal/main.c +3 -2
@@ -341,7 +341,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),char *config;const char *prefix, *fw_path; - fw_path =grub_env_get ("fw_path" ); + prefix = fw_path =grub_env_get ("fw_path" );if (fw_path) { config =grub_xasprintf ("%s/grub.cfg" , fw_path);
@@ -364,7 +364,8 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), } } - prefix =grub_env_get ("prefix" ); +if (! prefix) + prefix =grub_env_get ("prefix" );if (prefix) {grub_size_t config_len;
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 15/17 normal/main: Try mac/guid/etc before grub.cfg on tftp config files.
In reply to Leo SandovalFrom: Peter Jones <[email protected]>
--- grub-core/normal/main.c | 93 ++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 44 deletions(-)
grub-core/normal/main.c +49 -44
@@ -339,61 +339,66 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),/* Guess the config filename. It is necessary to make CONFIG static, so that it won't get broken by longjmp. */ char *config; -const char *prefix, *fw_path; - - prefix = fw_path =grub_env_get ("fw_path" ); -if (fw_path) - { - config =grub_xasprintf ("%s/grub.cfg" , fw_path); -if (config) - { -grub_file_t file; - - file =grub_file_open (config,GRUB_FILE_TYPE_CONFIG ); -if (file) - { -grub_file_close (file); -grub_enter_normal_mode (config); - } -else - { -/* Ignore all errors. */ - grub_errno =0 ; - } -grub_free (config); - } - } +const char *prefix; +const char *net_search_cfg; +int disable_net_search =0 ; + prefix =grub_env_get ("fw_path" );if (! prefix) prefix =grub_env_get ("prefix" ); + + net_search_cfg =grub_env_get ("feature_net_search_cfg" ); +if (net_search_cfg && net_search_cfg[0 ] =='n' ) + disable_net_search =1 ; +if (prefix) { -grub_size_t config_len; -int disable_net_search =0 ; -const char *net_search_cfg; - - config_len =grub_strlen (prefix) + -sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" ); - config =grub_malloc (config_len); +if (grub_strncmp (prefix +1 ,"tftp" ,sizeof ("tftp" ) -1 ) ==0 && + !disable_net_search) + { +grub_size_t config_len; + config_len =grub_strlen (prefix) + +sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" ); + config =grub_malloc (config_len); -if (!config) - goto quit; +if (! config) + goto quit; -grub_snprintf (config, config_len,"%s/grub.cfg" , prefix); +grub_snprintf (config, config_len,"%s/grub.cfg" , prefix); - net_search_cfg =grub_env_get ("feature_net_search_cfg" ); -if (net_search_cfg && net_search_cfg[0 ] =='n' ) - disable_net_search =1 ; +grub_net_search_configfile (config); -if (grub_strncmp (prefix +1 ,"tftp" ,sizeof ("tftp" ) -1 ) ==0 && - !disable_net_search) -grub_net_search_config_file (config); +grub_enter_normal_mode (config); +grub_free (config); + config =NULL ; + } -grub_enter_normal_mode (config); -grub_free (config); - } +if (!config) + { + config =grub_xasprintf ("%s/grub.cfg" , prefix); +if (config) + { +grub_file_t file; + + file =grub_file_open (config,GRUB_FILE_TYPE_CONFIG ); +if (file) + { +grub_file_close (file); +grub_enter_normal_mode (config); + } +else + { +/* Ignore all errors. */ + grub_errno =0 ; + } +grub_free (config); + } + } + }else -grub_enter_normal_mode (0 ); + { +grub_enter_normal_mode (0 ); + } }else grub_enter_normal_mode (argv[0 ]);
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 16/17 10_linux.in: Generate OS and CLASS in 10_linux from /etc/os-release
In reply to Leo SandovalFrom: Peter Jones <[email protected]>
This makes us use pretty names in the titles we generate in grub2-mkconfig when GRUB_DISTRIBUTOR isn't set.
Resolves: rhbz#996794
--- util/grub.d/10_linux.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
util/grub.d/10_linux.in +2 -1
@@ -29,7 +29,8 @@ export TEXTDOMAINDIR="@localedir@" CLASS="--class gnu-linux --class gnu --class os --unrestricted" if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then - OS=GNU/Linux + OS="$(eval $(grep PRETTY_NAME /etc/os-release) ; echo ${PRETTY_NAME})" + CLASS="--class $(eval $(grep '^ID_LIKE=\|^ID=' /etc/os-release) ; [ -n "${ID_LIKE}" ] && echo ${ID_LIKE} || echo ${ID}) ${CLASS}" else OS="${GRUB_DISTRIBUTOR} GNU/Linux" CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 17/17 normal/main: Try $prefix if $fw_path doesn't work.
In reply to Leo SandovalFrom: Peter Jones <[email protected]>
Related: rhbz#1148652
--- grub-core/kern/ieee1275/init.c | 28 +++---- grub-core/net/net.c | 2 +- grub-core/normal/main.c | 132 ++++++++++++++++----------------- 3 files changed, 81 insertions(+), 81 deletions(-)
grub-core/kern/ieee1275/init.c +15 -13
@@ -170,23 +170,25 @@ grub_machine_get_bootlocation (char **device, char **path)grub_free (canon); }else - *device =grub_ieee1275_encode_devname (bootpath); -grub_free (type); - - filename =grub_ieee1275_get_filename (bootpath); -if (filename) { -char *lastslash =grub_strrchr (filename,'\\' ); - -/* Truncate at last directory. */ -if (lastslash) + filename =grub_ieee1275_get_filename (bootpath); +if (filename) { - *lastslash ='\0' ; -grub_translate_ieee1275_path (filename); +char *lastslash =grub_strrchr (filename,'\\' ); - *path = filename; - } +/* Truncate at last directory. */ +if (lastslash) + { + *lastslash ='\0' ; +grub_translate_ieee1275_path (filename); + + *path = filename; + } + } + *device =grub_ieee1275_encode_devname (bootpath); } + +grub_free (type);grub_free (bootpath); }
grub-core/net/net.c +1 -1
@@ -2005,7 +2005,7 @@ grub_net_search_config_file (char *config)/* Remove the remaining minus sign at the end. */ config[config_len] ='\0' ; -return GRUB_ERR_NONE ; +return GRUB_ERR_FILE_NOT_FOUND ; }static struct grub_preboot *fini_hnd;
grub-core/normal/main.c +65 -67
146 lines not on this page · raw message
Signature · 7 lines
2.46.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel