From patchwork Fri Feb 9 14:39:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127823 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp679625ljc; Fri, 9 Feb 2018 06:42:00 -0800 (PST) X-Google-Smtp-Source: AH8x226KHTVHxiI+x09WkP+KtjIyUyT8nLZ276SO25VhKRMbBTTCOM9Uc9WQ6+DKq9alld9wxTrv X-Received: by 10.36.41.72 with SMTP id p69mr3850640itp.18.1518187320471; Fri, 09 Feb 2018 06:42:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518187320; cv=none; d=google.com; s=arc-20160816; b=VuFTYU2+ila/vzbXUUKc+J0pFC2zk5ukRFe/swY2vyNZE8x22hhS+EsmmlSyWzYgUP TvuVYiiNzePm4/y6l+fvOXrUdsVgHvs9JS/EBU0cvdk1Q52fUuhXudjhibenFXHjRhaI jgGNQ0q+4f1xebV8q+J3y83A+rILbZnGbwKmZPezbMh2JfMZoSuM5c2yzibwWd0LSmGV yU9VNlAxKs4ISEFPHrWySGaT6mxnwkA8Vh0cbH5KgclmzYLw1s+M8lDVztDNO6M7XBR9 iEHdLEwitqdjEo6xz7dCoUobb26Y3bqvM5Fho3YefK/Ay7uvHM3tJtq2kdmYYfsZRei7 w1Rg== 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:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=+5tW3sEyabE5zAhV9mQFhrPes+PrzXkahniwyIlqxi4=; b=rUi0TuV4QYRYvjV+D5s2QGJ5x/TpkBehytd3hd+vLWFomdA52lW1d3o2R8U6HJ6kb2 BA/ffTLBX7d4uV+T2qpGSkv3FgsAE0CYT7i2bZMKp3fqKgN/g6yIGqYauVxFPh8ycAfV GYOr987RtLXnW3rdYWUWf6SZSX4GLYmwLRZU3IJaQBQE1/neMp7E0yNdcEVR1DVkkMbx 6EVxlT/DkfxTLSxq5iBNzAcQkOLIlto5Mu7elRIa/TdDDTKlFkLXOdVJzybpIOaI5McN EOk/Gc3U8wx+lA5ooNSWPtnivE1N/1YORJBazxEsxeDCySaV3yU0mPIb1X8fFg3M/G5/ 0cJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZZBqQ7yz; 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 f90si1636146ioi.246.2018.02.09.06.42.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 06:42:00 -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=ZZBqQ7yz; 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 1ek9qa-0000uB-Hm; Fri, 09 Feb 2018 14:40:16 +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 1ek9qY-0000pG-Me for xen-devel@lists.xenproject.org; Fri, 09 Feb 2018 14:40:14 +0000 X-Inumbo-ID: 12119528-0da7-11e8-ba59-bc764e045a96 Received: from mail-wm0-x244.google.com (unknown [2a00:1450:400c:c09::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 12119528-0da7-11e8-ba59-bc764e045a96; Fri, 09 Feb 2018 15:39:45 +0100 (CET) Received: by mail-wm0-x244.google.com with SMTP id j21so4255560wmh.1 for ; Fri, 09 Feb 2018 06:40:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=TQ5sZNE5L+cFBfwD20qDu443gHTrLJ10+9zEUql6gCA=; b=ZZBqQ7yzCIi6r4ssJbKUBxedKzq3HZwM+T6wDEXWtz3M9/x0Jy6Cj5XoK/jOs96GDX fVjH8fnp5WUE4PyBJeVUsf3vO2S/tu936yAW3ybHYRLP1FzI2SyRYWOZDg9TEn84rD+x aN8OTKZhmzFkPlF0VglnkGuQUOg0W7H7SxsIg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=TQ5sZNE5L+cFBfwD20qDu443gHTrLJ10+9zEUql6gCA=; b=MWZm2MSdAuRDFyIrN07HgKBv8V98eRSSCjFu5+NwqlcNM74NV3kFvfYj4jMyYlbPay zPbT/+EruKfOREaJSPyfuOxHRkFwLUTMOhhcl3kx5eCBH0C7J3TQneBm58leMK7zEMhO VHzCrBDCYoUq6AO25fD9NSOXGeOw+K2IEapK3NZ826ZNyfOAEpNXO4YXVLwh4S2d5muy E8wBJ/ds72vmmbPlIDQ/Gj/nKxHoQcxsObmANxYJ5Y724Dsp/88hQKk3CeWFRLiS4/HG JTGHcoeoCtr8vQkRCzYZ0XOmuHxSA+rMEpzvUmZRRe+gImLOGz/Mmzrzoe6PlfF2zuPe UqkQ== X-Gm-Message-State: APf1xPA4DMgl2r5ADF7CP/MOLiciZVu/hvZaHJ7c8j22RDiA5ADz+3kv tMe5+IcSZSMt6Yn4rlH/lJCo+JdT+2k= X-Received: by 10.28.120.15 with SMTP id t15mr2296230wmc.34.1518187212698; Fri, 09 Feb 2018 06:40:12 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id b35sm2552229wra.13.2018.02.09.06.40.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:40:12 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall , xen-devel@lists.xenproject.org Date: Fri, 9 Feb 2018 14:39:14 +0000 Message-Id: <20180209143937.28866-27-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180209143937.28866-1-andre.przywara@linaro.org> References: <20180209143937.28866-1-andre.przywara@linaro.org> Subject: [Xen-devel] [RFC PATCH 26/49] 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. This is based on Linux commit 90eee56c5f90, written by Eric Auger. Signed-off-by: Andre Przywara --- xen/arch/arm/vgic/vgic.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index f4f2a04a60..9e7fb1edcb 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -646,6 +646,38 @@ void gic_inject(void) vgic_restore_state(current); } +static int vgic_vcpu_pending_irq(struct vcpu *vcpu) +{ + struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; + 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; +} + +int gic_events_need_delivery(void) +{ + return vgic_vcpu_pending_irq(current); +} + /* * Local variables: * mode: C