From patchwork Wed Dec 3 16:07:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 5431931 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 520249F472 for ; Wed, 3 Dec 2014 16:11:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B28BE200E0 for ; Wed, 3 Dec 2014 16:11:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0C752012E for ; Wed, 3 Dec 2014 16:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752146AbaLCQLg (ORCPT ); Wed, 3 Dec 2014 11:11:36 -0500 Received: from mail-wi0-f182.google.com ([209.85.212.182]:37816 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752446AbaLCQJL (ORCPT ); Wed, 3 Dec 2014 11:09:11 -0500 Received: by mail-wi0-f182.google.com with SMTP id h11so24938898wiw.15 for ; Wed, 03 Dec 2014 08:09:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Jucit/lAXd9wPEa1ZRWMQkhYc7v2fXpVCWukcy3/1nY=; b=mGZFx68PZ9EqK31KUDh4Ezs+4XmfOl6Bf9LAI4vL88fMfoINMgeeBVf/4TTZQ5946y FD78BEUHu0ABGCQ6vmiEEr5Ybq8c9LhuaRjtg6/QbdwYY9CCCUjwavzlmnK7YCpKkrh6 cGoDhgztetc2oeiMmgCkB4zNuE+O7j33GG6H1IX6Xv5bNNozCbo3QnO69y8HhT8jEhzR 25Hwe550g3x8cTmOxelG/9T04/kUPp+mOjB07oohB9NjO5x8zqP3nzNm3bW13H8dTmBW wo+l4obtj9Oz25aQoT8X4Ru+Qr6tRWc8UZgdTiz7SHB9KsB2MVoWPrv14CPhoQo3Xm0m WFFg== X-Gm-Message-State: ALoCoQkYOTeRmdllNZFW/He2+MqdnVFWtmEpV1ir5oi6FSq3zRpjBS9xHi+21izyfsFYcBbApdju X-Received: by 10.194.200.1 with SMTP id jo1mr8937072wjc.64.1417622949545; Wed, 03 Dec 2014 08:09:09 -0800 (PST) Received: from gnx2579.gnb.st.com (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id kn5sm36849121wjb.48.2014.12.03.08.09.07 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Dec 2014 08:09:08 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, alex.williamson@redhat.com, agraf@suse.de, joel.schopp@amd.com, gleb@kernel.org, pbonzini@redhat.com, borntraeger@de.ibm.com, cornelia.huck@de.ibm.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, a.motakis@virtualopensystems.com Subject: [PATCH v5 4/5] KVM: irqfd: use kvm_arch_is_virtual_intc_initialized Date: Wed, 3 Dec 2014 17:07:11 +0100 Message-Id: <1417622832-5460-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417622832-5460-1-git-send-email-eric.auger@linaro.org> References: <1417622832-5460-1-git-send-email-eric.auger@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On arm/arm64, the interrupt controller is dynamically instantiated. There is a risk the user-space assigns an irqfd before this latter is initialized and ready to accept virtual irq injection. On such attempt, the IRQFD setup is rejected and -EAGAIN is returned. Signed-off-by: Eric Auger --- virt/kvm/eventfd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index b0fb390..f837c83 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -314,6 +314,9 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) unsigned int events; int idx; + if (!kvm_arch_is_virtual_intc_initialized(kvm)) + return -EAGAIN; + irqfd = kzalloc(sizeof(*irqfd), GFP_KERNEL); if (!irqfd) return -ENOMEM;