Skip to contentSkip to conversation

Funny -m arguments can crash

Qemu-devel Markus Armbruster 8 participants 29 messages Jul 25, 2012 – Aug 19, 2012

lore
Share & tools
lore
#0 lore raw

Asking for "funny" memory sizes sometimes crashes for me. For instance -m 0.8 or the equivalent -m 838860b. -m 0.7 appears to work.

Should we round memory sizes? How? Where?

$ gdb --args qemu-system-x86_64 -nodefaults --enable-kvm -S -vnc :0 -monitor stdio -m 0.8
[...]
(gdb) r
Starting program: /home/armbru/bin/upstream-qemu -nodefaults --enable-kvm -S -vnc :0 -monitor stdio -m 0.8
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff6efe700 (LWP 29525)]
upstream-qemu: /work/armbru/qemu/exec.c:2263: register_subpage: Assertion `existing->mr->subpage || existing->mr == &io_mem_unassigned' failed.

Program received signal SIGABRT, Aborted. 0x00000033e0835965 in raise () from /lib64/libc.so.6 [...]
(gdb) bt

#0  0x00000033e0835965 in raise () from /lib64/libc.so.6
#1  0x00000033e0837118 in abort () from /lib64/libc.so.6
#2  0x00000033e082e6e2 in __assert_fail_base () from /lib64/libc.so.6
#3  0x00000033e082e792 in __assert_fail () from /lib64/libc.so.6
#4  0x00000000006078fa in register_subpage (section=0x7fffffffd4e0)
    at /work/armbru/qemu/exec.c:2263
#5  0x0000000000607b55 in cpu_register_physical_memory_log (section=
    0x7fffffffd6a0, readonly=false) at /work/armbru/qemu/exec.c:2303
#6  0x0000000000609d1c in core_region_nop (listener=0xac5e60, section=
    0x7fffffffd6a0) at /work/armbru/qemu/exec.c:3183
#7  0x0000000000667a58 in address_space_update_topology_pass (as=0x12fdca0, 
    old_view=..., new_view=..., adding=true) at /work/armbru/qemu/memory.c:693
#8  0x0000000000668045 in address_space_update_topology (as=0x12fdca0)
    at /work/armbru/qemu/memory.c:722
#9  0x0000000000668147 in memory_region_update_topology (mr=0x0)
    at /work/armbru/qemu/memory.c:743
#10 0x0000000000668252 in memory_region_transaction_commit ()
    at /work/armbru/qemu/memory.c:764
#11 0x0000000000636612 in i440fx_update_memory_mappings (d=0x13a9310)
    at /work/armbru/qemu/hw/i386/../piix_pci.c:155
#12 0x0000000000636db6 in i440fx_common_init (device_name=0x7ea470 "i440FX", 
    pi440fx_state=0x7fffffffdb98, piix3_devfn=0x7fffffffdb88, isa_bus=
    0x7fffffffdb90, pic=0x13a49c0, address_space_mem=0x1381150, 
    address_space_io=0x1381220, ram_size=0, pci_hole_start=838860, 
    pci_hole_size=4294128436, pci_hole64_start=4294967296, pci_hole64_size=
    4611686018427387904, pci_address_space=0x13a4200, ram_memory=0x13a42b0)
    at /work/armbru/qemu/hw/i386/../piix_pci.c:330
#13 0x0000000000636ea8 in i440fx_init (pi440fx_state=0x7fffffffdb98, 
    piix3_devfn=0x7fffffffdb88, isa_bus=0x7fffffffdb90, pic=0x13a49c0, 
    address_space_mem=0x1381150, address_space_io=0x1381220, ram_size=838860, 
    pci_hole_start=838860, pci_hole_size=4294128436, pci_hole64_start=
    4294967296, pci_hole64_size=4611686018427387904, pci_memory=0x13a4200, 
    ram_memory=0x13a42b0) at /work/armbru/qemu/hw/i386/../piix_pci.c:349
#14 0x000000000063469b in pc_init1 (system_memory=0x1381150, system_io=
    0x1381220, ram_size=838860, boot_device=0x7fffffffdee0 "cad", 
    kernel_filename=0x0, kernel_cmdline=0x7cad82 "", initrd_filename=0x0, 
    cpu_model=0x0, pci_enabled=1, kvmclock_enabled=1)
    at /work/armbru/qemu/hw/i386/../pc_piix.c:193
#15 0x0000000000634c0e in pc_init_pci (ram_size=838860, boot_device=
    0x7fffffffdee0 "cad", kernel_filename=0x0, kernel_cmdline=0x7cad82 "", 
    initrd_filename=0x0, cpu_model=0x0)
    at /work/armbru/qemu/hw/i386/../pc_piix.c:297
#16 0x000000000057a89e in main (argc=10, argv=0x7fffffffe118, envp=
    0x7fffffffe170) at /work/armbru/qemu/vl.c:3520
(gdb) up 4
#4  0x00000000006078fa in register_subpage (section=0x7fffffffd4e0)
    at /work/armbru/qemu/exec.c:2263
2263	    assert(existing->mr->subpage || existing->mr == &io_mem_unassigned);
(gdb) p/x *section
$1 = {mr = 0x1399860, address_space = 0x1381150, offset_within_region = 
    0xcccc, size = 0x334, offset_within_address_space = 0xccccc, readonly = 
    0x0}
#1 lore raw
Quoted 4 lines · Markus Armbruster

Asking for "funny" memory sizes sometimes crashes for me. For instance -m 0.8 or the equivalent -m 838860b. -m 0.7 appears to work.

Should we round memory sizes? How? Where?

We had a discussion about this recently:
http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg02800.html

Quoted 69 lines


$ gdb --args qemu-system-x86_64 -nodefaults --enable-kvm -S -vnc :0 -monitor stdio -m 0.8
[...]
(gdb) r
Starting program: /home/armbru/bin/upstream-qemu -nodefaults --enable-kvm -S -vnc :0 -monitor stdio -m 0.8
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff6efe700 (LWP 29525)]
upstream-qemu: /work/armbru/qemu/exec.c:2263: register_subpage: Assertion `existing->mr->subpage || existing->mr == &io_mem_unassigned' failed.

Program received signal SIGABRT, Aborted. 0x00000033e0835965 in raise () from /lib64/libc.so.6 [...]
(gdb) bt

#0  0x00000033e0835965 in raise () from /lib64/libc.so.6
#1  0x00000033e0837118 in abort () from /lib64/libc.so.6
#2  0x00000033e082e6e2 in __assert_fail_base () from /lib64/libc.so.6
#3  0x00000033e082e792 in __assert_fail () from /lib64/libc.so.6
#4  0x00000000006078fa in register_subpage (section=0x7fffffffd4e0)
    at /work/armbru/qemu/exec.c:2263
#5  0x0000000000607b55 in cpu_register_physical_memory_log (section=
    0x7fffffffd6a0, readonly=false) at /work/armbru/qemu/exec.c:2303
#6  0x0000000000609d1c in core_region_nop (listener=0xac5e60, section=
    0x7fffffffd6a0) at /work/armbru/qemu/exec.c:3183
#7  0x0000000000667a58 in address_space_update_topology_pass (as=0x12fdca0,
    old_view=..., new_view=..., adding=true) at /work/armbru/qemu/memory.c:693
#8  0x0000000000668045 in address_space_update_topology (as=0x12fdca0)
    at /work/armbru/qemu/memory.c:722
#9  0x0000000000668147 in memory_region_update_topology (mr=0x0)
    at /work/armbru/qemu/memory.c:743
#10 0x0000000000668252 in memory_region_transaction_commit ()
    at /work/armbru/qemu/memory.c:764
#11 0x0000000000636612 in i440fx_update_memory_mappings (d=0x13a9310)
    at /work/armbru/qemu/hw/i386/../piix_pci.c:155
#12 0x0000000000636db6 in i440fx_common_init (device_name=0x7ea470 "i440FX",
    pi440fx_state=0x7fffffffdb98, piix3_devfn=0x7fffffffdb88, isa_bus=
    0x7fffffffdb90, pic=0x13a49c0, address_space_mem=0x1381150,
    address_space_io=0x1381220, ram_size=0, pci_hole_start=838860,
    pci_hole_size=4294128436, pci_hole64_start=4294967296, pci_hole64_size=
    4611686018427387904, pci_address_space=0x13a4200, ram_memory=0x13a42b0)
    at /work/armbru/qemu/hw/i386/../piix_pci.c:330
#13 0x0000000000636ea8 in i440fx_init (pi440fx_state=0x7fffffffdb98,
    piix3_devfn=0x7fffffffdb88, isa_bus=0x7fffffffdb90, pic=0x13a49c0,
    address_space_mem=0x1381150, address_space_io=0x1381220, ram_size=838860,
    pci_hole_start=838860, pci_hole_size=4294128436, pci_hole64_start=
    4294967296, pci_hole64_size=4611686018427387904, pci_memory=0x13a4200,
    ram_memory=0x13a42b0) at /work/armbru/qemu/hw/i386/../piix_pci.c:349
#14 0x000000000063469b in pc_init1 (system_memory=0x1381150, system_io=
    0x1381220, ram_size=838860, boot_device=0x7fffffffdee0 "cad",
    kernel_filename=0x0, kernel_cmdline=0x7cad82 "", initrd_filename=0x0,
    cpu_model=0x0, pci_enabled=1, kvmclock_enabled=1)
    at /work/armbru/qemu/hw/i386/../pc_piix.c:193
#15 0x0000000000634c0e in pc_init_pci (ram_size=838860, boot_device=
    0x7fffffffdee0 "cad", kernel_filename=0x0, kernel_cmdline=0x7cad82 "",
    initrd_filename=0x0, cpu_model=0x0)
    at /work/armbru/qemu/hw/i386/../pc_piix.c:297
#16 0x000000000057a89e in main (argc=10, argv=0x7fffffffe118, envp=
    0x7fffffffe170) at /work/armbru/qemu/vl.c:3520
(gdb) up 4
#4  0x00000000006078fa in register_subpage (section=0x7fffffffd4e0)
    at /work/armbru/qemu/exec.c:2263
2263        assert(existing->mr->subpage || existing->mr == &io_mem_unassigned);
(gdb) p/x *section
$1 = {mr = 0x1399860, address_space = 0x1381150, offset_within_region =
    0xcccc, size = 0x334, offset_within_address_space = 0xccccc, readonly =
    0x0}
#2 lore raw
Quoted 8 lines · Blue Swirl
Quoted 4 lines · Markus Armbruster

Asking for "funny" memory sizes sometimes crashes for me. For instance -m 0.8 or the equivalent -m 838860b. -m 0.7 appears to work.

Should we round memory sizes? How? Where?

We had a discussion about this recently:
http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg02800.html

I missed that, thanks!

Unfortunately, the thread petered out without a conclusion. What now?

#3 lore raw
Quoted 6 lines · Markus Armbruster
Quoted 4 lines · Blue Swirl
Quoted 3 lines · Markus Armbruster

Asking for "funny" memory sizes sometimes crashes for me. For instance -m 0.8 or the equivalent -m 838860b. -m 0.7 appears to work.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Should we round memory sizes? How? Where?

We had a discussion about this recently:
http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg02800.html

I missed that, thanks!

Unfortunately, the thread petered out without a conclusion. What now?

There's no patch to do the check in vl.c for 8k. Lacking the patch, we don't know exactly what is the charge level of megaphone batteries:
like Schrödinger's cat, they may be dead or fully charged.

#4 lore raw
Quoted 13 lines · Blue Swirl
Quoted 12 lines · Markus Armbruster
Quoted 9 lines · Blue Swirl
Quoted 4 lines · Markus Armbruster

Asking for "funny" memory sizes sometimes crashes for me. For instance -m 0.8 or the equivalent -m 838860b. -m 0.7 appears to work.

Should we round memory sizes? How? Where?

We had a discussion about this recently:
http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg02800.html

Quoted 7 lines
Quoted 3 lines

I missed that, thanks!

Unfortunately, the thread petered out without a conclusion. What now?

There's no patch to do the check in vl.c for 8k. Lacking the patch, we don't know exactly what is the charge level of megaphone batteries:
like Schrödinger's cat, they may be dead or fully charged.

What would you like me to do? Round argument of -m up to next multiple of 8KiB?

#5 lore raw
Quoted 17 lines · Markus Armbruster
Quoted 15 lines · Blue Swirl
Quoted 14 lines · Markus Armbruster
Quoted 9 lines · Blue Swirl
Quoted 4 lines · Markus Armbruster

Asking for "funny" memory sizes sometimes crashes for me. For instance -m 0.8 or the equivalent -m 838860b. -m 0.7 appears to work.

Should we round memory sizes? How? Where?

We had a discussion about this recently:
http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg02800.html

I missed that, thanks!

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Unfortunately, the thread petered out without a conclusion. What now?

There's no patch to do the check in vl.c for 8k. Lacking the patch, we don't know exactly what is the charge level of megaphone batteries:
like Schrödinger's cat, they may be dead or fully charged.

What would you like me to do? Round argument of -m up to next multiple of 8KiB?

Yes please, maybe with a notice to the user.

#6 lore raw
Quoted 20 lines · Blue Swirl
Quoted 19 lines · Markus Armbruster
Quoted 17 lines · Blue Swirl
Quoted 15 lines · Markus Armbruster
Quoted 9 lines · Blue Swirl
Quoted 4 lines · Markus Armbruster

Asking for "funny" memory sizes sometimes crashes for me. For instance -m 0.8 or the equivalent -m 838860b. -m 0.7 appears to work.

Should we round memory sizes? How? Where?

We had a discussion about this recently:
http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg02800.html

I missed that, thanks!

Unfortunately, the thread petered out without a conclusion. What now?

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

There's no patch to do the check in vl.c for 8k. Lacking the patch, we don't know exactly what is the charge level of megaphone batteries:
like Schrödinger's cat, they may be dead or fully charged.

What would you like me to do? Round argument of -m up to next multiple of 8KiB?

Yes please, maybe with a notice to the user.

Next problem: minimum RAM size.

For instance, -M pc -m X, where X < 32KiB dies "qemu: fatal: Trying to execute code outside RAM or ROM at [...] Aborted (core dumped)" with TCG, and "KVM internal error. Suberror: 1" with KVM.

Should a minimum RAM size be enforced? Board-specific?

I'm inclined to declare this one a feature...

#7 lore raw
Quoted 7 lines · Markus Armbruster

Next problem: minimum RAM size.

For instance, -M pc -m X, where X < 32KiB dies "qemu: fatal: Trying to execute code outside RAM or ROM at [...] Aborted (core dumped)" with TCG, and "KVM internal error. Suberror: 1" with KVM.

Should a minimum RAM size be enforced? Board-specific?

Good luck. Last time I tried to add RAM size checks it got shot down in review...
(http://lists.gnu.org/archive/html/qemu-devel/2011-03/msg02907.html)

-- PMM

#8 lore raw
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Markus Armbruster

Next problem: minimum RAM size.

For instance, -M pc -m X, where X < 32KiB dies "qemu: fatal: Trying to execute code outside RAM or ROM at [...] Aborted (core dumped)" with TCG, and "KVM internal error. Suberror: 1" with KVM.

Quoted 5 lines
Quoted 1 line

Should a minimum RAM size be enforced? Board-specific?

Good luck. Last time I tried to add RAM size checks it got shot down in review...
(http://lists.gnu.org/archive/html/qemu-devel/2011-03/msg02907.html)

I think I want to stay out of that swamp; thanks for the warning.

#9 lore raw
In reply to Markus Armbruster
Quoted 11 lines · Markus Armbruster
Quoted 2 lines

Yes please, maybe with a notice to the user.

Next problem: minimum RAM size.

For instance, -M pc -m X, where X < 32KiB dies "qemu: fatal: Trying to execute code outside RAM or ROM at [...] Aborted (core dumped)" with TCG, and "KVM internal error. Suberror: 1" with KVM.

Should a minimum RAM size be enforced? Board-specific?

It's really a BIOS bug causing a limitation of both kvm and tcg to be hit. The BIOS should recognize it doesn't have sufficient memory and hang gracefully (if you can picture that). It just assumes some low memory is available and tries to execute it with the results you got.

Signature · 1 line
error compiling committee.c: too many arguments to function
#10 lore raw
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Markus Armbruster
Quoted 2 lines

Yes please, maybe with a notice to the user.

Next problem: minimum RAM size.

For instance, -M pc -m X, where X < 32KiB dies "qemu: fatal: Trying to execute code outside RAM or ROM at [...] Aborted (core dumped)" with TCG, and "KVM internal error. Suberror: 1" with KVM.

Quoted 7 lines
Quoted 2 lines

Should a minimum RAM size be enforced? Board-specific?

It's really a BIOS bug causing a limitation of both kvm and tcg to be hit. The BIOS should recognize it doesn't have sufficient memory and hang gracefully (if you can picture that). It just assumes some low memory is available and tries to execute it with the results you got.

SeaBIOS indeed assumes it got at least 1MiB of RAM. It doesn't bother to check CMOS for a smaller RAM size. However, that bug / feature is currently masked by a QEMU bug: we screw up CMOS contents when there's less than 1 MiB of RAM. pc_cmos_init():

    int val, nb, i;
[...]
    /* memory size */
    val = 640; /* base memory in K */
    rtc_set_memory(s, 0x15, val);
    rtc_set_memory(s, 0x16, val >> 8);

    val = (ram_size / 1024) - 1024;
    if (val > 65535)
        val = 65535;
    rtc_set_memory(s, 0x17, val);
    rtc_set_memory(s, 0x18, val >> 8);

If ram_size < 1MiB, val goes negative. Oops.

For instance, with -m 500k, we happily promise 640KiB base memory (CMOS addr 0x15..16), almost 64MiB extended memory (0x17..18 and 0x30..31), yet no memory above 16MiB (0x34..35).

An easy way to fix this is to require 1MiB of RAM :)

But if you like, I'll put sane values in CMOS instead. That'll expose the SeaBIOS bug.

Anthony, you're the PC maintainer, got a preference?

SeaBIOS thread:
http://comments.gmane.org/gmane.comp.bios.coreboot.seabios/4341

#11 lore raw
Quoted 40 lines · Markus Armbruster
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Markus Armbruster
Quoted 2 lines

Yes please, maybe with a notice to the user.

Next problem: minimum RAM size.

For instance, -M pc -m X, where X < 32KiB dies "qemu: fatal: Trying to execute code outside RAM or ROM at [...] Aborted (core dumped)" with TCG, and "KVM internal error. Suberror: 1" with KVM.

Quoted 7 lines
Quoted 2 lines

Should a minimum RAM size be enforced? Board-specific?

It's really a BIOS bug causing a limitation of both kvm and tcg to be hit. The BIOS should recognize it doesn't have sufficient memory and hang gracefully (if you can picture that). It just assumes some low memory is available and tries to execute it with the results you got.

SeaBIOS indeed assumes it got at least 1MiB of RAM. It doesn't bother to check CMOS for a smaller RAM size. However, that bug / feature is currently masked by a QEMU bug: we screw up CMOS contents when there's less than 1 MiB of RAM. pc_cmos_init():

    int val, nb, i;
[...]
    /* memory size */
    val = 640; /* base memory in K */
    rtc_set_memory(s, 0x15, val);
    rtc_set_memory(s, 0x16, val >> 8);

    val = (ram_size / 1024) - 1024;
    if (val > 65535)
        val = 65535;
    rtc_set_memory(s, 0x17, val);
    rtc_set_memory(s, 0x18, val >> 8);

If ram_size < 1MiB, val goes negative. Oops.

Quoted 8 lines

For instance, with -m 500k, we happily promise 640KiB base memory (CMOS addr 0x15..16), almost 64MiB extended memory (0x17..18 and 0x30..31), yet no memory above 16MiB (0x34..35).

An easy way to fix this is to require 1MiB of RAM :)

But if you like, I'll put sane values in CMOS instead. That'll expose the SeaBIOS bug.

IMO we need to fix CMOS reporting.

(technically we shouldn't touch CMOS NVRAM at all; seabios should discover memory size via fwcfg and program it itself. But it's pointless to change it now)

Signature · 1 line
error compiling committee.c: too many arguments to function
#12 lore raw
Quoted 47 lines · Avi Kivity
Quoted 46 lines · Markus Armbruster
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Markus Armbruster
Quoted 2 lines

Yes please, maybe with a notice to the user.

Next problem: minimum RAM size.

For instance, -M pc -m X, where X < 32KiB dies "qemu: fatal: Trying to execute code outside RAM or ROM at [...] Aborted (core dumped)" with TCG, and "KVM internal error. Suberror: 1" with KVM.

Quoted 7 lines
Quoted 2 lines

Should a minimum RAM size be enforced? Board-specific?

It's really a BIOS bug causing a limitation of both kvm and tcg to be hit. The BIOS should recognize it doesn't have sufficient memory and hang gracefully (if you can picture that). It just assumes some low memory is available and tries to execute it with the results you got.

SeaBIOS indeed assumes it got at least 1MiB of RAM. It doesn't bother to check CMOS for a smaller RAM size. However, that bug / feature is currently masked by a QEMU bug: we screw up CMOS contents when there's less than 1 MiB of RAM. pc_cmos_init():

    int val, nb, i;
[...]
    /* memory size */
    val = 640; /* base memory in K */
    rtc_set_memory(s, 0x15, val);
    rtc_set_memory(s, 0x16, val >> 8);

    val = (ram_size / 1024) - 1024;
    if (val > 65535)
        val = 65535;
    rtc_set_memory(s, 0x17, val);
    rtc_set_memory(s, 0x18, val >> 8);

If ram_size < 1MiB, val goes negative. Oops.

For instance, with -m 500k, we happily promise 640KiB base memory (CMOS addr 0x15..16), almost 64MiB extended memory (0x17..18 and 0x30..31), yet no memory above 16MiB (0x34..35).

An easy way to fix this is to require 1MiB of RAM :)

Quoted 9 lines
Quoted 2 lines

But if you like, I'll put sane values in CMOS instead. That'll expose the SeaBIOS bug.

IMO we need to fix CMOS reporting.

(technically we shouldn't touch CMOS NVRAM at all; seabios should discover memory size via fwcfg and program it itself. But it's pointless to change it now)

Chipset we emulate does not support all those crazy memory values you can give to -m.

--
Gleb.

#13 lore raw
Quoted 8 lines · Gleb Natapov
Quoted 6 lines

IMO we need to fix CMOS reporting.

(technically we shouldn't touch CMOS NVRAM at all; seabios should discover memory size via fwcfg and program it itself. But it's pointless to change it now)

Chipset we emulate does not support all those crazy memory values you can give to -m.

Our chipset is a 440fx enhanced with fwcfg and other goodies, not a plain 440fx.

But it's true it probably doesn't support 82.66642kB RAM.

Signature · 1 line
error compiling committee.c: too many arguments to function
#14 lore raw
Quoted 8 lines · Avi Kivity
Quoted 6 lines · Gleb Natapov
Quoted 6 lines

IMO we need to fix CMOS reporting.

(technically we shouldn't touch CMOS NVRAM at all; seabios should discover memory size via fwcfg and program it itself. But it's pointless to change it now)

Quoted 6 lines
Quoted 2 lines

Chipset we emulate does not support all those crazy memory values you can give to -m.

Our chipset is a 440fx enhanced with fwcfg and other goodies, not a plain 440fx.

It has registers to program DIMM slots configs. fwcfg does not enhanced it in any way. And you cannot program more than 4G memory there may be even less. So what do you mean by "program it itself"? Program CMOS itself? (What for? QEMU does not care). Or program 440fx DIMM config?

Quoted 1 line

But it's true it probably doesn't support 82.66642kB RAM.

It does not support much less exotic 4G.

--
Gleb.

#15 lore raw
Quoted 12 lines · Gleb Natapov
Quoted 11 lines · Avi Kivity
Quoted 8 lines · Gleb Natapov
Quoted 6 lines

IMO we need to fix CMOS reporting.

(technically we shouldn't touch CMOS NVRAM at all; seabios should discover memory size via fwcfg and program it itself. But it's pointless to change it now)

Chipset we emulate does not support all those crazy memory values you can give to -m.

Quoted 7 lines
Quoted 3 lines

Our chipset is a 440fx enhanced with fwcfg and other goodies, not a plain 440fx.

It has registers to program DIMM slots configs. fwcfg does not enhanced it in any way. And you cannot program more than 4G memory there may be even less. So what do you mean by "program it itself"? Program CMOS itself? (What for? QEMU does not care). Or program 440fx DIMM config?

An idealistic emulator would not have an fw_cfg but it would let BIOS discover everything, exactly like a real BIOS would do. It would also support using BIOS ROM images from real 440fx machine. This approach, taken to its extreme, would eventually lead to an cycle accurate emulator, it would emulate various chip erratas and probably become a very slow monster.

However, the approach which we have taken in QEMU is that performance is more important than uselessly exact emulation and the OSes don't care what is the exact interface between BIOS and HW. Thus we can take a few PV shortcuts.

Modeling the RAM as linear area with any integer amount of MB has taken us pretty far, but modeling the DIMM slots can still be interesting because it gives better emulation without performance loss. Modeling what happens if CAS latency programming is off limits would not be interesting for QEMU.

Quoted 7 lines
Quoted 2 lines

But it's true it probably doesn't support 82.66642kB RAM.

It does not support much less exotic 4G.

--
Gleb.

#16 lore raw
In reply to Avi Kivity
Quoted 5 lines · Avi Kivity

IMO we need to fix CMOS reporting.

(technically we shouldn't touch CMOS NVRAM at all; seabios should discover memory size via fwcfg and program it itself. But it's pointless to change it now)

It would be nice to pass all values via fw_cfg instead of cmos. Using the cmos to pass valus is cumbersome.

If there is some desire to specify memory to a finer granularity than 1MiB (and frankly I'm struggling to understand the desire for that), then lets pass it via fw_cfg instead of cmos.

-Kevin

#17 lore raw
In reply to Markus Armbruster
Quoted 46 lines · Markus Armbruster
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Markus Armbruster
Quoted 2 lines

Yes please, maybe with a notice to the user.

Next problem: minimum RAM size.

For instance, -M pc -m X, where X < 32KiB dies "qemu: fatal: Trying to execute code outside RAM or ROM at [...] Aborted (core dumped)" with TCG, and "KVM internal error. Suberror: 1" with KVM.

Quoted 7 lines
Quoted 2 lines

Should a minimum RAM size be enforced? Board-specific?

It's really a BIOS bug causing a limitation of both kvm and tcg to be hit. The BIOS should recognize it doesn't have sufficient memory and hang gracefully (if you can picture that). It just assumes some low memory is available and tries to execute it with the results you got.

SeaBIOS indeed assumes it got at least 1MiB of RAM. It doesn't bother to check CMOS for a smaller RAM size. However, that bug / feature is currently masked by a QEMU bug: we screw up CMOS contents when there's less than 1 MiB of RAM. pc_cmos_init():

    int val, nb, i;
[...]
    /* memory size */
    val = 640; /* base memory in K */
    rtc_set_memory(s, 0x15, val);
    rtc_set_memory(s, 0x16, val >> 8);

    val = (ram_size / 1024) - 1024;
    if (val > 65535)
        val = 65535;
    rtc_set_memory(s, 0x17, val);
    rtc_set_memory(s, 0x18, val >> 8);

If ram_size < 1MiB, val goes negative. Oops.

For instance, with -m 500k, we happily promise 640KiB base memory (CMOS addr 0x15..16), almost 64MiB extended memory (0x17..18 and 0x30..31), yet no memory above 16MiB (0x34..35).

An easy way to fix this is to require 1MiB of RAM :)

Quoted 7 lines

But if you like, I'll put sane values in CMOS instead. That'll expose the SeaBIOS bug.

Anthony, you're the PC maintainer, got a preference?

SeaBIOS thread:
http://comments.gmane.org/gmane.comp.bios.coreboot.seabios/4341

I'd prefer fixing the CMOS values over limiting to 1MB of RAM.

Having a 1MB limit is purely theoritical--not practical. There's no good reason for anyone to ask for < 1MB unless they know what they're doing. If it's truly a mistake, then asking for 2MB is just as much of a mistake because no real guest will run with 2MB of memory anyway (you can't even load a kernel).

So if we're just going for theoritical correctness, we ought to do it the Right Way which is fixing the CMOS values and putting the check in SeaBIOS.

Regards,

Anthony Liguori

#18 lore raw
Quoted 64 lines · Anthony Liguori
Quoted 46 lines · Markus Armbruster
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Markus Armbruster
Quoted 2 lines

Yes please, maybe with a notice to the user.

Next problem: minimum RAM size.

For instance, -M pc -m X, where X < 32KiB dies "qemu: fatal: Trying to execute code outside RAM or ROM at [...] Aborted (core dumped)" with TCG, and "KVM internal error. Suberror: 1" with KVM.

Quoted 7 lines
Quoted 2 lines

Should a minimum RAM size be enforced? Board-specific?

It's really a BIOS bug causing a limitation of both kvm and tcg to be hit. The BIOS should recognize it doesn't have sufficient memory and hang gracefully (if you can picture that). It just assumes some low memory is available and tries to execute it with the results you got.

SeaBIOS indeed assumes it got at least 1MiB of RAM. It doesn't bother to check CMOS for a smaller RAM size. However, that bug / feature is currently masked by a QEMU bug: we screw up CMOS contents when there's less than 1 MiB of RAM. pc_cmos_init():

    int val, nb, i;
[...]
    /* memory size */
    val = 640; /* base memory in K */
    rtc_set_memory(s, 0x15, val);
    rtc_set_memory(s, 0x16, val >> 8);

    val = (ram_size / 1024) - 1024;
    if (val > 65535)
        val = 65535;
    rtc_set_memory(s, 0x17, val);
    rtc_set_memory(s, 0x18, val >> 8);

If ram_size < 1MiB, val goes negative. Oops.

For instance, with -m 500k, we happily promise 640KiB base memory (CMOS addr 0x15..16), almost 64MiB extended memory (0x17..18 and 0x30..31), yet no memory above 16MiB (0x34..35).

An easy way to fix this is to require 1MiB of RAM :)

Quoted 7 lines

But if you like, I'll put sane values in CMOS instead. That'll expose the SeaBIOS bug.

Anthony, you're the PC maintainer, got a preference?

SeaBIOS thread:
http://comments.gmane.org/gmane.comp.bios.coreboot.seabios/4341

I'd prefer fixing the CMOS values over limiting to 1MB of RAM.

Having a 1MB limit is purely theoritical--not practical. There's no good reason for anyone to ask for < 1MB unless they know what they're doing. If it's truly a mistake, then asking for 2MB is just as much of a mistake because no real guest will run with 2MB of memory anyway (you can't even load a kernel).

Quoted 3 lines

So if we're just going for theoritical correctness, we ought to do it the Right Way which is fixing the CMOS values and putting the check in SeaBIOS.

Okay, I'll cook up a patch fixing pc_cmos_init().

#19 lore raw
In reply to Anthony Liguori
Quoted 64 lines · Anthony Liguori
Quoted 46 lines · Markus Armbruster
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Markus Armbruster
Quoted 2 lines

Yes please, maybe with a notice to the user.

Next problem: minimum RAM size.

For instance, -M pc -m X, where X < 32KiB dies "qemu: fatal: Trying to execute code outside RAM or ROM at [...] Aborted (core dumped)" with TCG, and "KVM internal error. Suberror: 1" with KVM.

Quoted 7 lines
Quoted 2 lines

Should a minimum RAM size be enforced? Board-specific?

It's really a BIOS bug causing a limitation of both kvm and tcg to be hit. The BIOS should recognize it doesn't have sufficient memory and hang gracefully (if you can picture that). It just assumes some low memory is available and tries to execute it with the results you got.

SeaBIOS indeed assumes it got at least 1MiB of RAM. It doesn't bother to check CMOS for a smaller RAM size. However, that bug / feature is currently masked by a QEMU bug: we screw up CMOS contents when there's less than 1 MiB of RAM. pc_cmos_init():

    int val, nb, i;
[...]
    /* memory size */
    val = 640; /* base memory in K */
    rtc_set_memory(s, 0x15, val);
    rtc_set_memory(s, 0x16, val >> 8);

    val = (ram_size / 1024) - 1024;
    if (val > 65535)
        val = 65535;
    rtc_set_memory(s, 0x17, val);
    rtc_set_memory(s, 0x18, val >> 8);

If ram_size < 1MiB, val goes negative. Oops.

For instance, with -m 500k, we happily promise 640KiB base memory (CMOS addr 0x15..16), almost 64MiB extended memory (0x17..18 and 0x30..31), yet no memory above 16MiB (0x34..35).

An easy way to fix this is to require 1MiB of RAM :)

Quoted 7 lines

But if you like, I'll put sane values in CMOS instead. That'll expose the SeaBIOS bug.

Anthony, you're the PC maintainer, got a preference?

SeaBIOS thread:
http://comments.gmane.org/gmane.comp.bios.coreboot.seabios/4341

I'd prefer fixing the CMOS values over limiting to 1MB of RAM.

Having a 1MB limit is purely theoritical--not practical. There's no good reason for anyone to ask for < 1MB unless they know what they're doing. If it's truly a mistake, then asking for 2MB is just as much of a mistake because no real guest will run with 2MB of memory anyway (you can't even load a kernel).

Quoted 3 lines

So if we're just going for theoritical correctness, we ought to do it the Right Way which is fixing the CMOS values and putting the check in SeaBIOS.

Next error:

    $ gdb --args qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -monitor stdio -m 640k
    [...]
    Program received signal SIGSEGV, Segmentation fault.
    [...]
    (gdb) bt
    #0  0x0000003b0de884ac in __memcmp_sse2 () from /lib64/libc.so.6
    #1  0x000000000063f1ad in patch_hypercalls (s=0x139b350)
        at /work/armbru/qemu/hw/i386/../kvmvapic.c:532
    #2  0x000000000063f3fe in vapic_prepare (s=0x139b350)
        at /work/armbru/qemu/hw/i386/../kvmvapic.c:597
    #3  0x000000000063f4ed in vapic_write (opaque=0x139b350, addr=0, data=32, size=
        2) at /work/armbru/qemu/hw/i386/../kvmvapic.c:634
    #4  0x0000000000677a44 in memory_region_write_accessor (opaque=0x139d670, addr=
        0, value=0x7ffff654bbf0, size=2, shift=0, mask=65535)
        at /work/armbru/qemu/memory.c:329
    #5  0x0000000000677b26 in access_with_adjusted_size (addr=0, value=
        0x7ffff654bbf0, size=2, access_size_min=1, access_size_max=4, access=
        0x6779d0 <memory_region_write_accessor>, opaque=0x139d670)
        at /work/armbru/qemu/memory.c:359
    #6  0x0000000000677f80 in memory_region_iorange_write (iorange=0x139e050, 
        offset=0, width=2, data=32) at /work/armbru/qemu/memory.c:436
    #7  0x00000000006709a5 in ioport_writew_thunk (opaque=0x139e050, addr=126, 
        data=32) at /work/armbru/qemu/ioport.c:219
    #8  0x0000000000670384 in ioport_write (index=1, address=126, data=32)
        at /work/armbru/qemu/ioport.c:83
    #9  0x0000000000670e32 in cpu_outw (addr=126, val=32)
        at /work/armbru/qemu/ioport.c:296
    #10 0x0000000000674637 in kvm_handle_io (port=126, data=0x7ffff7ffb000, 
        direction=1, size=2, count=1) at /work/armbru/qemu/kvm-all.c:1411
    #11 0x0000000000674bc5 in kvm_cpu_exec (env=0x1389b30)
        at /work/armbru/qemu/kvm-all.c:1556
    #12 0x000000000060e0b4 in qemu_kvm_cpu_thread_fn (arg=0x1389b30)
        at /work/armbru/qemu/cpus.c:757
    #13 0x0000003b0ea07d14 in start_thread () from /lib64/libpthread.so.0
    #14 0x0000003b0def197d in clone () from /lib64/libc.so.6

Happens when -m argument is a multiple of 4k in [648k..768k]. Only with --enable-kvm. With and without my CMOS fix applied.

And another one:

    $  qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -monitor stdio -m 900k
    QEMU 1.1.50 monitor - type 'help' for more information
    (qemu) KVM internal error. Suberror: 1
    emulation failure
    EAX=000fdb78 EBX=00000000 ECX=00000000 EDX=000fdb64
    ESI=00000000 EDI=000fdb64 EBP=00000000 ESP=00006f98
    EIP=000e3492 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
    ES =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
    SS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    DS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    FS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    GS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
    TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
    GDT=     000fcd68 00000037
    IDT=     000fdb60 00000000
    CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
    DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000 
    DR6=00000000ffff0ff0 DR7=0000000000000400
    EFER=0000000000000000
    Code=00 00 b8 26 00 00 00 eb 95 83 c8 ff 83 c4 4c 5b 5e 5f 5d c3 <57> 56 53 89 d6 39 c2 72 06 89 c7 f3 a4 eb 1b 8d 51 ff 01 d0 01 d6 89 cf 31 d2 eb 08 8a 1c
    q

Breakpoint on kvm_handle_internal_error() yields backtrace:

    #0  kvm_handle_internal_error (env=0x1389b30, run=0x7ffff7ffa000)
        at /work/armbru/qemu/kvm-all.c:1424
    #1  0x0000000000674c5a in kvm_cpu_exec (env=0x1389b30)
        at /work/armbru/qemu/kvm-all.c:1586
    #2  0x000000000060e0b4 in qemu_kvm_cpu_thread_fn (arg=0x1389b30)
        at /work/armbru/qemu/cpus.c:757
    #3  0x0000003b0ea07d14 in start_thread () from /lib64/libpthread.so.0
    #4  0x0000003b0def197d in clone () from /lib64/libc.so.6

Also seen with 904k, 908k, 964k, 968k, 972k 976k, and a whole lot more. Not reproduced with 1024k+.

An easy way to "fix" these is to require 1MiB of RAM :)

#20 lore raw
Quoted 17 lines · Markus Armbruster

Next error:

    $ gdb --args qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -monitor stdio -m 640k
    [...]
    Program received signal SIGSEGV, Segmentation fault.
    [...]
    (gdb) bt
    #0  0x0000003b0de884ac in __memcmp_sse2 () from /lib64/libc.so.6
    #1  0x000000000063f1ad in patch_hypercalls (s=0x139b350)
        at /work/armbru/qemu/hw/i386/../kvmvapic.c:532
    #2  0x000000000063f3fe in vapic_prepare (s=0x139b350)
        at /work/armbru/qemu/hw/i386/../kvmvapic.c:597
    #3  0x000000000063f4ed in vapic_write (opaque=0x139b350, addr=0, data=32, size=
        2) at /work/armbru/qemu/hw/i386/../kvmvapic.c:634
    #4  0x0000000000677a44 in memory_region_write_accessor (opaque=0x139d670, addr=
Quoted 2 lines

Happens when -m argument is a multiple of 4k in [648k..768k]. Only with --enable-kvm. With and without my CMOS fix applied.

kvmvapic requires RAM to be present underneath the ROM. We could fix up kvmvapic to allocate a 4k region and insert it as an overlay, but it's sufficient IMO to require sub-1M users to disable it. It won't be of any use to the anyway as Windows XP requires more than 1MB.

Quoted 18 lines

And another one:

    $  qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -monitor stdio -m 900k
    QEMU 1.1.50 monitor - type 'help' for more information
    (qemu) KVM internal error. Suberror: 1
    emulation failure
    EAX=000fdb78 EBX=00000000 ECX=00000000 EDX=000fdb64
    ESI=00000000 EDI=000fdb64 EBP=00000000 ESP=00006f98
    EIP=000e3492 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
    ES =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
    SS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    DS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    FS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    GS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
    TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
Quoted 9 lines
    GDT=     000fcd68 00000037
    IDT=     000fdb60 00000000
    CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
    DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000 
    DR6=00000000ffff0ff0 DR7=0000000000000400
    EFER=0000000000000000
    Code=00 00 b8 26 00 00 00 eb 95 83 c8 ff 83 c4 4c 5b 5e 5f 5d c3 <57> 56 53 89 d6 39 c2 72 06 89 c7 f3 a4 eb 1b 8d 51 ff 01 d0 01 d6 89 cf 31 d2 eb 08 8a 1c
    q

Not sure what's the problem. 57 is a push reg instruction which we ought to emulate fine.

900k is 0xe1000, just below eip, but we ought to execute just fine from unshadowed ROM.

Quoted 11 lines

Breakpoint on kvm_handle_internal_error() yields backtrace:

    #0  kvm_handle_internal_error (env=0x1389b30, run=0x7ffff7ffa000)
        at /work/armbru/qemu/kvm-all.c:1424
    #1  0x0000000000674c5a in kvm_cpu_exec (env=0x1389b30)
        at /work/armbru/qemu/kvm-all.c:1586
    #2  0x000000000060e0b4 in qemu_kvm_cpu_thread_fn (arg=0x1389b30)
        at /work/armbru/qemu/cpus.c:757
    #3  0x0000003b0ea07d14 in start_thread () from /lib64/libpthread.so.0
    #4  0x0000003b0def197d in clone () from /lib64/libc.so.6
Quoted 1 line

Also seen with 904k, 908k, 964k, 968k, 972k 976k, and a whole lot more.

Same EIP in the dump with those?

Quoted 3 lines

Not reproduced with 1024k+.

An easy way to "fix" these is to require 1MiB of RAM :)

Or disabling kvm.

Signature · 1 line
error compiling committee.c: too many arguments to function
#21 lore raw
Quoted 18 lines · Avi Kivity
Quoted 17 lines · Markus Armbruster

Next error:

    $ gdb --args qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -monitor stdio -m 640k
    [...]
    Program received signal SIGSEGV, Segmentation fault.
    [...]
    (gdb) bt
    #0  0x0000003b0de884ac in __memcmp_sse2 () from /lib64/libc.so.6
    #1  0x000000000063f1ad in patch_hypercalls (s=0x139b350)
        at /work/armbru/qemu/hw/i386/../kvmvapic.c:532
    #2  0x000000000063f3fe in vapic_prepare (s=0x139b350)
        at /work/armbru/qemu/hw/i386/../kvmvapic.c:597
    #3  0x000000000063f4ed in vapic_write (opaque=0x139b350, addr=0, data=32, size=
        2) at /work/armbru/qemu/hw/i386/../kvmvapic.c:634
    #4  0x0000000000677a44 in memory_region_write_accessor (opaque=0x139d670, addr=
Quoted 7 lines
Quoted 2 lines

Happens when -m argument is a multiple of 4k in [648k..768k]. Only with --enable-kvm. With and without my CMOS fix applied.

kvmvapic requires RAM to be present underneath the ROM. We could fix up kvmvapic to allocate a 4k region and insert it as an overlay, but it's sufficient IMO to require sub-1M users to disable it. It won't be of any use to the anyway as Windows XP requires more than 1MB.

We can also easily automatically disable it when there is insufficient (<1MB) memory. Will post a patch.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
#22 lore raw
Quoted 22 lines · Jan Kiszka
Quoted 21 lines · Avi Kivity
Quoted 19 lines · Markus Armbruster

Next error:

    $ gdb --args qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -monitor stdio -m 640k
    [...]
    Program received signal SIGSEGV, Segmentation fault.
    [...]
    (gdb) bt
    #0  0x0000003b0de884ac in __memcmp_sse2 () from /lib64/libc.so.6
    #1  0x000000000063f1ad in patch_hypercalls (s=0x139b350)
        at /work/armbru/qemu/hw/i386/../kvmvapic.c:532
    #2  0x000000000063f3fe in vapic_prepare (s=0x139b350)
        at /work/armbru/qemu/hw/i386/../kvmvapic.c:597
    #3  0x000000000063f4ed in vapic_write (opaque=0x139b350, addr=0, data=32, size=
        2) at /work/armbru/qemu/hw/i386/../kvmvapic.c:634
    #4  0x0000000000677a44 in memory_region_write_accessor (opaque=0x139d670, addr=

Happens when -m argument is a multiple of 4k in [648k..768k]. Only with --enable-kvm. With and without my CMOS fix applied.

Quoted 7 lines
Quoted 4 lines

kvmvapic requires RAM to be present underneath the ROM. We could fix up kvmvapic to allocate a 4k region and insert it as an overlay, but it's sufficient IMO to require sub-1M users to disable it. It won't be of any use to the anyway as Windows XP requires more than 1MB.

We can also easily automatically disable it when there is insufficient (<1MB) memory. Will post a patch.

Would be nicer if it auto-disables itself, but don't know if the option ROM has access to the memory size.

Signature · 1 line
error compiling committee.c: too many arguments to function
#23 lore raw
Quoted 28 lines · Avi Kivity
Quoted 27 lines · Jan Kiszka
Quoted 25 lines · Avi Kivity
Quoted 17 lines · Markus Armbruster

Next error:

    $ gdb --args qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -monitor stdio -m 640k
    [...]
    Program received signal SIGSEGV, Segmentation fault.
    [...]
    (gdb) bt
    #0  0x0000003b0de884ac in __memcmp_sse2 () from /lib64/libc.so.6
    #1  0x000000000063f1ad in patch_hypercalls (s=0x139b350)
        at /work/armbru/qemu/hw/i386/../kvmvapic.c:532
    #2  0x000000000063f3fe in vapic_prepare (s=0x139b350)
        at /work/armbru/qemu/hw/i386/../kvmvapic.c:597
    #3  0x000000000063f4ed in vapic_write (opaque=0x139b350, addr=0, data=32, size=
        2) at /work/armbru/qemu/hw/i386/../kvmvapic.c:634
    #4  0x0000000000677a44 in memory_region_write_accessor (opaque=0x139d670, addr=
Quoted 2 lines

Happens when -m argument is a multiple of 4k in [648k..768k]. Only with --enable-kvm. With and without my CMOS fix applied.

kvmvapic requires RAM to be present underneath the ROM. We could fix up kvmvapic to allocate a 4k region and insert it as an overlay, but it's sufficient IMO to require sub-1M users to disable it. It won't be of any use to the anyway as Windows XP requires more than 1MB.

Quoted 5 lines
Quoted 2 lines

We can also easily automatically disable it when there is insufficient (<1MB) memory. Will post a patch.

Would be nicer if it auto-disables itself, but don't know if the option ROM has access to the memory size.

There is that global ram_size, also used by vmport. Not really nice but no precedent.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
#24 lore raw
Quoted 8 lines · Jan Kiszka
Quoted 5 lines
Quoted 2 lines

We can also easily automatically disable it when there is insufficient (<1MB) memory. Will post a patch.

Would be nicer if it auto-disables itself, but don't know if the option ROM has access to the memory size.

There is that global ram_size, also used by vmport. Not really nice but no precedent.

I meant do the detection in the guest. But don't respin the patch, it doesn't really matter and host-side works just as well.

Signature · 1 line
error compiling committee.c: too many arguments to function
#25 lore raw
Quoted 5 lines · Avi Kivity
Quoted 3 lines · Jan Kiszka
Quoted 3 lines
Quoted 2 lines

We can also easily automatically disable it when there is insufficient (<1MB) memory. Will post a patch.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Would be nicer if it auto-disables itself, but don't know if the option ROM has access to the memory size.

There is that global ram_size, also used by vmport. Not really nice but no precedent.

I meant do the detection in the guest. But don't respin the patch, it doesn't really matter and host-side works just as well.

We must not allow the guest to decide over this. Unless I'm misinterpreting something, a malicious guest could still trigger this patching (in non-existent RAM) and crash the host.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
#26 lore raw
Quoted 12 lines · Jan Kiszka
Quoted 11 lines · Avi Kivity
Quoted 8 lines · Jan Kiszka
Quoted 5 lines
Quoted 2 lines

We can also easily automatically disable it when there is insufficient (<1MB) memory. Will post a patch.

Would be nicer if it auto-disables itself, but don't know if the option ROM has access to the memory size.

There is that global ram_size, also used by vmport. Not really nice but no precedent.

Quoted 6 lines
Quoted 2 lines

I meant do the detection in the guest. But don't respin the patch, it doesn't really matter and host-side works just as well.

We must not allow the guest to decide over this. Unless I'm misinterpreting something, a malicious guest could still trigger this patching (in non-existent RAM) and crash the host.

Right.

Signature · 1 line
error compiling committee.c: too many arguments to function
#27 lore raw
In reply to Avi Kivity
Quoted 1 line · Avi Kivity

On 08/14/2012 11:44 AM, Markus Armbruster wrote:

[...]

Quoted 49 lines
Quoted 21 lines

And another one:

    $ qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -monitor
stdio -m 900k
    QEMU 1.1.50 monitor - type 'help' for more information
    (qemu) KVM internal error. Suberror: 1
    emulation failure
    EAX=000fdb78 EBX=00000000 ECX=00000000 EDX=000fdb64
    ESI=00000000 EDI=000fdb64 EBP=00000000 ESP=00006f98
    EIP=000e3492 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
    ES =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
    SS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    DS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    FS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    GS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
    TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
    GDT=     000fcd68 00000037
    IDT=     000fdb60 00000000
    CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
Quoted 9 lines
    DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000
DR3=0000000000000000
    DR6=00000000ffff0ff0 DR7=0000000000000400
    EFER=0000000000000000
    Code=00 00 b8 26 00 00 00 eb 95 83 c8 ff 83 c4 4c 5b 5e 5f 5d c3
<57> 56 53 89 d6 39 c2 72 06 89 c7 f3 a4 eb 1b 8d 51 ff 01 d0 01 d6
89 cf 31 d2 eb 08 8a 1c
    q

Not sure what's the problem. 57 is a push reg instruction which we ought to emulate fine.

900k is 0xe1000, just below eip, but we ought to execute just fine from unshadowed ROM.

Quoted 11 lines

Breakpoint on kvm_handle_internal_error() yields backtrace:

    #0  kvm_handle_internal_error (env=0x1389b30, run=0x7ffff7ffa000)
        at /work/armbru/qemu/kvm-all.c:1424
    #1  0x0000000000674c5a in kvm_cpu_exec (env=0x1389b30)
        at /work/armbru/qemu/kvm-all.c:1586
    #2  0x000000000060e0b4 in qemu_kvm_cpu_thread_fn (arg=0x1389b30)
        at /work/armbru/qemu/cpus.c:757
    #3  0x0000003b0ea07d14 in start_thread () from /lib64/libpthread.so.0
    #4  0x0000003b0def197d in clone () from /lib64/libc.so.6
Quoted 3 lines
Quoted 1 line

Also seen with 904k, 908k, 964k, 968k, 972k 976k, and a whole lot more.

Same EIP in the dump with those?

Offenders within 1s in range 868k..1028k step 4:

900
EIP=000e3492 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0 904
EIP=000e3492 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0 908
EIP=000e3492 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0 916
EIP=000e570e EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0 964
EIP=000f2b76 EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0 968
EIP=000f2b76 EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0 972
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 976
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 980
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 984
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 988
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 992
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 996
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 1000
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 1004
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 1008
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 1012
EIP=000fe69f EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 1016
EIP=000fe69f EFL=00000083 [--S---C] CPL=0 II=0 A20=1 SMM=0 HLT=0 1020
EIP=0000f000 EFL=00000046 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0

Quoted 5 lines
Quoted 3 lines

Not reproduced with 1024k+.

An easy way to "fix" these is to require 1MiB of RAM :)

Or disabling kvm.

#28 lore raw
Quoted 89 lines · Markus Armbruster
Quoted 1 line · Avi Kivity

On 08/14/2012 11:44 AM, Markus Armbruster wrote:

[...]

Quoted 49 lines
Quoted 21 lines

And another one:

    $ qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -monitor
stdio -m 900k
    QEMU 1.1.50 monitor - type 'help' for more information
    (qemu) KVM internal error. Suberror: 1
    emulation failure
    EAX=000fdb78 EBX=00000000 ECX=00000000 EDX=000fdb64
    ESI=00000000 EDI=000fdb64 EBP=00000000 ESP=00006f98
    EIP=000e3492 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
    ES =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
    SS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    DS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    FS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    GS =0010 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
    LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
    TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
    GDT=     000fcd68 00000037
    IDT=     000fdb60 00000000
    CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
Quoted 9 lines
    DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000
DR3=0000000000000000
    DR6=00000000ffff0ff0 DR7=0000000000000400
    EFER=0000000000000000
    Code=00 00 b8 26 00 00 00 eb 95 83 c8 ff 83 c4 4c 5b 5e 5f 5d c3
<57> 56 53 89 d6 39 c2 72 06 89 c7 f3 a4 eb 1b 8d 51 ff 01 d0 01 d6
89 cf 31 d2 eb 08 8a 1c
    q

Not sure what's the problem. 57 is a push reg instruction which we ought to emulate fine.

900k is 0xe1000, just below eip, but we ought to execute just fine from unshadowed ROM.

Quoted 11 lines

Breakpoint on kvm_handle_internal_error() yields backtrace:

    #0  kvm_handle_internal_error (env=0x1389b30, run=0x7ffff7ffa000)
        at /work/armbru/qemu/kvm-all.c:1424
    #1  0x0000000000674c5a in kvm_cpu_exec (env=0x1389b30)
        at /work/armbru/qemu/kvm-all.c:1586
    #2  0x000000000060e0b4 in qemu_kvm_cpu_thread_fn (arg=0x1389b30)
        at /work/armbru/qemu/cpus.c:757
    #3  0x0000003b0ea07d14 in start_thread () from /lib64/libpthread.so.0
    #4  0x0000003b0def197d in clone () from /lib64/libc.so.6
Quoted 3 lines
Quoted 1 line

Also seen with 904k, 908k, 964k, 968k, 972k 976k, and a whole lot more.

Same EIP in the dump with those?

Offenders within 1s in range 868k..1028k step 4:

900
EIP=000e3492 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0 904
EIP=000e3492 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0 908
EIP=000e3492 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0 916
EIP=000e570e EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0 964
EIP=000f2b76 EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0 968
EIP=000f2b76 EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0 972
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 976
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 980
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 984
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 988
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 992
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 996
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 1000
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 1004
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0

Quoted 9 lines

1008
EIP=000fc6db EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 1012
EIP=000fe69f EFL=00000087 [--S--PC] CPL=0 II=0 A20=1 SMM=0 HLT=0 1016
EIP=000fe69f EFL=00000083 [--S---C] CPL=0 II=0 A20=1 SMM=0 HLT=0 1020
EIP=0000f000 EFL=00000046 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0

Seems like crash eip always > end of memory.

It's the new flash firmware: it's set up as rom_device, and we can't execute from that (yet). There's a patchset to allow that, but it's not merged yet.

If you set pc-sysfw.rom_only, it should work.

Signature · 1 line
error compiling committee.c: too many arguments to function