From patchwork Thu Dec 11 12:19:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 42123 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 49E4F26C6D for ; Thu, 11 Dec 2014 12:25:41 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gd6sf3358884lab.4 for ; Thu, 11 Dec 2014 04:25:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=9KF10+40nk/Zgvp30c2NLdU0o38kIShYjLzxOomwB3w=; b=JTkiSUMpOhoaJSYj663D03586VNXPIIsbyIq2V7K+1MPUiuQjwnMJ5fbjDPq77thIH I/l/VEQdzppFjxf6//Ermmpdeg38aph3GbdOrHn7Et3kWTsHYrNcFLiLFpt7Uf7b+T4e 2JSNlqYYk9KeZkFlsOoWIUpZ/TBQYwa6dWOAu0FVyqQlUayQGtf8SB+URZMD1n/vIFuD /ajeWFj9xdVdaXmWESBPaVSFBzoMJJHpnt7e2Dgg0WQP9ka2+0AHauwcn7gjiR/GmqzH iiYJD4ivKBBttzVo/sHkddnVa986hMs6GYCqdf2Cy3dOomW1XxXdwSARz2uS41zvKzYc 1zRA== X-Gm-Message-State: ALoCoQkwovLnfXrj8Jc7KOVX6SWXV1JIThnqmhfNBKG8xBssLZ2Y5E9lG5JY5Z/bvm+Jwe05j7Ls X-Received: by 10.112.142.36 with SMTP id rt4mr1619187lbb.3.1418300739852; Thu, 11 Dec 2014 04:25:39 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.74 with SMTP id q10ls299474laq.43.gmail; Thu, 11 Dec 2014 04:25:39 -0800 (PST) X-Received: by 10.152.7.193 with SMTP id l1mr9389380laa.57.1418300739616; Thu, 11 Dec 2014 04:25:39 -0800 (PST) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id s4si1081622las.118.2014.12.11.04.25.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Dec 2014 04:25:39 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id p9so3944155lbv.7 for ; Thu, 11 Dec 2014 04:25:39 -0800 (PST) X-Received: by 10.152.45.41 with SMTP id j9mr9659807lam.59.1418300739189; Thu, 11 Dec 2014 04:25:39 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp504881lbb; Thu, 11 Dec 2014 04:25:38 -0800 (PST) X-Received: by 10.224.166.67 with SMTP id l3mr19002173qay.15.1418300737626; Thu, 11 Dec 2014 04:25:37 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w7si1052932qcg.40.2014.12.11.04.25.36 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 11 Dec 2014 04:25:37 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:50564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz2oK-0004tY-LO for patch@linaro.org; Thu, 11 Dec 2014 07:25:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz2iz-0004s8-Qf for qemu-devel@nongnu.org; Thu, 11 Dec 2014 07:20:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xz2iy-0007GQ-Gj for qemu-devel@nongnu.org; Thu, 11 Dec 2014 07:20:05 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:54567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz2iy-0006sg-Am for qemu-devel@nongnu.org; Thu, 11 Dec 2014 07:20:04 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Xz2iq-0001B1-WD for qemu-devel@nongnu.org; Thu, 11 Dec 2014 12:19:57 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 11 Dec 2014 12:19:52 +0000 Message-Id: <1418300395-4348-31-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1418300395-4348-1-git-send-email-peter.maydell@linaro.org> References: <1418300395-4348-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 30/33] arm_gic_kvm: Tell kernel about number of IRQs 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Newer kernels support a device attribute on the GIC which allows us to tell it how many IRQs this GIC instance is configured with; use it, if it exists. Signed-off-by: Peter Maydell Reviewed-by: Christoffer Dall Message-id: 1417718679-1071-1-git-send-email-peter.maydell@linaro.org --- hw/intc/arm_gic_kvm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c index 5038885..1ad3eb0 100644 --- a/hw/intc/arm_gic_kvm.c +++ b/hw/intc/arm_gic_kvm.c @@ -92,6 +92,21 @@ static bool kvm_arm_gic_can_save_restore(GICState *s) return s->dev_fd >= 0; } +static bool kvm_gic_supports_attr(GICState *s, int group, int attrnum) +{ + struct kvm_device_attr attr = { + .group = group, + .attr = attrnum, + .flags = 0, + }; + + if (s->dev_fd == -1) { + return false; + } + + return kvm_device_ioctl(s->dev_fd, KVM_HAS_DEVICE_ATTR, &attr) == 0; +} + static void kvm_gic_access(GICState *s, int group, int offset, int cpu, uint32_t *val, bool write) { @@ -553,6 +568,11 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) return; } + if (kvm_gic_supports_attr(s, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0)) { + uint32_t numirqs = s->num_irq; + kvm_gic_access(s, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0, 0, &numirqs, 1); + } + /* Distributor */ memory_region_init_reservation(&s->iomem, OBJECT(s), "kvm-gic_dist", 0x1000);