From patchwork Wed Mar 21 16:31:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 132218 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp2356086ljb; Wed, 21 Mar 2018 09:35:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELskKc+g3oHAygLrvm3Q1K/Zes9RZsvu54niqI2hAXTDQh3r/208gzd86Q8C5E+CtYbtYNOD X-Received: by 2002:a24:7cc2:: with SMTP id a185-v6mr5080138itd.8.1521650101561; Wed, 21 Mar 2018 09:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521650101; cv=none; d=google.com; s=arc-20160816; b=RD17LrCBuAyTOWod8eS0ZrGg+JrK4N7DQOhXljeT0lskh6YAEH4o57nHnhagxYPWS3 fEei+Q/EWQ/1iUjnaKgt6MDP27gg9KDEojKbJdRdXy9JEC5ER+DKI6TqDFaWKym+Mnaf i2egSoGECrRTta0PEDudhOkt4G2sXuRcaoxd3wBdYN+SjbGlTZt0PXjfMHDgU23OJBxo sAtmCuqd/EMpppiXnqlRAcP3s9i6w6rBoy1c8LsOMwOQ6QlX7sSPgK0m0jGYU1WUCRyY UB8C9JbmobTvMv9Yw4361JEKiP9mRcj3RR0WzlFjXfK4c8YMPqs/ES7OsUFEoGMek3Kb ls7A== 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=fIvevYlLwVLByK7oivhuwhVZNEJsWrDSgzpv1yZQPEg=; b=bt4QlktphqMv12Z99D1YmWI5gSeGH+Tc/4sZ9QXDmES3PQOFSrMsEk5wtzRy39DuUf Sc2YIvEjDm7zirbfj+wWzvw8k/B1oUSssFlUhbaEUdCPN6bwIE+YvBg8DBTr0dpU6aDD KVZr+bYIqt8ZIIfaBzcLSAlKSOAhY+ncrrBAVP+nSedgsTkO0N3FWgcaomXv63T3BLEE AxJu4Z3+uZLTAqKMMgRpSiMYE0ve3YAu5k9arhFQLkfuZc1GTcEtpJI/ghRZ8ehBBXsl +7RWwNBfe+i7Wxv7c5D7ee67C+rDeeaBDTUqSBHr1S4meFpMhF2f0JJr7b524ZYyyRIK h7tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BbD8JT35; 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 e196si3380189ioe.252.2018.03.21.09.35.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Mar 2018 09:35:01 -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=BbD8JT35; 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 1eygfU-0001yP-Hf; Wed, 21 Mar 2018 16:32:52 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1eygfT-0001y8-Dn for xen-devel@lists.xenproject.org; Wed, 21 Mar 2018 16:32:51 +0000 X-Inumbo-ID: 75b38402-2d25-11e8-9728-bc764e045a96 Received: from mail-wm0-x241.google.com (unknown [2a00:1450:400c:c09::241]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 75b38402-2d25-11e8-9728-bc764e045a96; Wed, 21 Mar 2018 17:32:35 +0100 (CET) Received: by mail-wm0-x241.google.com with SMTP id l9so10908617wmh.2 for ; Wed, 21 Mar 2018 09:32:49 -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=JTuI0AiXGA3X3Pa4JdRiT1ML1iGYGOXGfFbkq1naXD4=; b=BbD8JT35X3ecPEJcwsY3nD5uAnb1U8rvQYBKyl0Xez7kVFCrR1LvWCU+kWLXztnpfO ol4016haVuRF8n29hLUjs3n1Gs7u3PIMyGrhnHjo+skjxoDrav+rOnH8+JnqEQBuIKIj eCzkZZMpsoEDf7oVGjEo+F3NPJtjYvlcJj0N4= 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=JTuI0AiXGA3X3Pa4JdRiT1ML1iGYGOXGfFbkq1naXD4=; b=ZpLvrgMNauzXU/s3mYGu+RgavDPaojWDWfqfLcgzmJFp/lBVAwhPdFXoPFovAh4Cgq EmY3cGiGHA6GlxjtuN6tygM97pEMyJUo2/l59IVvFjfC5ChO80d4HnVwBeyxDMw9SGx9 4qc8J3H50TMv9Loy2bPQK9ucGe7mCuP1JbTAdHUyThnE2ZZvHhpk8EiQs/0OFogg9QI8 wWuqm1Lkd1CDqGPbzItn99EbTztFnUayHIjec4d68BAPotb7MJqce5Hi1KdpWMDFI0s/ FdXfpbnovClvBgWySuTanTSDzYRPjrO1BJUWMuiB+Khl9ggNaCjkz49kAYg992TP1IgF glFg== X-Gm-Message-State: AElRT7GEsrOWmAf8u3y25s7+jnpL5zkui047e/Mr/S+Ll1whlu1Oi5BZ 48TTRg/KCktvH8LSGUCXhUd1ng== X-Received: by 10.28.105.19 with SMTP id e19mr3326560wmc.3.1521649968879; Wed, 21 Mar 2018 09:32:48 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Mar 2018 09:32:48 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Wed, 21 Mar 2018 16:31:57 +0000 Message-Id: <20180321163235.12529-2-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 01/39] xen/arm: gic: Read unconditionally the source from the LRs 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" From: Julien Grall Commit 5cb00d1 "ARM: GIC: extend LR read/write functions to cover EOI and source" extended gic_lr to cover the source. The new field was only set for SGIs interrupt in the read function. However, the write function is writing the field unconditionally for virtual interrupt. This means that if the caller was combining the 2 functions (e.g to update the LR), the source need to be set to 0 by the caller. Unfortunately, gic_update_one_lr is not zeroing the structure before reading the LRs. This will lead to trigger the assert randomly. Instead of zeroing the structure in gic_update_one_lr, make sure that the source is written unconditionally on read. This is also simplifying the code to avoid an if statement in the read path. Lastly, properly update the comments in write_lr that was mistakenly speaking about the read lr path. Signed-off-by: Julien Grall Reviewed-by: Andre Przywara Signed-off-by: Andre Przywara --- xen/arch/arm/gic-v2.c | 15 ++++++++------- xen/arch/arm/gic-v3.c | 13 ++++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index 7dfe6fc68d..aa0fc6c1a1 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -480,11 +480,12 @@ static void gicv2_read_lr(int lr, struct gic_lr *lr_reg) else { lr_reg->virt.eoi = (lrv & GICH_V2_LR_MAINTENANCE_IRQ); - if ( lr_reg->virq < NR_GIC_SGI ) - { - lr_reg->virt.source = (lrv >> GICH_V2_LR_CPUID_SHIFT) - & GICH_V2_LR_CPUID_MASK; - } + /* + * This is only valid for SGI, but it does not matter to always + * read it as it should be 0 by default. + */ + lr_reg->virt.source = (lrv >> GICH_V2_LR_CPUID_SHIFT) + & GICH_V2_LR_CPUID_MASK; } } @@ -512,8 +513,8 @@ static void gicv2_write_lr(int lr, const struct gic_lr *lr_reg) if ( lr_reg->virt.eoi ) lrv |= GICH_V2_LR_MAINTENANCE_IRQ; /* - * This is only valid for SGI, but it does not matter to always - * read it as it should be 0 by default. + * Source is only valid for SGIs, the caller should make sure + * the field virt.source is always 0 for non-SGI. */ ASSERT(!lr_reg->virt.source || lr_reg->virq < NR_GIC_SGI); lrv |= (uint32_t)lr_reg->virt.source << GICH_V2_LR_CPUID_SHIFT; diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index 392cf91b58..cb41844af2 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1018,10 +1018,13 @@ static void gicv3_read_lr(int lr, struct gic_lr *lr_reg) else { lr_reg->virt.eoi = (lrv & ICH_LR_MAINTENANCE_IRQ); - /* Source only exists for SGI and in GICv2 compatible mode */ - if ( lr_reg->virq < NR_GIC_SGI && - current->domain->arch.vgic.version == GIC_V2 ) + /* Source only exists in GICv2 compatible mode */ + if ( current->domain->arch.vgic.version == GIC_V2 ) { + /* + * This is only valid for SGI, but it does not matter to always + * read it as it should be 0 by default. + */ lr_reg->virt.source = (lrv >> ICH_LR_CPUID_SHIFT) & ICH_LR_CPUID_MASK; } @@ -1056,8 +1059,8 @@ static void gicv3_write_lr(int lr_reg, const struct gic_lr *lr) if ( vgic_version == GIC_V2 ) { /* - * This is only valid for SGI, but it does not matter to always - * read it as it should be 0 by default. + * Source is only valid for SGIs, the caller should make + * sure the field virt.source is always 0 for non-SGI. */ ASSERT(!lr->virt.source || lr->virq < NR_GIC_SGI); lrv |= (uint64_t)lr->virt.source << ICH_LR_CPUID_SHIFT;