From patchwork Mon Mar 5 16:03:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 130665 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2853677lja; Mon, 5 Mar 2018 08:07:05 -0800 (PST) X-Google-Smtp-Source: AG47ELv+p8ZogQ1deuR/1sq4dNbJYK3Oo8ICKEvZ0oHrKXqK5J3ksmiJqQ7lVlSWZw3mNrAPMPfk X-Received: by 10.107.163.78 with SMTP id m75mr14602437ioe.26.1520266025001; Mon, 05 Mar 2018 08:07:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520266024; cv=none; d=google.com; s=arc-20160816; b=WvzgL0TgcTwENC2+imxClPpRCnPDa3HNLQlltbHXlCBL4KIS2OCXP653aJ7X1KrMQx h8zsWqZwJRqIuksm22V0sSnEiEr2ohI+6j00LGaXXVcyqcy++bTFM7/HFEy5JampU9lM WK8Uijrv0VUwwwGX1JMTUHDZVjdYvERE7fiwdx9xDErz2wQJ2zeUQz1V24V5Y21u3cht Bp5L7uCBS/bM44KCtctc4DR/OAB1XwBKUnyWLdF/Azn1HCoKpcNCr0nXbMYqOgM9G7wn jyejWVAJpdRrBTc9mcZbX15fZYUL9wf7JoosVld+KynKh6YkTett7TbqGHdAvxY/HDUN 1tKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=N9T7JNdo7esTvBEr47nPRDOYsrHfQJ6mTLJ0+FblZyw=; b=ZSYl1chYw4i9kegLhetCMWxvi071e4ohJ1gdTlcr+qrUPhwQsnmcpazD9kb8JKlG/R hGwOfqCfJnqnsdZj+vPUOFioBPtquEuZgSFo6wEGf7TlmeEuL2BH0FLqQVfEBvEAHfGF x4d3ERM2ttvYO8YNQMA0bDem2ufEX+ki09sUsOMiW00IxKeS54yYVYnZrP2iOu79bn+i q3/QPBg3B0WKdxAvdRZw4ygVABjIhHYrTd2J+l9AEw7v8kK2RXqrYr7nIwky7M5YuM4S AsDKZd1ZFaESYbUPV8E4hAvX+EAQiCzWpGX3t4C7l59kbMEcuUQY47ENKSwvg8E+GYK5 UpgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SfepsSdU; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v36si9189687ioi.227.2018.03.05.08.07.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 08:07:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SfepsSdU; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1essbj-00087R-2I; Mon, 05 Mar 2018 16:04:59 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1essbh-000832-Gn for xen-devel@lists.xenproject.org; Mon, 05 Mar 2018 16:04:57 +0000 X-Inumbo-ID: cb6f085e-208e-11e8-ba59-bc764e045a96 Received: from mail-wr0-x242.google.com (unknown [2a00:1450:400c:c0c::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id cb6f085e-208e-11e8-ba59-bc764e045a96; Mon, 05 Mar 2018 17:03:51 +0100 (CET) Received: by mail-wr0-x242.google.com with SMTP id o76so17831602wrb.7 for ; Mon, 05 Mar 2018 08:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5k/J/LmAjl7IhlrI18/SGNlYlX5EntDZOAifR7EwCYU=; b=SfepsSdUDv9QugZuOlJAPxI/6JAXCFOLcUxuqQpWbZk9IYGJFmXw1EZe81u7aCkJjh txwvtZUFxMZNtqHrH0PuHe4HyIKZbnf8Mx1EPRnEyJapKRXeahCYbBzTV1kVEk2TDOmL SoeVYEjhvsGCe6WsCK7dpK4Unw0d7hTU28TN4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5k/J/LmAjl7IhlrI18/SGNlYlX5EntDZOAifR7EwCYU=; b=W2pUUo5v5sZgN5qgXwN+txcY+MglYZEnOgw0W83ICa6YUKuoyrxZRGndnhtUhE2qOg ExRUWEhuLdWxvfh42bR93PCPxulp7Bf8NHgVXLgcHsvJ0bTDXvylnQGI42SzKQi397cW BJqAVjG+nUrDqhtE7jXZw9PDEqxPxLwbNJ0gwYi70dHvnZvWCKPcnPO7KDfg7U/Rie5l Yafasr+funiQ6y+994PR09nje2ARZRgToMvI5/b5oNuxuqrn8W7XNWQjV1R4ptXGjpNM /jiMl6mYdQmUus1kfHW1WofA1xYMpvyhDbrCJ3eWywbyXsaXRGSEji9rABjthw8hsgNU jW4w== X-Gm-Message-State: APf1xPC1psi493FYi0pEHXZSR/dPN0Hf312aqCyO/2tGl4JlsZXAPLzG axxu4DBExS4WXfMCGscqFifZcQ== X-Received: by 10.223.187.72 with SMTP id x8mr12452016wrg.217.1520265895832; Mon, 05 Mar 2018 08:04:55 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id y6sm6574381wmy.14.2018.03.05.08.04.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Mar 2018 08:04:55 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Mon, 5 Mar 2018 16:03:51 +0000 Message-Id: <20180305160415.16760-34-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180305160415.16760-1-andre.przywara@linaro.org> References: <20180305160415.16760-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 33/57] ARM: new VGIC: Implement vgic_vcpu_pending_irq X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Tell Xen whether a particular VCPU has an IRQ that needs handling in the guest. This is used to decide whether a VCPU is runnable or if a hypercall should be preempted to let the guest handle the IRQ. This is based on Linux commit 90eee56c5f90, written by Eric Auger. Signed-off-by: Andre Przywara --- Changelog RFC ... v1: - extend commit message - use new function name xen/arch/arm/vgic/vgic.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index 85e39f6f42..66a366176a 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -646,6 +646,43 @@ void vgic_sync_to_lrs(void) gic_hw_ops->update_hcr_status(GICH_HCR_EN, 1); } +static int vgic_vcpu_pending_irq(struct vcpu *vcpu) +{ + struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic; + struct vgic_irq *irq; + bool pending = false; + unsigned long flags; + + if ( !vcpu->domain->arch.vgic.enabled ) + return false; + + spin_lock_irqsave(&vgic_cpu->ap_list_lock, flags); + + list_for_each_entry(irq, &vgic_cpu->ap_list_head, ap_list) + { + spin_lock(&irq->irq_lock); + pending = irq_is_pending(irq) && irq->enabled; + spin_unlock(&irq->irq_lock); + + if ( pending ) + break; + } + + spin_unlock_irqrestore(&vgic_cpu->ap_list_lock, flags); + + return pending; +} + +/** + * vgic_pending_irq() - determine if interrupts need to be injected + * + * Returns: 1 if the guest should run to handle interrupts, 0 otherwise. + */ +int vgic_pending_irq(void) +{ + return vgic_vcpu_pending_irq(current); +} + /* * Local variables: * mode: C