From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id E7F2E740068 for ; Thu, 26 Sep 2024 19:46:42 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=W8aATisH0raVLsx3R52GbhiUZGCFsUQ4EFxP81Nln4o=; c=relaxed/simple; d=groups.io; h=MIME-Version:From:Date:Message-ID:Subject:To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240830; t=1727380002; v=1; x=1727639201; b=i62V6cLRDJRzDn131PXFY8U9DeJBkqjwHxjjZreBsERUpzJsglQKEBFXJ8Kg7PkUCHck/Vge Sfz32BFFJaSknEOYDAux5S5SORJD/mY1bNvwss8TY1UxuD08w2ATtsGzSmNGmE3jCiaTd8MVPAY sRc2oUR1h8Q5QNr1EnWhXg9ctF5TIMxscK1MpxMCl5otHYZAaQ4keDBn3ql/3hQ9VSdSLlPHmnJ /0kw709q9Xq9hgVz5kCntSVz6mjv5TMFHGy+Weri0ou43RjNKUJP88dpcTsi09pk4UEKEJO5eZL lkH2ccRJUJ27OqaU3zZNxi0dN9MwFKPuVZ+AWE7c9V4LA== X-Received: by 127.0.0.2 with SMTP id yuhlYY7687511xozV1V3asCC; Thu, 26 Sep 2024 12:46:41 -0700 X-Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by mx.groups.io with SMTP id smtpd.web11.48336.1727367829926744651 for ; Thu, 26 Sep 2024 09:23:50 -0700 X-Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 06D263F1CC for ; Thu, 26 Sep 2024 16:23:43 +0000 (UTC) X-Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6c5984bc3fdso13607596d6.0 for ; Thu, 26 Sep 2024 09:23:42 -0700 (PDT) X-Gm-Message-State: UXQ21gjersle5coIcZAT9Cuex7686176AA= X-Received: by 2002:a05:6214:5d8d:b0:6c1:6e3a:6d17 with SMTP id 6a1803df08f44-6cb3b5b906amr4376486d6.6.1727367821121; Thu, 26 Sep 2024 09:23:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHp8AzduZw/rdsYQ3PIXMTc/Frpaz89D1HhBNEEoG6/dyF9DsgC+TCc7IjsmNQek4pB0a5qR+3lQ3gyEnwAJCU= X-Received: by 2002:a05:6214:5d8d:b0:6c1:6e3a:6d17 with SMTP id 6a1803df08f44-6cb3b5b906amr4376106d6.6.1727367820557; Thu, 26 Sep 2024 09:23:40 -0700 (PDT) MIME-Version: 1.0 From: Fred Lotter Date: Thu, 26 Sep 2024 18:23:29 +0200 Message-ID: Subject: [edk2-devel] QEMU / OVMF ESP corruption To: devel@edk2.groups.io Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Thu, 26 Sep 2024 12:46:41 -0700 Resent-From: fred.lotter@canonical.com Reply-To: devel@edk2.groups.io,fred.lotter@canonical.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: multipart/alternative; boundary="0000000000005759fa0623082976" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=i62V6cLR; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=canonical.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io --0000000000005759fa0623082976 Content-Type: text/plain; charset="UTF-8" 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] -=-=-=-=-=-=-=-=-=-=-=- --0000000000005759fa0623082976 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I would like to ask for help on a particul= ar 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_bl= k_handle_write vdev 0x5e72efe06150 req 0x5e72ef435910 sector 7283 nsectors = 1
virtio_blk_rw_complete vdev 0x5e72efe06150 req 0x5e72ef435910 ret 0virtio_blk_req_complete vdev 0x5e72efe06150 req 0x5e72ef435910 status 0virtio_blk_handle_write vdev 0x5e72efe06150 req 0x5e72ef435910 sector 7284= nsectors 1
virtio_blk_rw_complete vdev 0x5e72efe06150 req 0x5e72ef43591= 0 ret 0
virtio_blk_req_complete vdev 0x5e72efe06150 req 0x5e72ef435910 s= tatus 0
save_env --file (hd0,gpt2)/EFI/foo/grub.env BOOT

2. The v= mlinux 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 0x5e72ef= 435910 ret 0
virtio_blk_req_complete vdev 0x5e72efe06150 req 0x5e72ef435= 910 status 0
virtio_blk_handle_write vdev 0x5e72efe06150 req 0x5e72ef435= 910 sector 4128 nsectors 64
virtio_blk_rw_complete vdev 0x5e72efe06150 r= eq 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 0x5e7= 2efe06150 req 0x5e72ef435910 ret 0
virtio_blk_req_complete vdev 0x5e72ef= e06150 req 0x5e72ef435910 status 0
virtio_blk_handle_write vdev 0x5e72ef= e06150 req 0x5e72ef435910 sector 7280 nsectors 128 =C2=A0## <=3D=3D=3D= =3D
virtio_blk_rw_complete vdev 0x5e72efe06150 req 0x5e72ef435910 ret 0<= br>virtio_blk_req_complete vdev 0x5e72efe06150 req 0x5e72ef435910 status 0<= br>virtio_blk_handle_write vdev 0x5e72efe06150 req 0x5e72ef435910 sector 83= 04 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.
<= br>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 st= artup this seems to repeat a number of times before Grub starts.

=3D= =3D=3D> 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 \=
=C2=A0 =C2=A0 -trace "virtio_blk*" \
=C2=A0 =C2=A0 -accel = kvm \
=C2=A0 =C2=A0 -bios /usr/share/ovmf/OVMF.fd \
=C2=A0 =C2=A0 -dr= ive format=3Draw,file=3Ddisk.img,if=3Dvirtio \
=C2=A0 =C2=A0 -device vir= tio-rng-pci \
=C2=A0 =C2=A0 -netdev user,id=3Dnet0,hostfwd=3Dtcp::8888-:= 8888 \
=C2=A0 =C2=A0 -device virtio-net-pci,netdev=3Dnet0 \
=C2=A0 = =C2=A0 -m 1G \
=C2=A0 =C2=A0 -serial mon:stdio \
=C2=A0 =C2=A0 -nodef= aults \
=C2=A0 =C2=A0 -nographic
=C2=A0 =C2=A0
DISK:
-----
=
fdisk -l disk.img
Disk disk.img: 600 MiB, 629145600 bytes, 1228800 s= ectors
Units: sectors of 1 * 512 =3D 512 bytes
Sector size (logical/p= hysical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / = 512 bytes
Disklabel type: gpt
Disk identifier: 8984DCD3-7190-1246-A4B= B-980CEE0EB65A

Device =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 Start =C2=A0 =C2=A0 End Sectors =C2=A0Size Type
disk.img1 =C2=A0 = =C2=A02048 =C2=A0 =C2=A04095 =C2=A0 =C2=A02048 =C2=A0 =C2=A01M BIOS bootdisk.img2 =C2=A0 =C2=A04096 =C2=A0208895 =C2=A0204800 =C2=A0100M EFI Syste= m =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ## EFI PARTITION
disk.img3 = =C2=A0208896 =C2=A0618495 =C2=A0409600 =C2=A0200M Microsoft basic data =C2= =A0 ## BOOT PARTITION
disk.img4 =C2=A0618496 1028095 =C2=A0409600 =C2=A0= 200M Microsoft basic data
disk.img5 1028096 1030143 =C2=A0 =C2=A02048 = =C2=A0 =C2=A01M Linux filesystem
disk.img6 1030144 1228766 =C2=A0198623 = =C2=A0 97M Linux filesystem =C2=A0 =C2=A0
=C2=A0 =C2=A0
EFI PARTITIO= N:
--------------

.:
total 22
drwxr-xr-x 3 root =C2=A0 =C2= =A0root =C2=A0 =C2=A0 =C2=A0512 Jan =C2=A01 =C2=A01970 ./
drwxrwxr-x 5 f= lotter flotter =C2=A0 =C2=A013 Sep 26 11:30 ../
drwxr-xr-x 4 root =C2=A0= =C2=A0root =C2=A0 =C2=A0 =C2=A0512 Sep 25 22:02 EFI/
-rwxr-xr-x 1 root = =C2=A0 =C2=A0root =C2=A0 =C2=A011375 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 =C2=A01 =C2=A01970 ../
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 =C2=A0 =C2=A0512 Sep 25 22:02 ./drwxr-xr-x 4 root root =C2=A0 =C2=A0512 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 =C2=A0512 Sep 25 22:02 ./
drwxr-xr-x 4 root root = =C2=A0512 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 PAR= TITION:
--------------

vmlinux.efi =C2=A0## EFI STUB binary (Linu= x + initramfs)

Kind Regards,
Fred Lotter
_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#120585) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--0000000000005759fa0623082976--