Re: [PATCH v4 3/5] efi: Drop all uses of efi_call_XX wrappers

2023-06-16 Thread Daniel Kiper
On Fri, Jun 16, 2023 at 02:24:51PM +0200, Christian Hesse wrote:
> Robin Candau  on Fri, 2023/06/16 12:48:
> > Le 16/06/2023 à 12:35, Daniel Kiper a écrit :
> > > On Fri, Jun 16, 2023 at 09:15:19AM +0200, Robin Candau wrote:
> > >> Le 15/06/2023 à 23:36, Christian Hesse a écrit :
> > >>> Daniel Kiper  on Thu, 2023/06/15 17:05:
> > > It looks I was able to reproduce this problem. I will be checking what
> > > is going on in following days...
> >  Here [1] is the fix. Please test...
> > >>> Works for me, thanks!
> > >> Works for me as well, thanks!
> > > Cool! Thanks for doing tests!
> > >
> > > Christian, Robin, may I add Tested-by tag on your behalf to the patch?
> >
> > Fine by me ;)
>
> Sure, same for me! :)

Great! Thanks a lot!

Daniel

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH v4 3/5] efi: Drop all uses of efi_call_XX wrappers

2023-06-16 Thread Christian Hesse
Robin Candau  on Fri, 2023/06/16 12:48:
> Le 16/06/2023 à 12:35, Daniel Kiper a écrit :
> > On Fri, Jun 16, 2023 at 09:15:19AM +0200, Robin Candau wrote:  
> >> Le 15/06/2023 à 23:36, Christian Hesse a écrit :  
> >>> Daniel Kiper  on Thu, 2023/06/15 17:05:  
> > It looks I was able to reproduce this problem. I will be checking what
> > is going on in following days...  
>  Here [1] is the fix. Please test...  
> >>> Works for me, thanks!  
> >> Works for me as well, thanks!  
> > Cool! Thanks for doing tests!
> >
> > Christian, Robin, may I add Tested-by tag on your behalf to the patch?
>
> Fine by me ;)

Sure, same for me! :)

Thanks a lot!
-- 
main(a){char*c=/*Schoene Gruesse */"B?IJj;MEH"
"CX:;",b;for(a/*Best regards my address:*/=0;b=c[a++];)
putchar(b-1/(/*Chriscc -ox -xc - && ./x*/b/42*2-3)*42);}


pgpheecrerVuv.pgp
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH v1a] grub-emu: Add SDL2 support

2023-06-16 Thread Julian Andres Klode
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.
> 
> 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.

So now we have both approaches for configure.ac, I'm really not sure
what to prefer and leave it up to reviews.

-- 
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer  i speak de, en

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH v1a] grub-emu: Add SDL2 support

2023-06-16 Thread Julian Andres Klode
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   | 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"])
+  [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] grub-emu: Add SDL2 support

2023-06-16 Thread Julian Andres Klode
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.

The configure script is changed to prefer SDL2 over SDL1 if available,
the detection of SDL2 is done using the pkg-config file. This does
not allow explicit choosing of SDL2 vs SDL1, but seems like it will
be less confusing as time goes on and you get SDL3 and so on.

Bug-Debian: https://bugs.debian.org/1038035
Signed-off-by: Julian Andres Klode 
---
 configure.ac|  22 +---
 grub-core/Makefile.core.def |   5 +-
 grub-core/video/emu/sdl.c   | 108 +---
 include/grub/sdl.h  |  16 +-
 4 files changed, 119 insertions(+), 32 deletions(-)

diff --git a/configure.ac b/configure.ac
index d9f088d12..ed5673534 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1578,15 +1578,19 @@ if test "$platform" = emu; then
   fi
   [if [ x"$grub_emu_sdl_excuse" = x ]; then
 # Check for libSDL libraries.]
-AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
-[grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' 
with SDL support"]])
-AC_SUBST([LIBSDL])
-  [fi]
-
-  [if [ x"$grub_emu_sdl_excuse" = x ]; then
-# Check for headers.]
-AC_CHECK_HEADERS([SDL/SDL.h], [],
-  [grub_emu_sdl_excuse=["libSDL header file is required to build 
\`grub-emu' with SDL support"]])
+  PKG_CHECK_MODULES([SDL2], [sdl2], [
+AC_DEFINE([HAVE_SDL2], [1], [Define to 1 if you have SDL2 
library.])
+AC_SUBST(HAVE_SDL2)], [
+AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
+[grub_emu_sdl_excuse=["libSDL libraries are required to build 
\`grub-emu' with SDL support"]])
+AC_SUBST([LIBSDL])
+
+  [if [ x"$grub_emu_sdl_excuse" = x ]; then
+# Check for headers.]
+AC_CHECK_HEADERS([SDL/SDL.h], [],
+  [grub_emu_sdl_excuse=["libSDL header file is required to build 
\`grub-emu' with SDL support"]])
+  [fi]
+  ])
   [fi]
 
   if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; 
then
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index e458aa665..100829853 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)';
 
   enable = emu;
 };
@@ -430,7 +430,7 @@ program = {
   emu_nodist = symlist.c;
 
   ldadd = 'kernel.exec$(EXEEXT)';
-  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)';
 
   enable = emu;
 };
@@ -2323,6 +2323,7 @@ module = {
   emu = video/emu/sdl.c;
   enable = emu;
   condition = COND_GRUB_EMU_SDL;
+  cflags = '$(SDL2_CFLAGS)';
 };
 
 module = {
diff --git a/grub-core/video/emu/sdl.c b/grub-core/video/emu/sdl.c
index 0ebab6f57..93fb83da0 100644
--- a/grub-core/video/emu/sdl.c
+++ b/grub-core/video/emu/sdl.c
@@ -18,6 +18,9 @@
 
 #define grub_video_render_target grub_video_fbrender_target
 
+#include 
+#include 
+
 #include 
 #include 
 #include 
@@ -25,11 +28,23 @@
 #include 
 #include 
 #include 
+#ifdef HAVE_SDL2
+#include 
+#else
 #include 
+#endif
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
+#ifdef HAVE_SDL2
+static SDL_Window *window = 0;
+static SDL_Surface *surface = 0;
+static SDL_Texture *texture = 0;
+static SDL_Renderer *renderer = 0;
+#else
 static SDL_Surface *window = 0;
+static SDL_Surface *surface = 0;
+#endif
 static struct grub_video_render_target *sdl_render_target;
 static struct grub_video_mode_info mode_info;
 
@@ -91,6 +106,34 @@ grub_video_sdl_setup (unsigned int width, unsigned int 
height,
   height = 600;
 }
 
+#ifdef HAVE_SDL2
+  (void) mode_mask; // We can't specify this in SDL2
+  window = SDL_CreateWindow ("grub-emu",
+SDL_WINDOWPOS_UNDEFINED,
+SDL_WINDOWPOS_UNDEFINED,
+width, height, flags);
+  if (! window)
+return grub_error (GRUB_ERR_BAD_DEVICE, "Couldn't open window: %s",
+  SDL_GetError ());
+  renderer = SDL_CreateRenderer (window, -1, 0);
+  if (! renderer)
+return grub_error 

grub-2.06 fails to load 64bit Multiboot2 ELF with regions above 4GiB

2023-06-16 Thread Baksik, Fred [USA] via Grub-devel
I tried report this issue to the bug-grub mailing list but didn't see the Bug 
Tracker get updated.
I'd like to get this reported so anyone else using multiboot2 to boot and 
embedded RTOS knows of this problem.

I also supplied a patch that fixes the issue.

Regards,
Fred Baksik
Sr Prin Software Engineer
Systems | Mission
Mercury Systems
6675 Shiloh Road East, Alpharetta, GA 30005
+1 978.967.3405 office

fred.bak...@mrcy.com | 
mrcy.com

From: Baksik, Fred [USA]
Sent: Wednesday, May 24, 2023 9:14 AM
To: bug-g...@gnu.org
Subject: grub-2.06 fails to load 64bit Multiboot2 ELF with regions above 4GiB

GRUB2 fails to load a Multiboot2 ELF with loadable regions above 4GiB.  The 
error seen is "segment crosses 4 GiB border".

The 4 GiB border check was added as part of "multiboot2: Add support for 
relocatable images" commit a620876e3b32e4ea0c9a7b3541fcb9a4dd4fb9eb.
I believe this check should only apply when the multiboot2 image supports 
relocation via the MULTIBOOT_HEADER_TAG_RELOCATABLE tag.

Subject: [PATCH] multiboot2: check 4GiB limit for relocatable images only

---
grub-core/loader/multiboot_elfxx.c | 9 +
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/grub-core/loader/multiboot_elfxx.c 
b/grub-core/loader/multiboot_elfxx.c
index f2318e0..0ac11f0 100644
--- a/grub-core/loader/multiboot_elfxx.c
+++ b/grub-core/loader/multiboot_elfxx.c
@@ -92,10 +92,6 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld)
highest_load = grub_max (highest_load, phdr(i)->p_paddr + phdr(i)->p_memsz);
   }

-#ifdef MULTIBOOT_LOAD_ELF64
-  if (highest_load >= 0x1)
-return grub_error (GRUB_ERR_BAD_OS, "segment crosses 4 GiB border");
-#endif

   if (mld->relocatable)
 {
@@ -106,6 +102,11 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld)
  (long) mld->align, mld->preference, load_size,
  mld->avoid_efi_boot_services);

+#ifdef MULTIBOOT_LOAD_ELF64
+  if (highest_load >= 0x1)
+return grub_error (GRUB_ERR_BAD_OS, "segment crosses 4 GiB border");
+#endif
+
   if (load_size > mld->max_addr || mld->min_addr > mld->max_addr - 
load_size)
return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load 
size");

--
2.31.1

Fred Baksik
Sr Prin Software Engineer
Systems | Mission
Mercury Systems
6675 Shiloh Road East, Alpharetta, GA 30005
+1 978.967.3405 office

fred.bak...@mrcy.com | 
mrcy.com

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH v4 3/5] efi: Drop all uses of efi_call_XX wrappers

2023-06-16 Thread Robin Candau

Le 16/06/2023 à 12:35, Daniel Kiper a écrit :

On Fri, Jun 16, 2023 at 09:15:19AM +0200, Robin Candau wrote:

Le 15/06/2023 à 23:36, Christian Hesse a écrit :

Daniel Kiper  on Thu, 2023/06/15 17:05:

It looks I was able to reproduce this problem. I will be checking what
is going on in following days...

Here [1] is the fix. Please test...

Works for me, thanks!

Works for me as well, thanks!

Cool! Thanks for doing tests!

Christian, Robin, may I add Tested-by tag on your behalf to the patch?

Daniel


Fine by me ;)

Thanks again

--
Regards,
Robin Candau / Antiz



OpenPGP_0xFDC3040B92ACA748.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH v4 3/5] efi: Drop all uses of efi_call_XX wrappers

2023-06-16 Thread Daniel Kiper
On Fri, Jun 16, 2023 at 09:15:19AM +0200, Robin Candau wrote:
> Le 15/06/2023 à 23:36, Christian Hesse a écrit :
> > Daniel Kiper  on Thu, 2023/06/15 17:05:
> > > > It looks I was able to reproduce this problem. I will be checking what
> > > > is going on in following days...
> > > Here [1] is the fix. Please test...
> > Works for me, thanks!
> Works for me as well, thanks!

Cool! Thanks for doing tests!

Christian, Robin, may I add Tested-by tag on your behalf to the patch?

Daniel

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH v4 3/5] efi: Drop all uses of efi_call_XX wrappers

2023-06-16 Thread Robin Candau

Le 15/06/2023 à 23:36, Christian Hesse a écrit :

Daniel Kiper  on Thu, 2023/06/15 17:05:

It looks I was able to reproduce this problem. I will be checking what
is going on in following days...

Here [1] is the fix. Please test...

Works for me, thanks!

Works for me as well, thanks!

--
Regards,
Robin Candau / Antiz



OpenPGP_0xFDC3040B92ACA748.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel