From patchwork Thu Dec 7 16:14:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 121015 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8556196qgn; Thu, 7 Dec 2017 08:16:34 -0800 (PST) X-Google-Smtp-Source: AGs4zMbHRuGR18xgz+tkMdTa+hpjccJFeZH70zFLBqcd9Z+vm6zNrUi9pB6ehXj+DBmtxXMVH9ks X-Received: by 10.107.159.13 with SMTP id i13mr37031564ioe.300.1512663394202; Thu, 07 Dec 2017 08:16:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512663394; cv=none; d=google.com; s=arc-20160816; b=TKuLC+gM0KZ+8dPSwpTWm40IjEXVy3K8HotjHfAoNhqeGfdxI3g2ya4/2Xg+rzGBWE FLzMaLap7ULDIq0aEQ3yKvyuoi93C6pZFinM+9d76Vsk9w59xNva2B1QhdhI5YVpEdsf R4tOwiXDmqOP7ppBMM57gGVC+om5GWTgu53vvLxxrFvqoPd+fQch5nJJb06yL8MV/jqA rIAC4VaRc48whfwBwWSE8F7PIPA4XVle7lXZR+Vum1w1rgT5vewIrtMI6C2TVTyVVmkR S6ZWGG7tZJlVKuyHzVZkSj5hOTdvmgladLN01WU+ELQ0cx3cG+kRivavNJc4f3AYWubT 4SCw== 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=y5ktjJOtWPYWWuE5kkDxIRcwaIzR764pgG3fZeHlgKg=; b=tCtK02UtB7wF3C0ijGE7PuMPd7gBc5NgzT4hZ+A3TeAKrhTAfCNtxXQ1aEJl8pKW1P W+3Fyi7ZwU4MkFyqxoax5CKH3Hm5wNY3Xa/LBetyMamCjlHei+IuUJaeQ9tMs/q3yFYN szxGXYAp8JfzPlZP6XlCM6YAbeHnT/nppXYYQ2kiQ+DJQ2ZauauRSjs6vDagTlyVwt2u K1PNRlzRLnQ+wCtq/kfr3uZUxtsxKWH1pX+spoN19cBwk5Rz9ENIne5GB9kppISX/Xsb yTMhtYqnN4kk0Kw/EH22zlDdgkWFjTmjIUyhM7gJ0ULGDPa9AKtuc+/iVXEAOocAiZnk +eLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RRQj60Hs; 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 f12si3714885ioi.227.2017.12.07.08.16.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 08:16:34 -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=RRQj60Hs; 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 1eMyoa-0002E8-Mk; Thu, 07 Dec 2017 16:14:24 +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 1eMyoZ-0002CI-1S for xen-devel@lists.xenproject.org; Thu, 07 Dec 2017 16:14:23 +0000 X-Inumbo-ID: a142d345-db69-11e7-b4a6-bc764e045a96 Received: from mail-wr0-x243.google.com (unknown [2a00:1450:400c:c0c::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id a142d345-db69-11e7-b4a6-bc764e045a96; Thu, 07 Dec 2017 17:13:58 +0100 (CET) Received: by mail-wr0-x243.google.com with SMTP id h1so8026371wre.12 for ; Thu, 07 Dec 2017 08:14:22 -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=y2XBjnEYIfuZ5jl1LOVuPCnbzrc4ymsXrUWOdhKwxEc=; b=RRQj60HsRae6xk/DWcBehN5Tz1hNHjGZeEdgoYel1XMPH0FvfDGgpG0SujKRmoI94P 91CKiwPcDNub1o/8E1sUzG1J2xqCJFUjEuy185IGxdydQqO5sqQqLXw1oE1jPJBwlGyg veZBjKOJV9KjfFY+otA5JdFnBewoyKbyz0qgA= 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=y2XBjnEYIfuZ5jl1LOVuPCnbzrc4ymsXrUWOdhKwxEc=; b=sYcY2RlvpX1i3eW8xDZp+xkkRQSQaynIAsEJrRStuHnOwTgbCaAQpdrCbg4EegiR2t jANtvI2myl/b0GNV+0zEySkkQJg+9oGrFprEXXdebE9JiJDTKZ+6Kn53ABiQLYNdPr1W ZKEQUvEBGxBnAVDdjZtbakLmunDmyL6i0fpPkc8JzQuBc3vQ0dMJ+cVOWq5/mV4O+QN4 FeppRnCiB7vDXMy0c/h6rgMfLJrhFkmO+Y3Vlbk0LwvgyRcZ6OIjAS6347pGUzIghsTi 7b9JdHCTTkTOBKmeVOXXUignM9U7/X3VnsAM2kBSX4XD1KNnQx2B1P23umarpL/HvOD5 RUeA== X-Gm-Message-State: AJaThX4OKdDVZe/F8z0US6qbOnHnY9En4SrtCvJDKzHVnpLbdgaNAY8A 3YlQeGnAPFFq2TQvkJuvwVQ1pA== X-Received: by 10.223.130.177 with SMTP id 46mr25909698wrc.176.1512663261224; Thu, 07 Dec 2017 08:14:21 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id f18sm6090624wrg.66.2017.12.07.08.14.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Dec 2017 08:14:20 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 7 Dec 2017 16:14:12 +0000 Message-Id: <20171207161415.20380-8-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171207161415.20380-1-andre.przywara@linaro.org> References: <20171207161415.20380-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v2 07/10] ARM: VGIC: rework events_need_delivery() 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" In event.h we very deeply dive into the VGIC to learn if an event for a guest is pending. Rework that function to abstract the VGIC specific part out. Also reorder the queries there, as we only actually need to check for the event channel if there are no other pending IRQs. Signed-off-by: Andre Przywara Reviewed-by: Stefano Stabellini --- xen/arch/arm/vgic.c | 11 +++++++++++ xen/include/asm-arm/event.h | 13 +++---------- xen/include/asm-arm/vgic.h | 2 ++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 6e933a86d3..9921769b15 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -593,6 +593,17 @@ void arch_evtchn_inject(struct vcpu *v) vgic_vcpu_inject_irq(v, v->domain->arch.evtchn_irq); } +bool vgic_evtchn_irq_pending(struct vcpu *v) +{ + struct pending_irq *p; + + p = irq_to_pending(v, v->domain->arch.evtchn_irq); + /* Does not work for LPIs. */ + ASSERT(!is_lpi(v->domain->arch.evtchn_irq)); + + return list_empty(&p->inflight); +} + bool vgic_emulate(struct cpu_user_regs *regs, union hsr hsr) { struct vcpu *v = current; diff --git a/xen/include/asm-arm/event.h b/xen/include/asm-arm/event.h index caefa506a9..67684e9763 100644 --- a/xen/include/asm-arm/event.h +++ b/xen/include/asm-arm/event.h @@ -16,12 +16,6 @@ static inline int vcpu_event_delivery_is_enabled(struct vcpu *v) static inline int local_events_need_delivery_nomask(void) { - struct pending_irq *p = irq_to_pending(current, - current->domain->arch.evtchn_irq); - - /* Does not work for LPIs. */ - ASSERT(!is_lpi(current->domain->arch.evtchn_irq)); - /* XXX: if the first interrupt has already been delivered, we should * check whether any other interrupts with priority higher than the * one in GICV_IAR are in the lr_pending queue or in the LR @@ -33,11 +27,10 @@ static inline int local_events_need_delivery_nomask(void) if ( gic_events_need_delivery() ) return 1; - if ( vcpu_info(current, evtchn_upcall_pending) && - list_empty(&p->inflight) ) - return 1; + if ( !vcpu_info(current, evtchn_upcall_pending) ) + return 0; - return 0; + return vgic_evtchn_irq_pending(current); } static inline int local_events_need_delivery(void) diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index 2a93a7bef9..22c8502c95 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -218,6 +218,8 @@ extern void register_vgic_ops(struct domain *d, const struct vgic_ops *ops); int vgic_v2_init(struct domain *d, int *mmio_count); int vgic_v3_init(struct domain *d, int *mmio_count); +bool vgic_evtchn_irq_pending(struct vcpu *v); + extern int domain_vgic_register(struct domain *d, int *mmio_count); extern int vcpu_vgic_free(struct vcpu *v); extern bool vgic_to_sgi(struct vcpu *v, register_t sgir,