[PATCH 0/6] Fix Yeeloong 2F support

2024-09-01 Thread Vladimir 'phcoder' Serbinenko
This series of patches fixes compilation and running on Yeeloong 2F
with new GCC.
Clang is not supported as it fails to compile for mips3 architecture

-- 
Regards
Vladimir 'phcoder' Serbinenko

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


[PATCH 2/6] erofs: Replace 64-bit modulo with bitwise operations

2024-09-01 Thread Vladimir Serbinenko
Otherwise depending on compiler we end up with umoddi3 reference and
failed module dependency resolution

Signed-off-by: Vladimir Serbinenko 
---
 grub-core/fs/erofs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grub-core/fs/erofs.c b/grub-core/fs/erofs.c
index 46cfc2e5c..f2a82e988 100644
--- a/grub-core/fs/erofs.c
+++ b/grub-core/fs/erofs.c
@@ -357,13 +357,13 @@ erofs_map_blocks_flatmode (grub_fshelp_node_t node,
 {
   if (grub_add (erofs_iloc (node), erofs_inode_size (node), &map->m_pa) ||
  grub_add (map->m_pa, erofs_inode_xattr_ibody_size (node), &map->m_pa) 
||
- grub_add (map->m_pa, map->m_la % blocksz, &map->m_pa))
+ grub_add (map->m_pa, map->m_la & (blocksz - 1), &map->m_pa))
return grub_error (GRUB_ERR_OUT_OF_RANGE, "m_pa overflow when handling 
tailpacking");
   if (grub_sub (file_size, map->m_la, &map->m_plen))
return grub_error (GRUB_ERR_OUT_OF_RANGE, "m_plen overflow when 
handling tailpacking");
 
   /* No overflow as map->m_plen <= UINT64_MAX - blocksz + 1. */
-  if (((map->m_pa % blocksz) + map->m_plen) > blocksz)
+  if (((map->m_pa & (blocksz - 1)) + map->m_plen) > blocksz)
return grub_error (GRUB_ERR_BAD_FS,
"inline data cross block boundary @ inode %" 
PRIuGRUB_UINT64_T,
node->ino);
-- 
2.39.2


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


[PATCH 3/6] xzembed: Silence warning when no BCJ is available

2024-09-01 Thread Vladimir Serbinenko
BCJ is not available for all platforms hence arguments may end up unused

Signed-off-by: Vladimir Serbinenko 
---
 grub-core/lib/xzembed/xz_dec_bcj.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/lib/xzembed/xz_dec_bcj.c 
b/grub-core/lib/xzembed/xz_dec_bcj.c
index bf6b5862e..aef4638d4 100644
--- a/grub-core/lib/xzembed/xz_dec_bcj.c
+++ b/grub-core/lib/xzembed/xz_dec_bcj.c
@@ -353,7 +353,7 @@ static noinline_for_stack size_t bcj_sparc(
  * avoid pointers to static data (at least on x86).
  */
 static void bcj_apply(struct xz_dec_bcj *s,
-   uint8_t *buf, size_t *pos, size_t size)
+ uint8_t *buf __attribute__((unused)), size_t *pos, size_t 
size __attribute__((unused)))
 {
size_t filtered;
 
-- 
2.39.2


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


[PATCH 1/6] configure: Look for .otf fonts

2024-09-01 Thread Vladimir Serbinenko
Signed-off-by: Vladimir Serbinenko 
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index d4a14bf93..fe5493246 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1875,7 +1875,7 @@ AC_ARG_WITH([unifont],
 
 if test "x$with_unifont" = x; then
   # search in well-known directories
-  for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
+  for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz otf otf.gz; do
 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont 
/usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc 
/usr/pkg/share/fonts/X11/misc /usr/local/share/fonts/gnu-unifont 
/usr/local/share/fonts/unifont; do
   if test -f "$dir/unifont.$ext"; then
 md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
-- 
2.39.2


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


Re: [PATCH 2/6] erofs: Replace 64-bit modulo with bitwise operations

2024-09-01 Thread Gao Xiang



On 2024/9/2 08:22, Vladimir Serbinenko wrote:

Otherwise depending on compiler we end up with umoddi3 reference and
failed module dependency resolution

Signed-off-by: Vladimir Serbinenko 


Reviewed-by: Gao Xiang 

Thanks,
Gao Xiang

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


[PATCH 4/6] configure: Add -mno-gpopt option

2024-09-01 Thread Vladimir Serbinenko
Without it compiler generates GPREL16 references which do not work
with our memory layout

Signed-off-by: Vladimir Serbinenko 
---
 configure.ac | 12 
 1 file changed, 12 insertions(+)

diff --git a/configure.ac b/configure.ac
index fe5493246..c3d9398ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -802,9 +802,21 @@ if test "x$target_cpu" = xmips || test "x$target_cpu" = 
xmipsel ; then
   if test "x$grub_cv_cc_mflush_func" = xyes; then
 TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
   fi
+
+  AC_CACHE_CHECK([whether -mno-gpopt works], [grub_cv_cc_mno_gpopt], [
+CFLAGS="$TARGET_CFLAGS -mno-gpopt -Werror"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+[grub_cv_cc_mno_gpopt=yes],
+   [grub_cv_cc_mno_gpopt=no])
+  ])
+
+  if test "x$grub_cv_cc_mno_gpopt" = xyes; then
+TARGET_CFLAGS="$TARGET_CFLAGS -mno-gpopt"
+  fi
 fi
 
 
+
 # Force no alignment to save space on i386.
 if test "x$target_cpu" = xi386; then
   TARGET_CFLAGS="$TARGET_CFLAGS -falign-functions=1"
-- 
2.39.2


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


[PATCH 5/6] mkimage: Fix section_align for Loongson

2024-09-01 Thread Vladimir Serbinenko
Correct value has been 4 fromthe beginning but it started mattering only
recently whether because of compiler or because of code reshuffling
---
 util/mkimage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/mkimage.c b/util/mkimage.c
index 8c5660825..d77399778 100644
--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -335,7 +335,7 @@ static const struct grub_install_image_target_desc 
image_targets[] =
   .decompressor_compressed_size = 
GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
   .decompressor_uncompressed_size = 
GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
   .decompressor_uncompressed_addr = 
GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
-  .section_align = 1,
+  .section_align = 4,
   .vaddr_offset = 0,
   .link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
   .elf_target = EM_MIPS,
-- 
2.39.2


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


[PATCH 6/6] gentpl: Put startup_raw.S into beginning of the image

2024-09-01 Thread Vladimir Serbinenko
Otherwise it breaks the decompressors for mips platforms

Signed-off-by: Vladimir Serbinenko 
---
 gentpl.py   | 4 ++--
 grub-core/Makefile.core.def | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gentpl.py b/gentpl.py
index 3b12eca6c..d8c6965d8 100644
--- a/gentpl.py
+++ b/gentpl.py
@@ -634,7 +634,7 @@ def extra_dist(defn):
 def extra_dep(defn):
 return foreach_value(defn, "depends", lambda value: value + " ")
 
-def platform_sources(defn, p): return platform_values(defn, p, "")
+def platform_sources(defn, p): return platform_values(defn, p, "_head") + 
platform_values(defn, p, "")
 def platform_nodist_sources(defn, p): return platform_values(defn, p, 
"_nodist")
 
 def platform_startup(defn, p): return platform_specific_values(defn, p, 
"_startup", "startup")
@@ -660,7 +660,7 @@ def first_time(defn, snippet):
 def is_platform_independent(defn):
 if 'enable' in defn:
 return False
-for suffix in [ "", "_nodist" ]:
+for suffix in [ "", "_head", "_nodist" ]:
 template = platform_values(defn, GRUB_PLATFORMS[0], suffix)
 for platform in GRUB_PLATFORMS[1:]:
 if template != platform_values(defn, platform, suffix):
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 705d73fab..063ef5dd7 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -536,7 +536,7 @@ image = {
 
 image = {
   name = xz_decompress;
-  mips = boot/mips/startup_raw.S;
+  mips_head = boot/mips/startup_raw.S;
   common = boot/decompressor/minilib.c;
   common = boot/decompressor/xz.c;
   common = lib/xzembed/xz_dec_bcj.c;
@@ -554,7 +554,7 @@ image = {
 
 image = {
   name = none_decompress;
-  mips = boot/mips/startup_raw.S;
+  mips_head = boot/mips/startup_raw.S;
   common = boot/decompressor/none.c;
 
   cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1';
-- 
2.39.2


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