Re: [PATCH v2 2/2] grub-emu: Add SDL2 support
On Wed, Jun 21, 2023 at 03:14:17PM +0200, Julian Andres Klode wrote: > So all we did with the surface in SDL1 was split into window, > surface, renderer, and texture. Instead of drawing into the > surface and then flipping, you build your pixels, then update > a texture, and then copy the texture to the renderer. > > Here we use an empty RGB surface to hold our Pixels, which enables > us to keep most of the code the same. The SDL1 code has been adjusted > to refer to `surface` instead of `window` when trying to access the > properties of the surface. > > This approaches the configuration by adding a new --enable-grub-emu-sdl2 > argument. If set to yes, or auto detected, it disables SDL1 support > automatically. > > This duplicates the `sdl` module block in Makefile.core.def which may > be something to be aware of, but we also don't want to build separate > module. I'm wondering if it makes sense to keep SDL1 support at all? SDL2 was released almost 10 years ago, I'd suggest to just do a hard switch from SDL1 to SDL2 instead of supporting both. take care, Gerd ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: GRUB 2.02 and APFS filesystems causing boot-time issue
Hi, On Thu, Jun 15, 2023 at 06:16:07PM -0400, vinc...@cojot.name wrote: > Hi all, > > I'm new to this list and I hope it's the right place to ask for help.. > > I'd like to better understand how to rebuild grubx64.efi from upstream > source so I could give a try at fixing the issue I've come across: > > https://bugzilla.redhat.com/show_bug.cgi?id=1524685 > > https://savannah.gnu.org/bugs/?64304 > > Long story short: the simple presence of an APFS filesystem on any disk in > an x86_64 system makes GRUB spit out errors (as if multiple disks were > unreadable). The machine still boots fine (after pressing 'q') but the > process requires human intervention on every reboot. > > The machine in question is a Mac Pro (Later 2013) but at this point I'm > pretty sure it's a software problem since changing the partition type of the > APFS partition to something else makes GRUB happy again. > > This system uses UEFI and the Linux boot entry shows this: > > [root@neraka ~]# efibootmgr -v|grep shim > Boot* Red Hat Enterprise Linux > HD(2,GPT,d36bfc93-9920-4346-9c56-bd7c57bdb0bb,0x1000,0x3f800)/File(\EFI\redhat\shimx64.efi) > > Is my interpretation of the issue correct? Something causes GRUB to get > confused when it probes/enumerates the partition and it fails in shimx64.efi > (a signed grubx64.efi rebuild) > > Since shimx64.efi is a signed binary which would not possible for me to > rebuild, am I correct to think that I instead want to boot grubx64.efi an > learn how to rebuild it (with efibootmgr it would be easy to add another > entry pointing to that binary and try to boot from it). shimx64.efi calls grubx64.efi from ESP. But you are right, you have to rebuild grubx64.efi. Though it should be signed too. Or disable UEFI Secure Boot for testing and development. > I would love to have a few pointers, Thank you. (I've done some 'C' and > 'ASM' in my past lives so I hope that will be enough... ) :) The INSTALL file in the GRUB source should have all info which you need to build your own GRUB binary. The upstream source code is here [1]. Please remember that (unfortunately) GRUB from Red Hat differs in many aspects from the GRUB upstream. If you still have any questions drop us a line. Daniel [1] http://git.savannah.gnu.org/gitweb/?p=grub.git&view=view+git+repository ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 2/2] grub-emu: Add SDL2 support
So all we did with the surface in SDL1 was split into window, surface, renderer, and texture. Instead of drawing into the surface and then flipping, you build your pixels, then update a texture, and then copy the texture to the renderer. Here we use an empty RGB surface to hold our Pixels, which enables us to keep most of the code the same. The SDL1 code has been adjusted to refer to `surface` instead of `window` when trying to access the properties of the surface. This approaches the configuration by adding a new --enable-grub-emu-sdl2 argument. If set to yes, or auto detected, it disables SDL1 support automatically. This duplicates the `sdl` module block in Makefile.core.def which may be something to be aware of, but we also don't want to build separate module. Bug-Debian: https://bugs.debian.org/1038035 Signed-off-by: Julian Andres Klode --- configure.ac| 34 +++ grub-core/Makefile.am | 3 + grub-core/Makefile.core.def | 12 +++- grub-core/video/emu/sdl.c | 109 +--- include/grub/sdl.h | 16 +- 5 files changed, 151 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index abd8375fd..0d5eb77a2 100644 --- a/configure.ac +++ b/configure.ac @@ -1563,6 +1563,10 @@ else fi AC_SUBST([BOOT_TIME_STATS]) +AC_ARG_ENABLE([grub-emu-sdl2], + [AS_HELP_STRING([--enable-grub-emu-sdl2], + [build and install the `grub-emu' debugging utility with SDL2 support (default=guessed)])]) + AC_ARG_ENABLE([grub-emu-sdl], [AS_HELP_STRING([--enable-grub-emu-sdl], [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])]) @@ -1572,6 +1576,28 @@ AC_ARG_ENABLE([grub-emu-pci], [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])]) if test "$platform" = emu; then + if test x"$enable_grub_emu_sdl2" = xno ; then +grub_emu_sdl2_excuse="explicitly disabled" + fi + [if [ x"$grub_emu_sdl2_excuse" = x ]; then +# Check for libSDL libraries.] +PKG_CHECK_MODULES([SDL2], [sdl2], [ +AC_DEFINE([HAVE_SDL2], [1], [Define to 1 if you have SDL2 library.]) +AC_SUBST(HAVE_SDL2)], +[grub_emu_sdl2_excuse="libSDL2 libraries are required to build \`grub-emu' with SDL2 support"]) + [fi] + if test x"enable_grub_emu_sdl2" = xyes && test x"$grub_emu_sdl2_excuse" != x ; then +AC_MSG_ERROR([SDL2 support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl2_excuse)]) + fi + if test x"$grub_emu_sdl2_excuse" = x ; then +enable_grub_emu_sdl2=yes + else +enable_grub_emu_sdl2=no + fi + if test x"$enable_grub_emu_sdl2" = xyes ; then +grub_emu_sdl_excuse="disabled by sdl2" + fi + if test x"$enable_grub_emu_sdl" = xno ; then grub_emu_sdl_excuse="explicitly disabled" @@ -1620,12 +1646,14 @@ AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"], enable_grub_emu_pci=no fi + AC_SUBST([enable_grub_emu_sdl2]) AC_SUBST([enable_grub_emu_sdl]) AC_SUBST([enable_grub_emu_pci]) else # Ignore --enable-emu-* if platform is not emu + enable_grub_emu_sdl2=no enable_grub_emu_sdl=no enable_grub_emu_pci=no fi @@ -2052,6 +2080,7 @@ AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu]) AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos]) AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x]) +AM_CONDITIONAL([COND_GRUB_EMU_SDL2], [test x$enable_grub_emu_sdl2 = xyes]) AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes]) AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes]) AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes]) @@ -2130,6 +2159,11 @@ echo "***" echo GRUB2 will be compiled with following components: echo Platform: "$target_cpu"-"$platform" if [ x"$platform" = xemu ]; then +if [ x"$grub_emu_sdl2_excuse" = x ]; then +echo SDL2 support for grub-emu: Yes +else +echo SDL2 support for grub-emu: No "($grub_emu_sdl2_excuse)" +fi if [ x"$grub_emu_sdl_excuse" = x ]; then echo SDL support for grub-emu: Yes else diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index d32f2b662..f0cb2f2cc 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -317,6 +317,9 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/exec.h if COND_GRUB_EMU_SDL KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h endif +if COND_GRUB_EMU_SDL2 +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h +endif if COND_GRUB_EMU_PCI KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h endif diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index e458aa665..d2cf29584 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @
[PATCH v2 1/2] grub-emu: SDL style fixes
These should be quite obvious and will make the SDL2 patch easier to read then doing it inline there. --- configure.ac | 2 +- grub-core/video/emu/sdl.c | 16 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index d9f088d12..abd8375fd 100644 --- a/configure.ac +++ b/configure.ac @@ -1590,7 +1590,7 @@ AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"], [fi] if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then - AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)]) +AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)]) fi if test x"$grub_emu_sdl_excuse" = x ; then enable_grub_emu_sdl=yes diff --git a/grub-core/video/emu/sdl.c b/grub-core/video/emu/sdl.c index 0ebab6f57..c1b66f01e 100644 --- a/grub-core/video/emu/sdl.c +++ b/grub-core/video/emu/sdl.c @@ -29,7 +29,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); -static SDL_Surface *window = 0; +static SDL_Surface *window = NULL; static struct grub_video_render_target *sdl_render_target; static struct grub_video_mode_info mode_info; @@ -40,10 +40,10 @@ grub_video_sdl_set_palette (unsigned int start, unsigned int count, static grub_err_t grub_video_sdl_init (void) { - window = 0; + window = NULL; if (SDL_Init (SDL_INIT_VIDEO) < 0) -return grub_error (GRUB_ERR_BAD_DEVICE, "Couldn't init SDL: %s", +return grub_error (GRUB_ERR_BAD_DEVICE, "could not init SDL: %s", SDL_GetError ()); grub_memset (&mode_info, 0, sizeof (mode_info)); @@ -55,7 +55,7 @@ static grub_err_t grub_video_sdl_fini (void) { SDL_Quit (); - window = 0; + window = NULL; grub_memset (&mode_info, 0, sizeof (mode_info)); @@ -96,10 +96,10 @@ grub_video_sdl_setup (unsigned int width, unsigned int height, flags |= SDL_DOUBLEBUF; window = SDL_SetVideoMode (width, height, depth, flags | SDL_HWSURFACE); - if (! window) + if (window == NULL) window = SDL_SetVideoMode (width, height, depth, flags | SDL_SWSURFACE); - if (! window) -return grub_error (GRUB_ERR_BAD_DEVICE, "Couldn't open window: %s", + if (window == NULL) +return grub_error (GRUB_ERR_BAD_DEVICE, "could not open window: %s", SDL_GetError ()); grub_memset (&sdl_render_target, 0, sizeof (sdl_render_target)); @@ -191,7 +191,7 @@ static grub_err_t grub_video_sdl_swap_buffers (void) { if (SDL_Flip (window) < 0) -return grub_error (GRUB_ERR_BAD_DEVICE, "couldn't swap buffers: %s", +return grub_error (GRUB_ERR_BAD_DEVICE, "could not swap buffers: %s", SDL_GetError ()); return GRUB_ERR_NONE; } -- 2.40.1 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 0/2] grub-emu: Add SDL2 support
This is version 2 of the patch series, addressing the review from v1a. It's split in two batches to first change the sdl code to match the coding style and then introduce the sdl2 support in the correct style, to avoid having unrelated style changes in the latter patch making it harder to read. I have not addressed the SDL2_LIBS vs LIBSDL2 controversy in the code: On Wed, Jun 21, 2023 at 02:24:56PM +0200, Daniel Kiper wrote: > On Fri, Jun 16, 2023 at 01:52:27PM +0200, Julian Andres Klode wrote: > > diff --git a/grub-core/Makefile.core.def > > b/grub-core/Makefile.core.def > > index e458aa665..d2cf29584 100644 > > --- a/grub-core/Makefile.core.def > > +++ b/grub-core/Makefile.core.def > > @@ -418,7 +418,7 @@ program = { > > > >ldadd = 'kernel.exec$(EXEEXT)'; > >ldadd = '$(MODULE_FILES)'; > > - ldadd = 'lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) > > $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) > > $(LIBGEOM)'; > > + ldadd = 'lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) > > $(SDL2_LIBS) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) > > $(LIBNVPAIR) $(LIBGEOM)'; > > s/SDL2_LIBS/LIBSDL2/? If possible stick to the naming convention here. The libs expand from pkg-config call, compare FUSE_LIBS, there's also SDL2_CPPFLAGS and so on or something. I don't think adding a 2nd variable with the same content adds value. ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v1a] grub-emu: Add SDL2 support
On Fri, Jun 16, 2023 at 01:52:27PM +0200, Julian Andres Klode wrote: > So all we did with the surface in SDL1 was split into window, > surface, renderer, and texture. Instead of drawing into the > surface and then flipping, you build your pixels, then update > a texture, and then copy the texture to the renderer. > > Here we use an empty RGB surface to hold our Pixels, which enables > us to keep most of the code the same. The SDL1 code has been adjusted > to refer to `surface` instead of `window` when trying to access the > properties of the surface. > > This approaches the configuration by adding a new --enable-grub-emu-sdl2 > argument. If set to yes, or auto detected, it disables SDL1 support > automatically. I think I prefer this approach. > This duplicates the `sdl` module block in Makefile.core.def which may > be something to be aware of, but we also don't want to build separate > module. > > Bug-Debian: https://bugs.debian.org/1038035 > Signed-off-by: Julian Andres Klode > --- > configure.ac| 34 > grub-core/Makefile.am | 3 + > grub-core/Makefile.core.def | 12 +++- > grub-core/video/emu/sdl.c | 108 +--- > include/grub/sdl.h | 16 +- > 5 files changed, 150 insertions(+), 23 deletions(-) > > diff --git a/configure.ac b/configure.ac > index d9f088d12..7747582df 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -1563,6 +1563,10 @@ else > fi > AC_SUBST([BOOT_TIME_STATS]) > > +AC_ARG_ENABLE([grub-emu-sdl2], > + [AS_HELP_STRING([--enable-grub-emu-sdl2], > + [build and install the `grub-emu' debugging > utility with SDL2 support (default=guessed)])]) > + > AC_ARG_ENABLE([grub-emu-sdl], > [AS_HELP_STRING([--enable-grub-emu-sdl], > [build and install the `grub-emu' debugging > utility with SDL support (default=guessed)])]) > @@ -1572,6 +1576,28 @@ AC_ARG_ENABLE([grub-emu-pci], > [build and install the `grub-emu' debugging > utility with PCI support (potentially dangerous) (default=no)])]) > > if test "$platform" = emu; then > + if test x"$enable_grub_emu_sdl2" = xno ; then > +grub_emu_sdl2_excuse="explicitly disabled" > + fi > + [if [ x"$grub_emu_sdl2_excuse" = x ]; then > +# Check for libSDL libraries.] > + PKG_CHECK_MODULES([SDL2], [sdl2], [ > +AC_DEFINE([HAVE_SDL2], [1], [Define to 1 if you have SDL2 > library.]) > +AC_SUBST(HAVE_SDL2)], > +[grub_emu_sdl2_excuse="libSDL2 libraries are required to build > \`grub-emu' with SDL2 support"]) Something is wrong with indention. > + [fi] > + if test x"enable_grub_emu_sdl2" = xyes && test x"$grub_emu_sdl2_excuse" != > x ; then > + AC_MSG_ERROR([SDL2 support for grub-emu was explicitly requested but can't > be compiled ($grub_emu_sdl2_excuse)]) Ditto. > + fi > + if test x"$grub_emu_sdl2_excuse" = x ; then > +enable_grub_emu_sdl2=yes > + else > +enable_grub_emu_sdl2=no > + fi > + if test x"$enable_grub_emu_sdl2" = xyes ; then > +grub_emu_sdl_excuse="disabled by sdl2" > + fi > + > >if test x"$enable_grub_emu_sdl" = xno ; then > grub_emu_sdl_excuse="explicitly disabled" > @@ -1620,12 +1646,14 @@ AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"], > enable_grub_emu_pci=no >fi > > + AC_SUBST([enable_grub_emu_sdl2]) >AC_SUBST([enable_grub_emu_sdl]) >AC_SUBST([enable_grub_emu_pci]) > > else > ># Ignore --enable-emu-* if platform is not emu > + enable_grub_emu_sdl2=no >enable_grub_emu_sdl=no >enable_grub_emu_pci=no > fi > @@ -2052,6 +2080,7 @@ AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = > xxnu]) > AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos]) > > AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN > != x]) > +AM_CONDITIONAL([COND_GRUB_EMU_SDL2], [test x$enable_grub_emu_sdl2 = xyes]) > AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes]) > AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes]) > AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes]) > @@ -2130,6 +2159,11 @@ echo > "***" > echo GRUB2 will be compiled with following components: > echo Platform: "$target_cpu"-"$platform" > if [ x"$platform" = xemu ]; then > +if [ x"$grub_emu_sdl2_excuse" = x ]; then > +echo SDL2 support for grub-emu: Yes > +else > +echo SDL2 support for grub-emu: No "($grub_emu_sdl2_excuse)" > +fi > if [ x"$grub_emu_sdl_excuse" = x ]; then > echo SDL support for grub-emu: Yes > else > diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am > index d32f2b662..f0cb2f2cc 100644 > --- a/grub-core/Makefile.am > +++ b/grub-core/Makefile.am > @@ -317,6 +317,9 @@ KERNEL_HEADER_FILES += > $(top_srcdir)/include/grub/emu/exec.h > if COND_GRUB_EMU_SDL > KERNEL_HEADER_FILES += $(top_srcdir)/include/gr
Re: [PATCH v2 0/1] tpm: Enable boot despite unknown firmware failure
On Fri, Jun 16, 2023 at 12:39:46AM +0200, Michał Grzelak wrote: > Hi all, > > This patch fixes small problem with my computer being unbootable under > certain circumstances. It also addresses concerns pointed out by Daniel > with previous version. If there are any, I would appreciate further > comments. > > Best regards, > Michał > > --- > Changelog: > v1->v2: > - change grub_tpm_is_fail_fatal() back to tpm_is_fail_fatal() Nah, we should not do this because the function is global. However, you did it due to my (wrong) suggestion. Sorry about that. I will fix it before push. Otherwise Reviewed-by: Daniel Kiper ... Daniel > - make is_tpm_fail_fatal() static > - move is_tpm_fail_fatal() body to include/grub/tpm.h > - update docs excerpt about tpm_fail_fatal > > Michał Grzelak (1): > tpm: Enable boot despite unknown firmware failure > > docs/grub.texi | 5 + > grub-core/commands/efi/tpm.c | 3 ++- > grub-core/commands/tpm.c | 7 --- > include/grub/tpm.h | 9 + > 4 files changed, 16 insertions(+), 8 deletions(-) ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v5 1/1] loongarch: disable relaxation relocations
On Thu, Jun 15, 2023 at 08:10:38PM +0800, Xiaotian Wu wrote: > A working grub cannot be built with upcoming binutils and gcc, because linker > relaxation was added [1] causing new unsupported relocations to appear in > modules. > > So we pass -mno-relax to gcc if it is supported, to disable relaxation and > make > grub forward-compatible with new toolchains. > > While similar code already exists for sparc64 in configure.ac, sparc64 sets > LDFLAGS while loongarch requires CFLAGS to be set. If we only set LDFLAGS on > loongarch, gcc will still generate relaxation relocations in the .o files, so > the sparc64 code cannot be reused. > > [1]: > https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=56576f4a722b7398d35802ecf7d4185c27d6d69b > > Signed-off-by: Xiaotian Wu Reviewed-by: Daniel Kiper Daniel ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel