From patchwork Wed Sep 3 09:54:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 36542 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f69.google.com (mail-oi0-f69.google.com [209.85.218.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2EA58202E4 for ; Wed, 3 Sep 2014 09:54:43 +0000 (UTC) Received: by mail-oi0-f69.google.com with SMTP id a141sf1487060oig.8 for ; Wed, 03 Sep 2014 02:54:42 -0700 (PDT) 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:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=qkB0Yf9vsKjEZGh5yH2pKUUxJyBGM9DPPj+nYxX5hxc=; b=DOnX56BlW3tQOErv+fZeV2a4wyX5OxQGobk89mmy/SBCmCvvXs1s0SWaeW6PgX4oM5 ljlgkYeEH6q0EruxtpmC5jlFZkRu7U9Zv38LeCGC0JFrTF/d3VATmLvdCrnJpNSayTzy qH8jVj5tm9VQgMcaPk3YLyGevwAYfooFWzYspYGuAsyff3Zn8RG+cWh9lIB/EGWMEa6i 5NlUUIgFVWSMHXVkKRnkhSrCP68c2EYp8PWEru2EiBSXnbW2oCVsHFcziv/QOKAng3G0 l+OGeH/P+uJxCSscMg8j8kKNZMVzpmbkpYEX3L1r3ddxxDxDJonnZofmZLO+NbkL2muz YLrQ== X-Gm-Message-State: ALoCoQmGeUJFW9N807bC98EvtS3TN/T3SHu5/lwW+s13ck65Jpkua9Yo6gu/O3fNI5jg4rDe0g0h X-Received: by 10.182.213.105 with SMTP id nr9mr23012089obc.36.1409738082669; Wed, 03 Sep 2014 02:54:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.46.100 with SMTP id j91ls2700963qga.44.gmail; Wed, 03 Sep 2014 02:54:42 -0700 (PDT) X-Received: by 10.220.168.210 with SMTP id v18mr34447937vcy.3.1409738082598; Wed, 03 Sep 2014 02:54:42 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id xe7si3396058vcb.14.2014.09.03.02.54.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Sep 2014 02:54:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id la4so8631899vcb.1 for ; Wed, 03 Sep 2014 02:54:42 -0700 (PDT) X-Received: by 10.52.102.204 with SMTP id fq12mr22501539vdb.26.1409738082516; Wed, 03 Sep 2014 02:54:42 -0700 (PDT) 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.221.45.67 with SMTP id uj3csp654493vcb; Wed, 3 Sep 2014 02:54:41 -0700 (PDT) X-Received: by 10.194.174.202 with SMTP id bu10mr45983311wjc.70.1409738081314; Wed, 03 Sep 2014 02:54:41 -0700 (PDT) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by mx.google.com with ESMTPS id t5si9535425wja.121.2014.09.03.02.54.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Sep 2014 02:54:41 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.179 as permitted sender) client-ip=209.85.212.179; Received: by mail-wi0-f179.google.com with SMTP id q5so9437782wiv.12 for ; Wed, 03 Sep 2014 02:54:40 -0700 (PDT) X-Received: by 10.194.205.102 with SMTP id lf6mr1852353wjc.112.1409738080899; Wed, 03 Sep 2014 02:54:40 -0700 (PDT) Received: from midway01-04-00.lavalab ([88.98.47.97]) by mx.google.com with ESMTPSA id gh1sm3606157wib.18.2014.09.03.02.54.39 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Sep 2014 02:54:40 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, a.rigo@virtualopensystems.com, agraf@suse.de, aik@ozlabs.ru, bsd@redhat.com, pbonzini@redhat.com, peter.maydell@linaro.org, mtosatti@redhat.com, borntraeger@de.ibm.com, cornelia.huck@de.ibm.com, rth@twiddle.net, thuth@linux.vnet.ibm.com, afaerber@suse.de, qemu-ppc@nongnu.org Cc: eric.auger@linaro.org, kvmarm@lists.cs.columbia.edu, patches@linaro.org, alex.williamson@redhat.com Subject: [PATCH v2 1/2] KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks Date: Wed, 3 Sep 2014 10:54:09 +0100 Message-Id: <1409738050-3810-2-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1409738050-3810-1-git-send-email-eric.auger@linaro.org> References: <1409738050-3810-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@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.220.170 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: , 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. Signed-off-by: Eric Auger --- in practice KVM_CAP_IRQFD_RESAMPLE seems to be always enabled as soon as kernel has HAVE_KVM_IRQFD so the resamplefd check may be unnecessary. --- 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 e3bce04..6cef3b1 100644 --- a/hw/intc/openpic_kvm.c +++ b/hw/intc/openpic_kvm.c @@ -229,7 +229,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 174ea36..69c4d0f 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 b240bf8..d635942 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -116,6 +116,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; @@ -1548,6 +1549,12 @@ int kvm_init(MachineClass *mc) 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 ddedc73..2320920 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -2544,7 +2544,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 a85a480..f937568 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -1290,7 +1290,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; }