From patchwork Thu Dec 4 18:44:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 41948 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5E28F25E8C for ; Thu, 4 Dec 2014 18:44:43 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf11484137eek.8 for ; Thu, 04 Dec 2014 10:44:42 -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:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=0NPmQc2KdtCHeeJ7PodngQPGden1hCDVlcwkHOOVOOI=; b=JBs9I9H8biz0qY9LT7qLrdIGRfPhJQkWxKH1c1p+WaGQLqTQmn0MSX+/jbojePmyAy KePQkKdjktkL7JmAb2HYL1bMlriHi84B17cEcK5YhfDXtwQPDVBJO9lfTUWF9zMzacIg r+V6vwT4bD4sPAs54UZTsweWhLM/Wx8myZ6s25yAd6336Zusvab3XcVDzQYUvPJBr7nF p8EvOVSVq9R8rWmUZevP2P9Gto1+hAM9J+ZIjfY4BPDV31rd24/k3c1MgN1SV74RqKBO ISvwMDWbtsL3ApGSd5Kp8BgqqasVFc/j9m8AB/aGr6THQRnM2R6RIN1ZJivff387TBcr jIlQ== X-Gm-Message-State: ALoCoQkD8fWKLfKz3cdCtH67ucqRyR0GKWzfC0yWpE52/SKQhZFow9P7TsI/9U/Tb6bMSrkt34Me X-Received: by 10.112.138.234 with SMTP id qt10mr2584173lbb.4.1417718682590; Thu, 04 Dec 2014 10:44:42 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.39 with SMTP id b7ls267594lae.38.gmail; Thu, 04 Dec 2014 10:44:42 -0800 (PST) X-Received: by 10.112.170.7 with SMTP id ai7mr11085999lbc.67.1417718682193; Thu, 04 Dec 2014 10:44:42 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id ls2si26722043lac.124.2014.12.04.10.44.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Dec 2014 10:44:41 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id u10so14892093lbd.34 for ; Thu, 04 Dec 2014 10:44:41 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr10914549lal.29.1417718681739; Thu, 04 Dec 2014 10:44:41 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp90076lbc; Thu, 4 Dec 2014 10:44:41 -0800 (PST) X-Received: by 10.180.9.229 with SMTP id d5mr23541562wib.22.1417718681201; Thu, 04 Dec 2014 10:44:41 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id l10si6653538wix.41.2014.12.04.10.44.40 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 04 Dec 2014 10:44:41 -0800 (PST) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1XwbOJ-0000Hk-1p; Thu, 04 Dec 2014 18:44:39 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Christoffer Dall Subject: [PATCH] arm_gic_kvm: Tell kernel about number of IRQs Date: Thu, 4 Dec 2014 18:44:39 +0000 Message-Id: <1417718679-1071-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 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.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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);