From patchwork Fri Feb 27 04:58:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 9096 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 n1R4xohh011559 for ; Fri, 27 Feb 2009 04:59:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755960AbZB0E7T (ORCPT ); Thu, 26 Feb 2009 23:59:19 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756326AbZB0E7P (ORCPT ); Thu, 26 Feb 2009 23:59:15 -0500 Received: from mga03.intel.com ([143.182.124.21]:18270 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756212AbZB0E7O (ORCPT ); Thu, 26 Feb 2009 23:59:14 -0500 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 26 Feb 2009 20:59:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,274,1233561600"; d="scan'208";a="114958471" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.13.48]) by azsmga001.ch.intel.com with ESMTP; 26 Feb 2009 20:58:59 -0800 Received: from yasker by syang10-desktop with local (Exim 4.69) (envelope-from ) id 1LcuoJ-0004Gs-3r; Fri, 27 Feb 2009 12:58:55 +0800 From: Sheng Yang To: Avi Kivity Cc: Gleb Natapov , kvm@vger.kernel.org, Sheng Yang Subject: [PATCH 1/1] KVM: Correct deliver_bitmask in kvm_get_intr_delivery_bitmask Date: Fri, 27 Feb 2009 12:58:55 +0800 Message-Id: <1235710735-16400-1-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.5.6.3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 1. deliver_bitmask is a bitmap rather than a unsigned long intereger. 2. Lowest priority target bitmap wrong calculated by mistake. 3. Prevent potential NULL reference. Signed-off-by: Sheng Yang --- virt/kvm/irq_comm.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index d165e05..8e1869d 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -54,8 +54,12 @@ void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic, deliver_bitmask); switch (entry->fields.delivery_mode) { case IOAPIC_LOWEST_PRIORITY: + /* Select one in deliver_bitmask */ vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm, entry->fields.vector, deliver_bitmask); + bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS); + if (!vcpu) + return; __set_bit(vcpu->vcpu_id, deliver_bitmask); break; case IOAPIC_FIXED: @@ -65,7 +69,7 @@ void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic, if (printk_ratelimit()) printk(KERN_INFO "kvm: unsupported delivery mode %d\n", entry->fields.delivery_mode); - *deliver_bitmask = 0; + bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS); } }