From patchwork Mon Dec 15 16:37:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 42261 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 C48EA26C69 for ; Mon, 15 Dec 2014 16:40:18 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf7812450eek.8 for ; Mon, 15 Dec 2014 08:40:18 -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:cc: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=lTck3Q2ebwS2bukLh6UwfVRS6nBKBgy4oQ2Iru8ERCs=; b=fW/+LtP/CbgstRzGJ7c5DKhAu1r4GtgmJvckpkucqont/XlM5KOeoTgIANF/Y6pw4y JvPbSjwW1zQqDiW56EEdefSynGDPz0fklm0dnYaB7RwVCLMQ84tC1fof5tKexmuMsYHA iD9G2XL7naD1VUiTP998EgZnfXn4CrANi3PoW7yXRgZHZOdJR+Sck1aLLyL/xIgA7GTA Imif05Asmcr4FSvZxENWwc2ejRRyo9norDWUquwVuUN2FNLyh0YNtzn1qEzPHyS6xfSn TH5lT9qRx7+h6R7y/6pUYuxsOx70FpC7QHvu4dfrsAJAcbLQXR7q3YOn4JJIFxhSyi5X 8TZw== X-Gm-Message-State: ALoCoQlomrKw+sMnI/wdOj9PBOLymCk784pXUA7IN2UzdsLG841yAFdyatEoYisDAGuIGqzpLRfS X-Received: by 10.112.146.104 with SMTP id tb8mr108973lbb.22.1418661618004; Mon, 15 Dec 2014 08:40:18 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.134 with SMTP id b6ls642248laa.27.gmail; Mon, 15 Dec 2014 08:40:17 -0800 (PST) X-Received: by 10.152.87.67 with SMTP id v3mr30398650laz.97.1418661617834; Mon, 15 Dec 2014 08:40:17 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id dd4si3336133lad.13.2014.12.15.08.40.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Dec 2014 08:40:17 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gm9so9628375lab.26 for ; Mon, 15 Dec 2014 08:40:17 -0800 (PST) X-Received: by 10.112.135.229 with SMTP id pv5mr31197094lbb.52.1418661617692; Mon, 15 Dec 2014 08:40:17 -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 ru5csp773056lbb; Mon, 15 Dec 2014 08:40:16 -0800 (PST) X-Received: by 10.140.104.169 with SMTP id a38mr54464819qgf.35.1418661616071; Mon, 15 Dec 2014 08:40:16 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o1si8536664qac.132.2014.12.15.08.40.15 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 15 Dec 2014 08:40:16 -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]:40563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Ygx-0006Va-2f for patch@linaro.org; Mon, 15 Dec 2014 11:40:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Yfd-0005Hc-Ci for qemu-devel@nongnu.org; Mon, 15 Dec 2014 11:39:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0YfV-000539-94 for qemu-devel@nongnu.org; Mon, 15 Dec 2014 11:38:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0YfV-00052z-2O for qemu-devel@nongnu.org; Mon, 15 Dec 2014 11:38:45 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBFGch1m028267 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 15 Dec 2014 11:38:43 -0500 Received: from playground.com (ovpn-112-26.ams2.redhat.com [10.36.112.26]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBFGcXOn031674; Mon, 15 Dec 2014 11:38:41 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 15 Dec 2014 17:37:47 +0100 Message-Id: <1418661511-22348-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1418661511-22348-1-git-send-email-pbonzini@redhat.com> References: <1418661511-22348-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Eric Auger Subject: [Qemu-devel] [PULL 03/47] KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks 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: pbonzini@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 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 From: Eric Auger Compute kvm_irqfds_allowed by checking the KVM_CAP_IRQFD extension. Remove direct settings in architecture specific files. Add a new kvm_resamplefds_allowed variable, initialized by checking the KVM_CAP_IRQFD_RESAMPLE extension. Add a corresponding kvm_resamplefds_enabled() function. A special notice for s390 where KVM_CAP_IRQFD was not immediatly advirtised when irqfd capability was introduced in the kernel. KVM_CAP_IRQ_ROUTING was advertised instead. This was fixed in "KVM: s390: announce irqfd capability", ebc3226202d5956a5963185222982d435378b899 whereas irqfd support was brought in 84223598778ba08041f4297fda485df83414d57e, "KVM: s390: irq routing for adapter interrupts". Both commits first appear in 3.15 so there should not be any kernel version impacted by this QEMU modification. Signed-off-by: Eric Auger Signed-off-by: Paolo Bonzini --- hw/intc/openpic_kvm.c | 1 - hw/intc/xics_kvm.c | 1 - include/sysemu/kvm.h | 10 ++++++++++ kvm-all.c | 7 +++++++ target-i386/kvm.c | 1 - target-s390x/kvm.c | 1 - 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c index 3e2cd18..f7cac58 100644 --- a/hw/intc/openpic_kvm.c +++ b/hw/intc/openpic_kvm.c @@ -248,7 +248,6 @@ static void kvm_openpic_realize(DeviceState *dev, Error **errp) kvm_irqchip_add_irq_route(kvm_state, i, 0, i); } - kvm_irqfds_allowed = true; kvm_msi_via_irqfd_allowed = true; kvm_gsi_routing_allowed = true; diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 20b19e9..c15453f 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -448,7 +448,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp) } kvm_kernel_irqchip = true; - kvm_irqfds_allowed = true; kvm_msi_via_irqfd_allowed = true; kvm_gsi_direct_mapping = true; diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 22e42ef..104cf35 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -45,6 +45,7 @@ extern bool kvm_async_interrupts_allowed; extern bool kvm_halt_in_kernel_allowed; extern bool kvm_eventfds_allowed; extern bool kvm_irqfds_allowed; +extern bool kvm_resamplefds_allowed; extern bool kvm_msi_via_irqfd_allowed; extern bool kvm_gsi_routing_allowed; extern bool kvm_gsi_direct_mapping; @@ -102,6 +103,15 @@ extern bool kvm_readonly_mem_allowed; #define kvm_irqfds_enabled() (kvm_irqfds_allowed) /** + * kvm_resamplefds_enabled: + * + * Returns: true if we can use resamplefds to inject interrupts into + * a KVM CPU (ie the kernel supports resamplefds and we are running + * with a configuration where it is meaningful to use them). + */ +#define kvm_resamplefds_enabled() (kvm_resamplefds_allowed) + +/** * kvm_msi_via_irqfd_enabled: * * Returns: true if we can route a PCI MSI (Message Signaled Interrupt) diff --git a/kvm-all.c b/kvm-all.c index 937bc9d..c86626f 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -120,6 +120,7 @@ bool kvm_async_interrupts_allowed; bool kvm_halt_in_kernel_allowed; bool kvm_eventfds_allowed; bool kvm_irqfds_allowed; +bool kvm_resamplefds_allowed; bool kvm_msi_via_irqfd_allowed; bool kvm_gsi_routing_allowed; bool kvm_gsi_direct_mapping; @@ -1584,6 +1585,12 @@ static int kvm_init(MachineState *ms) kvm_eventfds_allowed = (kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0); + kvm_irqfds_allowed = + (kvm_check_extension(s, KVM_CAP_IRQFD) > 0); + + kvm_resamplefds_allowed = + (kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0); + ret = kvm_arch_init(s); if (ret < 0) { goto err; diff --git a/target-i386/kvm.c b/target-i386/kvm.c index ccf36e8..3a3dfc4 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -2563,7 +2563,6 @@ void kvm_arch_init_irq_routing(KVMState *s) * irqchip, so we can use irqfds, and on x86 we know * we can use msi via irqfd and GSI routing. */ - kvm_irqfds_allowed = true; kvm_msi_via_irqfd_allowed = true; kvm_gsi_routing_allowed = true; } diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 50709ba..1b79c4d 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -1294,7 +1294,6 @@ void kvm_arch_init_irq_routing(KVMState *s) * have to override the common code kvm_halt_in_kernel_allowed setting. */ if (kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) { - kvm_irqfds_allowed = true; kvm_gsi_routing_allowed = true; kvm_halt_in_kernel_allowed = false; }