From patchwork Mon May 4 21:09:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beth Kon X-Patchwork-Id: 21780 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n44L9EQj011980 for ; Mon, 4 May 2009 21:09:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756125AbZEDVJI (ORCPT ); Mon, 4 May 2009 17:09:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755878AbZEDVJI (ORCPT ); Mon, 4 May 2009 17:09:08 -0400 Received: from e5.ny.us.ibm.com ([32.97.182.145]:58918 "EHLO e5.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755537AbZEDVJC (ORCPT ); Mon, 4 May 2009 17:09:02 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e5.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n44L49Me004907 for ; Mon, 4 May 2009 17:04:09 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n44L93d8119862 for ; Mon, 4 May 2009 17:09:03 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n44L92aT008655 for ; Mon, 4 May 2009 17:09:02 -0400 Received: from localhost.localdomain (sig-9-76-12-41.mts.ibm.com [9.76.12.41]) by d01av03.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n44L91Sv008595; Mon, 4 May 2009 17:09:02 -0400 From: Beth Kon To: kvm@vger.kernel.org Cc: Beth Kon Subject: [PATCH 4/4] Userspace changes for KVM HPET Date: Mon, 4 May 2009 17:09:12 -0400 Message-Id: <1241471352-1642-4-git-send-email-eak@us.ibm.com> X-Mailer: git-send-email 1.5.4.3 In-Reply-To: <1241471352-1642-1-git-send-email-eak@us.ibm.com> References: <1241471352-1642-1-git-send-email-eak@us.ibm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Beth Kon --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/hw/hpet.c b/hw/hpet.c index c7945ec..47c9f89 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -30,6 +30,7 @@ #include "console.h" #include "qemu-timer.h" #include "hpet_emul.h" +#include "qemu-kvm.h" //#define HPET_DEBUG #ifdef HPET_DEBUG @@ -48,6 +49,43 @@ uint32_t hpet_in_legacy_mode(void) return 0; } +static void hpet_kpit_enable(void) +{ + struct kvm_pit_state ps; + kvm_get_pit(kvm_context, &ps); + kvm_set_pit(kvm_context, &ps); +} + +static void hpet_kpit_disable(void) +{ + struct kvm_pit_state ps; + kvm_get_pit(kvm_context, &ps); + ps.channels[0].mode = 0xff; + kvm_set_pit(kvm_context, &ps); +} + +static void hpet_legacy_enable(void) +{ + if (qemu_kvm_pit_in_kernel()) { + hpet_kpit_disable(); + dprintf("qemu: hpet disabled kernel pit\n"); + } else { + hpet_pit_disable(); + dprintf("qemu: hpet disabled userspace pit\n"); + } +} + +static void hpet_legacy_disable(void) +{ + if (qemu_kvm_pit_in_kernel()) { + hpet_kpit_enable(); + dprintf("qemu: hpet enabled kernel pit\n"); + } else { + hpet_pit_enable(); + dprintf("qemu: hpet enabled userspace pit\n"); + } +} + static uint32_t timer_int_route(struct HPETTimer *timer) { uint32_t route; @@ -475,9 +513,9 @@ static void hpet_ram_writel(void *opaque, target_phys_addr_t addr, } /* i8254 and RTC are disabled when HPET is in legacy mode */ if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) { - hpet_pit_disable(); + hpet_legacy_enable(); } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) { - hpet_pit_enable(); + hpet_legacy_disable(); } break; case HPET_CFG + 4: @@ -560,7 +598,7 @@ static void hpet_reset(void *opaque) { * hpet_reset is called due to system reset. At this point control must * be returned to pit until SW reenables hpet. */ - hpet_pit_enable(); + hpet_legacy_disable(); count = 1; } diff --git a/pc-bios/bios.bin b/pc-bios/bios.bin index d5d42f3..2503783 100644 Binary files a/pc-bios/bios.bin and b/pc-bios/bios.bin differ diff --git a/vl.c b/vl.c index 5eacd6a..1334344 100644 --- a/vl.c +++ b/vl.c @@ -5666,10 +5666,15 @@ int main(int argc, char **argv, char **envp) } if (kvm_enabled()) { - kvm_init_ap(); + kvm_init_ap(); #ifdef USE_KVM if (kvm_irqchip && !qemu_kvm_has_gsi_routing()) { - irq0override = 0; + irq0override = 0; + /* if kernel can't do irq routing, interrupt source + * override 0->2 can not be set up as required by hpet, + * so disable hpet. + */ + no_hpet=1; } #endif }