riscv64: Support riscv_align relocations
PATCH 1/8 riscv64: Support riscv_align relocations
They are purely for optimization, so no need to do anything.
Signed-off-by Vladimir Serbinenko <[email protected]>
--- grub-core/kern/riscv/dl.c | 1 + util/grub-mkimagexx.c | 2 ++ 2 files changed, 3 insertions(+)
grub-core/kern/riscv/dl.c +1 -0
@@ -329,6 +329,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,break ;case R_RISCV_RELAX : +case R_RISCV_ALIGN :break ;default : {
util/grub-mkimagexx.c +2 -0
@@ -1477,6 +1477,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, }break ;case R_RISCV_RELAX : +case R_RISCV_ALIGN :break ;default : grub_util_error (_("relocation 0x%x is not implemented yet"),
@@ -1891,6 +1892,7 @@ translate_relocation_pe (struct translate_context *ctx, }break ;case R_RISCV_RELAX : +case R_RISCV_ALIGN :break ;default : grub_util_error (_("relocation 0x%x is not implemented yet"),
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 2/8 compiler-rt: Add __multi3
It's necessary for clang sparc64 support
--- grub-core/kern/compiler-rt.c | 58 ++++++++++++++++++++++++++++++++++++ include/grub/compiler-rt.h | 7 +++++ 2 files changed, 65 insertions(+)
grub-core/kern/compiler-rt.c +58 -0
@@ -452,3 +452,61 @@ __clzdi2 (grub_uint64_t val) } }#endif + +#if defined(__sparc__) && defined(__clang__) +/* Copied from multi3.c which is under MIT license. */ +typedef long long di_int ; +typedef unsigned long long du_int ; + +typedef union +{ +grub_clang_ti_int all; +struct + { +#ifndef GRUB_CPU_WORDS_BIGENDIAN +du_int low; +di_int high; +#else +di_int high; +du_int low; +#endif /* _YUGA_LITTLE_ENDIAN */ + }s; +}twords ; + +static +grub_clang_ti_int +__mulddi3 (du_int a,du_int b) +{ +twords r; +const int bits_in_dword_2 = (int )(sizeof (di_int) *8 ) /2 ; +const du_int lower_mask = (du_int )~0 >> bits_in_dword_2; + r.s.low = (a & lower_mask) * (b & lower_mask); +du_int t = r.s.low >> bits_in_dword_2; + r.s.low &= lower_mask; + t += (a >> bits_in_dword_2) * (b & lower_mask); + r.s.low += (t & lower_mask) << bits_in_dword_2; + r.s.high = t >> bits_in_dword_2; + t = r.s.low >> bits_in_dword_2; + r.s.low &= lower_mask; + t += (b >> bits_in_dword_2) * (a & lower_mask); + r.s.low += (t & lower_mask) << bits_in_dword_2; + r.s.high += t >> bits_in_dword_2; + r.s.high += (a >> bits_in_dword_2) * (b >> bits_in_dword_2); +return r.all; +} + +/* Returns: a * b */ + +grub_clang_ti_int +__multi3 (grub_clang_ti_int a,grub_clang_ti_int b) +{ +twords x; + x.all = a; +twords y; + y.all = b; +twords r; + r.all =__mulddi3 (x.s.low, y.s.low); + r.s.high += x.s.high * y.s.low + x.s.low * y.s.high; +return r.all; +} +#endif
include/grub/compiler-rt.h +7 -0
@@ -209,5 +209,12 @@ void EXPORT_FUNC (___chkstk_ms) (void);void EXPORT_FUNC (__chkstk_ms ) (void );#endif +#if defined(__sparc__) && defined(__clang__) +/* Copied from multi3.c which is under MIT license. */ +typedef int grub_clang_ti_int __attribute__ ((mode (TI ))); + +grub_clang_ti_int EXPORT_FUNC (__multi3 ) (grub_clang_ti_int a,grub_clang_ti_int b); +#endif +#endif
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 3/8 Support clang integrated-as sparc64
In reply to Vladimir Serbinenko--- asm-tests/sparc64.S | 2 +- grub-core/boot/sparc64/ieee1275/boot.S | 3 +++ grub-core/boot/sparc64/ieee1275/diskboot.S | 3 +++ grub-core/kern/sparc64/ieee1275/crt0.S | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-)
asm-tests/sparc64.S +1 -1
@@ -3,7 +3,7 @@ /* A small list of examples of what clang doesn't support. */ clr %o0 lduw [%o4 + 4], %o4 - and %o6, ~0xff, %o6 + and %o6, 0xffffffffffffff00, %o6 stw %o5, [%o3] bne,pt %icc, 1b nop
grub-core/boot/sparc64/ieee1275/boot.S +3 -0
@@ -93,7 +93,10 @@ prom_exit_name: .asciz "exit" grub_name: .asciz "GRUB " #ifdef CDBOOT prom_close_name: .asciz "close" + .byte 0 + .byte 0 #endif + .byte 0 #define GRUB_NAME_LEN 5
grub-core/boot/sparc64/ieee1275/diskboot.S +3 -0
@@ -43,6 +43,9 @@ notification_step: .asciz "." notification_done: .asciz "\r\n" #define NOTIFICATION_DONE_LEN 2 + .byte 0 + .byte 0 + .align 4 /* %o2: message string
grub-core/kern/sparc64/ieee1275/crt0.S +1 -1
@@ -56,7 +56,7 @@ codestart: sethi %hi(GRUB_KERNEL_MACHINE_STACK_SIZE), %o5 or %o5, %lo(GRUB_KERNEL_MACHINE_STACK_SIZE), %o5 add %o3, %o5, %o6 - and %o6, ~0xff, %o6 + and %o6, 0xffffffffffffff00, %o6 sub %o6, 2047, %o6 sub %o2, 4, %o2
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 4/8 powerpc-ieee1275: Fix warnings and alignment
In reply to Vladimir SerbinenkoSigned-off-by Vladimir Serbinenko <[email protected]>
--- grub-core/kern/ieee1275/init.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
grub-core/kern/ieee1275/init.c +10 -9
@@ -789,7 +789,10 @@ grub_ieee1275_ibm_cas (void) {int rc;grub_ieee1275_ihandle_t root; -grub_uint8_t ibm_arch_platform_support[8 ]; +union { +grub_uint8_t u8[8 ]; +grub_uint32_t u32[2 ]; + } ibm_arch_platform_support;grub_ssize_t actual;grub_uint8_t xive_support =0 ;grub_uint8_t mmu_support =0 ;
@@ -807,23 +810,23 @@ grub_ieee1275_ibm_cas (void)grub_ieee1275_get_integer_property (grub_ieee1275_chosen,"ibm,arch-vec-5-platform-support" , - (grub_uint32_t *) ibm_arch_platform_support, + ibm_arch_platform_support.u32,sizeof (ibm_arch_platform_support), &actual); -for (i =0 ; i < prop_len; i++) +for (i =0 ; i < prop_len; i +=2 ) { -switch (ibm_arch_platform_support[i]) +switch (ibm_arch_platform_support.u8[i]) {case XIVE_INDEX : -if (ibm_arch_platform_support[i +1 ] &MAX_SUPPORTED ) +if (ibm_arch_platform_support.u8[i +1 ] &MAX_SUPPORTED ) xive_support =XIVE_ENABLED ;else xive_support =0 ;break ;case MMU_INDEX : -if (ibm_arch_platform_support[i +1 ] &MAX_SUPPORTED ) +if (ibm_arch_platform_support.u8[i +1 ] &MAX_SUPPORTED ) mmu_support =RADIX_ENABLED ;else mmu_support =HASH_ENABLED ;
@@ -831,7 +834,7 @@ grub_ieee1275_ibm_cas (void)case RADIX_GTSE_INDEX :if (mmu_support ==RADIX_ENABLED ) - radix_gtse_support = ibm_arch_platform_support[i +1 ] &RADIX_GTSE_ENABLED ; + radix_gtse_support = ibm_arch_platform_support.u8[i +1 ] &RADIX_GTSE_ENABLED ;else radix_gtse_support =0 ;break ;
@@ -840,8 +843,6 @@ grub_ieee1275_ibm_cas (void)/* Ignoring the other indexes of ibm,arch-vec-5-platform-support. */ break ; } -/* Skipping the property value. */ - i++; } struct cas_vector vector =
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 5/8 efi/linux: Silence warning
In reply to Vladimir Serbinenko--- grub-core/loader/efi/linux.c | 1 + 1 file changed, 1 insertion(+)
grub-core/loader/efi/linux.c +1 -0
@@ -55,6 +55,7 @@ static bool initrd_use_loadfile2 = false;static grub_guid_t load_file2_guid =GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID ;static grub_guid_t device_path_guid =GRUB_EFI_DEVICE_PATH_GUID ; +#pragma GCC diagnostic ignored "-Wmissing-field-initializers"static initrd_media_device_path_t initrd_lf2_device_path = { { {
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 6/8 btrfs: Add an explicit GRUB_PACKED
In reply to Vladimir SerbinenkoOtherwise clang on arm complains
--- grub-core/fs/btrfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/fs/btrfs.c +1 -1
@@ -222,7 +222,7 @@ struct grub_btrfs_extent_datagrub_uint64_t compressed_size;grub_uint64_t offset;grub_uint64_t filled; - }; + }GRUB_PACKED ; }; }GRUB_PACKED ;
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 7/8 Enable __clzsi2/__clzdi2 on arm
In reply to Vladimir SerbinenkoIt's emitted by clang
--- grub-core/kern/compiler-rt.c | 4 +--- include/grub/compiler-rt.h | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-)
grub-core/kern/compiler-rt.c +1 -3
@@ -410,7 +410,7 @@ __aeabi_llsl (grub_uint64_t u, int b)#endif -#if defined(__mips__) || defined(__riscv) || defined(__sparc__) +#if defined(__mips__) || defined(__riscv) || defined(__sparc__) || defined(__arm__)/* Based on libgcc from gcc suite. */ int __clzsi2 (grub_uint32_t val)
@@ -436,9 +436,7 @@ __clzsi2 (grub_uint32_t val) }return (i - val); } -#endif -#if defined(__mips__) || defined(__riscv) || defined(__sparc__)int __clzdi2 (grub_uint64_t val) {
include/grub/compiler-rt.h +1 -4
@@ -110,12 +110,9 @@ EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b);#endif -#if defined(__mips__) || defined(__riscv) || defined(__sparc__) +#if defined(__mips__) || defined(__riscv) || defined(__sparc__) || defined(__arm__)int EXPORT_FUNC (__clzsi2 ) (grub_uint32_t val); -#endif - -#if defined(__mips__) || defined(__riscv) || defined(__sparc__)int EXPORT_FUNC (__clzdi2 ) (grub_uint64_t val);#endif
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 8/8 configure: Try -msoft-float -mfloat-abi=soft on arm
In reply to Vladimir SerbinenkoSigned-off-by Vladimir Serbinenko <[email protected]>
--- configure.ac | 5 +++++ 1 file changed, 5 insertions(+)
configure.ac +5 -0
@@ -941,6 +941,11 @@ if test x"$platform" != xemu ; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_target_cc_soft_float="-m4-nofpu"], []) fi + if test "x$target_cpu" = xarm; then + CFLAGS="$TARGET_CFLAGS -msoft-float -mfloat-abi=soft -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_soft_float="-msoft-float -mfloat-abi=soft"], []) + fi for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \ "-Xclang -msoft-float -Xclang -no-implicit-float" \ "-Xclang -msoft-float" "-msoft-float"; do
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel