[PATCH 3/3] kern/efi/mm: introduce 'mmunlimited' for allocates on higher memories.

2022-12-05 Thread Jeremy Szu
In some recent EFI firwmare implmentation, the Loader-Data, Loader-Code and Conventional memory regions (grub loader prefer to use) are located under 1G (for example some HP platforms). Which causes there are only ~700MB on a 8G HP platform. (There are other 4G+ memories available above 0x1

[PATCH 2/3] include/grub/i386/linux.h support xloadflags

2022-12-05 Thread Jeremy Szu
Protocal 2.13 (Kernel 3.14) supports xloadflags to check the kernel supported boot loader. It's also kernel recommended to use. --- include/grub/i386/linux.h | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux

[PATCH 1/3] grub-core/kern/efi/mm.c fix warning message

2022-12-05 Thread Jeremy Szu
From: Jeremy Su When enable print_memory_map() for debugging, the warning message presents because of the types. Fix it by adding the macros in include/grub/efi/api.h. --- grub-core/kern/efi/mm.c | 5 - include/grub/efi/api.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --g

[PATCH 0/3] introduce "mmunlimited" to allocate higher memories.

2022-12-05 Thread Jeremy Szu
In some recent EFI firwmare implmentation, the Loader-Data, Loader-Code and Conventional memory regions (grub loader prefer to use) are located under 1G (for example some HP platforms). Which causes there are only ~700MB on a 8G HP platform. (There are other 4G+ memories available above 0x1

[PATCH] kern/file: Fix error handling in grub_file_open()

2022-12-05 Thread Steve McIntyre
grub_file_open() calls grub_file_get_device_name(), but doesn't check the return. Instead, it checks if grub_errno is set. However, nothing initialises grub_errno here when grub_file_open() starts. This means that trying to open one file that doesn't exist and then trying to open another file that

[RFC PATCH 4/4] kern/efi/sb: Use shim to verify font files

2022-12-05 Thread Zhang Boyang
Since font files can be wrapped as PE images by grub-wrap, use shim to verify font files if Secure Boot is enabled. To prevent other PE files (e.g. kernel images) used as wrappers, it only allows files marked as Windows GUI used as wrappers. Signed-off-by: Zhang Boyang --- grub-core/kern/efi/sb.

[RFC PATCH 3/4] kern/efi/sb: Set requirements for PE images

2022-12-05 Thread Zhang Boyang
There is a problem in shim lock verifier after PE wrappers created by grub-wrap are introduced. The shim lock verifier always says a file is ok as long as shim says that file is ok, so there is a possibility that wrappers may be used as kernel images, leading to crashes or vulnerabilities. This pa

[RFC PATCH 2/4] kern/unwrap: File filter to unwrap files wrapped by grub-wrap

2022-12-05 Thread Zhang Boyang
This file filter can unwrap a file wrapped by grub-wrap. This process is done automatically and transparently, thus no additional code is required at user's side. First, it checks for file type flags and ignore irrelevant files. Then, it find target PE section and unwraps the file. Subsequent read

[RFC PATCH 0/4] Wrap font files into PE files

2022-12-05 Thread Zhang Boyang
Hi, This patchset introduces a utility: grub-wrap. It can wrap a non-PE file as a PE file, which can be subsequently digitally signed (and verified by shim). The wrapped file will be unwrapped at runtime automatically and transparently by the unwrap filter. With grub-wrap, a PF2 font file can be

[RFC PATCH 1/4] util/grub-wrap: New tool to wrap a file as a PE image

2022-12-05 Thread Zhang Boyang
This new tool can wrap a non-PE file as a PE image, which can be subsequently digitally signed (and verified by shim). It's important that this type of PE images must be rejected when trying to execute them. This is done by making them look like plain Windows DLLs instead of UEFI images. Major dif

Re: [PATCH 4/5] font: Add font scaling feature to grub_font_draw_glyph()

2022-12-05 Thread Zhang Boyang
On 2022/12/5 19:29, Zhang Boyang wrote: This patch also adds a new metadata entry named MAXS to font files, limiting the maximum acceptable scale factor at runtime for a specific font. Currently MAXS is set to 8, which is sufficient for 16K monitors. Oh, I forgot to delete this paragraph of com

[PATCH 2/5] font: Assign null_font to unknown_glyph

2022-12-05 Thread Zhang Boyang
Like glyphs in ascii_font_glyph[], assign null_font to unknown_glyph->font in order to prevent grub_font_get_*() from dereferencing NULL pointer. Signed-off-by: Zhang Boyang --- grub-core/font/font.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/font/font.c b/grub-core/font/font.

[PATCH 1/5] font: Check return value of grub_malloc() in ascii_glyph_lookup()

2022-12-05 Thread Zhang Boyang
There is a problem in ascii_glyph_lookup(). It doesn't check the return value of grub_malloc(). If memory can't be allocated, then NULL pointer will be written to. This patch fixes the problem by fallbacking to unknown_glyph in case of grub_malloc() returns NULL. Signed-off-by: Zhang Boyang ---

[PATCH 3/5] font: Reject fonts with negative max_char_width or max_char_height

2022-12-05 Thread Zhang Boyang
If max_char_width or max_char_height is negative, bad values might be propagated by grub_font_get_max_char_width() or grub_font_get_max_char_height(). Prevent this from happening. Signed-off-by: Zhang Boyang --- grub-core/font/font.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) dif

[PATCH 4/5] font: Add font scaling feature to grub_font_draw_glyph()

2022-12-05 Thread Zhang Boyang
This patch adds an argument 'scale' to grub_font_draw_glyph(). If scale > 1, then the function will create a new scaled bitmap of the drawing glyph, and draws the scaled glyph. The scaled bitmap is cached in the glyph itself, so it can be reused if same glyph is used many times. This patch also ad

[PATCH 5/5] term/gfxterm: Preliminary HiDPI support

2022-12-05 Thread Zhang Boyang
Currently GRUB's default font is too small to see on a HiDPI monitor. This patch adds preliminary HiDPI support to gfxterm. It introduces a new environment variable 'gfxterm_scale'. If set to 0, and a high resolution monitor is detected, it will scale the font size automatically. If set to other nu

[PATCH 0/5] Font fixes and preliminary HiDPI support

2022-12-05 Thread Zhang Boyang
Hi, PATCH 1-3 are additional fixes to font code. PATCH 4-5 are the refactored and rebased version of HiDPI patches. They add preliminary HiDPI support for gfxterm. There is no HiDPI support for gfxmenu yet. Best Regards, Zhang Boyang ___ Grub-devel

[PATCH v12 10/10] tests: add support for LoongArch

2022-12-05 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu --- tests/ahci_test.in | 2 +- tests/ehci_test.in | 2 +- tests/ohci_test.in | 2 +- tests/pata_test.in | 2 +- tests/uhci_test.in | 2 +- tests/util/grub-shell.in | 14 ++ 6 files changed, 19 insertions(+), 5 deletions(-)

[PATCH v12 09/10] LoongArch: Support new relocation types in v2.00 ABI

2022-12-05 Thread Xiaotian Wu
Link: https://github.com/loongson/LoongArch-Documentation/pull/57 Signed-off-by: Xiaotian Wu --- configure.ac | 17 grub-core/kern/loongarch64/dl.c| 54 +-- grub-core/kern/loongarch64/dl_helper.c | 59 ++ inclu

[PATCH v12 00/10] Add support for LoongArch

2022-12-05 Thread Xiaotian Wu
This patchset adds support for the LoongArch instruction set. Please review the patches and let me know if changes are needed. v11->v12: - based on the last commit. - use LoadFile2 to loader initrd. Xiaotian Wu (10): PE: Add LoongArch definitions Add LoongArch definitions LoongArch: Add se

[PATCH v12 07/10] LoongArch: Add auxiliary files

2022-12-05 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- grub-core/kern/efi/mm.c | 3 +- grub-core/kern/loongarch64/cache.c | 39 grub-core/kern/loongarch64/cache_flush.S | 33 ++ grub-core/kern/loongarch64/efi/init.c| 77

[PATCH v12 08/10] LoongArch: Add to build system

2022-12-05 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- Makefile.util.def | 1 + configure.ac| 22 - gentpl.py | 27 ++-- grub-core/Makefile.am | 6 + grub-core/Makefile.core.def | 17 + include/g

[PATCH v12 05/10] LoongArch: Add efi stubs kernel loader support

2022-12-05 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu --- grub-core/loader/loongarch64/linux.c | 513 +++ include/grub/loongarch64/linux.h | 44 +++ 2 files changed, 557 insertions(+) create mode 100644 grub-core/loader/loongarch64/linux.c create mode 100644 include/grub/loongarch64/linux.h

[PATCH v12 06/10] LoongArch: Add awareness for LoongArch relocations

2022-12-05 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- grub-core/kern/dl.c| 9 +- grub-core/kern/loongarch64/dl.c| 102 + grub-core/kern/loongarch64/dl_helper.c | 202 + include/grub/dl.h | 1 + include/gru

[PATCH v12 04/10] LoongArch: Add early startup code

2022-12-05 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- grub-core/kern/loongarch64/efi/startup.S | 34 1 file changed, 34 insertions(+) create mode 100644 grub-core/kern/loongarch64/efi/startup.S diff --git a/grub-core/kern/loongarch64/efi/startup.S b/grub-core/kern/l

[PATCH v12 03/10] LoongArch: Add setjmp implementation

2022-12-05 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang Signed-off-by: Sun Haiyong --- grub-core/lib/loongarch64/setjmp.S | 69 ++ grub-core/lib/setjmp.S | 2 + include/grub/loongarch64/setjmp.h | 27 3 files changed, 98 insertions(+) create m

[PATCH v12 01/10] PE: Add LoongArch definitions

2022-12-05 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- include/grub/efi/pe32.h | 36 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h index 98c4ff177..101859af1 100644 --- a/include/grub/efi/pe

[PATCH v12 02/10] Add LoongArch definitions

2022-12-05 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- include/grub/elf.h | 23 +++ 1 file changed, 23 insertions(+) diff --git a/include/grub/elf.h b/include/grub/elf.h index e6f073bc9..c36d7dab2 100644 --- a/include/grub/elf.h +++ b/include/grub/elf.h @@ -252,6 +252,7 @@