Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1497880pxb; Fri, 20 Aug 2021 06:58:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpjeKACcst0yAhpL5Y76ykyr1v2al0nkWd8FsEDVWLv6mxxdzxHLiR/UPDf75qxJBne7iO X-Received: by 2002:a17:907:2141:: with SMTP id rk1mr978037ejb.138.1629467939465; Fri, 20 Aug 2021 06:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629467939; cv=none; d=google.com; s=arc-20160816; b=L9eNCzT0xbCLz2kcs5eHoMGDIzieUtDavw2FTgYPZj8zH0bnu+Z7X6+hOOnIg21IoQ 5yIWDiiW6v6rkU/2L0M9QT+CHKStLn7kR1TaYCHYDEaWUp5trI8eEkOZtdhwP5Jl+a0K hqFXFNK7RRNJ2lL7gBpgHV6+PxDKkh5dklLV9fpWtapQQOyooeFpjPc9GQA/MmJ13k0k 0kEOPTbqMA4PD/ZWtHXXkds2iJY9kZoc1W0ZAaMPCDoQ1rCEMYgV+kmU99m7OZVMf9Bv cQce9HwkIy+xt8L8vcGQ/Hy24NA5bs3ERpXgChwZBVcT4O2WAUGp3i8k34IwHcMst/b4 4efw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=SFPO20A72rckEKv/ve67elUb8pg2DnQy245XUsPxkGU=; b=ugguuvwwvA33Q+iCq8+2ZOFLSKUqUJsbJvvEX/IiDL93Rfe/z2czuwvLXFha0zquEz zv3MhJyCGMdxXyj2zEmvntp39i8tgZubY9IMxqykf32nL8KMvcdEhmEvu7gPgREc9Bkc 3NFkjxNl14XJkKw7z5xWsTyWLB9MfQtRL0YNISU63oFRfPN7EGvSrdQM5LiDC/Eza/I7 TdNTNsIl81BpnuahNGwCuc15Y9y2HFRVHcgJwQNr1nNNQjnOVdhiFNKRATWO95TKb+pK UUbyo5lgdFRhZiAbCatnxLRDTY5e4ovllMzY+beg6auBDHdp+GcE+RCw2TFy3GLxpOPn 8cuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z19si7370479edq.65.2021.08.20.06.58.35; Fri, 20 Aug 2021 06:58:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240807AbhHTN4F (ORCPT + 99 others); Fri, 20 Aug 2021 09:56:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:60364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240679AbhHTN4A (ORCPT ); Fri, 20 Aug 2021 09:56:00 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A93C661075; Fri, 20 Aug 2021 13:55:22 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mH4zQ-006CSZ-Pu; Fri, 20 Aug 2021 14:55:20 +0100 Date: Fri, 20 Aug 2021 14:55:20 +0100 Message-ID: <87mtpcqkzb.wl-maz@kernel.org> From: Marc Zyngier To: Alexandru Elisei Cc: Chen-Yu Tsai , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] irqchip/gic-v3: Fix priority comparison when non-secure priorities are used In-Reply-To: References: <20210811171505.1502090-1-wenst@chromium.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: alexandru.elisei@arm.com, wenst@chromium.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 20 Aug 2021 14:31:39 +0100, Alexandru Elisei wrote: > > Hello, > > Pending Marc's testing (I realized I don't have any hardware to test > this on at the moment), this patch looks correct to me. One comment > below. Seems good so far. I tested it both in a VM, on a FIQ==1 host, and on D05, which runs with FIQ==0. Can't be more broken than it was... ;-) > > On 8/11/21 6:15 PM, Chen-Yu Tsai wrote: > > 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 > > --- > > 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; \ > > + }) > > Would you mind adding a comment to the macro explaining why it's > needed? This behaviour is rather subtle and I'm hoping it will save > someone's time at some point in the future. I'm thinking something > like this (please ignore it if you can think of something better): > > When the Non-secure world has access to group 0 interrupts > (SCR_EL3.FIQ = 0), reading the ICC_RPR_EL1 register will return the > Distributor's view of the interrupt priority. When GIC security is > enabled (GICD_CTLR.DS = 0), the interrupt priority written by > software is moved to the Non-secure range by the Distributor. If > both are true (which is the situation where gic_nonsecure_priorities > gets enabled), then we need to shift down the priority programmed by > software if we want match it against the value returned from > ICC_RPR_EL1. > > With a comment added: > > Reviewed-by: Alexandru Elisei Let me fold this into the commit and push it out again. Thanks, M. -- Without deviation from the norm, progress is not possible.