* [edk2-devel] QEMU / OVMF ESP corruption
@ 2024-09-26 16:23 Fred Lotter
0 siblings, 0 replies; only message in thread
From: Fred Lotter @ 2024-09-26 16:23 UTC (permalink / raw)
To: devel
[-- Attachment #1: Type: text/plain, Size: 4741 bytes --]
Hi,
I would like to ask for help on a particular failure I am observing.
I have this boot flow:
OVMF -> bootx64.efi (GRUB) ---chainloads--> vmlinux.efi
1. Grub updates a variable grub.env in the EFI partition (sector 7283/7284)
virtio_blk_handle_write vdev 0x5e72efe06150 req 0x5e72ef435910 sector 7283
nsectors 1
virtio_blk_rw_complete vdev 0x5e72efe06150 req 0x5e72ef435910 ret 0
virtio_blk_req_complete vdev 0x5e72efe06150 req 0x5e72ef435910 status 0
virtio_blk_handle_write vdev 0x5e72efe06150 req 0x5e72ef435910 sector 7284
nsectors 1
virtio_blk_rw_complete vdev 0x5e72efe06150 req 0x5e72ef435910 ret 0
virtio_blk_req_complete vdev 0x5e72efe06150 req 0x5e72ef435910 status 0
save_env --file (hd0,gpt2)/EFI/foo/grub.env BOOT
2. The vmlinux EFI stub results in a write area which includes the grub env
block
virtio_blk_handle_write vdev 0x5e72efe06150 req 0x5e72ef435910 sector 4097
nsectors 1
virtio_blk_rw_complete vdev 0x5e72efe06150 req 0x5e72ef435910 ret 0
virtio_blk_req_complete vdev 0x5e72efe06150 req 0x5e72ef435910 status 0
virtio_blk_handle_write vdev 0x5e72efe06150 req 0x5e72ef435910 sector 4128
nsectors 64
virtio_blk_rw_complete vdev 0x5e72efe06150 req 0x5e72ef435910 ret 0
virtio_blk_req_complete vdev 0x5e72efe06150 req 0x5e72ef435910 status 0
virtio_blk_handle_write vdev 0x5e72efe06150 req 0x5e72ef435910 sector 5704
nsectors 64
virtio_blk_rw_complete vdev 0x5e72efe06150 req 0x5e72ef435910 ret 0
virtio_blk_req_complete vdev 0x5e72efe06150 req 0x5e72ef435910 status 0
virtio_blk_handle_write vdev 0x5e72efe06150 req 0x5e72ef435910 sector 7280
nsectors 128 ## <====
virtio_blk_rw_complete vdev 0x5e72efe06150 req 0x5e72ef435910 ret 0
virtio_blk_req_complete vdev 0x5e72efe06150 req 0x5e72ef435910 status 0
virtio_blk_handle_write vdev 0x5e72efe06150 req 0x5e72ef435910 sector 8304
nsectors 128
The end result of this is that the grub.env file is reset to its original
value, with the change written by grub reverted.
This pattern seen during the EFI stub preamble is also seen during OVMF
startup, so it seems this is some common EFI VAR ? related code. At OVMF
startup this seems to repeat a number of times before Grub starts.
===> If I move OVMF to pflash disks for code + vars, this issue does not
happen.
DETAILS:
I am using Ubuntu Noble (24.04) packages for the test environment.
QEMU:
----
qemu-system-x86_64 \
-trace "virtio_blk*" \
-accel kvm \
-bios /usr/share/ovmf/OVMF.fd \
-drive format=raw,file=disk.img,if=virtio \
-device virtio-rng-pci \
-netdev user,id=net0,hostfwd=tcp::8888-:8888 \
-device virtio-net-pci,netdev=net0 \
-m 1G \
-serial mon:stdio \
-nodefaults \
-nographic
DISK:
-----
fdisk -l disk.img
Disk disk.img: 600 MiB, 629145600 bytes, 1228800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 8984DCD3-7190-1246-A4BB-980CEE0EB65A
Device Start End Sectors Size Type
disk.img1 2048 4095 2048 1M BIOS boot
disk.img2 4096 208895 204800 100M EFI System ## EFI
PARTITION
disk.img3 208896 618495 409600 200M Microsoft basic data ## BOOT
PARTITION
disk.img4 618496 1028095 409600 200M Microsoft basic data
disk.img5 1028096 1030143 2048 1M Linux filesystem
disk.img6 1030144 1228766 198623 97M Linux filesystem
EFI PARTITION:
--------------
.:
total 22
drwxr-xr-x 3 root root 512 Jan 1 1970 ./
drwxrwxr-x 5 flotter flotter 13 Sep 26 11:30 ../
drwxr-xr-x 4 root root 512 Sep 25 22:02 EFI/
-rwxr-xr-x 1 root root 11375 Sep 26 11:01 NvVars*
./EFI:
total 2
drwxr-xr-x 4 root root 512 Sep 25 22:02 ./
drwxr-xr-x 3 root root 512 Jan 1 1970 ../
drwxr-xr-x 2 root root 512 Sep 25 22:02 boot/
drwxr-xr-x 2 root root 512 Sep 25 22:02 foo/
./EFI/boot:
total 557
drwxr-xr-x 2 root root 512 Sep 25 22:02 ./
drwxr-xr-x 4 root root 512 Sep 25 22:02 ../
-rwxr-xr-x 1 root root 569344 Sep 25 22:02 bootx64.efi*
./EFI/foo:
total 6
drwxr-xr-x 2 root root 512 Sep 25 22:02 ./
drwxr-xr-x 4 root root 512 Sep 25 22:02 ../
-rwxr-xr-x 1 root root 3151 Sep 25 22:02 grub.cfg*
-rwxr-xr-x 1 root root 1024 Sep 25 22:02 grub.env*
BOOT PARTITION:
--------------
vmlinux.efi ## EFI STUB binary (Linux + initramfs)
Kind Regards,
Fred Lotter
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120585): https://edk2.groups.io/g/devel/message/120585
Mute This Topic: https://groups.io/mt/108674692/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 5693 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-09-26 19:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26 16:23 [edk2-devel] QEMU / OVMF ESP corruption Fred Lotter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox