Bug 9496 - GRUB在QEMU的sbsa-ref配置上启动失败
Summary: GRUB在QEMU的sbsa-ref配置上启动失败
Status: NEW
Alias: None
Product: Anolis OS 23
Classification: Anolis OS
Component: BaseOS Modules (show other bugs) BaseOS Modules
Version: 23.1
Hardware: aarch64 Linux
: P2-High S2-major
Target Milestone: ---
Assignee: happy_orange
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-11 15:10 UTC by Jun He
Modified: 2024-09-11 17:59 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jun He 2024-07-11 15:10:54 UTC
### 问题描述
+ GRUB版本: grub2-2.12-8.an23
+ OS 版本: Anolis-23.1
+ 平台架构: Arm64
+ 相关日志:

```
NOTICE:  Booting Trusted Firmware
NOTICE:  BL1: v2.11.0(release):v2.11.0
NOTICE:  BL1: Built : 18:14:37, May 28 2024
NOTICE:  BL1: Booting BL2
NOTICE:  BL2: v2.11.0(release):v2.11.0
NOTICE:  BL2: Built : 18:14:38, May 28 2024
NOTICE:  BL1: Booting BL31
NOTICE:  BL31: v2.11.0(release):v2.11.0
NOTICE:  BL31: Built : 18:14:38, May 28 2024
UEFI firmware (version 1.0 built at 08:31:08 on Jul 10 2024)



dynamic_load_symbols 0x101f7fe5000


Synchronous Exception at 0x00000101F7FFB0C4


Synchronous Exception at 0x00000101F7FFB0C4
```

### 复现方法
1. 编译SBSA-ref所需的firmware

```
mkdir -p FW
cd FW
git clone --depth 1 --recurse-submodules https://github.com/tianocore/edk2.git
git clone --depth 1 --recurse-submodules https://github.com/tianocore/edk2-platforms.git
git clone --depth 1 --recurse-submodules https://github.com/tianocore/edk2-non-osi.git
export PACKAGES_PATH=$(pwd)/edk2:$(pwd)/edk2-platforms:$(pwd)/edk2-non-osi
make -C edk2/BaseTools
export GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
source edk2/edksetup.sh
build -b RELEASE -a AARCH64 -t GCC5 -p edk2-platforms/Platform/Qemu/SbsaQemu/SbsaQemu.dsc -n 0
cp Build/SbsaQemu/RELEASE_GCC5/FV/SBSA_FLASH0.fd Build/SbsaQemu/RELEASE_GCC5/FV/SBSA_FLASH1.fd .
truncate -s 256M SBSA_FLASH0.fd SBSA_FLASH1.fd
```

2. 使用sbsa-ref配置启动qemu

```
dd if=/dev/zero of=anolis.img bs=1G count=16
./qemu/build/aarch64-softmmu/qemu-system-aarch64 \
    -machine sbsa-ref -m 8192 -nographic -device qemu-xhci -device usb-kbd -device e1000e \
    -drive if=pflash,file=SBSA_FLASH0.fd,format=raw,readonly=on \
    -drive if=pflash,file=SBSA_FLASH1.fd,format=raw \
    -drive media=disk,format=raw,index=1,file=anolis.img -drive media=cdrom,readonly=on,index=0,file=AnolisOS-23.1-aarch64-dvd.iso
```


### 实际效果
启动失败,提示

```
dynamic_load_symbols 0x101f7fe5000

Synchronous Exception at 0x00000101F7FFB0C4

Synchronous Exception at 0x00000101F7FFB0C4
```


### 期望效果
正常启动
Comment 1 Jun He 2024-09-11 17:59:39 UTC
已提交PR:https://gitee.com/src-anolis-os/grub2/pulls/61

该问题出现的原因是NX patch series中将各个架构的grub_arch_dl_min_alignment改为4096,但是在grub_dl_load_segments中仍然是使用默认的GRUB_ARCH_DL_TRAMP_ALIGN,前后不一致导致grub_dl_set_mem_attrs中设置page permissions时出现”permission denied"异常。

提交的PR是回合了https://lists.gnu.org/archive/html/grub-devel/2024-06/msg00085.html中的变动。