Skip to contentSkip to conversation

Problems with hpet on kvm

RFC PATCH New Beth Kon 1 participant 1 message Aug 19, 2008 KVM

lore
Share & tools
lore

Beth Kon

author
#0 lore raw

RFC PATCH 1/1 Problems with hpet on kvm

I've been playing with my hpet patch on kvm and seeing some strange behavior. The patch I've been using is attached below.

/usr/local/bin/qemu-system-x86_64 -boot cd -hda /home/beth/images/ubuntu_server_8.04_10G.img -m 1024 -net nic,model=e1000 -net user -smp 2 -vnc :1

With the above command line the boot intermittently fails with an infinite roll of error messages that look something like this:

*********************BEGIN ERROR MESSAGES********************************
...
ACPI Exception (evgpe-0704): AE_NO_MEMORY, Unable to queue handler for GPE[ E] - event disabled [20070126] ACPI Exception (evgpe-0704): AE_NO_MEMORY, Unable to queue handler for GPE[ F] - event disabled [20070126]
printk: 242 messages suppressed.
kacpid: page allocation failure. order:0, mode:0x20
Pid: 93, comm: kacpid Not tainted 2.6.25.9 #13

Call Trace:
 <IRQ>  [<ffffffff8025f143>] __alloc_pages+0x325/0x33e
 [<ffffffff8027b27c>] kmem_getpages+0xc6/0x194
 [<ffffffff8027b85a>] fallback_alloc+0x10d/0x185
 [<ffffffff8027bea7>] kmem_cache_alloc+0xbd/0xe7
 [<ffffffff80369944>] acpi_ev_asynch_execute_gpe_method+0x0/0x117
 [<ffffffff80362e9f>] acpi_os_execute+0x2e/0x9a
 [<ffffffff80369823>] acpi_ev_gpe_dispatch+0xd0/0x149
 [<ffffffff80369b0c>] acpi_ev_gpe_detect+0xb1/0x104
 [<ffffffff80367600>] acpi_ev_fixed_event_detect+0x34/0xd4
 [<ffffffff8036800a>] acpi_ev_sci_xrupt_handler+0x1a/0x22
 [<ffffffff80362895>] acpi_irq+0x11/0x23
 [<ffffffff802553a0>] handle_IRQ_event+0x25/0x53
 [<ffffffff802567f6>] handle_fasteoi_irq+0x90/0xc8
 [<ffffffff8020da12>] do_IRQ+0xf1/0x15f
 [<ffffffff8020b471>] ret_from_intr+0x0/0xa
 [<ffffffff80233398>] __do_softirq+0x5a/0xce
 [<ffffffff8020c0ec>] call_softirq+0x1c/0x28
 [<ffffffff8020d794>] do_softirq+0x2c/0x68
 [<ffffffff802332fa>] irq_exit+0x3f/0x83
 [<ffffffff8020da5f>] do_IRQ+0x13e/0x15f
 [<ffffffff8020b471>] ret_from_intr+0x0/0xa
 <EOI>  [<ffffffff80371f1c>] acpi_ns_get_parent_node+0x14/0x15
 [<ffffffff80371b08>] acpi_ns_delete_namespace_by_owner+0xb7/0xde
 [<ffffffff80365641>] acpi_ds_terminate_control_method+0x73/0xc6
 [<ffffffff80373933>] acpi_ps_parse_aml+0x179/0x254
 [<ffffffff80374c4c>] acpi_ps_execute_method+0x12b/0x1d7
 [<ffffffff80371c18>] acpi_ns_evaluate+0xa4/0x100
 [<ffffffff80369a08>] acpi_ev_asynch_execute_gpe_method+0xc4/0x117
 [<ffffffff80362dd6>] acpi_os_execute_deferred+0x0/0x2c
 [<ffffffff80362df9>] acpi_os_execute_deferred+0x23/0x2c
 [<ffffffff8023cb6c>] run_workqueue+0x79/0x104
 [<ffffffff8023d47f>] worker_thread+0xd9/0xe8
 [<ffffffff8023fc91>] autoremove_wake_function+0x0/0x2e
 [<ffffffff8023d3a6>] worker_thread+0x0/0xe8
 [<ffffffff8023fb5d>] kthread+0x47/0x76
 [<ffffffff80229e74>] schedule_tail+0x28/0x5c
 [<ffffffff8020bd78>] child_rip+0xa/0x12
 [<ffffffff8023fb16>] kthread+0x0/0x76
 [<ffffffff8020bd6e>] child_rip+0x0/0x12

Mem-info:
Node 0 DMA per-cpu:
CPU 0: hi: 0, btch: 1 usd: 0
CPU 1: hi: 0, btch: 1 usd: 0
Node 0 DMA32 per-cpu:
CPU 0: hi: 186, btch: 31 usd: 65
CPU 1: hi: 186, btch: 31 usd: 184
Active:0 inactive:0 dirty:0 writeback:0 unstable:0
free:0 slab:255796 mapped:0 pagetables:0 bounce:0
Node 0 DMA free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:8924kB pages_scanned:0 all_unreclaimable? no lowmem_reserve[]: 0 0 0 0
Node 0 DMA32 free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:1018020kB pages_scanned:0 all_unreclaimable? no lowmem_reserve[]: 0 0 0 0
Node 0 DMA: 0*4kB 0*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 0kB Node 0 DMA32: 0*4kB 0*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 0kB
0 total pagecache pages
Swap cache: add 0, delete 0, find 0/0
Free swap = 0kB
Total swap = 0kB
Free swap: 0kB
262128 pages of RAM
5637 reserved pages
0 pages shared
0 pages swap cached
ACPI Exception (evgpe-0704): AE_NO_MEMORY, Unable to queue handler for GPE[ 8] - event disabled [20070126] ACPI Exception (evgpe-0704): AE_NO_MEMORY, Unable to queue handler for GPE[ 9] - event disabled [20070126]
...
*************END ERROR MESSAGES******************************************

If I add -no-kvm-irqchip, the error disappears.

Can anyone offer any insight about what is going on here? I don't know if it is related, but booting linux with the hpet seems to stall in some places, and I don't see that when booting without the hpet.

Other than this problem, I have booted win2k8 and linux with the hpet. The only other odd situation is that, to get linux to work I
have to use irq 0 for timer0, but to get windows to work, I have to use irq 2. In hpet.c update_irq:

if (timer->tn == 0)

            irq=timer->state->irqs[0];

must be changed to

if (timer->tn == 0)

            irq=timer->state->irqs[2];

to get win2k8 to boot.

Any ideas?

Beth Kon
IBM Linux Technology Center
**************************************

signed-off-by Beth Kon <[email protected]>

qemu/Makefile.target +1 -1
index a86464f..8634186 100644
@@ -607,7 +607,7 @@ ifeq ($(TARGET_BASE_ARCH), i386)
 OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
 OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
 OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
-OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o extboot.o
+OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o extboot.o hpet.o
 ifeq ($(USE_KVM_PIT), 1)
 OBJS+= i8254-kvm.o
 endif
qemu/hw/hpet.c new file +486 -0

486 lines not on this page · raw message

qemu/hw/i8254.c +11 -1
index 69eb889..452dcee 100644
@@ -27,6 +27,10 @@
 #include "qemu-timer.h"
 #include "i8254.h"
 
+#if defined TARGET_I386 || defined TARGET_X86_64
+extern int hpet_legacy;
+#endif
+
 //#define DEBUG_PIT
 
 static PITState pit_state;
@@ -344,9 +348,15 @@ static void pit_irq_timer_update(PITChannelState *s, int64_t current_time)
 
     if (!s->irq_timer)
         return;
+#if defined TARGET_I386 || defined TARGET_X86_64
+    if (hpet_legacy) {
+        qemu_del_timer(s->irq_timer);
+        return;
+    }
+#endif
     expire_time = pit_get_next_transition_time(s, current_time);
     irq_level = pit_get_out1(s, current_time);
-    qemu_set_irq(s->irq, irq_level);
+        qemu_set_irq(s->irq, irq_level);
     if (time_drift_fix && irq_level==1) {
         /* FIXME: fine tune timer_max_fix (max fix per tick). 
          *        Should it be 1 (double time), 2 , 4, 10 ? 
qemu/hw/mc146818rtc.c +27 -2
index 30bb044..3b6157e 100644
@@ -27,6 +27,9 @@
 #include "pc.h"
 #include "isa.h"
 
+#if defined TARGET_I386 || defined TARGET_X86_64
+extern int hpet_legacy;
+#endif
 //#define DEBUG_CMOS
 
 #define RTC_SECONDS             0
@@ -80,7 +83,11 @@ static void rtc_timer_update(RTCState *s, int64_t current_time)
 
     period_code = s->cmos_data[RTC_REG_A] & 0x0f;
     if (period_code != 0 &&
+#if defined TARGET_I386 || defined TARGET_X86_64
+        (s->cmos_data[RTC_REG_B] & REG_B_PIE) && !hpet_legacy) {
+#else
         (s->cmos_data[RTC_REG_B] & REG_B_PIE)) {
+#endif
         if (period_code <= 2)
             period_code += 7;
         /* period in 32 Khz cycles */
@@ -101,7 +108,10 @@ static void rtc_periodic_timer(void *opaque)
 
     rtc_timer_update(s, s->next_periodic_time);
     s->cmos_data[RTC_REG_C] |= 0xc0;
-    qemu_irq_raise(s->irq);
+#if defined TARGET_I386 || defined TARGET_X86_64
+    if (!hpet_legacy)
+#endif
+        qemu_irq_raise(s->irq);
 }
 
 static void cmos_ioport_write(void *opaque, uint32_t addr, uint32_t data)
@@ -281,6 +291,12 @@ static void rtc_update_second(void *opaque)
     RTCState *s = opaque;
     int64_t delay;
 
+#if defined TARGET_I386 || defined TARGET_X86_64
+    if (hpet_legacy) {
+        qemu_del_timer(s->second_timer2);
+        return;
+    }
+#endif
     /* if the oscillator is not in normal operation, we do not update */
     if ((s->cmos_data[RTC_REG_A] & 0x70) != 0x20) {
         s->next_second_time += ticks_per_sec;
@@ -306,6 +322,12 @@ static void rtc_update_second2(void *opaque)
 {
     RTCState *s = opaque;
 
+#if defined TARGET_I386 || defined TARGET_X86_64
+    if (hpet_legacy) {
+        qemu_del_timer(s->second_timer);
+        return;
+    }
+#endif
     if (!(s->cmos_data[RTC_REG_B] & REG_B_SET)) {
         rtc_copy_date(s);
     }
@@ -359,7 +381,10 @@ static uint32_t cmos_ioport_read(void *opaque, uint32_t addr)
             break;
         case RTC_REG_C:
             ret = s->cmos_data[s->cmos_index];
-            qemu_irq_lower(s->irq);
+#if defined TARGET_I386 || defined TARGET_X86_64
+            if (!hpet_legacy)
+#endif
+                qemu_irq_lower(s->irq);
             s->cmos_data[RTC_REG_C] = 0x00;
             break;
         default:
qemu/hw/pc.c +3 -0
index 3a8269b..385361f 100644
@@ -50,6 +50,8 @@
 
 #define MAX_IDE_BUS 2
 
+void hpet_init(qemu_irq irq);
+
 static fdctrl_t *floppy_controller;
 static RTCState *rtc_state;
 static PITState *pit;
@@ -1016,6 +1018,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
 #endif
 	pit = pit_init(0x40, i8259[0]);
     pcspk_init(pit);
+    hpet_init(i8259);
     if (pci_enabled) {
         pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic);
     }