!177 修复在24.03的物理机上使用shim启动虚拟机报错问题

From: @hzero1996 
Reviewed-by: @zhujianwei001 
Signed-off-by: @zhujianwei001
This commit is contained in:
openeuler-ci-bot 2024-05-17 06:11:00 +00:00 committed by Gitee
commit 8f88adaa5a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,33 @@
From c7b305152802c8db688605654f75e1195def9fd6 Mon Sep 17 00:00:00 2001
From: Nicholas Bishop <nicholasbishop@google.com>
Date: Mon, 19 Dec 2022 18:56:13 -0500
Subject: [PATCH] pe: Align section size up to page size for mem attrs
Setting memory attributes is generally done at page granularity, and
this is enforced by checks in `get_mem_attrs` and
`update_mem_attrs`. But unlike the section address, the section size
isn't necessarily aligned to 4KiB. Round up the section size to fix
this.
Signed-off-by: Nicholas Bishop <nicholasbishop@google.com>
---
pe.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/pe.c b/pe.c
index 9a3679e16..5ad0914ba 100644
--- a/pe.c
+++ b/pe.c
@@ -1372,7 +1372,11 @@ handle_image (void *data, unsigned int datasize,
+ Section->Misc.VirtualSize - 1);
addr = (uintptr_t)base;
- length = (uintptr_t)end - (uintptr_t)base + 1;
+ // Align the length up to PAGE_SIZE. This is required because
+ // platforms generally set memory attributes at page
+ // granularity, but the section length (unlike the section
+ // address) is not required to be aligned.
+ length = ALIGN_VALUE((uintptr_t)end - (uintptr_t)base + 1, PAGE_SIZE);
if (Section->Characteristics & EFI_IMAGE_SCN_MEM_WRITE) {
set_attrs |= MEM_ATTR_W;

View File

@ -25,7 +25,7 @@
Name: shim Name: shim
Version: 15.7 Version: 15.7
Release: 11 Release: 12
Summary: First-stage UEFI bootloader Summary: First-stage UEFI bootloader
ExclusiveArch: x86_64 aarch64 ExclusiveArch: x86_64 aarch64
License: BSD License: BSD
@ -51,6 +51,7 @@ Patch13:backport-CVE-2023-0465.patch
Patch14:backport-CVE-2023-2650.patch Patch14:backport-CVE-2023-2650.patch
Patch15:backport-CVE-2024-0727.patch Patch15:backport-CVE-2024-0727.patch
Patch16:backport-Always-clear-SbatLevel-when-Secure-Boot-is-disabled.patch Patch16:backport-Always-clear-SbatLevel-when-Secure-Boot-is-disabled.patch
Patch17:backport-Align-section-size-up-to-page-size-for-mem-attrs.patch
# Feature for shim SMx support # Feature for shim SMx support
Patch9000:Feature-shim-openssl-add-ec-support.patch Patch9000:Feature-shim-openssl-add-ec-support.patch
@ -190,6 +191,9 @@ make test
/usr/src/debug/%{name}-%{version}-%{release}/* /usr/src/debug/%{name}-%{version}-%{release}/*
%changelog %changelog
* Fri May 17 2024 wangcheng <wangcheng156@huawei.com> - 15.7-12
- Align section size up to page size for mem attrs
* Wed May 8 2024 lijuzhang <lijuzhang@inspur.com> - 15.7-11 * Wed May 8 2024 lijuzhang <lijuzhang@inspur.com> - 15.7-11
- replace vendor for BOOTX64.CSV or BOOTAA64.CSV - replace vendor for BOOTX64.CSV or BOOTAA64.CSV