From ebbb326f68c98b148684210c84c98a6b8994685f Mon Sep 17 00:00:00 2001 From: songmingliang Date: Mon, 4 Jul 2022 12:46:50 +0800 Subject: [PATCH] fix 1000-loongarch64-add-support.patch --- 1000-loongarch64-add-support.patch | 64 +++++++++++++++++------------- grub.patches | 2 +- grub2.spec | 5 ++- 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/1000-loongarch64-add-support.patch b/1000-loongarch64-add-support.patch index 2d83c94..35b378e 100644 --- a/1000-loongarch64-add-support.patch +++ b/1000-loongarch64-add-support.patch @@ -1,7 +1,7 @@ -From febee03c70471fd2ce6f0b4cc0f365c32c106ab3 Mon Sep 17 00:00:00 2001 +From 6b9dd3680fa61d682c0651a809eb272dbcb317a2 Mon Sep 17 00:00:00 2001 From: Fedora Ninjas -Date: Wed, 18 May 2022 23:50:45 +0800 -Subject: [PATCH] add loongarch64 support +Date: Mon, 4 Jul 2022 18:15:58 +0800 +Subject: [PATCH] loongarch add support --- conf/Makefile.common | 4 + @@ -9,10 +9,10 @@ Subject: [PATCH] add loongarch64 support gentpl.py | 5 +- grub-core/Makefile.am | 7 + grub-core/Makefile.core.def | 20 + - grub-core/kern/efi/mm.c | 29 +- + grub-core/kern/efi/mm.c | 28 +- grub-core/kern/elfXX.c | 6 + grub-core/kern/loongarch64/cache.S | 26 + - grub-core/kern/loongarch64/dl.c | 258 +++++++++ + grub-core/kern/loongarch64/dl.c | 266 +++++++++ grub-core/kern/loongarch64/efi/init.c | 76 +++ grub-core/kern/loongarch64/efi/startup.S | 45 ++ grub-core/kern/loongarch64/init.c | 47 ++ @@ -51,7 +51,7 @@ Subject: [PATCH] add loongarch64 support util/grub-mknetdir.c | 3 +- util/grub-module-verifier.c | 46 ++ util/mkimage.c | 16 + - 47 files changed, 3176 insertions(+), 32 deletions(-) + 47 files changed, 3184 insertions(+), 31 deletions(-) create mode 100644 grub-core/kern/loongarch64/cache.S create mode 100644 grub-core/kern/loongarch64/dl.c create mode 100644 grub-core/kern/loongarch64/efi/init.c @@ -285,7 +285,7 @@ index ef06f8c..74e66d3 100644 module = { diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 9e76f23..fb087e3 100644 +index 8a89614..665d8cd 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -157,7 +157,11 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, @@ -312,23 +312,23 @@ index 9e76f23..fb087e3 100644 status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &ret); grub_efi_free_pages (0, pages); if (status != GRUB_EFI_SUCCESS) -@@ -195,9 +203,14 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, +@@ -195,9 +203,15 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, void * grub_efi_allocate_any_pages (grub_efi_uintn_t pages) { -- return grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS, +#ifdef GRUB_CPU_LOONGARCH64 + return grub_efi_allocate_pages_real (grub_efi_max_usable_address(), ++ pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, ++ GRUB_EFI_LOADER_DATA); ++#else + return grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS, pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, GRUB_EFI_LOADER_DATA); -+#else -+ return grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS, -+ pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, -+#endif GRUB_EFI_LOADER_DATA); ++#endif } void * -@@ -471,7 +484,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, +@@ -471,7 +485,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) { if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY @@ -339,7 +339,7 @@ index 9e76f23..fb087e3 100644 && desc->physical_start <= GRUB_EFI_MAX_ALLOCATION_ADDRESS #endif && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000 -@@ -486,8 +501,14 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, +@@ -486,8 +502,14 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, - desc->physical_start); desc->physical_start = 0x100000; } @@ -407,10 +407,10 @@ index 0000000..d291c67 + diff --git a/grub-core/kern/loongarch64/dl.c b/grub-core/kern/loongarch64/dl.c new file mode 100644 -index 0000000..a6fd387 +index 0000000..7d9e2a1 --- /dev/null +++ b/grub-core/kern/loongarch64/dl.c -@@ -0,0 +1,258 @@ +@@ -0,0 +1,266 @@ +/* loongarch64/dl.c - arch-dependent part of loadable module support */ +/* + * GRUB -- GRand Unified Bootloader @@ -669,6 +669,14 @@ index 0000000..a6fd387 + return GRUB_ERR_NONE; +} + ++/* ++ * Tell the loader what our minimum section alignment is. ++ */ ++grub_size_t ++grub_arch_dl_min_alignment (void) ++{ ++ return 1; ++} diff --git a/grub-core/kern/loongarch64/efi/init.c b/grub-core/kern/loongarch64/efi/init.c new file mode 100644 index 0000000..b21d4f1 @@ -1789,10 +1797,10 @@ index f6e4905..023dc90 100644 #error "Unknown target cpu type" #endif diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 29663f7..c0ca17d 100644 +index b72e6bd..f4066b5 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -332,6 +332,8 @@ static const grub_uint16_t machine_type __attribute__((__unused__)) = +@@ -343,6 +343,8 @@ static const grub_uint16_t machine_type __attribute__((__unused__)) = GRUB_PE32_MACHINE_I386; #elif defined(__ia64__) GRUB_PE32_MACHINE_IA64; @@ -2388,10 +2396,10 @@ index 0000000..c769bb2 + grub_unregister_command (cmd_initrd); +} diff --git a/include/grub/dl.h b/include/grub/dl.h -index 6a3e251..c1b6dd9 100644 +index 6f46b7e..50e04ac 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h -@@ -314,7 +314,7 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, +@@ -360,7 +360,7 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, #define GRUB_ARCH_DL_GOT_ALIGN 4 #endif @@ -2401,11 +2409,11 @@ index 6a3e251..c1b6dd9 100644 #define GRUB_ARCH_DL_GOT_ALIGN 8 #endif diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 37e7b16..049326c 100644 +index 510a403..a57187f 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -2087,7 +2087,8 @@ struct grub_efi_rng_protocol - typedef struct grub_efi_rng_protocol grub_efi_rng_protocol_t; +@@ -2117,7 +2117,8 @@ struct grub_efi_memory_attribute_protocol + typedef struct grub_efi_memory_attribute_protocol grub_efi_memory_attribute_protocol_t; #if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \ - || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) @@ -2415,10 +2423,10 @@ index 37e7b16..049326c 100644 #define efi_call_0(func) func() #define efi_call_1(func, a) func(a) diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h -index c03cc59..be88c54 100644 +index 45c9f8b..f612a55 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h -@@ -66,6 +66,7 @@ struct grub_pe32_coff_header +@@ -89,6 +89,7 @@ struct grub_pe32_coff_header }; #define GRUB_PE32_MACHINE_I386 0x14c @@ -2426,7 +2434,7 @@ index c03cc59..be88c54 100644 #define GRUB_PE32_MACHINE_IA64 0x200 #define GRUB_PE32_MACHINE_X86_64 0x8664 #define GRUB_PE32_MACHINE_ARMTHUMB_MIXED 0x01c2 -@@ -329,6 +330,7 @@ struct grub_pe32_fixup_block +@@ -355,6 +356,7 @@ struct grub_pe32_fixup_block #define GRUB_PE32_REL_BASED_IA64_IMM64 9 #define GRUB_PE32_REL_BASED_DIR64 10 #define GRUB_PE32_REL_BASED_HIGH3ADJ 11 @@ -3937,7 +3945,7 @@ index 03ba1ab..4a9943a 100644 struct platform_whitelist { diff --git a/util/mkimage.c b/util/mkimage.c -index 16418e2..0d39c07 100644 +index c770259..250ca81 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -609,6 +609,22 @@ static const struct grub_install_image_target_desc image_targets[] = diff --git a/grub.patches b/grub.patches index 63b9afb..106e853 100644 --- a/grub.patches +++ b/grub.patches @@ -548,5 +548,5 @@ Patch0547: 0547-nx-set-attrs-in-our-kernel-loaders.patch Patch0548: 0548-nx-set-the-nx-compatible-flag-in-EFI-grub-images.patch Patch0549: 0549-Fixup-grub_efi_get_variable-type-in-our-loaders.patch # Support loongarch64 -#Patch1000: 1000-loongarch64-add-support.patch +Patch1000: 1000-loongarch64-add-support.patch Patch1001: 1001-bls-make-list.patch diff --git a/grub2.spec b/grub2.spec index b7a8c85..a4ce453 100644 --- a/grub2.spec +++ b/grub2.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.1 +%define anolis_release .0.2 %undefine _hardened_build %global tarversion 2.02 @@ -523,6 +523,9 @@ fi %endif %changelog +* Sat Jul 02 2022 songmingliang - 2.02-123.0.2.8 +- fix 1000-loongarch64-add-support.patch + * Fri Jun 17 2022 Bo Ren - 2.02-123.0.1.8 - Build pc-modules package on x86_64 (geliwei@openanolis.org) - Add loongarch64 base support (zhangwenlong@loongson.cn)(chenguoqi@loongson.cn) -- Gitee