From mboxrd@z Thu Jan 1 00:00:00 1970 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=-4.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 0D83CC4338F for ; Fri, 20 Aug 2021 13:01:12 +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 C1F6B601FD for ; Fri, 20 Aug 2021 13:01:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C1F6B601FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.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:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kdmE7osK9dYIPjyuToNnghS3wj9JYZFB5JPbz8Ad51o=; b=WZu6J9dIo4m9fV X5dcMe41KhB61BebIMKfleCXvoScrztR5C1ReyM/V+ILqpJT1jP2sSj/jjzn3HORG7vxS9vlk5G6U sVGLrEw2E4BNWbILYnXqmGrEKig4mCXpuWYbLgXPEcl5dFLeG54+zMc/xTCwUWg+40Vm0iBZYIA4D gyvLcZ2vGecsP8UfoUMXlt0NGwohBpzFKn6iarEizdX+htZKu9vc6gERH5ZS7qYHj5sOoyy2btDw2 X1RbrR61VaKQJgEi1WQErxyt3sQwdMi1Loy+1UK6veqVZdXJ3Y8PqfVXcyqMJs0Zikis6Go54wZxb FFT1NmarL8cuyP8iyR0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mH46x-00BD95-0j; Fri, 20 Aug 2021 12:59:03 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mH46t-00BD8T-6r for linux-arm-kernel@lists.infradead.org; Fri, 20 Aug 2021 12:59:00 +0000 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 DEE2A6101A; Fri, 20 Aug 2021 12:58:58 +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 1mH46q-006BtP-VK; Fri, 20 Aug 2021 13:58:57 +0100 Date: Fri, 20 Aug 2021 13:58:56 +0100 Message-ID: <87pmu8qnlb.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: <061bafb6-b0fe-bd7c-1567-a642d3ddd4a5@arm.com> References: <20210811171505.1502090-1-wenst@chromium.org> <87fsvfal4n.wl-maz@kernel.org> <79eabae1-e4a3-7a12-7aa0-3680569584e5@arm.com> <871r6yajy7.wl-maz@kernel.org> <061bafb6-b0fe-bd7c-1567-a642d3ddd4a5@arm.com> 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") 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210820_055859_324358_B5923B9B X-CRM114-Status: GOOD ( 31.42 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Alex, On Thu, 12 Aug 2021 15:24:03 +0100, Alexandru Elisei wrote: > > Hi Marc, > > On 8/12/21 2:09 PM, Marc Zyngier wrote: > > On Thu, 12 Aug 2021 12:51:34 +0100, > > Alexandru Elisei wrote: > >> Hi, > >> > >> After re-familiarizing myself with the spec, it starting to look to > >> me like indeed there's something not quite right (read as: totally > >> broken) with my patch. > >> > >> Arm IHI 0069F, the pseudocode for reading ICC_RPR_EL1 (page 11-797), > >> says that the priority returned is unchanged if SCTLR_EL3.FIQ == > >> 0. > > Sure, but look at what ICC_RPR_EL1 does for FIQ==1: > > > > > > if HaveEL(EL3) && !IsSecure() && SCR_EL3.FIQ == '1' then > > // A Non-secure GIC access and Group 0 inaccessible to Non-secure. > > if pPriority<7> == '0' then > > // Priority is in Secure half and not visible to Non-secure > > Priority = Zeros(); > > elsif !IsOnes(pPriority) then > > // Non-secure access and not idle, so physical priority must be shifted > > pPriority<7:0> = (pPriority AND PRIMask())<6:0>:'0'; > > > > return ZeroExtend(pPriority); > > > > > > See how the the priority is shifted *left* (bits [6:0] end up in > > [7:1])? > > Yes, when SCR_EL3.FIQ=1, but gic_nonsecure_priorities is enabled > when SCR_EL3.FIQ=0 (gic_has_group0()). In that case ICC_RPR_EL1 > returns (what I assume to be) the highest priority interrupt from > ICC_AP0R_EL1, ICC_AP1R_EL1NS and ICC_AP1R_EL1S. Isn't that the > secure view (or Distributor value) of the priority? Yup. I guess I got confused with what "non-secure" priorities mean in this context. [...] > I don't see how that is the case - ICC_RPR_EL1 contains the priority > value as seen by the Distributor, and non-secure priorities get > right-shifted when SCR_EL3.FIQ=0, meaning that GICD_INT_NMI_PRI > becomes (GICD_INT_NMI_PRI >> 1) | 0x80 in the Distributor. Can you > elaborate where I'm contradicting myself? I think I know why I confused myself. When FIQ==0, G0 is NS. On the face of it, this should mean that no shift occurs. However, G1S is still in the picture, and we get the extra shift to preserve the ordering with G1S. This is a different configuration from that of a guest, where G0 is also NS, but there is no shift at all, as there is no G1S. The GIC strikes back. Again. I run some more tests with this patch, and merge it of nothing breaks. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel