<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15274</bug_id>
          
          <creation_ts>2023-11-06 23:11:51 +0000</creation_ts>
          <short_desc>qemuarmv5 fails to boot with qemu lsi hw error</short_desc>
          <delta_ts>2023-11-20 23:06:34 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>virtual machines</component>
          <version>3.1.34</version>
          <rep_platform>Other</rep_platform>
          <op_sys>arm</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>3.1.30</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jon Mason">jon.mason</reporter>
          <assigned_to name="Steve Sakoman">steve</assigned_to>
          <cc>peter.maydell</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>ross.burton</cc>
    
    <cc>steve</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>97207</commentid>
    <comment_count>0</comment_count>
    <who name="Jon Mason">jon.mason</who>
    <bug_when>2023-11-06 23:11:51 +0000</bug_when>
    <thetext>I see the following error (100% reproducible) when booting qemuarmv5 on dunfell:


WARNING: core-image-base-1.0-r0 do_testimage: Last 25 lines of text:
[    2.346176] pci 0000:00:10.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
[    2.347319] PCI: bus0: Fast back to back transfers disabled
[    2.348129] pci 0000:00:0e.0: BAR 6: assigned [mem 0x60000000-0x6003ffff pref]
[    2.348404] pci 0000:00:0e.0: BAR 4: assigned [mem 0x60040000-0x60043fff 64bit pref]
[    2.348658] pci 0000:00:0f.0: BAR 4: assigned [mem 0x60044000-0x60047fff 64bit pref]
[    2.348840] pci 0000:00:10.0: BAR 4: assigned [mem 0x60048000-0x6004bfff 64bit pref]
[    2.349017] pci 0000:00:0d.0: BAR 2: assigned [mem 0x50000000-0x50001fff]
[    2.349168] pci 0000:00:0d.0: BAR 1: assigned [mem 0x50002000-0x500023ff]
[    2.349310] pci 0000:00:0c.0: BAR 0: assigned [mem 0x50002400-0x500024ff]
[    2.349467] pci 0000:00:0d.0: BAR 0: assigned [io  0x1000-0x10ff]
[    2.349762] pci 0000:00:10.0: BAR 0: assigned [io  0x1400-0x147f]
[    2.349926] pci 0000:00:0e.0: BAR 0: assigned [io  0x1480-0x149f]
[    2.350065] pci 0000:00:0f.0: BAR 0: assigned [io  0x14a0-0x14bf]
[    2.350645] pci 0000:00:0c.0: enabling device (0100 -&gt; 0102)
[    2.351795] clcd-pl11x 10120000.display: PL110 designer 41 rev0 at 0x10120000
[    2.352619] clcd-pl11x: probe of 10120000.display failed with error -2
[    2.353713] virtio-pci 0000:00:0e.0: enabling device (0100 -&gt; 0103)
[    2.355176] virtio-pci 0000:00:0f.0: enabling device (0100 -&gt; 0103)
[    2.355893] virtio-pci 0000:00:10.0: enabling device (0100 -&gt; 0103)
[    2.370420] random: crng init done
[    2.385144] brd: module loaded
[    2.388394] virtio_blk virtio2: [vda] 131072 512-byte logical blocks (67.1 MB/64.0 MiB)
[    2.396945] sym53c8xx 0000:00:0d.0: enabling device (0100 -&gt; 0103)
[    2.398519] sym0: &lt;895a&gt; rev 0x0 at pci 0000:00:0d.0 irq 67
[    2.402440] sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
WARNING: core-image-base-1.0-r0 do_testimage: Check full boot log: /builder/meta-arm/build/tmp/work/qemuarmv5-poky-linux-gnueabi/core-image-base/1.0-r0/testimage/qemu_boot_log.20231106203634
WARNING: core-image-base-1.0-r0 do_testimage: Qemu ended unexpectedly, dump data from host is in /builder/meta-arm/build/tmp/log/runtime-hostdump/202311062040_qemu
WARNING: core-image-base-1.0-r0 do_testimage: qemu-system ended unexpectedly
Output from runqemu:
vpb_sic_write: Bad register offset 0x2c
runqemu - ERROR - Failed to run qemu: qemu-system-arm: warning: Blocked re-entrant IO on MemoryRegion: lsi-ram at addr: 0x1000
qemu-system-arm: /builder/meta-arm/build/tmp/work/x86_64-linux/qemu-system-native/4.2.1-r0/qemu-4.2.1/hw/scsi/lsi53c895a.c:624: lsi_do_dma: Assertion `s-&gt;current&apos; failed.

runqemu - INFO - Cleaning up</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97212</commentid>
    <comment_count>1</comment_count>
    <who name="Peter Maydell">peter.maydell</who>
    <bug_when>2023-11-07 10:37:34 +0000</bug_when>
    <thetext>Hi; this error message:

runqemu - ERROR - Failed to run qemu: qemu-system-arm: warning: Blocked re-entrant IO on MemoryRegion: lsi-ram at addr: 0x1000

means you have hit a bug which is fixed in newer versions of QEMU. The simplest solution is to use a newer QEMU version than whatever this is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97213</commentid>
    <comment_count>2</comment_count>
    <who name="Peter Maydell">peter.maydell</who>
    <bug_when>2023-11-07 10:42:46 +0000</bug_when>
    <thetext>PS: the assertion message filename implies that this is qemu-4.2.1, which is odd because the assertion you hit was not present in that upstream QEMU. That suggests that perhaps this is a custom QEMU with some backported patches, and the set of patches backported was not correct or complete or is missing some later fixes for backported pieces.

Backporting the patch which added this assert was probably a mistake -- it is a useful security fix if you&apos;re using an up to date QEMU, but on something as elderly as 4.2 there are bound to be a ton of other security problems unfixed. So either (a) don&apos;t bother backporting security fixes or (b) use newer QEMU. If you only care about emulation then (a) is probably better, because from upstream QEMU&apos;s point of view the emulation-only use case is not on our security boundary and bugs allowing an emulated guest to escape the VM are not considered &quot;security&quot; bugs that get CVEs/announcements/etc.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97214</commentid>
    <comment_count>3</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2023-11-07 11:19:52 +0000</bug_when>
    <thetext>It does look like the backport of a2e1753b8054344f32cf94f31c6399a58794a380 adds this message so the fix for CVE-2023-0330 looks to have broken qemuarmv5. Dunfell is our oldest LTS release and upgrading QEMU there likely isn&apos;t an option sadly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97215</commentid>
    <comment_count>4</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2023-11-07 11:24:25 +0000</bug_when>
    <thetext>It looks like the crash is in hw/scsi/lsi53c895a.c and the short log for hw/scsi/lsi53c895a.c is:

b987718bbb hw/scsi/lsi53c895a: Fix reentrancy issues in the LSI controller (CVE-2023-0330)
d139fe9ad8 lsi53c895a: disable reentrancy detection for MMIO region, too
bfd6e7ae6a lsi53c895a: disable reentrancy detection for script RAM

i.e. the first one is definitely needed, perhaps with the other two?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97216</commentid>
    <comment_count>5</comment_count>
    <who name="Peter Maydell">peter.maydell</who>
    <bug_when>2023-11-07 11:44:10 +0000</bug_when>
    <thetext>My suggestions in order of preference:

(1) drop the backport of a2e1753b8054344f32 -- if you&apos;re running QEMU 4.2 you clearly don&apos;t care about security against guests escaping from the VM, so applying this change only introduces the possibility of regressions for existing guest setups you&apos;re using

(2) backport at least commit bfd6e7ae6a72 and commit d139fe9ad8a27bc

Some background to a2e1753b8054344f32: there is a longstanding class of bugs in QEMU where a malicious guest can program a DMA-capable device so that it does DMA to its own registers (or more complicated scenarios where device A DMAs to device B which DMAs back to device A), and then the QEMU device model code is re-entered in a way it doesn&apos;t expect, causing misbehaviour, crashes, etc. Commit a2e1753b8054344f32 is a big hammer which forbids this for all devices; it then caused a certain amount of fallout where we found cases where in fact DMA back to a particular device was a legitimate scenario, and we had to permit those special cases. It&apos;s not a good idea to backport a2e1753b8054344f32 without also tracking down and backporting the subsequent fixes (and unfortunately we didn&apos;t always tag those commits with &quot;Fixes: a2e1753b805&quot; when we made them, so there&apos;s no easy way to locate them all). So a2e1753b8054344f32 is a very risky commit to backport from a &quot;possible regressions&quot; perspective and you should only do it if you critically need the security improvement it gets you; which you don&apos;t if you&apos;re happy to stay on 4.2.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97292</commentid>
    <comment_count>6</comment_count>
    <who name="Steve Sakoman">steve</who>
    <bug_when>2023-11-20 23:06:34 +0000</bug_when>
    <thetext>Peter&apos;s #1 suggestion seems like the best approach.

Fixed in:
https://git.yoctoproject.org/poky/commit/?h=dunfell&amp;id=72c7bacfd367378e979d7800e655f6b445733e60</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>