Bug 963280

Summary: Kill the "use flash device for BIOS unless KVM" misfeature
Product: Red Hat Enterprise Linux 7 Reporter: Markus Armbruster <armbru>
Component: qemu-kvmAssignee: Markus Armbruster <armbru>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, armbru, flang, juzhang, mrezanin, pbonzini, qiguo, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-1.5.2-2.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 10:16:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 841379, 895959, 983997, 984008, 984010    
Attachments:
Description Flags
check with kvm under unfix build
none
check with tcg under unfix build
none
check with kvm under fix build
none
check with tcg under fix build
none
Check with kvm under unfix build, and use right script
none
Check with tcg under unfix build, and use right script
none
Check with kvm under fix build, and use right script
none
Check with tcg under fix build, and use right script none

Description Markus Armbruster 2013-05-15 14:53:45 UTC
Description of problem:

Upstream QEMU can use a flash device for the BIOS instead of a ROM,
but it doesn't actually work yet with KVM.  Flash vs. ROM is a
user-controllable option (--global pc-sysfw.rom_only=...), which
defaults to "ROM" if KVM is disabled, and for old machine types, else
to "flash".  Not a good idea, because it makes enabling/disabling KVM
guest-visible, and because it creates yet another pointless way for
users to break things.

Upstream commit 9953f88 has more details.  It was my attempt to get a
sane baseline for RHEL-7 upstream.  However, it was effectively
reverted in commit 9e1c2ec, because we expect flash with KVM to be
fixed in 1.6.

For RHEL-7, we need to

* either backport the fixes that make flash work with KVM,

* or disable flash entirely.

Regardless, we should support only either flash or ROM, not both.  I
strongly recommend to get rid of the configuration knob entirely.

How reproducible:
Always

Steps to Reproduce:
1. $ echo -e "info qtree\nq" | qemu-kvm -nodefaults -S -nographic -monitor stdio | egrep -C 1 'rom_only|pflash'
2. Add qemu-kvm option "-machine accel=kvm".
  
Actual results:
Step 1 prints:
    mmio ffffffffffffffff/0000000000000001
  dev: cfi.pflash01, id ""
    drive = pflash0
    num-blocks = 32
--
  dev: pc-sysfw, id ""
    rom_only = 0
    irq 0
Step 2 prints:
  dev: pc-sysfw, id ""
    rom_only = 1
    irq 0

Expected results:
Both steps print exactly the same.

Comment 2 Markus Armbruster 2013-07-10 10:58:13 UTC
Updated reproducer: run
    for i in kvm tcg
    do echo -e "info qtree\ninfo mtree\nq" | qemu-kvm-nodefaults -S \
    -nographic -monitor stdio -machine "accel=$i,kernel_irqchip=off"
    done
with and without the fix.

kernel_irqchip=off is just for getting some unrelated KVM vs. TCG
differences out of the way.

Compare TCG with KVM output without the fix:

* Device kvmclock exists only with KVM.  Good.

* Property pc-sysfw.rom_only is zero with TCG, one with KVM.  Harmless.

* KVM has a pc.bios memory region, while TCG has a cfi.pflash01 device
  with a system.flash memory region.  Bad.

* Memory region isa-bios is an alias for pc.bios with KVM, and a normal
  memory region with TCG (actually a copy of system.flash).  Harmless.

Compare TCG with KVM output with the fix:

* Device kvmclock exists only with KVM.  Good.

Effect of the fix out KVM output:

* Device pc-sysfw is gone.  Good.

Effect of the fix out TCG output:

* Device pc-sysfw is gone.  Good.

* Device cfi.pflash01 with system.flash memory region is gone.  Good.

* Memory region isa-bios becomes an alias for pc.bios.  Good.

Comment 3 Miroslav Rezanina 2013-07-31 12:02:56 UTC
Fix included in qemu-kvm-1.5.2-2.el7

Comment 4 Miroslav Rezanina 2013-07-31 12:08:55 UTC
Fix included in qemu-kvm-1.5.2-2.el7

Comment 6 Qian Guo 2013-12-17 10:08:09 UTC
Reproduced with qemu-kvm-1.5.1-2.el7.x86_64

Steps
1.run the script:
# echo -e "info qtree\ninfo mtree\nq" | /usr/libexec/qemu-kvm -S     -nographic -monitor stdio -machine "accel=kvm,kernel_irqchip=off" > kvm.check1

#echo -e "info qtree\ninfo mtree\nq" | /usr/libexec/qemu-kvm -S     -nographic -monitor stdio -machine "accel=tcg,kernel_irqchip=off" > tcg.check1

result:
1. Checking "kvmclock" in kvm.check1 and tcg.check1, can not find it both tcg/kvm, but find following devices in both files
  0000000000000070-0000000000000071 (prio 0, RW): rtc
  000000000000007e-000000000000007f (prio 0, RW): kvmvapic

2. Checking "Device pc-sysfw" in both files, can not find the device

3. Checking "pc.bios" and "system.flash" in both files:
From "kvm.check1"
...
pc.bios
00000000fffe0000-00000000ffffffff (prio 0, R-): pc.bios
...

and from "tcg.check1"
...
  00000000fffe0000-00000000ffffffff (prio 0, R-): system.flash
...

4. Checking isa-bios in both files:
From kvm.check1
...
  00000000000e0000-00000000000fffff (prio 1, R-): alias isa-bios @pc.bios 0000000000000000-000000000001ffff
...

from the tcg.bios
...
  00000000000e0000-00000000000fffff (prio 1, R-): isa-bios
...


So according to above, reproduced the checkpoint 3 and 4, but can not find the kvmclock device.

Try to verify this bug with qemu-kvm-1.5.3-21.el7.x86_64

Steps
1.run the script:
# echo -e "info qtree\ninfo mtree\nq" | /usr/libexec/qemu-kvm -S     -nographic -monitor stdio -machine "accel=kvm,kernel_irqchip=off" > kvm.check2

#echo -e "info qtree\ninfo mtree\nq" | /usr/libexec/qemu-kvm -S     -nographic -monitor stdio -machine "accel=tcg,kernel_irqchip=off" > tcg.check2

Result:
1. Checking "kvmclock" in kvm.check1 and tcg.check1, can not find it both tcg/kvm, but find following devices in both files
  0000000000000070-0000000000000071 (prio 0, RW): rtc
  000000000000007e-000000000000007f (prio 0, RW): kvmvapic

2.Checking "Device pc-sysfw" in both files, can not find the device

3. Checking "pc.bios" and "system.flash" in both files, get same value, and no "system.flash" anymore:
pc.bios
00000000fffe0000-00000000ffffffff (prio 0, R-): pc.bios

4. Check the "isa-bios", check in both files, get same value:
  00000000000e0000-00000000000fffff (prio 1, R-): alias isa-bios @pc.bios 0000000000000000-000000000001ffff


So according above, except the "kvmclock", all issues are fixed by qemu-kvm-1.5.3-21.el7.x86_64.

Hi, Markus

Could you help check if the result is right, I can not find devices named "kvmclock" in all files, I will attach all files in this bug

Comment 7 Qian Guo 2013-12-17 10:10:43 UTC
Created attachment 837618 [details]
check with kvm under unfix build

Comment 8 Qian Guo 2013-12-17 10:11:15 UTC
Created attachment 837619 [details]
check with tcg under unfix build

Comment 9 Qian Guo 2013-12-17 10:11:49 UTC
Created attachment 837620 [details]
check with kvm under fix build

Comment 10 Qian Guo 2013-12-17 10:12:25 UTC
Created attachment 837621 [details]
check with tcg under fix build

Comment 11 Markus Armbruster 2013-12-17 15:13:04 UTC
Your attachments all start like this:

QEMU 1.5.3 monitor - type 'help' for more information
(qemu) i[K[Dif[K[D[Difo[K[D[D[Difo [K[D[D[D[Difo q[K[D[D[D[D[Difo qt[K[D[D[D[D[D[Difo qtr[K[D[D[D[D[D[D[Difo qtre[K[D[D[D[D[D[D[D[Difo qtree[K
unknown command: 'ifo'
(qemu) i[K[Din[K[D[Dinf[K[D[D[Dinfo[K[D[D[D[Dinfo [K[D[D[D[D[Dinfo m[K[D[D[D[D[D[Dinfo mt[K[D[D[D[D[D[D[Dinfo mtr[K[D[D[D[D[D[D[D[Dinfo mtre[K[D[D[D[D[D[D[D[D[Dinfo mtree[K
memory

Looks like you mistyped "info qtree".  Please try again :)

Comment 12 Qian Guo 2013-12-20 03:39:29 UTC
(In reply to Markus Armbruster from comment #11)
> Your attachments all start like this:
> 
> QEMU 1.5.3 monitor - type 'help' for more information
> (qemu) i[K[Dif[K[D[Difo[K[D[D[Difo [K[D[D[D[Difo
> q[K[D[D[D[D[Difo qt[K[D[D[D[D[D[Difo
> qtr[K[D[D[D[D[D[D[Difo qtre[K[D[D[D[D[D[D[D[Difo qtree[K
> unknown command: 'ifo'
> (qemu) i[K[Din[K[D[Dinf[K[D[D[Dinfo[K[D[D[D[Dinfo
> [K[D[D[D[D[Dinfo m[K[D[D[D[D[D[Dinfo
> mt[K[D[D[D[D[D[D[Dinfo mtr[K[D[D[D[D[D[D[D[Dinfo
> mtre[K[D[D[D[D[D[D[D[D[Dinfo mtree[K
> memory
> 
> Looks like you mistyped "info qtree".  Please try again :)
Got it, thanks. the script is wrong, retest in this comment:
Reproduced with qemu-kvm-1.5.1-2.el7.x86_64

Steps
1.run the script:
# echo -e "\n\info qtree\ninfo mtree\nq" | /usr/libexec/qemu-kvm -S     -nographic -monitor stdio -machine "accel=kvm,kernel_irqchip=off" > kvm.check1_v2

# echo -e "\n\info qtree\ninfo mtree\nq" | /usr/libexec/qemu-kvm -S     -nographic -monitor stdio -machine "accel=tcg,kernel_irqchip=off" > tcg.check1_v2

result:
1. Checking "kvmclock" in kvm.check1_v2 and tcg.check1_v2,find it only with kvm.
# cat kvm.check1_v2 |grep kvmclock
  dev: kvmclock, id ""
# cat tcg.check1_v2 |grep kvmclock
# 


2. Checking "Device pc-sysfw" in both files, "rom_only=1" when test with kvm, and "rom_only=0" when with tcg
# cat kvm.check1_v2 
...
    dev: pc-sysfw, id ""
    rom_only = 1
    irq 0
...
# cat tcg.check1_v2 
...
  dev: pc-sysfw, id ""
    rom_only = 0
    irq 0


3. Checking "pc.bios" and "system.flash" in both files, find that only tcg has cfi.pflash device and has system.flash mem region and kvm has pc.bios

# cat tcg.check1_v2
...
  dev: cfi.pflash01, id ""
    drive = pflash0
    num-blocks = 32
    sector-length = 4096
    width = 1
    big-endian = 0
    id0 = 0
    id1 = 0
    id2 = 0
    id3 = 0
    name = "system.flash"
    irq 0
    mmio 00000000fffe0000/0000000000020000
...

# cat kvm.check1_v2 |grep cfi
#

# cat tcg.check1_v2 |grep pc.bios
# cat kvm.check1_v2 |grep pc.bios
  00000000000e0000-00000000000fffff (prio 1, R-): alias isa-bios @pc.bios 0000000000000000-000000000001ffff
  00000000fffe0000-00000000ffffffff (prio 0, R-): pc.bios
pc.bios
00000000fffe0000-00000000ffffffff (prio 0, R-): pc.bios


# cat kvm.check1_v2 |grep system.flash
# cat tcg.check1_v2 |grep system.flash
    name = "system.flash"
  00000000fffe0000-00000000ffffffff (prio 0, R-): system.flash


4. Checking isa-bios in both files, memory region isa-bios is an alias for pc.bios with KVM, and a normal
  memory region with TCG
# cat tcg.check1_v2 |grep isa-bios
  00000000000e0000-00000000000fffff (prio 1, R-): isa-bios
# cat kvm.check1_v2 |grep isa-bios
  00000000000e0000-00000000000fffff (prio 1, R-): alias isa-bios @pc.bios 0000000000000000-000000000001ffff

So according to above, this bug is reproduced.

Try to verify this bug with qemu-kvm-1.5.3-21.el7.x86_64

Steps
1.run the script:
# echo -e "\n\info qtree\ninfo mtree\nq" | /usr/libexec/qemu-kvm -S     -nographic -monitor stdio -machine "accel=kvm,kernel_irqchip=off" > kvm.check2_v2
# echo -e "\n\info qtree\ninfo mtree\nq" | /usr/libexec/qemu-kvm -S     -nographic -monitor stdio -machine "accel=tcg,kernel_irqchip=off" > tcg.check2_v2


Result:
1. Checking "kvmclock" in both files, only kvm has kvmclock:
# cat kvm.check2_v2 |grep kvmclock
  dev: kvmclock, id ""
# cat tcg.check2_v2 |grep kvmclock

2.Checking "Device pc-sysfw" in both files, can not find the device
# cat tcg.check2_v2 |grep pc-sysfw
# cat kvm.check2_v2 |grep pc-sysfw

3.Checking "pc.bios" and "system.flash" in both files, find that no files have cfi.pflash device or has system.flash mem region; And in both files, memory region isa-bios is an alias for pc.bios with KVM 
# cat kvm.check2_v2 |grep cfi
# cat tcg.check2_v2 |grep cfi
# cat tcg.check2_v2 |grep system.flash
# cat kvm.check2_v2 |grep system.flash

# cat kvm.check2_v2 |grep pc.bios
  00000000000e0000-00000000000fffff (prio 1, R-): alias isa-bios @pc.bios 0000000000000000-000000000001ffff
  00000000fffe0000-00000000ffffffff (prio 0, R-): pc.bios
pc.bios
00000000fffe0000-00000000ffffffff (prio 0, R-): pc.bios

# cat tcg.check2_v2 |grep pc.bios
  00000000000e0000-00000000000fffff (prio 1, R-): alias isa-bios @pc.bios 0000000000000000-000000000001ffff
  00000000fffe0000-00000000ffffffff (prio 0, R-): pc.bios
pc.bios
00000000fffe0000-00000000ffffffff (prio 0, R-): pc.bios


So according above, all issues are fixed by qemu-kvm-1.5.3-21.el7.x86_64.

Comment 13 Qian Guo 2013-12-20 03:42:41 UTC
Created attachment 839328 [details]
Check with kvm under unfix build, and use right script

Comment 14 Qian Guo 2013-12-20 03:43:11 UTC
Created attachment 839330 [details]
Check with tcg under unfix build, and use right script

Comment 15 Qian Guo 2013-12-20 03:43:43 UTC
Created attachment 839337 [details]
Check with kvm under fix build, and use right script

Comment 16 Qian Guo 2013-12-20 03:44:17 UTC
Created attachment 839345 [details]
Check with tcg under fix build, and use right script

Comment 18 Ludek Smid 2014-06-13 10:16:46 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.