From patchwork Wed Aug 11 17:15:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12431625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFF15C4338F for ; Wed, 11 Aug 2021 17:18:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 43E1461019 for ; Wed, 11 Aug 2021 17:18:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 43E1461019 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=psJWkxYJ4goYUxh5BX9Q8K3MgXtlzBUim5dq7P6b9b8=; b=Ov03XrhwBtrKSO +BW4rwJKZ3w+e50eplM3gn+HxrJyN5BzKM6YB3K+UxSEQkkLiReEacQ9hsjpZo3usTy93+ZtCChnn u74XA96XzGN8Xc8mpQK79PTtBsdVZ3jn37ZErmf+LkzSpAymjuvkjG/QbeZf2Gern4eMBspJAp6dZ N9vwaYqzr1NDYUYO7EzRK+t8BPRPcjgVJ6R8tgpD8ldb00gIQTStmoa+TwZJsgRfEGSkb7J4Z6AV1 5OexPYW/uWkR5ycSlVsl5hHz+SAOT7+rxny6ude1AyCiWp5NHRb/8XvzqF4CR74V+a7YZIQaN/8cr yYMqcHBuAWnLLQ/6kSkQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDrp8-007lTO-OW; Wed, 11 Aug 2021 17:15:26 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDrp2-007lSf-8g for linux-arm-kernel@lists.infradead.org; Wed, 11 Aug 2021 17:15:24 +0000 Received: by mail-pl1-x629.google.com with SMTP id q2so3503118plr.11 for ; Wed, 11 Aug 2021 10:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=W3lgVTDmn4REk4t2oeucExyGZOCRsT1uMYJwLq6FhDY=; b=B4hYOwUHJTDjeHffrgREh5JvbeliZf4NEzbkiQR+9n0PyE9RCJNHkLuhdJ2tkf3bBU d5PgdZ7hxQoffqr2nZ0nK/TCh1AmC3h2gm1YLK7GHTjYxdYIA2OVVcwIk6DOUaEmsKlV EZCw5flmfbhqU5oM6lqK6lvOvhsBUl98KoEsY= 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:mime-version :content-transfer-encoding; bh=W3lgVTDmn4REk4t2oeucExyGZOCRsT1uMYJwLq6FhDY=; b=SES2BuBQfgADcXXpmzQN2DDHtV5bqO8byH/rqRDWH3S9oD5ZcMrc162ww6+e0ucPmp y7q2Bb4ILMzrEy7ROFBtcE3+FgX3Q7rKrZo9QU6HDADeRTdiWevAILMNCNKDXaNysVhO Bc8Qkk+aGjROaSK35qJX5c+pAIKnlRrhzCJv2FKK0iFPE19FPNHf5YP2pR4FeZiE2Ka3 S3YYSl7TuRWxNafXCmHiRHDACiIa7g8/QYknIOHXnFwZtza2Kc/Ub+DGyoPB8oLd4ztj XPiSMLQxjgfEzQ3aAG0gUnYGqUS4P8Mne7Xfk6T7Tg3aCXyRxH+rO9g+zSHTx/InN7rL vaFg== X-Gm-Message-State: AOAM5312UNHwd3fz1COywTmE0XdjFqwVpeUCeQdrIF9ghaVtSUCmGdcM d1BW+8UskylqCLaLvWxFm4Kpjw== X-Google-Smtp-Source: ABdhPJxzS41HJ4lI8js1Vi/wUD8ZXHL+vcSufocIoSsgrBqNub2ovhtvFZiNvYILdOLUa6Tdz7WFlw== X-Received: by 2002:a17:90b:1bca:: with SMTP id oa10mr40013310pjb.177.1628702115738; Wed, 11 Aug 2021 10:15:15 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:293c:bdfb:3e50:5db1]) by smtp.gmail.com with ESMTPSA id 21sm65163pfh.103.2021.08.11.10.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 10:15:15 -0700 (PDT) From: Chen-Yu Tsai To: Thomas Gleixner , Marc Zyngier Cc: Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] irqchip/gic-v3: Fix priority comparison when non-secure priorities are used Date: Thu, 12 Aug 2021 01:15:05 +0800 Message-Id: <20210811171505.1502090-1-wenst@chromium.org> X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210811_101520_353046_ADAC0FC5 X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When non-secure priorities are used, compared to the raw priority set, the value read back from RPR is also right-shifted by one and the highest bit set. Add a macro to do the modifications to the raw priority when doing the comparison against the RPR value. This corrects the pseudo-NMI behavior when non-secure priorities in the GIC are used. Tested on 5.10 with the "IPI as pseudo-NMI" series [1] applied on MT8195. [1] https://lore.kernel.org/linux-arm-kernel/1604317487-14543-1-git-send-email-sumit.garg@linaro.org/ Fixes: 336780590990 ("irqchip/gic-v3: Support pseudo-NMIs when SCR_EL3.FIQ == 0") Signed-off-by: Chen-Yu Tsai Reviewed-by: Alexandru Elisei --- drivers/irqchip/irq-gic-v3.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index e0f4debe64e1..e7a0b55413db 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -100,6 +100,15 @@ EXPORT_SYMBOL(gic_pmr_sync); DEFINE_STATIC_KEY_FALSE(gic_nonsecure_priorities); EXPORT_SYMBOL(gic_nonsecure_priorities); +#define GICD_INT_RPR_PRI(priority) \ + ({ \ + u32 __priority = (priority); \ + if (static_branch_unlikely(&gic_nonsecure_priorities)) \ + __priority = 0x80 | (__priority >> 1); \ + \ + __priority; \ + }) + /* ppi_nmi_refs[n] == number of cpus having ppi[n + 16] set as NMI */ static refcount_t *ppi_nmi_refs; @@ -687,7 +696,7 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs return; if (gic_supports_nmi() && - unlikely(gic_read_rpr() == GICD_INT_NMI_PRI)) { + unlikely(gic_read_rpr() == GICD_INT_RPR_PRI(GICD_INT_NMI_PRI))) { gic_handle_nmi(irqnr, regs); return; }