From patchwork Mon Jun 27 10:22:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 920292 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5RAbjqw028362 for ; Mon, 27 Jun 2011 10:38:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759230Ab1F0KXO (ORCPT ); Mon, 27 Jun 2011 06:23:14 -0400 Received: from goliath.siemens.de ([192.35.17.28]:32073 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756354Ab1F0KWd (ORCPT ); Mon, 27 Jun 2011 06:22:33 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id p5RAMTGn009283; Mon, 27 Jun 2011 12:22:29 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id p5RAMSb3009574; Mon, 27 Jun 2011 12:22:29 +0200 Message-ID: <4E0859E4.20509@siemens.com> Date: Mon, 27 Jun 2011 12:22:28 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Avi Kivity , Marcelo Tosatti CC: kvm Subject: [PATCH] qemu-kvm: Fix in-kernel PIC reset Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 27 Jun 2011 10:38:37 +0000 (UTC) Lacking sync of the user space state to the kernel after system reset left the PIC behind in an undefined state. This broke IRQ delivery in some scenarios, e.g. when resetting while in the BIOS. Signed-off-by: Jan Kiszka --- hw/i8259.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/hw/i8259.c b/hw/i8259.c index 1c545c7..463ce72 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -278,6 +278,8 @@ int pic_read_irq(PicState2 *s) return intno; } +static int kvm_kernel_pic_load_from_user(PicState *s); + static void pic_reset(void *opaque) { PicState *s = opaque; @@ -298,6 +300,10 @@ static void pic_reset(void *opaque) s->init4 = 0; s->single_mode = 0; /* Note: ELCR is not reset */ + + if (kvm_enabled() && kvm_irqchip_in_kernel()) { + kvm_kernel_pic_load_from_user(s); + } } static void pic_ioport_write(void *opaque, uint32_t addr, uint32_t val) @@ -465,7 +471,6 @@ static uint32_t elcr_ioport_read(void *opaque, uint32_t addr1) } static void kvm_kernel_pic_save_to_user(PicState *s); -static int kvm_kernel_pic_load_from_user(PicState *s); static void pic_pre_save(void *opaque) {