From patchwork Thu Mar 15 20:30:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 131840 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp1579128ljb; Thu, 15 Mar 2018 13:33:16 -0700 (PDT) X-Google-Smtp-Source: AG47ELv/W1eiTxcGVTff2MwwjNeHfMXnuloZ2kVX+mSRp3bwYrGgNLXcd7d+H3mungwD6U1LawDe X-Received: by 10.107.20.131 with SMTP id 125mr10844290iou.239.1521145996276; Thu, 15 Mar 2018 13:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521145996; cv=none; d=google.com; s=arc-20160816; b=q8kjZI/nrLsvHpAJP+8HkCnUhjmkIsp0gmvd3Bu9uYSwRe8a47zX2sOXZA4G0nYYGd 560nl2TSn+lvMKqhWHG0abxnC4/kmDVu7JTz9/48+B9P+YCfxGbh160swgcyJkzmxLRh 0flR08jFhpjclfcFFhQSORiRxuU8yacKtwhLySoPvoppiPsrAgvMKFDd0WCzEMjUevre 1F+xmJ03T45za989/xBsLlXGcGv6eCMl/nXcgsfxq8GTY2dqaG1svxeXqx7nVuQoeys6 h66mlP0YH+4ROBtnrFcXROTW/kvi0+npDsrv54y/m/yzTqjMXhouE24HG0pVzttwSqOq Cxug== 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=b6Cn/+Yj8Wxd+gFpHJJ6Ow1QOc0gDVPgcjCczEHudro=; b=u3jGFI2AwyZ/EP0ktcYgHUSa1ve2mdydc3nudZ4Jm+TOhkYx+AVZImqM3jZsVdPgpI ixtN0OBYjOfu1st7sYZqpS1yUe1KdiDVQXnuw0SvP+zGvud1lNGC4RIyG2CDexgLG+98 zpj5O+9DhOdr5gfME2A36coSEOSE7x+yMge9Y421C2nHj9UgcsyBQSXek9C3/rpuMU/T ZpZDKpN1MK+X/xltbfTJDzUTWTOFaNrYIrxevIV5FssG/sD+FTIOmlXy73BwrwntWaxX ME92TE1Jc7n2mWvlB5jzn8lWO+jKLGFYpJFsdM80HUZhwC/+U3aDvlUd1+VLnq1R8kIf vptg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WbNbnZU2; 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 e86si2996461ioj.308.2018.03.15.13.33.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 13:33:16 -0700 (PDT) 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=WbNbnZU2; 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 1ewZXB-0003d0-1y; Thu, 15 Mar 2018 20:31:33 +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 1ewZXA-0003aF-1L for xen-devel@lists.xenproject.org; Thu, 15 Mar 2018 20:31:32 +0000 X-Inumbo-ID: d4252c0b-288f-11e8-9728-bc764e045a96 Received: from mail-wm0-x243.google.com (unknown [2a00:1450:400c:c09::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id d4252c0b-288f-11e8-9728-bc764e045a96; Thu, 15 Mar 2018 21:31:24 +0100 (CET) Received: by mail-wm0-x243.google.com with SMTP id n3so31685wmd.1 for ; Thu, 15 Mar 2018 13:31:30 -0700 (PDT) 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=8K6wv2kF5qTjx5i0vUVQEiAYO9tj5QDWkqY7qc/CyFo=; b=WbNbnZU2Hr+NIO0SXZopm6UbsCkH9mz2RGf4KjaRTWOqSmEtMFJhW4PBMutgoFpRxt 2kGJWx4Pdz1g9QFKzxSNOHWVfoY4YKah6nmkufqKTbs/QHncO5d3Vgb1UwHNoUr3G+KM eiK1vbCiUf3avv7kLbMgo5BskzMZh1Xy/h1/o= 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=8K6wv2kF5qTjx5i0vUVQEiAYO9tj5QDWkqY7qc/CyFo=; b=UCF6Bgmk919E1Qi00MeLuQKno6SsUH4d/EMPOGupogJgt7Xkm8mDtCxuikU+exFH+L tWy96dFtLxxMLCgT3DCFFbr/TDUvtSYX8sQ6e8AYHqnGVYdBoy1IlW0u6U2NjA0i3dcD WN6d+yVCdG/fpj46SCG3dFDfZg0GY5AQo3Qo7pIwInsGBXAqzk7+24dT+NmtKS457YaG +u7dkwqP08nct2NIS6GseT/jA65YFaAg1yq+lqufC2fQrqj7PcSe8WuHUzigwQZngmdE 2NRH7TdrgZy0blXx5NGHXD2x+IPRhks9YCZeGvPSEe+EZu8jXN7T9ubN5d7OW8t7V5kp dl8g== X-Gm-Message-State: AElRT7EHJb2wCiMMQmag4awseyzKFKpEK5f6l4m8IX0ZofmTt/XTjqk6 jMYMgEnNEH4F64omgOvPX8dKMA== X-Received: by 10.28.214.194 with SMTP id n185mr6127522wmg.73.1521145889019; Thu, 15 Mar 2018 13:31:29 -0700 (PDT) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id w125sm3217102wmw.20.2018.03.15.13.31.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Mar 2018 13:31:28 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 15 Mar 2018 20:30:26 +0000 Message-Id: <20180315203050.19791-22-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180315203050.19791-1-andre.przywara@linaro.org> References: <20180315203050.19791-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v2 21/45] 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 v1 ... v2: - adjust to new vgic_vcpu_pending_irq() prototype, drop wrapper 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 035c8c8f74..a1556e53e8 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -637,6 +637,43 @@ void vgic_sync_to_lrs(void) gic_hw_ops->update_hcr_status(GICH_HCR_EN, 1); } +/** + * vgic_vcpu_pending_irq() - determine if interrupts need to be injected + * @vcpu: The vCPU on which to check for interrupts. + * + * Checks whether there is an interrupt on the given VCPU which needs + * handling in the guest. This requires at least one IRQ to be pending + * and enabled. + * + * Returns: 1 if the guest should run to handle interrupts, 0 otherwise. + */ +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; +} + /* * Local variables: * mode: C