From patchwork Thu May 10 21:02:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 158395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1F811B6FD8 for ; Fri, 11 May 2012 07:03:24 +1000 (EST) Received: from localhost ([::1]:45550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSaW9-00087d-VH for incoming@patchwork.ozlabs.org; Thu, 10 May 2012 17:03:21 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSaVz-00086z-Me for qemu-devel@nongnu.org; Thu, 10 May 2012 17:03:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSaVx-0006ON-UI for qemu-devel@nongnu.org; Thu, 10 May 2012 17:03:11 -0400 Received: from thoth.sbs.de ([192.35.17.2]:17171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSaVx-0006Kw-LB for qemu-devel@nongnu.org; Thu, 10 May 2012 17:03:09 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.13.6/8.13.6) with ESMTP id q4AL37Ws027789; Thu, 10 May 2012 23:03:07 +0200 Received: from mchn199C.mchp.siemens.de ([139.22.46.144]) by mail1.siemens.de (8.13.6/8.13.6) with SMTP id q4AL31b6028153; Thu, 10 May 2012 23:03:05 +0200 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Thu, 10 May 2012 18:02:50 -0300 Message-Id: X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.2 Cc: qemu-devel , kvm@vger.kernel.org, "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v3 1/8] kvm: Refactor KVMState::max_gsi to gsi_count X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Instead of the bitmap size, store the maximum of GSIs the kernel support. Move the GSI limit assertion to the API function kvm_irqchip_add_route and make it stricter. Signed-off-by: Jan Kiszka --- kvm-all.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 9b73ccf..2d82d54 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -86,7 +86,7 @@ struct KVMState struct kvm_irq_routing *irq_routes; int nr_allocated_irq_routes; uint32_t *used_gsi_bitmap; - unsigned int max_gsi; + unsigned int gsi_count; #endif }; @@ -859,8 +859,6 @@ int kvm_irqchip_set_irq(KVMState *s, int irq, int level) #ifdef KVM_CAP_IRQ_ROUTING static void set_gsi(KVMState *s, unsigned int gsi) { - assert(gsi < s->max_gsi); - s->used_gsi_bitmap[gsi / 32] |= 1U << (gsi % 32); } @@ -875,7 +873,7 @@ static void kvm_init_irq_routing(KVMState *s) /* Round up so we can search ints using ffs */ gsi_bits = ALIGN(gsi_count, 32); s->used_gsi_bitmap = g_malloc0(gsi_bits / 8); - s->max_gsi = gsi_bits; + s->gsi_count = gsi_count; /* Mark any over-allocated bits as already in use */ for (i = gsi_count; i < gsi_bits; i++) { @@ -920,6 +918,8 @@ void kvm_irqchip_add_route(KVMState *s, int irq, int irqchip, int pin) { struct kvm_irq_routing_entry e; + assert(pin < s->gsi_count); + e.gsi = irq; e.type = KVM_IRQ_ROUTING_IRQCHIP; e.flags = 0;