From patchwork Wed Mar 21 16:32:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 132228 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp2356277ljb; Wed, 21 Mar 2018 09:35:10 -0700 (PDT) X-Google-Smtp-Source: AG47ELum3bM7Dl3Hj38eCvAgZJDWV9c6ebkeVUuTHzrCMOA9EPSPzzi8fR1Kmqc4pByoq+M1zISj X-Received: by 2002:a24:3715:: with SMTP id r21-v6mr4941946itr.110.1521650110667; Wed, 21 Mar 2018 09:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521650110; cv=none; d=google.com; s=arc-20160816; b=eAgmxyEVoa+SmALfj9Suw/hQjC81qbLj6IZD0GSUXW+vxnwxRMmYX0HVi0f+AGpMc/ OdeYwG7hSZmAp8FD+cK9On9Kpqb5nuajLMJhFF2Z/v44B+PpS3jPlOqfhxPjyMeNeRrQ f4PLATlNwEtWDWhXOwHu3CnotvFk9tYWcas/LfOXiRKxdYmRpmU7Ua162/p6z29pg4Iw VXGy+zTr1UBzdFxG3y8U6r7leneYZGMK4W31+jhUzxaMGXJg7Tt/xSts6tXZ+ErbMNO5 HXyWzMX9DBwPbWXzQSg6/pK3vRKQ/BE+9X7eBS+i9x3xepOA0PxbPZuvv+3qK4NGciw8 iQmw== 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=cNKVCaWTEtPEv1p9IQW2Y+2RrZOv4AU4ANXWqmMXiB0=; b=qWLLAR7TNWz98dSIoMyr7tEKtTfTepKyNKBm1yeBIwY8yQZmt2/MzJO3mqF9R0LFmN Zrsz0BAyuwQwtYcHcc6tZ5JQcWbXBfnes0sjrsSoUvcSuXvEcmq9fXAdSOaXlJfIXyRr COpYMhcMcn0PIYdr//z7Hyw9bG0ZbsDgOOLBFmzYxpDjpDRH3K/PsMjt4sDXp+MDUcrG x25fEIZeoyCipSqdoAOkTacQPmSd71RW9aprXJKO1hu5FzEfuz7tsv4at4b6rsGhSqgc 2gWGrg7h47gtTdcNPQVEm1aj3brLGcddH6dTYvakoNfwXjhxbyvtlaaJDz5U0XxPGDfq OlQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=D+eiZMTZ; 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 m202-v6si3494906itm.125.2018.03.21.09.35.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Mar 2018 09:35:10 -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=D+eiZMTZ; 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 1eygfZ-000244-Sz; Wed, 21 Mar 2018 16:32:57 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1eygfY-00022f-SF for xen-devel@lists.xenproject.org; Wed, 21 Mar 2018 16:32:56 +0000 X-Inumbo-ID: 78edd208-2d25-11e8-9728-bc764e045a96 Received: from mail-wm0-x242.google.com (unknown [2a00:1450:400c:c09::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 78edd208-2d25-11e8-9728-bc764e045a96; Wed, 21 Mar 2018 17:32:41 +0100 (CET) Received: by mail-wm0-x242.google.com with SMTP id r82so11032410wme.0 for ; Wed, 21 Mar 2018 09:32:55 -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=wfQJwn3y4yayUU9b6/hSjYEHKuKvWqIKmm6bZ2VrhH0=; b=D+eiZMTZJc8OoDSIuttuV/5ZEL1bZxe9cOdiInMB4pbxC7BbTFb/siIt54R/Js/D7v mhI7PkfdnhgNw42sLLkOo8PgZ/fAynue3I1mUAOSMhDQ2wMrLsfcslpJJZ1GotONrLeU 1Mzu2eDxgSFuFYth8Zn+Xa2TPxYu5RrV6ygxU= 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=wfQJwn3y4yayUU9b6/hSjYEHKuKvWqIKmm6bZ2VrhH0=; b=TSYl20AOkR8Qmm/NAeh67vUlt9FXx3ypYycbyLF8l8VGxExZDtuq4qXHmxQIuJYVR3 MDiVTUFPR3yTBWBgaLHlcVr5ZnURK2PtFQjAfZI64Mgw3xLzf+Jqvu8d/kilpa9b7UmM H0oBO25o4rQL9HnX5jDl59+///X4RJiAjGvjySe4JWnX3L7ZVxdc7NCUVKPXpGKUmZPN Axl2C2yBGICp/jpINU7J87SVyOhx8yUu6BOnCmnjRR1qCi+mE2DG70zC5h75UEODEr6p RvOJN0NUOhBDdqui2hc/isgBcRtxhFshNq5NpbuN7cJhr8836muV4NcK/KQ8shHcvd33 y++Q== X-Gm-Message-State: AElRT7EAn647QHeM1wEsQAkKT5kjT31CBMyQWpoSdbUY+VrS/8BD7VCe JT3YgZw/AiaTEgeuKmK5EylYXQ== X-Received: by 10.28.141.4 with SMTP id p4mr3414263wmd.59.1521649974303; Wed, 21 Mar 2018 09:32:54 -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.32.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Mar 2018 09:32:53 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Wed, 21 Mar 2018 16:32:02 +0000 Message-Id: <20180321163235.12529-7-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 06/39] ARM: evtchn: Handle level triggered IRQs correctly 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" The event channel IRQ has level triggered semantics, however the current VGIC treats everything as edge triggered. To correctly process those IRQs, we have to lower the (virtual) IRQ line at some point in time, depending on whether ther interrupt condition still prevails. Check the per-VCPU evtchn_upcall_pending variable to make the interrupt line match its status, and call this function upon every hypervisor entry. Signed-off-by: Andre Przywara Reviewed-by: Julien Grall Acked-by: Stefano Stabellini --- xen/arch/arm/domain.c | 7 +++++++ xen/arch/arm/traps.c | 1 + xen/include/asm-arm/event.h | 1 + 3 files changed, 9 insertions(+) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index ff97f2bc76..9688e62f78 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -953,6 +953,13 @@ void vcpu_mark_events_pending(struct vcpu *v) vgic_inject_irq(v->domain, v, v->domain->arch.evtchn_irq, true); } +void vcpu_update_evtchn_irq(struct vcpu *v) +{ + bool pending = vcpu_info(v, evtchn_upcall_pending); + + vgic_inject_irq(v->domain, v, v->domain->arch.evtchn_irq, pending); +} + /* The ARM spec declares that even if local irqs are masked in * the CPSR register, an irq should wake up a cpu from WFI anyway. * For this reason we need to check for irqs that need delivery, diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 2638446693..5c18e918b0 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2033,6 +2033,7 @@ static void enter_hypervisor_head(struct cpu_user_regs *regs) * trap and how it can be optimised. */ vtimer_update_irqs(current); + vcpu_update_evtchn_irq(current); #endif vgic_sync_from_lrs(current); diff --git a/xen/include/asm-arm/event.h b/xen/include/asm-arm/event.h index c7a415ef57..2f51864043 100644 --- a/xen/include/asm-arm/event.h +++ b/xen/include/asm-arm/event.h @@ -6,6 +6,7 @@ void vcpu_kick(struct vcpu *v); void vcpu_mark_events_pending(struct vcpu *v); +void vcpu_update_evtchn_irq(struct vcpu *v); void vcpu_block_unless_event_pending(struct vcpu *v); static inline int vcpu_event_delivery_is_enabled(struct vcpu *v)