From patchwork Tue Feb 6 17:08:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127061 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3107843ljc; Tue, 6 Feb 2018 09:11:33 -0800 (PST) X-Google-Smtp-Source: AH8x227iefkUmYcmp4NAYYLSRdbYQf2YG7f7V3uy9lxBolAIlmyIzlHKZWNUUe93pAs3nghRj//G X-Received: by 10.36.124.1 with SMTP id a1mr4064763itd.92.1517937093467; Tue, 06 Feb 2018 09:11:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517937093; cv=none; d=google.com; s=arc-20160816; b=t+HRZb+JI43hWUiTTe807SD1z/v3qx3CX7F0NF6cG1ATCrYZJZ+jKhCle0eh3u8+Pq g7d2+VSP6EM9eyv1lLB9EYwEbbtT8GDi0HCmd7aXtqrpRsJ/ZzzlOITIPgqFo6eV2d67 G18WYsbn2DKzwy8rt8k5xtg7dmOgLCLiGqbnLat99IxENKe3ieWd94nMb7HM3Dl3IQ27 Bld8xHhK3aTnH3XTOGiRuROlTrCFR5VIByJ77swZH2+Jof8PIe2XS2RQiAHn9DghrrDy QRdWFUcpC8jvnPTJHZG8FJyusCqgb+gXc10mue+pH7ioIaqbrsP9Qglxc/6LGF92GiNw So4g== 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=M0RCpKwN/V9R1duxlG4gsDoAC2FZQSNCAaGEUvP/jEc=; b=OEMPxO3mAq21Ai7MEVO8/H7L3hGKWF39PHGfh7NTeDErpP+NFEcrh0fW/hB9V0xF72 1ZHkSgmmdplbI1NxF7qgrDAxrGzkpaKUjpzIJ6axJiwlvVFQltxAY8mWbjJZGYAtvWNm i9auSX63DbhG8GjDBkZ0kPdC/zXNzIbxu6WD7JcMSJH6OOySE3VzfSrG6Y9plopuOtCM NJZk8BvCOUVsWhs5ZYSgPeH7LyFxEi2a/k14xH5iU7rIYFY7IkVtdKSb9A4tMQDCxIXP T7Z+sMB1ZnaHT9Sob5dQYaBIQObhI0lXYBzgcztGOk9QOYn9nAENRPy5wa9mh4Rbd7XB LkMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MmS8uvYs; 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 a1si40703ith.23.2018.02.06.09.11.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Feb 2018 09:11:33 -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=MmS8uvYs; 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 1ej6kA-0003qu-9Z; Tue, 06 Feb 2018 17:09:18 +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 1ej6k8-0003pL-FJ for xen-devel@lists.xenproject.org; Tue, 06 Feb 2018 17:09:16 +0000 X-Inumbo-ID: 66cca04f-0b60-11e8-ba59-bc764e045a96 Received: from mail-wr0-x243.google.com (unknown [2a00:1450:400c:c0c::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 66cca04f-0b60-11e8-ba59-bc764e045a96; Tue, 06 Feb 2018 18:08:51 +0100 (CET) Received: by mail-wr0-x243.google.com with SMTP id w50so2732823wrc.2 for ; Tue, 06 Feb 2018 09:09:14 -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=/iFiRioaWybYXFPWnLQfwYwIxtm/qB+W/kdRHjA1yFo=; b=MmS8uvYsLMKRyWF4lsg721ATP9VGssxa+OvqhTZgwRUw8W2QczmeBs+Ehopb6SSvNe ykS54wzDxVp6zchHTkCyiIx7aZJqV3qmPW4xIXynQ2eXhf9nbqiJWr889D9FCXFpsqCa RXFW0zVPhnnUPeFEyEqJLZsSncopSrJzvIfr8= 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=/iFiRioaWybYXFPWnLQfwYwIxtm/qB+W/kdRHjA1yFo=; b=tiV9JOPzDoNipOBTXHkiz5uBut8OKW11intFvAGuPXag8tfdJxZFzNwrysClyEFf9W or1cEPEv5q8D+Nu3kcpM+7QB94/jJPMCzwgXUkLAncfSrV1vfPEwp8/Q+rA16AmQHkcx pABIyVWqQ/gjbj6v8ZPy0IM9rGHo2AWFTUNLncvT7JcBz9JKINmJ/kqxwm2SkNu9Dn30 U2wEEEXeaJxtGe+h/26omCbsEzTMw88NUCgw2+1JV7HmEUXVim95DyfeED7u/U42rBFr MAJMI2H2kAGz39KQcU18j81iqYURnw2Lwm7BX+9PcDV8M30xma4M3m6mRYAlrl+MRilr iPow== X-Gm-Message-State: APf1xPACNIdPUuW+32hPb5yBcHpg600ifYG9YRIKN/kpk6LYqN0HcSqN CP4dJIktrdSu5BF8VaEA3IEhlg== X-Received: by 10.223.138.164 with SMTP id y33mr2969639wry.224.1517936953726; Tue, 06 Feb 2018 09:09:13 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id n2sm7885819wra.41.2018.02.06.09.09.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Feb 2018 09:09:13 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Tue, 6 Feb 2018 17:08:59 +0000 Message-Id: <20180206170903.30637-5-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180206170903.30637-1-andre.przywara@linaro.org> References: <20180206170903.30637-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v5 4/8] 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 2b20d1aa15..e8c2a6cb44 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,