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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04D42C43334 for ; Fri, 3 Jun 2022 18:22:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347762AbiFCSVI (ORCPT ); Fri, 3 Jun 2022 14:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348053AbiFCSQN (ORCPT ); Fri, 3 Jun 2022 14:16:13 -0400 Received: from relay04.th.seeweb.it (relay04.th.seeweb.it [5.144.164.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CA2663500 for ; Fri, 3 Jun 2022 11:03:50 -0700 (PDT) Received: from [192.168.1.101] (abxj27.neoplus.adsl.tpnet.pl [83.9.3.27]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by m-r1.th.seeweb.it (Postfix) with ESMTPSA id 7880920521; Fri, 3 Jun 2022 20:03:28 +0200 (CEST) Message-ID: <6efeafbc-d366-bddd-faa4-4359f3a56f4a@somainline.org> Date: Fri, 3 Jun 2022 20:03:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 1/6] iommu/qcom: Use the asid read from device-tree if specified Content-Language: en-US To: Rob Clark , Will Deacon Cc: ~postmarketos/upstreaming@lists.sr.ht, linux-arm-msm , Bjorn Andersson , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , "list@263.net:IOMMU DRIVERS" , Joerg Roedel , iommu@lists.linux-foundation.org, Martin Botka , AngeloGioacchino Del Regno , Marijn Suijten , jamipkettunen@somainline.org, Andy Gross , Joerg Roedel , Rob Herring , Krzysztof Kozlowski , Robin Murphy , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux Kernel Mailing List References: <20220527212901.29268-1-konrad.dybcio@somainline.org> <20220527212901.29268-2-konrad.dybcio@somainline.org> <20220531154631.GA25502@willie-the-truck> <20220531161910.GE25502@willie-the-truck> From: Konrad Dybcio In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31.05.2022 22:57, Rob Clark wrote: > On Tue, May 31, 2022 at 9:19 AM Will Deacon wrote: >> >> On Tue, May 31, 2022 at 09:15:22AM -0700, Rob Clark wrote: >>> On Tue, May 31, 2022 at 8:46 AM Will Deacon wrote: >>>> >>>> On Fri, May 27, 2022 at 11:28:56PM +0200, Konrad Dybcio wrote: >>>>> From: AngeloGioacchino Del Regno >>>>> >>>>> As specified in this driver, the context banks are 0x1000 apart. >>>>> Problem is that sometimes the context number (our asid) does not >>>>> match this logic and we end up using the wrong one: this starts >>>>> being a problem in the case that we need to send TZ commands >>>>> to do anything on a specific context. >>>> >>>> I don't understand this. The ASID is a software construct, so it shouldn't >>>> matter what we use. If it does matter, then please can you explain why? The >>>> fact that the context banks are 0x1000 apart seems unrelated. >>> >>> I think the connection is that mapping from ctx bank to ASID is 1:1 >> >> But in what sense? How is the ASID used beyond a tag in the TLB? The commit >> message hints at "TZ commands" being a problem. >> >> I'm not doubting that this is needed to make the thing work, I just don't >> understand why. > > (disclaimer, it has been quite a while since I've looked at the smmu > setup with earlier tz, ie. things that use qcom_iommu, but from > memory...) > > We cannot actually assign the context banks ourselves, so in the dt > bindings the "ASID" is actually the context bank index. I think so. I don't > remember exactly if this was a limitation of the tz interface, or > result of not being able to program the smmu's global registers > ourselves. As far as I understand, it's the latter, as changing the defaults is not allowed by the security policy on consumer devices. Qualcomm arbitrarily chose some numbers that may or may have not aligned with their usual index-is-offset-divided-by-0x1000 and hardcoded them in the BSP, and now the secure side (if required, and well, it is..) expects precisely that configuration. Konrad