From patchwork Wed Mar 21 16:32:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 132205 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp2355763ljb; Wed, 21 Mar 2018 09:34:43 -0700 (PDT) X-Google-Smtp-Source: AG47ELsIZKM3vP4T3knARNNEQHssU1M7olpR4D1clPMOTTp0ERnVL2/6LPA9GUjgFkFdi5rECSF3 X-Received: by 10.107.43.7 with SMTP id r7mr20976131ior.302.1521650082900; Wed, 21 Mar 2018 09:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521650082; cv=none; d=google.com; s=arc-20160816; b=yY5E+qB8mMXtdHNjooH0/WfAIbUIiRZI4WWCGcMyXUxXd0YTe9dRHfE+1E3SWOPwPj O2pya9C56vXFIpRNGKn/7rzUA2hHzZYA0X5YB9gp9rB4r6Qip6crhAtQoerGjZe7ltd4 cuwClw1roGFTChNPw42t/SnGnUUJNUPCN9jA94yixcRJCTM0YygRY9VXNoHT+2lsU38F HaujKzgdaQ92rqNgIp2W9LwlBtVJS4cNaYTen+3pdc4d6K4vLcqAVZtTPXHFLeCRhk8A 8xN1F96eoD7jMWaupoSJF8559As7yoKPg4K2UjFKwrvIl6EOg+iqCpPppfC+J9ChgvYR iUxw== 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:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=+hIUNOWsBgDSsxwZblG4ZG/tzFohb77DwAAA48xboeI=; b=phmEw+rZPbw4nTsrn7tn6EWKJdCTBchhCZqRr4Uwxrdoxkyj4z2bwLDpNXq+m9kwIa I4kIQ9YGI/SVtZ5ofQTykom7TQE4ilTCcDEuC3UWxJcDK06rNWSTcVoXy3l+l9erLX7I VPkTP3UroMA12Q8Ggr3IteVVNniP/qw29UPS8O2gtp2cFOIi+DGTxRnUzmkHOAgnbT29 4NvacTjJ0doPsFp2LoQ2oZHK7QgwrbIGQ1LElhiThAm9230W3SPwsdYyAYgcVPXAnFF7 4rjwXpxAZkrdcFm4lqy+xt4NaV3h8RqKiVCaLLY60wy7y8BKfv2bIIZsL4CRrbyNwxWE 3UUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GqjxOL+C; 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 y140si3563715iof.236.2018.03.21.09.34.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Mar 2018 09:34:42 -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=GqjxOL+C; 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.89) (envelope-from ) id 1eygfl-0002Kn-65; Wed, 21 Mar 2018 16:33:09 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1eygfj-0002HQ-IX for xen-devel@lists.xenproject.org; Wed, 21 Mar 2018 16:33:07 +0000 X-Inumbo-ID: 7f1a20cc-2d25-11e8-9728-bc764e045a96 Received: from mail-wr0-x243.google.com (unknown [2a00:1450:400c:c0c::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 7f1a20cc-2d25-11e8-9728-bc764e045a96; Wed, 21 Mar 2018 17:32:51 +0100 (CET) Received: by mail-wr0-x243.google.com with SMTP id l8so5837796wrg.5 for ; Wed, 21 Mar 2018 09:33:05 -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=fjcrWXQWMqfReYsDQw7daa0k1+KL9kJqj6K+8Z6B8iA=; b=GqjxOL+CT5LBL8TSePHTsCVPrUJVLZ9oqZ0x2g6Ccz2+MXoelnkMipLZnhjjErS1o/ UWWNUJ0SJcqkzVpLuMH2NO+/q8oj48cPgXL8M5szZ+F2Gf6MXTiDy3Ceh0iZS76jsgq/ Igmn3f7R0VSoIcHKdC+AAndhHljj2GtZngaNc= 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=fjcrWXQWMqfReYsDQw7daa0k1+KL9kJqj6K+8Z6B8iA=; b=YlcV+VeIqQrmuguCm1lJyaO1JdxocBeAG+xzu8R2QjcflP9QBIXC/P1Y4FnanbUaA7 2ozXti3x1TVtyZhkp+85COcV6f5mLzvwkQ66rbBuE/xNze4xUe2cEjmg5eIRQ4xACPkI Sgd9U/7AEH1men56Q9YcuZweoJBHuHtsjDGQBYzthp5jedA2LV8f1WiVrtHlzECjUw7Z HdC2gMlAq4cJo0EQa3nTBtGYqldhlNbRd5vFctiPv4fbw5QewOncWN6pAY2jicrV5GxG NQ4pDcrCxZM45pugC2pwa5yg7Vz1/xH47vaXAo6odw5BEdz2lQr6uyzV1gdh8dpoGa3r zGyg== X-Gm-Message-State: AElRT7FcuN64Bkgko5QrAYB0EegvEd0qvZI5ksPf3qXWRQi0xfyxz44R s5shBi3DD4H/xO/r7NVNH19h3Q== X-Received: by 10.223.152.142 with SMTP id w14mr18108284wrb.210.1521649984629; Wed, 21 Mar 2018 09:33:04 -0700 (PDT) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id n64sm4423724wmd.11.2018.03.21.09.33.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Mar 2018 09:33:03 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Wed, 21 Mar 2018 16:32:11 +0000 Message-Id: <20180321163235.12529-16-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180321163235.12529-1-andre.przywara@linaro.org> References: <20180321163235.12529-1-andre.przywara@linaro.org> Subject: [Xen-devel] [PATCH v3 15/39] ARM: new VGIC: Implement vgic_vcpu_pending_irq X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, Andre Przywara 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 Reviewed-by: Julien Grall Acked-by: Stefano Stabellini --- Changelog v2 ... v3: - adjust vgic_vcpu_pending_irq() to return integers, not false/true 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 2fa595f4f7..925cda4580 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -647,6 +647,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; + unsigned long flags; + int ret = 0; + + if ( !vcpu->domain->arch.vgic.enabled ) + return 0; + + 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); + ret = irq_is_pending(irq) && irq->enabled; + spin_unlock(&irq->irq_lock); + + if ( ret ) + break; + } + + spin_unlock_irqrestore(&vgic_cpu->ap_list_lock, flags); + + return ret; +} + /* * Local variables: * mode: C