Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1333888 - shim in F24 needs upstream d01421eb5ae6 for working with grub 2.02-0.26 and later on AARCH64
Summary: shim in F24 needs upstream d01421eb5ae6 for working with grub 2.02-0.26 and l...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: shim-signed
Version: 24
Hardware: aarch64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Peter Jones
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-05-06 14:45 UTC by Andrea Bolognani
Modified: 2016-05-21 20:27 UTC (History)
9 users (show)

Fixed In Version: shim-signed-0.8-9
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-05-21 20:27:50 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Andrea Bolognani 2016-05-06 14:45:37 UTC
Description of problem
======================

After a guest has been upgraded from Fedora 23 to Fedora 24, it
can no longer be booted and remains stuck in AAVMF.

This is the error shown on the guest console:

    Failed to set MokListRT: Invalid Parameter


    Synchronous Exception at 0x00000000B83BE498

      X0 0x1100069417FFFFE2   X1 0x00000000BBFF0018   X2 0x00000000B83C4C58   X3 0x00000000000FC400
      X4 0x0000000000000000   X5 0x0000000000000007   X6 0x00000000B9DEF018   X7 0x00000000BF1743A4
      X8 0x00000000BF1746E8   X9 0x00000000BF174A00  X10 0x0000000000000023  X11 0x000000000000009A
     X12 0x00000000700FE0FA  X13 0x0000000000000000  X14 0x0000000000000000  X15 0x0000000000000000
     X16 0x00000000BF174C80  X17 0x0000000000000000  X18 0x0000000000000000  X19 0x00000000BBFF0018
     X20 0x0000000000000000  X21 0x00000000B83C5000  X22 0x0000000000000000  X23 0xAA1303E4F940E022
     X24 0x0000000000000000  X25 0x0000000000000000  X26 0x0000000000000000  X27 0x0000000000000000
     X28 0x0000000000000000   FP 0x00000000BF174A10   LR 0x00000000B83BF040  

      V0 0x0000000000000000 0000000000000000   V1 0x0000000000000000 0000000000000000
      V2 0x0000000000000000 0000000000000000   V3 0x0000000000000000 0000000000000000
      V4 0x0000000000000000 0000000000000000   V5 0x0000000000000000 0000000000000000
      V6 0x0000000000000000 0000000000000000   V7 0x0000000000000000 0000000000000000
      V8 0x0000000000000000 0000000000000000   V9 0x0000000000000000 0000000000000000
     V10 0x0000000000000000 0000000000000000  V11 0x0000000000000000 0000000000000000
     V12 0x0000000000000000 0000000000000000  V13 0x0000000000000000 0000000000000000
     V14 0x0000000000000000 0000000000000000  V15 0x0000000000000000 0000000000000000
     V16 0x0000000000000000 0000000000000000  V17 0x0000000000000000 0000000000000000
     V18 0x0000000000000000 0000000000000000  V19 0x0000000000000000 0000000000000000
     V20 0x0000000000000000 0000000000000000  V21 0x0000000000000000 0000000000000000
     V22 0x0000000000000000 0000000000000000  V23 0x0000000000000000 0000000000000000
     V24 0x0000000000000000 0000000000000000  V25 0x0000000000000000 0000000000000000
     V26 0x0000000000000000 0000000000000000  V27 0x0000000000000000 0000000000000000
     V28 0x0000000000000000 0000000000000000  V29 0x0000000000000000 0000000000000000
     V30 0x0000000000000000 0000000000000000  V31 0x0000000000000000 0000000000000000

      SP 0x00000000BF174A10  ELR 0x00000000B83BE498  SPSR 0x60000305  FPSR 0x00000000
     ESR 0x96000004          FAR 0x1100069417FFFFE2

     ESR : EC 0x25  IL 0x1  ISS 0x00000004

    Data abort: Translation fault, zeroth level
    ASSERT [ArmCpuDxe] /builddir/build/BUILD/ovmf-90bb4c5/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c(184): ((BOOLEAN)(0==1))


Version-Release number of selected component (if applicable)
============================================================

  * kernel-4.5.0-0.33.el7.aarch64
  * libvirt-client-1.3.4-1.el7.aarch64
  * AAVMF-20160419-1.git90bb4c5.el7.noarch
  * custom QEMU binary built from tag v2.6.0-rc4


Steps to Reproduce
==================

  1. Create Fedora 23 guest

  2. Follow procedure outlined in
     [https://fedoraproject.org/wiki/DNF_system_upgrade] to
     upgrade from Fedora 23 to Fedora 24. The upgrade will
     complete successfully and the guest will reboot

  3. The guest will no longer be able to get past AAVMF


Additional info
===============

  This is the domain XML:

    <domain type='kvm'>
      <name>abologna-f23</name>
      <uuid>10a494bc-76ca-40d0-adec-fee38467a1ca</uuid>
      <memory unit='KiB'>2097152</memory>
      <currentMemory unit='KiB'>2097152</currentMemory>
      <vcpu placement='static'>4</vcpu>
      <os>
        <type arch='aarch64' machine='virt-2.6'>hvm</type>
        <loader readonly='yes' type='pflash'>/usr/share/AAVMF/AAVMF_CODE.fd</loader>
        <nvram>/var/lib/libvirt/qemu/nvram/abologna-f23_VARS.fd</nvram>
        <boot dev='hd'/>
      </os>
      <features>
        <gic version='2'/>
      </features>
      <cpu mode='host-passthrough'/>
      <clock offset='utc'/>
      <on_poweroff>destroy</on_poweroff>
      <on_reboot>restart</on_reboot>
      <on_crash>restart</on_crash>
      <devices>
        <emulator>/usr/libexec/abologna-qemu-kvm</emulator>
        <disk type='file' device='disk'>
          <driver name='qemu' type='qcow2'/>
          <source file='/var/lib/libvirt/images/abologna-f23.qcow2'/>
          <target dev='sda' bus='scsi'/>
          <address type='drive' controller='0' bus='0' target='0' unit='0'/>
        </disk>
        <controller type='scsi' index='0' model='virtio-scsi'>
          <address type='virtio-mmio'/>
        </controller>
        <controller type='pci' index='0' model='pcie-root'/>
        <controller type='pci' index='1' model='dmi-to-pci-bridge'>
          <model name='i82801b11-bridge'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
        </controller>
        <controller type='pci' index='2' model='pci-bridge'>
          <model name='pci-bridge'/>
          <target chassisNr='2'/>
          <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
        </controller>
        <interface type='network'>
          <mac address='52:54:00:44:73:48'/>
          <source network='default'/>
          <model type='virtio'/>
          <address type='virtio-mmio'/>
        </interface>
        <serial type='pty'>
          <target port='0'/>
        </serial>
        <console type='pty'>
          <target type='serial' port='0'/>
        </console>
      </devices>
    </domain>

Comment 2 Laszlo Ersek 2016-05-06 15:22:01 UTC
Hi Andrea,

the error message you quoted ("Failed to set MokListRT") comes from shim. I think that the shim package was upgraded as part of the F23 -> F24 transition. Also, since shim is a UEFI application, if it dances a fandango on core (NULL pointer deref and the like), that would be consistent with the symptom you are seeing (CPU exception caught and dumped by the edk2 exception handler).

What are your shim package versions, before and after?

CC'ing Peter.

Anyway, the error message is printed when the MokListRT or MokListXRT UEFI variables cannot be set (with the SetVariable() runtime service). The EFI_INVALID_PARAMETER error code is specified for the following cases:

* An invalid combination of attribute bits, name, and GUID was supplied, or the
  DataSize exceeds the maximum allowed.

* VariableName is an empty string.

Did you try installing an F24 guest from scratch? (Or maybe there's no released ISO yet, I don't know.)

Comment 3 Laszlo Ersek 2016-05-06 22:44:31 UTC
I reproduced the bug, using the exact same host-side components, and a
practically identical guest configuration too.

There was one important difference in my setup: instead of AAVMF_CODE.fd, I
used AAVMF_CODE.verbose.fd, which is why I have a bit of additional
information now, from the console:

> Booting Fedora
> FSOpen: Open '\EFI\fedora\shim.efi' Success
> InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B BA0238C0
> Loading driver at 0x000B85B6000 EntryPoint=0x000B85B6148
> Loading driver at 0x000B85B6000 EntryPoint=0x000B85B6148
> InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF BA01EA58
> InstallProtocolInterface: 605DAB50-E046-4300-ABB6-3DD810DD8B23 B8652948
> Failed to set MokListRT: Invalid Parameter
> FSOpen: Open '\EFI\fedora\grubaa64.efi' Success
>
>
> Synchronous Exception at 0x00000000B83BE498
>
>   X0 0x1100069417FFFFE2   X1 0x00000000BBFF0018   X2 0x00000000B83C4C58   X3 0x00000000000FC400
>   X4 0x0000000000000000   X5 0x0000000000000007   X6 0x00000000B9DEF018   X7 0x00000000BF1743A4
>   X8 0x00000000BF1746E8   X9 0x00000000BF174A00  X10 0x000000000000003D  X11 0x00000000000000B6
>  X12 0x00000000700FE0FA  X13 0x0000000000000000  X14 0x0000000000000000  X15 0x0000000000000000
>  X16 0x00000000BF174C80  X17 0x0000000000000000  X18 0x0000000000000000  X19 0x00000000BBFF0018
>  X20 0x0000000000000000  X21 0x00000000B83C5000  X22 0x0000000000000000  X23 0xAA1303E4F940E022
>  X24 0x0000000000000000  X25 0x0000000000000000  X26 0x0000000000000000  X27 0x0000000000000000
>  X28 0x0000000000000000   FP 0x00000000BF174A10   LR 0x00000000B83BF040
>
>   V0 0x0000000000000000 0000000000000000   V1 0x0000000000000000 0000000000000000
>   V2 0x0000000000000000 0000000000000000   V3 0x0000000000000000 0000000000000000
>   V4 0x0000000000000000 0000000000000000   V5 0x0000000000000000 0000000000000000
>   V6 0x0000000000000000 0000000000000000   V7 0x0000000000000000 0000000000000000
>   V8 0x0000000000000000 0000000000000000   V9 0x0000000000000000 0000000000000000
>  V10 0x0000000000000000 0000000000000000  V11 0x0000000000000000 0000000000000000
>  V12 0x0000000000000000 0000000000000000  V13 0x0000000000000000 0000000000000000
>  V14 0x0000000000000000 0000000000000000  V15 0x0000000000000000 0000000000000000
>  V16 0x0000000000000000 0000000000000000  V17 0x0000000000000000 0000000000000000
>  V18 0x0000000000000000 0000000000000000  V19 0x0000000000000000 0000000000000000
>  V20 0x0000000000000000 0000000000000000  V21 0x0000000000000000 0000000000000000
>  V22 0x0000000000000000 0000000000000000  V23 0x0000000000000000 0000000000000000
>  V24 0x0000000000000000 0000000000000000  V25 0x0000000000000000 0000000000000000
>  V26 0x0000000000000000 0000000000000000  V27 0x0000000000000000 0000000000000000
>  V28 0x0000000000000000 0000000000000000  V29 0x0000000000000000 0000000000000000
>  V30 0x0000000000000000 0000000000000000  V31 0x0000000000000000 0000000000000000
>
>   SP 0x00000000BF174A10  ELR 0x00000000B83BE498  SPSR 0x60000305  FPSR 0x00000000
>  ESR 0x96000004          FAR 0x1100069417FFFFE2
>
>  ESR : EC 0x25  IL 0x1  ISS 0x00000004
>
> Data abort: Translation fault, zeroth level
> ASSERT [ArmCpuDxe] /builddir/build/BUILD/ovmf-90bb4c5/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c(184): ((BOOLEAN)(0==1))

See those "FSOpen" lines? Those are printed by the FAT driver, when it was
not built with a silent log mask.

So, from the above, we can tell that "shim.efi" recovers from the "Failed to
set MokListRT" error, launches grub, and "grubaa64.efi" blows up.

Interestingly, if I reboot the guest, interrupt the boot process, go to the
UEFI shell, then launch grubaa64.efi manually, then it works all fine. If I
launch "shim.efi" from the UEFI shell, then the same issue occurs.

Now, let's compare the shim and grub versions, across the upgrade. The shim
version doesn't change, it is "shim-0.8-8.aarch64" on both sides of the
upgrade.

The grub2 and grubby packages change from:

  grub2-efi-2.02-0.25.fc23.aarch64
  grub2-tools-2.02-0.25.fc23.aarch64
  grubby-8.40-2.fc23.aarch64

to:

  grub2-efi-2.02-0.30.fc24.aarch64
  grub2-tools-2.02-0.30.fc24.aarch64
  grubby-8.40-3.fc24.aarch64

The grubby change is irrelevant, it is only

> * Wed Feb 03 2016 Fedora Release Engineering <releng> - 8.40-3
> - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

grub2 is more interesting:

> * Thu Apr 07 2016 pjones <pjones> - 1:2.02-0.30
> - Revert 27e66193, which was replaced by upstream's 49426e9fd
>   Resolves: rhbz#1251600
>
> * Thu Apr 07 2016 Peter Jones <pjones> - 2.02-0.29
> - Fix ppc64 build failure on fedora-24
>
> * Tue Apr 05 2016 pjones <pjones> - 1:2.02-0.27
> - Pull TPM updates from mjg59.
>   Resolves: rhbz#1318067
>
> * Tue Mar 08 2016 pjones <pjones> - 1:2.02-0.27
> - Fix aarch64 build problem.
>
> * Fri Mar 04 2016 Peter Jones <pjones> - 2.02-0.26
> - Rebased to newer upstream (grub-2.02-beta3) for fedora-24

I downgraded to grub2-2.02-0.27.fc24, from Koji (the smallest release
increment available in Koji after 2.02-0.25). The bug persists.

Then I downgraded to grub2-2.02-0.24.fc24 (again from Koji) -- the closest
earlier version. With it the guest boots all fine, using shim.efi, without
any manual intervention.

I think the culprit is probably the rebase to upstream beta3, in the
2.02-0.26 downstream version (which was first built for aarch64 as
2.02-0.27).

Namely, the changelog mentions bug 1318067, so I briefly looked that over,
before the above "bisection". One of the comments there, bug 1318067 comment
33, says "It's 2 years between beta2 and beta3, per upstream's summary, with
hundreds of insertions/deletions". That's where I expect the regression to
come from.

Reassigning to grub2, per the above results:

- grub2-efi-2.02-0.24.fc24.aarch64: PASS
- grub2-efi-2.02-0.25.fc23.aarch64: PASS
- grub2-efi-2.02-0.27.fc24.aarch64: FAIL
- grub2-efi-2.02-0.30.fc24.aarch64: FAIL

Comment 4 Laszlo Ersek 2016-05-11 15:52:06 UTC
Actually, this is a bug in shim. Grub is not at fault; the grub2 versions I
identified above as problematic only trigger the bug in shim. (This is also
evident, in retrospect, from the fact that the UEFI shell has zero problems
launching grub2 directly.)

Using most recent upstream shim (e22a7b5b772d), things work. I tried to
bisect upstream shim, between 0.8 and e22a7b5b772d. The bisection narrowed
it down to the following commit range:

broken 4316fbd2a2ba Bump version to 0.8
skip   361716dd4a61 Add nostdinc to the CFLAGS for lib
skip   d01421eb5ae6 Align the sections we're loading, and check for validity /after/ discarding.
skip   5195d7d31bde Don't install our protocols if we're not in secure mode.
skip   90c65f72f882 fallback: Fix comparison between signed and unsigned in debugging code.
skip   6b2510522f92 Fix length of allocated buffer for boot option comparison.
skip   7fdbd9d48a4e Make lib/ build right with the cflags it should be using...
fixed  605be9f1793e Make lib/ use the right CFLAGS.

Those skipped commits are marked as such because they don't build.

(In general my impression of the shim upstream repository is: throw patches
at the wall until something sticks. There seems to be minimal effort to
ensure a healthy build on *all* supported architectures. My impression is
that noone cares about bisectability as a first class goal. And this shows;
see above.

Even just to get this far in the bisection, I regularly had to hack the
Makefile (remember: I started to bisect the range 0.8..e22a7b5b772d). For
example, for commits beyond

  929b5b762be0 Make the build failed with objcopy < 2.24

I had to undo the changes added by this patch, because it broke the build on
my aarch64 host *unconditionally*, despite my objcopy being >= 2.24! (The
exact version was "2.25.1-9.el7".))

So anyway, after eyeballing the listed commits, d01421eb5ae6 looks like a
clear suspect.

I tried to port this commit to Fedora 24's shim-signed package, on top of
build 0.8-8 (more precisely, on top of dist-git commit 99c75437001f). I have
fedpkg installed on my RHEL-7 system, and I have scratch-built Fedora
packages before. (I have a valid FAS account and a fresh certificate too.)

Clearly, I couldn't do that in this case, because aarch64 is a secondary
architecture for Fedora, with a separate Koji instance at
<http://arm.koji.fedoraproject.org/koji/>; and my fedpkg doesn't know
anything about it.

In an aarch64 Fedora 24 guest, I installed the "fedora-packager" package. I
grabbed the ARM koji configuration from it, and tried to pass it to  fedpkg
with --config. Unfortunately, the fedpkg command needs a *higher level*
configuration file, which in turn references the koji config file. I found
this higher level fedpkg config file on my RHEL-7 system
(/etc/rpkg/fedpkg.conf), but I failed to customize it (beyond the reference
to the ARM koji config file) for aarch64. I found no usable documentation
either.

Thus, shim in Fedora 24 needs a backport of upstream commit d01421eb5ae6,
otherwise it corrupts the grubaa64.efi image, and I couldn't test such a
build myself, because the infrastructure is plain unusable for someone who
doesn't work with it every day. Not good, Fedora, not good.

Comment 5 Marcin Juszkiewicz 2016-05-12 09:12:21 UTC
Yesterday I also looked at that with help from Peter Jones. Shim is definitely the source of problem.

Comment 6 Fedora Update System 2016-05-17 17:59:35 UTC
shim-signed-0.8-9 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-0b7e5ceb72

Comment 7 Marcin Juszkiewicz 2016-05-18 10:00:41 UTC
Fedora 24 cloud image from 20160518 booted perfectly:

FSOpen: Open '\EFI\BOOT\BOOTAA64.EFI' Success
FSOpen: Open '\EFI\BOOT\BOOTAA64.EFI' Success
InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B B9F3D8C0
Loading driver at 0x000B8564000 EntryPoint=0x000B8564148
Loading driver at 0x000B8564000 EntryPoint=0x000B8564148 
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF BB1D3998
Failed to set MokListRT: Invalid Parameter
FSOpen: Open '\EFI\BOOT\fallback.efi' Success
FSOpen: Open '\EFI\BOOT\fallback.efi' Success
System BootOrder not found.  Initializing defaults.
FSOpen: Open 'EFI' Success
FSOpen: Open 'fedora' Success
FSOpen: Open 'BOOT.CSV' Success
FSOpen: Open '\EFI\fedora\BOOT.CSV' Success
Creating boot entry "Boot0003" with label "Fedora" for file "\EFI\fedora\shim.efi"
FSOpen: Open '\EFI\fedora\shim.efi' Success
InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B B9F41AC0
Loading driver at 0x000B8498000 EntryPoint=0x000B8498148
Loading driver at 0x000B8498000 EntryPoint=0x000B8498148 
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF B9F3DB58
Failed to set MokListRT: Invalid Parameter
FSOpen: Open '\EFI\fedora\grubaa64.efi' Success




      Fedora (4.5.4-300.fc24.aarch64) 24 (Cloud Edition)                        
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                                

      Use the ^ and v keys to change the selection.                       
      Press 'e' to edit the selected item, or 'c' for a command prompt.   
   The selected entry will be started automatically in 0s.

Comment 8 Peter Robinson 2016-05-18 10:04:28 UTC
Fixed in today's compose

https://dl.fedoraproject.org/pub/fedora-secondary/development/24/

Comment 9 Fedora Update System 2016-05-21 01:35:44 UTC
shim-signed-0.8-9 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-0b7e5ceb72

Comment 10 Fedora Update System 2016-05-21 20:27:41 UTC
shim-signed-0.8-9 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.