[PATCH v3 1/2] search: fixed bug stopping iteration when --no-floppy is used

2022-02-08 Thread Renaud Métrich
When using --no-floppy and a floppy was encountered, iterate_device()
was returning 1, causing the iteration to stop instead of continuing.

Signed-off-by: Renaud Métrich 
---
 grub-core/commands/search.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c
index ed090b3af..51656e361 100644
--- a/grub-core/commands/search.c
+++ b/grub-core/commands/search.c
@@ -64,7 +64,7 @@ iterate_device (const char *name, void *data)
   /* Skip floppy drives when requested.  */
   if (ctx->no_floppy &&
   name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
-return 1;
+return 0;
 
 #ifdef DO_SEARCH_FS_UUID
 #define compare_fn grub_strcasecmp
-- 
2.34.1


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


[PATCH v3 2/2] search: new --efidisk-only option on EFI systems

2022-02-08 Thread Renaud Métrich
When using 'search' on EFI systems, we sometimes want to exclude devices
that are not EFI disks (e.g. md, lvm).
This is typically used when wanting to chainload when having a software
raid (md) for EFI partition:
with no option, 'search --file /EFI/redhat/shimx64.efi' sets root envvar
to 'md/boot_efi' which cannot be used for chainloading since there is no
effective EFI device behind.

This commit also refactors handling of --no-floppy option.

Signed-off-by: Renaud Métrich 
---
 grub-core/commands/search.c  | 27 +++
 grub-core/commands/search_wrap.c | 18 --
 include/grub/search.h| 15 ---
 3 files changed, 47 insertions(+), 13 deletions(-)

diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c
index 51656e361..57d26ced8 100644
--- a/grub-core/commands/search.c
+++ b/grub-core/commands/search.c
@@ -47,7 +47,7 @@ struct search_ctx
 {
   const char *key;
   const char *var;
-  int no_floppy;
+  enum search_flags flags;
   char **hints;
   unsigned nhints;
   int count;
@@ -62,10 +62,29 @@ iterate_device (const char *name, void *data)
   int found = 0;
 
   /* Skip floppy drives when requested.  */
-  if (ctx->no_floppy &&
+  if (ctx->flags & SEARCH_FLAGS_NO_FLOPPY &&
   name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
 return 0;
 
+  /* Limit to EFI disks when requested.  */
+  if (ctx->flags & SEARCH_FLAGS_EFIDISK_ONLY)
+{
+  grub_device_t dev;
+  dev = grub_device_open (name);
+  if (! dev)
+   {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+   }
+  if (! dev->disk || dev->disk->dev->id != GRUB_DISK_DEVICE_EFIDISK_ID)
+   {
+ grub_device_close (dev);
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+   }
+  grub_device_close (dev);
+}
+
 #ifdef DO_SEARCH_FS_UUID
 #define compare_fn grub_strcasecmp
 #else
@@ -261,13 +280,13 @@ try (struct search_ctx *ctx)
 }
 
 void
-FUNC_NAME (const char *key, const char *var, int no_floppy,
+FUNC_NAME (const char *key, const char *var, enum search_flags flags,
   char **hints, unsigned nhints)
 {
   struct search_ctx ctx = {
 .key = key,
 .var = var,
-.no_floppy = no_floppy,
+.flags = flags,
 .hints = hints,
 .nhints = nhints,
 .count = 0,
diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c
index 47fc8eb99..464e6ebb1 100644
--- a/grub-core/commands/search_wrap.c
+++ b/grub-core/commands/search_wrap.c
@@ -40,6 +40,7 @@ static const struct grub_arg_option options[] =
  N_("Set a variable to the first device found."), N_("VARNAME"),
  ARG_TYPE_STRING},
 {"no-floppy",  'n', 0, N_("Do not probe any floppy drive."), 0, 0},
+{"efidisk-only",   0, 0, N_("Only probe EFI disks."), 0, 0},
 {"hint",   'h', GRUB_ARG_OPTION_REPEATABLE,
  N_("First try the device HINT. If HINT ends in comma, "
"also try subpartitions"), N_("HINT"), ARG_TYPE_STRING},
@@ -73,6 +74,7 @@ enum options
 SEARCH_FS_UUID,
 SEARCH_SET,
 SEARCH_NO_FLOPPY,
+SEARCH_EFIDISK_ONLY,
 SEARCH_HINT,
 SEARCH_HINT_IEEE1275,
 SEARCH_HINT_BIOS,
@@ -89,6 +91,7 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char 
**args)
   const char *id = 0;
   int i = 0, j = 0, nhints = 0;
   char **hints = NULL;
+  enum search_flags flags;
 
   if (state[SEARCH_HINT].set)
 for (i = 0; state[SEARCH_HINT].args[i]; i++)
@@ -180,15 +183,18 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, 
char **args)
   goto out;
 }
 
+  if (state[SEARCH_NO_FLOPPY].set)
+flags |= SEARCH_FLAGS_NO_FLOPPY;
+
+  if (state[SEARCH_EFIDISK_ONLY].set)
+flags |= SEARCH_FLAGS_EFIDISK_ONLY;
+
   if (state[SEARCH_LABEL].set)
-grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set, 
-  hints, nhints);
+grub_search_label (id, var, flags, hints, nhints);
   else if (state[SEARCH_FS_UUID].set)
-grub_search_fs_uuid (id, var, state[SEARCH_NO_FLOPPY].set,
-hints, nhints);
+grub_search_fs_uuid (id, var, flags, hints, nhints);
   else if (state[SEARCH_FILE].set)
-grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set, 
-hints, nhints);
+grub_search_fs_file (id, var, flags, hints, nhints);
   else
 grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
 
diff --git a/include/grub/search.h b/include/grub/search.h
index d80347df3..4190aeb2c 100644
--- a/include/grub/search.h
+++ b/include/grub/search.h
@@ -19,11 +19,20 @@
 #ifndef GRUB_SEARCH_HEADER
 #define GRUB_SEARCH_HEADER 1
 
-void grub_search_fs_file (const char *key, const char *var, int no_floppy,
+enum search_flags
+  {
+SEARCH_FLAGS_NO_FLOPPY = 1,
+SEARCH_FLAGS_EFIDISK_ONLY  = 2
+  };
+
+void grub_search_fs_file (const char *key, const char *var,
+ enum search_flags flags,
  char **hints, unsigned nh

Re: [PATCH] search: new --efidisk-only option on EFI systems

2022-02-08 Thread Renaud Métrich
So Glenn, I'm new to Grub developer, in the past I was relying on Javier 
Martinez Canillas ...


Just sent v3.

Le 2/7/22 à 22:32, Glenn Washburn a écrit :

On Mon, 7 Feb 2022 12:12:14 +0100
Renaud Métrich  wrote:


Please find inline the new patch integrating Glenn's comments (new
"flags" option instead of "no-floppy" / "efidisk-only").

Thanks for making this inline, but its still not in a great format for
maintainers. Please use "git format-patch" and "git send-email" for the
next iteration. Its pretty easy to setup.

Also, please use the -v option to format-patch to increment the version
of the patch we're on (the next should be v3). Also create a new thread
for each new patch series sent to this list.

I suspect tht Daniel will also request that it be documented in the
commit message that no-floppy handling was changed. Perhaps a line like
"Refactor handling of --no-floppy option as well." Daniel might have
other ideas though.


When using 'search' on EFI systems, we sometimes want to exclude devices
that are not EFI disks (e.g. md, lvm).
This is typically used when wanting to chainload when having a software
raid (md) for EFI partition:
with no option, 'search --file /EFI/redhat/shimx64.efi' sets root envvar
to 'md/boot_efi' which cannot be used for chainloading since there is no
effective EFI device behind.

Signed-off-by: Renaud Métrich 

diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c
index ed090b3af..57d26ced8 100644
--- a/grub-core/commands/search.c
+++ b/grub-core/commands/search.c
@@ -47,7 +47,7 @@ struct search_ctx
   {
     const char *key;
     const char *var;
-  int no_floppy;
+  enum search_flags flags;
     char **hints;
     unsigned nhints;
     int count;
@@ -62,9 +62,28 @@ iterate_device (const char *name, void *data)
     int found = 0;

     /* Skip floppy drives when requested.  */
-  if (ctx->no_floppy &&
+  if (ctx->flags & SEARCH_FLAGS_NO_FLOPPY &&
     name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <=
'9')
-    return 1;
+    return 0;

Ok, so this fixes a bug. At a minimum, that needs to be documented in
the commit message. I think there should be a separate patch with this
bug fix, since its unrelated. Daniel may accept it all as one patch.
I'll let him chime in.


+
+  /* Limit to EFI disks when requested.  */
+  if (ctx->flags & SEARCH_FLAGS_EFIDISK_ONLY)
+    {
+  grub_device_t dev;
+  dev = grub_device_open (name);
+  if (! dev)
+    {
+      grub_errno = GRUB_ERR_NONE;
+      return 0;
+    }

This indent formatting looks off. I think some tabs are getting
converted to 4 spaces.


+  if (! dev->disk || dev->disk->dev->id != GRUB_DISK_DEVICE_EFIDISK_ID)
+    {
+      grub_device_close (dev);
+      grub_errno = GRUB_ERR_NONE;
+      return 0;
+    }

Ditto.


+  grub_device_close (dev);
+    }

   #ifdef DO_SEARCH_FS_UUID
   #define compare_fn grub_strcasecmp
@@ -261,13 +280,13 @@ try (struct search_ctx *ctx)
   }

   void
-FUNC_NAME (const char *key, const char *var, int no_floppy,
+FUNC_NAME (const char *key, const char *var, enum search_flags flags,
      char **hints, unsigned nhints)
   {
     struct search_ctx ctx = {
   .key = key,
   .var = var,
-    .no_floppy = no_floppy,
+    .flags = flags,
   .hints = hints,
   .nhints = nhints,
   .count = 0,
diff --git a/grub-core/commands/search_wrap.c
b/grub-core/commands/search_wrap.c
index 47fc8eb99..464e6ebb1 100644
--- a/grub-core/commands/search_wrap.c
+++ b/grub-core/commands/search_wrap.c
@@ -40,6 +40,7 @@ static const struct grub_arg_option options[] =
    N_("Set a variable to the first device found."), N_("VARNAME"),
    ARG_TYPE_STRING},
   {"no-floppy",    'n', 0, N_("Do not probe any floppy drive."), 0, 0},
+    {"efidisk-only",    0, 0, N_("Only probe EFI disks."), 0, 0},
   {"hint",        'h', GRUB_ARG_OPTION_REPEATABLE,
    N_("First try the device HINT. If HINT ends in comma, "
   "also try subpartitions"), N_("HINT"), ARG_TYPE_STRING},
@@ -73,6 +74,7 @@ enum options
   SEARCH_FS_UUID,
   SEARCH_SET,
   SEARCH_NO_FLOPPY,
+    SEARCH_EFIDISK_ONLY,
   SEARCH_HINT,
   SEARCH_HINT_IEEE1275,
   SEARCH_HINT_BIOS,
@@ -89,6 +91,7 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc,
char **args)
     const char *id = 0;
     int i = 0, j = 0, nhints = 0;
     char **hints = NULL;
+  enum search_flags flags;

     if (state[SEARCH_HINT].set)
   for (i = 0; state[SEARCH_HINT].args[i]; i++)
@@ -180,15 +183,18 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int
argc, char **args)
     goto out;
   }

+  if (state[SEARCH_NO_FLOPPY].set)
+    flags |= SEARCH_FLAGS_NO_FLOPPY;
+
+  if (state[SEARCH_EFIDISK_ONLY].set)
+    flags |= SEARCH_FLAGS_EFIDISK_ONLY;
+
     if (state[SEARCH_LABEL].set)
-    grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set,
-           hints, nhints);
+    grub_search_label (id, var, flags, hints, nhints);
     else if (state[SEARCH

Re: [PATCH] efi: make sure EFI disk controllers are connected when, discovering devices

2022-02-08 Thread Renaud Métrich

Please ignore, resent properly using a git send-email command.

Le 2/1/22 à 11:38, Renaud Métrich a écrit :


When efi.quickboot is enabled on VMWare (which is the default for 
hardware release 16 and later), it may happen that not all EFI devices 
are connected.


Due to this, browsing the devices in make_devices() just fails to find 
devices, in particular partitions for a given disk.
This typically happens when network booting, then trying to chainload 
to local disk (this is used in deployment tools such as Red Hat 
Satellite).


This patch makes sure all controllers are connected before enumerating 
the disks.


It blindly calls the EFI ConnectController function with recursive 
option and just ignores the result, which is 0 (EFI_SUCCESS) or 14 
(EFI_NOT_FOUND) when the handle is not a controller.


Example of "grub.cfg" file used to chainload when system boots over 
the network:


~~~

menuentry 'Chainload Grub2 EFI from ESP' --id local {
   unset root
   search --file --no-floppy --efidisk-only --set=root /EFI/BOOT/BOOTX64.EFI
   if [ -f ($root)/EFI/BOOT/grubx64.efi ]; then
     chainloader ($root)/EFI/BOOT/grubx64.efi
   elif [ -f ($root)/EFI/redhat/shimx64.efi ]; then
     chainloader ($root)/EFI/redhat/shimx64.efi
   elif [ -f ($root)/EFI/redhat/grubx64.efi ]; then
     chainloader ($root)/EFI/redhat/grubx64.efi
   fi
}

~~~

This patch has been tested on QEMU/KVM systems (for non regression) 
and VMWare VMs (at hardware level 6.7 and 7.0u2, with and without 
quickboot for functionality testing).





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


[PATCH v1] efi: make sure EFI disk controllers are connected when discovering devices

2022-02-08 Thread Renaud Métrich
When efi.quickboot is enabled on VMWare (which is the default for
hardware release 16 and later), it may happen that not all EFI devices
are connected. Due to this, browsing the devices in make_devices() just
fails to find devices, in particular partitions for a given disk.
This typically happens when network booting, then trying to chainload to
local disk (this is used in deployment tools such as Red Hat Satellite).

This patch makes sure all controllers are connected before enumerating
the disks. It blindly calls the EFI ConnectController function with
recursive option and just ignores the result, which is 0 (EFI_SUCCESS)
or 14 (EFI_NOT_FOUND) when the handle is not a controller.

Signed-off-by: Renaud Métrich 
---
 grub-core/disk/efi/efidisk.c | 10 ++
 grub-core/kern/efi/efi.c | 13 +
 include/grub/efi/efi.h   |  5 +
 3 files changed, 28 insertions(+)

diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index f077b5f55..0b16c3868 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -387,6 +387,16 @@ static void
 enumerate_disks (void)
 {
   struct grub_efidisk_data *devices;
+  unsigned i;
+  grub_efi_handle_t *handles;
+  grub_efi_uintn_t num_handles;
+
+  /* Prior to enumerating, make sure all EFI devices are connected */
+
+  handles = grub_efi_locate_handle (GRUB_EFI_ALL_HANDLES,
+   NULL, NULL, &num_handles);
+  for (i = 0; i < num_handles; i++)
+(void) grub_efi_connect_controller(handles[i], NULL, NULL, 1);
 
   devices = make_devices ();
   if (! devices)
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index 18858c327..bdfff3dd0 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -95,6 +95,19 @@ grub_efi_locate_handle (grub_efi_locate_search_type_t 
search_type,
   return buffer;
 }
 
+grub_efi_status_t
+grub_efi_connect_controller (grub_efi_handle_t controller_handle,
+grub_efi_handle_t *driver_image_handle,
+grub_efi_device_path_protocol_t 
*remaining_device_path,
+grub_efi_boolean_t recursive)
+{
+  grub_efi_boot_services_t *b;
+
+  b = grub_efi_system_table->boot_services;
+  return efi_call_4 (b->connect_controller, controller_handle,
+driver_image_handle, remaining_device_path, recursive);
+}
+
 void *
 grub_efi_open_protocol (grub_efi_handle_t handle,
grub_efi_guid_t *protocol,
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index fc723962d..62dbd9788 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -32,6 +32,11 @@ EXPORT_FUNC(grub_efi_locate_handle) 
(grub_efi_locate_search_type_t search_type,
 grub_efi_guid_t *protocol,
 void *search_key,
 grub_efi_uintn_t *num_handles);
+grub_efi_status_t
+EXPORT_FUNC(grub_efi_connect_controller) (grub_efi_handle_t controller_handle,
+ grub_efi_handle_t 
*driver_image_handle,
+ grub_efi_device_path_protocol_t 
*remaining_device_path,
+ grub_efi_boolean_t recursive);
 void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle,
   grub_efi_guid_t *protocol,
   grub_efi_uint32_t attributes);
-- 
2.34.1


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


Re: [PATCH 4/4] util/grub-module-verifierXX.c: Add module_size parameter to functions for sanity checking

2022-02-08 Thread Daniel Kiper
On Wed, Feb 02, 2022 at 07:27:00PM -0500, Alec Brown wrote:
> In grub-module-verifierXX.c, the function grub_module_verifyXX() performs an
> initial check that the ELF section headers are within the module's size but
> doesn't check if the sections being accessed have contents that are within the
> module's size. In particular, we need to check that sh_offset and sh_size are
> less than the module's size. However, for some section header types we don't
> need to make these checks. For the type SHT_NULL, the section header is marked
> as inactive and the rest of the members within the section header have 
> undefined
> values, so we don't need to check for sh_offset or sh_size. In the case of the
> type SHT_NOBITS, sh_offset has a conceptual offset which may be beyond the
> module size. Also, this type's sh_size may have a non-zero size, but a section
> of this type will take up no space in the module. This can all be checked in 
> the
> function get_shdr(), but in order to do so, the parameter module_size must be
> added to functions so that the value of the module size can be used in
> get_shdr() from grub_module_verifyXX().
>
> Signed-off-by: Alec Brown 

Sadly this patch breaks one of ARM builds:
  build-grub-module-verifier: error: Section 12 starts after the end of the 
module.
  Makefile:47473: recipe for target 'disk.mod' failed
  make[3]: *** [disk.mod] Error 1
  make[3]: *** Waiting for unfinished jobs
  build-grub-module-verifier: error: Section 12 starts after the end of the 
module.
  Makefile:47473: recipe for target 'boot.mod' failed
  make[3]: *** [boot.mod] Error 1
  ...

You can reproduce this by doing:
  ./configure --target=arm-linux-gnueabihf --with-platform=coreboot 
--enable-grub-mkfont --prefix="`pwd`/grub-dist"
  make install

I have taken the rest of patches and skipped this one.

Daniel

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


Re: [PATCH 2/2] util/resolve.c: Bail with error if moddep lst file line is too long

2022-02-08 Thread Daniel Kiper
On Wed, Jan 12, 2022 at 08:55:01PM -0600, Glenn Washburn wrote:
> The code reads each line into a buffer of size 1024 and does not check if
> the line is longer. So a line longer than 1024 will be read as a valid line
> followed by an invalid line. Then an error confusing to the user is sent
> with the test "invalid line format". But the line format is prefectly fine,
> the problem is in GRUB's parser. Check if we've hit a line longer than the
> size of the buffer, and if so send a more correct and reasonable error.
>
> Signed-off-by: Glenn Washburn 
> ---
>  util/resolve.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/util/resolve.c b/util/resolve.c
> index 5e9afa10c..b0f2661f7 100644
> --- a/util/resolve.c
> +++ b/util/resolve.c
> @@ -127,6 +127,9 @@ read_dep_list (FILE *fp)
> mod->next = dep->list;
> dep->list = mod;
>   }
> +
> + if ((p - buf) == sizeof (buf))
> +   grub_util_error (_("line too long, length greater than %lu: module 
> %s"), sizeof (buf), dep->name);

I had to replace "%lu" with "%zu". Otherwise Windows builds were broken.

Daniel

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


Re: [PATCH 2/2] tests: Add check-native and check-nonnative make targets

2022-02-08 Thread Daniel Kiper
On Wed, Jan 12, 2022 at 08:19:04PM -0600, Glenn Washburn wrote:
> This allows for testing only tests that run directly on the build machine or
> only tests that run in a virtualized environment. When testing multiple
> targets on the same build machine the native tests only need to be run once
> for all targets. Whereas, the nonnative tests must be run for each target
> because the test is potentially compiled differently for each target.
>
> Signed-off-by: Glenn Washburn 

This patch makes bootstrap unhappy:
  Makefile.am:27: warning: check_SCRIPTS multiply defined in condition TRUE ...
  conf/Makefile.common:107: ... 'check_SCRIPTS' previously defined here
  Makefile.am:10:   'conf/Makefile.common' included from here
  Makefile.am:28: warning: check_PROGRAMS multiply defined in condition TRUE ...
  conf/Makefile.common:110: ... 'check_PROGRAMS' previously defined here
  Makefile.am:10:   'conf/Makefile.common' included from here
  Makefile.am:29: warning: TESTS multiply defined in condition TRUE ...
  conf/Makefile.common:128: ... 'TESTS' previously defined here
  Makefile.am:10:   'conf/Makefile.common' included from here

I have just taken patch #1.

Daniel

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


Re: [PATCH v3 0/5] Various test fixes and improvements

2022-02-08 Thread Daniel Kiper
On Sun, Feb 06, 2022 at 04:00:07PM -0600, Glenn Washburn wrote:
> v3 - Fix botched v2 udate
> v2 - Updated with Daniel's suggestions.
>
> Glenn
>
> Glenn Washburn (5):
>   tests: Do not remove image file on error in pata_test
>   tests: Skip pata_test on i386-efi
>   tests: Remove $((BASE#NUM)) bashism in grub-fs-tester

I have just taken these three patches from this series.

Daniel

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


Re: [PATCH v2] grub-mount: Support libfuse 3

2022-02-08 Thread Daniel Kiper
On Mon, Jan 17, 2022 at 03:34:37PM +0100, Fabian Vogt wrote:
> libfuse 3.0.0 got released in 2016, with some API changes compared to 2.x.
> This commit introduces support for 3.x while keeping it compatible with 2.6
> as a fallback still.
>
> To detect fuse3, switch configure over to use pkg-config, which is simpler yet
> more reliable than looking for library and header manually. Also set
> FUSE_USE_VERSION that way, as it depends on the used libfuse version.
>
> Now that the CFLAGS are read from pkg-config, use just , which works
> with 2.x as well as 3.x and is recommended by libfuse upstream.
>
> One behaviour change of libfuse3 is that FUSE_ATOMIC_O_TRUNC is set by 
> default,
> which means that open with O_TRUNC is passed as-is instead of calling the
> truncate operation. With libfuse2, truncate failed with -ENOSYS and that was
> returned to the application. To make O_TRUNC fail with libfuse3, return -EROFS
> explicitly if writing was requested.
>
> Signed-off-by: Fabian Vogt 

Sadly this patch breaks Windows builds:
  In file included from util/grub-mount.c:36:0:
  /usr/include/fuse/fuse.h:33:25: fatal error: sys/statvfs.h: No such file or 
directory
   #include 
 ^
  compilation terminated.

I think it happens because pkg-config is not aware we want make Windows
version of the GRUB. So, I would suggest to disable FUSE detection when
the host for tools is Windows.

And two nits below...

> ---
> v2: add __attribute__ ((unused))
>
>  Makefile.util.def |  4 +++-
>  configure.ac  | 16 +---
>  util/grub-mount.c | 25 ++---
>  3 files changed, 30 insertions(+), 15 deletions(-)
>
> diff --git a/Makefile.util.def b/Makefile.util.def
> index f8b356cc1..e92c1f346 100644
> --- a/Makefile.util.def
> +++ b/Makefile.util.def
> @@ -309,11 +309,13 @@ program = {
>common = grub-core/disk/host.c;
>common = grub-core/osdep/init.c;
>
> +  cflags = '$(FUSE_CFLAGS)';
> +
>ldadd = libgrubmods.a;
>ldadd = libgrubgcry.a;
>ldadd = libgrubkern.a;
>ldadd = grub-core/lib/gnulib/libgnu.a;
> -  ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM) 
> -lfuse';
> +  ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM) 
> $(FUSE_LIBS)';
>condition = COND_GRUB_MOUNT;
>  };
>
> diff --git a/configure.ac b/configure.ac
> index 4f649edaf..1d40f9560 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1787,17 +1787,11 @@ if test x"$enable_grub_mount" = xno ; then
>  fi
>
>  if test x"$grub_mount_excuse" = x ; then
> -  AC_CHECK_LIB([fuse], [fuse_main_real], [],
> -   [grub_mount_excuse="need FUSE library"])
> -fi
> -
> -if test x"$grub_mount_excuse" = x ; then
> -  # Check for fuse headers.
> -  SAVED_CPPFLAGS="$CPPFLAGS"
> -  CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26"
> -  AC_CHECK_HEADERS([fuse/fuse.h], [],
> - [grub_mount_excuse=["need FUSE headers"]])
> -  CPPFLAGS="$SAVED_CPPFLAGS"
> +  PKG_CHECK_MODULES([FUSE], [fuse3], [FUSE_CFLAGS="$FUSE_CFLAGS 
> -DFUSE_USE_VERSION=32"], [

s/[FUSE]/[fuse3]/

> +PKG_CHECK_MODULES([FUSE], [fuse], [FUSE_CFLAGS="$FUSE_CFLAGS 
> -DFUSE_USE_VERSION=26"], [

s/[FUSE]/[fuse]/

Otherwise you cannot differentiate FUSE3 and FUSE detection just reading the
configure messages.

Daniel

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


Re: [PATCH] Revert "iee1275/datetime: Fix off-by-1 error."

2022-02-08 Thread Glenn Washburn
On Tue, 08 Feb 2022 15:51:41 +1100
Daniel Axtens  wrote:

> Hi,
> 
> I tested a pseries guest under:
>  - qemu + KVM on a Power8 host with a fairly modern qemu
>  - qemu + TCG
> 
> Here the 'date' command simply reports "error: no cmos found", so
> this patch will have no impact on those platforms.

I suspect its the same on KVM and TCG because the machine definition is
the same and doesn't container either an RTC nor a CMOS. What confusing
to me is, don't these machines have clocks?

> 
> I also tested an LPAR on a Power8 PowerVM machine. In this case, before
> the patch, grub printed:
> 
> grub> date
> 2022-02-09 04:31:10 Wednesday
> 
> whereas on booting:
> 
> [dja@sauce ~]$ date -u
> Tue Feb  8 04:46:40 UTC 2022
> 
> After applying the patch, grub printed:
> 
> grub> date
> 2022-02-08 04:51:27 Tuesday
> 
> It seems the patch makes things better.

Great thanks Daniel for confirming this.

Glenn

> 
> Tested-by: Daniel Axtens 
> 
> Kind regards,
> Daniel
> 
> Glenn Washburn  writes:
> 
> > This is causing the test grub_cmd_date to fail because the returned date is
> > one day more than it should be.
> >
> > This reverts commit 607d66116a67e5a13eb0d46076f26dedc988e6a4.
> >
> > Signed-off-by: Glenn Washburn 
> > ---
> > Hi all,
> >
> > Reverting this commit allows the grub_cmd_date test to pass. It appears that
> > this commit is (now) causing an off-by-1 error in QEMU and the latest 
> > OpenBIOS.
> > What I'm unsure of is if the original commit is actually correct on real
> > hardware and that potentially OpenBIOS has a bug.
> >
> > Adrian and Daniel A, could you test the reverting of this commit on real
> > hardware and see if date does in fact produce the expected date (and do 
> > current
> > builds show a date one day ahead of what it should be)? Can anyone point to
> > documentation saying that the original commit is in fact what should
> > be done? If the issue is in OpenBIOS I'd like to have some documentation
> > to back up a bug report.
> >
> > Vladimir, do you have any thoughts on this?
> >
> > Glenn
> >
> > ---
> >  grub-core/lib/ieee1275/datetime.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/grub-core/lib/ieee1275/datetime.c 
> > b/grub-core/lib/ieee1275/datetime.c
> > index b81fba2ed..74578f15a 100644
> > --- a/grub-core/lib/ieee1275/datetime.c
> > +++ b/grub-core/lib/ieee1275/datetime.c
> > @@ -95,7 +95,7 @@ grub_get_datetime (struct grub_datetime *datetime)
> >  
> >datetime->year = args.year;
> >datetime->month = args.month;
> > -  datetime->day = args.day + 1;
> > +  datetime->day = args.day;
> >datetime->hour = args.hour;
> >datetime->minute = args.minute;
> >datetime->second = args.second;
> > @@ -140,7 +140,7 @@ grub_set_datetime (struct grub_datetime *datetime)
> >  
> >args.year = datetime->year;
> >args.month = datetime->month;
> > -  args.day = datetime->day - 1;
> > +  args.day = datetime->day;
> >args.hour = datetime->hour;
> >args.minute = datetime->minute;
> >args.second = datetime->second;
> > -- 
> > 2.27.0

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


Re: [PATCH 2/2] tests: Add check-native and check-nonnative make targets

2022-02-08 Thread Glenn Washburn
On Tue, 8 Feb 2022 17:10:32 +0100
Daniel Kiper  wrote:

> On Wed, Jan 12, 2022 at 08:19:04PM -0600, Glenn Washburn wrote:
> > This allows for testing only tests that run directly on the build machine or
> > only tests that run in a virtualized environment. When testing multiple
> > targets on the same build machine the native tests only need to be run once
> > for all targets. Whereas, the nonnative tests must be run for each target
> > because the test is potentially compiled differently for each target.
> >
> > Signed-off-by: Glenn Washburn 
> 
> This patch makes bootstrap unhappy:
>   Makefile.am:27: warning: check_SCRIPTS multiply defined in condition TRUE 
> ...
>   conf/Makefile.common:107: ... 'check_SCRIPTS' previously defined here
>   Makefile.am:10:   'conf/Makefile.common' included from here
>   Makefile.am:28: warning: check_PROGRAMS multiply defined in condition TRUE 
> ...
>   conf/Makefile.common:110: ... 'check_PROGRAMS' previously defined here
>   Makefile.am:10:   'conf/Makefile.common' included from here
>   Makefile.am:29: warning: TESTS multiply defined in condition TRUE ...
>   conf/Makefile.common:128: ... 'TESTS' previously defined here
>   Makefile.am:10:   'conf/Makefile.common' included from here
> 
> I have just taken patch #1.

I didn't notice this as it seems to have no effect on building or
testing. I'll send an updated patch removing these warnings.

Glenn

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


[PATCH v2] tests: Add check-native and check-nonnative make targets

2022-02-08 Thread Glenn Washburn
This allows for testing only tests that run directly on the build machine or
only tests that run in a virtualized environment. When testing multiple
targets on the same build machine the native tests only need to be run once
for all targets. Whereas, the nonnative tests must be run for each target
because the test is potentially compiled differently for each target.

Signed-off-by: Glenn Washburn 
---
v2: Fix new warnings in bootstrap pointed out by Daniel K

Glenn

---
Range-diff against v1:
1:  0fa3194bd ! 1:  60195f95e tests: Add check-native and check-nonnative make 
targets
@@ Makefile.util.def: program = {
 
  ## conf/Makefile.common ##
 @@ conf/Makefile.common: KERNEL_HEADER_FILES =
+ 
  bin_SCRIPTS =
  bin_PROGRAMS =
- check_SCRIPTS =
+-check_SCRIPTS =
+-check_PROGRAMS =
 +check_SCRIPTS_native =
 +check_SCRIPTS_nonnative =
- check_PROGRAMS =
 +check_PROGRAMS_native =
 +check_PROGRAMS_nonnative =
  dist_grubconf_DATA =
  dist_noinst_DATA =
  grubconf_SCRIPTS =
+@@ conf/Makefile.common: platform_PROGRAMS =
+ sbin_SCRIPTS =
+ sbin_PROGRAMS =
+ 
+-TESTS =
+ EXTRA_DIST =
+ CLEANFILES =
+ BUILT_SOURCES =
 
  ## gentpl.py ##
 @@ gentpl.py: def program(defn, platform, test=False):

 Makefile.am  |   9 +++
 Makefile.util.def| 164 +--
 conf/Makefile.common |   7 +-
 gentpl.py|   6 +-
 4 files changed, 97 insertions(+), 89 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index bf9c1ba64..10faf670b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,6 +24,15 @@ CCASFLAGS_PROGRAM += $(CCASFLAGS_GNULIB)
 
 include $(srcdir)/Makefile.util.am
 
+check_SCRIPTS = $(check_SCRIPTS_native) $(check_SCRIPTS_nonnative)
+check_PROGRAMS = $(check_PROGRAMS_native) $(check_PROGRAMS_nonnative)
+TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
+
+check-native:
+   $(MAKE) TESTS="$(check_PROGRAMS_native) $(check_SCRIPTS_native)" check
+check-nonnative:
+   $(MAKE) TESTS="$(check_PROGRAMS_nonnative) $(check_SCRIPTS_nonnative)" 
check
+
 # XXX Use Automake's LEX & YACC support
 grub_script.tab.h: $(top_srcdir)/grub-core/script/parser.y
$(YACC) -d -p grub_script_yy -b grub_script 
$(top_srcdir)/grub-core/script/parser.y
diff --git a/Makefile.util.def b/Makefile.util.def
index f8b356cc1..b098d5bba 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -749,470 +749,470 @@ script = {
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = ext234_test;
   common = tests/ext234_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = squashfs_test;
   common = tests/squashfs_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = iso9660_test;
   common = tests/iso9660_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = hfsplus_test;
   common = tests/hfsplus_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = ntfs_test;
   common = tests/ntfs_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = reiserfs_test;
   common = tests/reiserfs_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = fat_test;
   common = tests/fat_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = minixfs_test;
   common = tests/minixfs_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = xfs_test;
   common = tests/xfs_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = f2fs_test;
   common = tests/f2fs_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = nilfs2_test;
   common = tests/nilfs2_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = romfs_test;
   common = tests/romfs_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = exfat_test;
   common = tests/exfat_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = tar_test;
   common = tests/tar_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = udf_test;
   common = tests/udf_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = hfs_test;
   common = tests/hfs_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = jfs_test;
   common = tests/jfs_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = btrfs_test;
   common = tests/btrfs_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = zfs_test;
   common = tests/zfs_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = cpio_test;
   common = tests/cpio_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = example_scripted_test;
   common = tests/example_scripted_test.in;
 };
 
 script = {
-  testcase;
+  testcase = native;
   name = gettext_strings_test;
   common = tests/gettext_strings_test.in;
   extra_dist = po/exclude.pot;
 };
 
 script = {
-  testcase;
+  testcase = nonnative;
   name

[PATCH] configure: Replace -Wl,-r,-d with -Wl,-r

2022-02-08 Thread Fangrui Song via Grub-devel
In GNU ld and ld.lld, -d is used with -r to allocate space to COMMON symbols.
This behavior is presumably to work around legacy projects which inspect
relocatable output by themselves and do not handle COMMON symbols. grub does
not do this.

See https://github.com/llvm/llvm-project/issues/53660
-d is quite useless and ld.lld may remove -d or make it a no-op for the
15.0.0 release.
---
 acinclude.m4|  2 +-
 conf/Makefile.common|  2 +-
 grub-core/Makefile.core.def | 20 ++--
 grub-core/genmod.sh.in  |  4 ++--
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 6e14bb553..fa7840f09 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -430,7 +430,7 @@ link_nopie_needed=no]
 AC_MSG_CHECKING([whether linker needs disabling of PIE to work])
 AC_LANG_CONFTEST([AC_LANG_SOURCE([[]])])
 
-[if eval "$ac_compile -Wl,-r,-d -nostdlib -Werror -o conftest.o" 2> /dev/null; 
then]
+[if eval "$ac_compile -Wl,-r -nostdlib -Werror -o conftest.o" 2> /dev/null; 
then]
   AC_MSG_RESULT([no])
   [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'?
   rm -f conftest.o
diff --git a/conf/Makefile.common b/conf/Makefile.common
index f0bb6e160..1d7b39599 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -41,7 +41,7 @@ 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
 
 CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
-LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) 
-Wl,-r,-d
+LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) 
-Wl,-r
 CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
 CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
 
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 8022e1c0a..ac00cc8a2 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -49,26 +49,26 @@ kernel = {
 
   nostrip = emu;
 
-  emu_ldflags  = '-Wl,-r,-d';
-  i386_efi_ldflags = '-Wl,-r,-d';
+  emu_ldflags  = '-Wl,-r';
+  i386_efi_ldflags = '-Wl,-r';
   i386_efi_stripflags  = '--strip-unneeded -K start -R .note -R .comment 
-R .note.gnu.gold-version';
-  x86_64_efi_ldflags   = '-Wl,-r,-d';
+  x86_64_efi_ldflags   = '-Wl,-r';
   x86_64_efi_stripflags= '--strip-unneeded -K start -R .note -R .comment 
-R .note.gnu.gold-version';
 
   ia64_efi_cflags = '-fno-builtin -fpic -minline-int-divide-max-throughput';
-  ia64_efi_ldflags = '-Wl,-r,-d';
+  ia64_efi_ldflags = '-Wl,-r';
   ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R 
.note.gnu.gold-version';
 
-  arm_efi_ldflags  = '-Wl,-r,-d';
+  arm_efi_ldflags  = '-Wl,-r';
   arm_efi_stripflags   = '--strip-unneeded -K start -R .note -R .comment 
-R .note.gnu.gold-version';
 
-  arm64_efi_ldflags  = '-Wl,-r,-d';
+  arm64_efi_ldflags  = '-Wl,-r';
   arm64_efi_stripflags   = '--strip-unneeded -K start -R .note -R .comment 
-R .note.gnu.gold-version -R .eh_frame';
 
-  riscv32_efi_ldflags  = '-Wl,-r,-d';
+  riscv32_efi_ldflags  = '-Wl,-r';
   riscv32_efi_stripflags   = '--strip-unneeded -K start -R .note -R .comment 
-R .note.gnu.gold-version -R .eh_frame';
 
-  riscv64_efi_ldflags  = '-Wl,-r,-d';
+  riscv64_efi_ldflags  = '-Wl,-r';
   riscv64_efi_stripflags   = '--strip-unneeded -K start -R .note -R .comment 
-R .note.gnu.gold-version -R .eh_frame';
 
   i386_pc_ldflags  = '$(TARGET_IMG_LDFLAGS)';
@@ -98,9 +98,9 @@ kernel = {
   i386_qemu_cppflags = 
'-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
   emu_cflags = '$(CFLAGS_GNULIB)';
   emu_cppflags = '$(CPPFLAGS_GNULIB)';
-  arm_uboot_ldflags   = '-Wl,-r,-d';
+  arm_uboot_ldflags   = '-Wl,-r';
   arm_uboot_stripflags= '--strip-unneeded -K start -R .note -R .comment -R 
.note.gnu.gold-version';
-  arm_coreboot_ldflags   = '-Wl,-r,-d';
+  arm_coreboot_ldflags   = '-Wl,-r';
   arm_coreboot_stripflags= '--strip-unneeded -K start -R .note -R .comment 
-R .note.gnu.gold-version';
 
   i386_pc_startup = kern/i386/pc/startup.S;
diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in
index 1250589b3..e57c4d920 100644
--- a/grub-core/genmod.sh.in
+++ b/grub-core/genmod.sh.in
@@ -83,9 +83,9 @@ else
 for dep in $deps; do echo "char moddep_$dep[] __attribute__ 
((section(\"_moddeps, _moddeps\"))) = \"$dep\";" >>$t2; done
 
 if test -n "$deps"; then
-   @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 
$t2 $tmpfile -Wl,-r,-d
+   @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 
$t2 $tmpfile -Wl,-r
 else
-   @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 
$tmpfile -Wl,-r,-d
+   @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding

Re: [PATCH 1/3] grub-fs-tester: add luks1 and luks2 support

2022-02-08 Thread Glenn Washburn
On Thu,  3 Feb 2022 18:21:03 +0100
Pierre-Louis Bonicoli  wrote:

> The logical sector size used by LUKS1 is 512 bytes. LUKS2 uses 512 to
> 4069 bytes.

I like that this has been added here. However there's no test that
actually runs this new code. Please add another two fs tests one for
LUKS and one for LUKS2.

> 
> Signed-off-by: Pierre-Louis Bonicoli 
> ---
>  tests/util/grub-fs-tester.in | 58 ++--
>  1 file changed, 55 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in
> index aa72b2174..7ed275fd0 100644
> --- a/tests/util/grub-fs-tester.in
> +++ b/tests/util/grub-fs-tester.in
> @@ -15,7 +15,12 @@ XORRISOFS_CHARSET="-input-charset UTF-8 -output-charset 
> UTF-8"
>  
>  # This wrapper is to ease insertion of valgrind or time statistics
>  run_it () {
> -LC_ALL=C "$GRUBFSTEST" "$@"
> +case x"$fs" in
> +xluks*)
> + LC_ALL=C echo -n pass | "$GRUBFSTEST" -C "$@";;

Why do this here instead of leaving this function alone and doing the
pipe and -C arg below when calling run_grubfstest?

> +*)
> + LC_ALL=C "$GRUBFSTEST" "$@";;
> +esac
>  }
>  
>  range() {
> @@ -48,6 +53,8 @@ run_grubfstest () {
>  MINLOGSECSIZE=9
>  MAXLOGSECSIZE=9
>  case x"$fs" in
> +xluks2*)
> + MAXLOGSECSIZE=12;;
>  xntfs*)
>   MINLOGSECSIZE=8
>   MAXLOGSECSIZE=12;;
> @@ -335,7 +342,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" 
> "$MAXLOGSECSIZE" 1); do
>   #FSLABEL="g;/_é莭莽😁кит u"
>   ;;
>   # FS LIMITATION: reiserfs, extN and jfs label is at most 16 UTF-8 
> characters
> - x"reiserfs_old" | x"reiserfs" | x"ext"* | x"lvm"* | x"mdraid"* 
> | x"jfs" | x"jfs_caseins")
> + x"reiserfs_old" | x"reiserfs" | x"ext"* | x"lvm"* | x"luks"* | 
> x"mdraid"* | x"jfs" | x"jfs_caseins")
>   FSLABEL="g;/éт 莭😁";;
>  # FS LIMITATION: No underscore, space, semicolon, slash or 
> international characters in UFS* in label. Limited to 32 UTF-8 characters
>   x"ufs1" | x"ufs1_sun" | x"ufs2")
> @@ -804,6 +811,12 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" 
> "$MAXLOGSECSIZE" 1); do
>   MOUNTDEVICE="/dev/mapper/grub_test-testvol"
>   MOUNTFS=ext2
>   "mkfs.ext2" -L "$FSLABEL" -q "${MOUNTDEVICE}"  ;;
> + x"luks"*)
> + echo -n pass | cryptsetup luksFormat --type $fs 
> --sector-size $SECSIZE --pbkdf pbkdf2 $LODEVICE
> + echo -n pass | cryptsetup open $LODEVICE grub_luks_test
> + MOUNTDEVICE="/dev/mapper/grub_luks_test"
> + MOUNTFS=ext2
> + "mkfs.ext2" -L "$FSLABEL" -q "${MOUNTDEVICE}"  ;;
>   xf2fs)
>   "mkfs.f2fs" -l "$FSLABEL" -q "${MOUNTDEVICE}" ;;
>   xnilfs2)
> @@ -916,6 +929,20 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" 
> "$MAXLOGSECSIZE" 1); do
>   GRUBDEVICE="mduuid/`mdadm --detail --export $MOUNTDEVICE | 
> grep MD_UUID=|sed 's,MD_UUID=,,g;s,:,,g'`";;
>   xlvm*)
>   GRUBDEVICE="lvm/grub_test-testvol";;
> + xluks*)
> + if test x"$fs" = xluks2 && ! (cryptsetup luksDump 
> --dump-json-metadata $LODEVICE | grep "\"sector_size\":$SECSIZE"); then
> + echo "Unexpected sector size for $LODEVICE 
> (expected: $SECSIZE)"
> + exit 1
> + fi
> +
> + uuid=$(cryptsetup luksUUID $LODEVICE | tr -d '-')
> + probe_uuid=$(@builddir@/grub-probe --device $MOUNTDEVICE 
> --target=cryptodisk_uuid)
> + if [ x"$uuid" != x"$probe_uuid" ]; then
> + echo "$fs probe command FAIL"
> + exit 1
> + fi
> + GRUBDEVICE="cryptouuid/${uuid}"
> + ;;
>   esac
>   GRUBDIR="($GRUBDEVICE)"
>   case x"$fs" in
> @@ -1071,6 +1098,18 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" 
> "$MAXLOGSECSIZE" 1); do
>   sleep 1
>   vgchange -a n grub_test
>   ;;
> + xluks*)
> + sleep 1

Bad indention. Why is this sleep desirable if there's a sleep in the
loop below?

> + for try in $(range 0 20 1); do
> + if umount "$MNTPOINTRW" ; then
> + break;
> + fi
> + sleep 1;
> + done
> + UMOUNT_TIME=$(date -u "+%Y-%m-%d %H:%M:%S")
> + sleep 1

Why sleeping here again? We already slept in the loop above. We need
more time?

> + cryptsetup close grub_luks_test
> + ;;
>   xmdraid*)
>   sleep 1
>   for try in $(range 0 20 1); do
> @@ -1117,6 +1156,10 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" 
> "$MAXLOGSECSIZE" 1