Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp8329780ioo; Sat, 4 Jun 2022 05:42:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUZ2JiwkoUxgyp4OIMPxWm+ij3kLIn648+JT1tRIfSgOnkl+sDJCwfYSbCdh1g7TT2IdKf X-Received: by 2002:a17:906:3087:b0:6f4:2901:608a with SMTP id 7-20020a170906308700b006f42901608amr13229012ejv.646.1654346563217; Sat, 04 Jun 2022 05:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654346563; cv=none; d=google.com; s=arc-20160816; b=f4wdxwGdwQcnuzfsqFP6QeNZCnQjp77xzKaLw6K6p3XuQl05klD0hrPESN3NvtRzmv /LszcKJQ83axMDpFLuw9JrOrE+LxaoeXH0Fn+m3BX1+3Ap+/ywruofO1kQP4kChBQ5Pp NCSgf4aPQNYkOpqXL+zAoLWvvObdpBdbu3tNK+Cb91/Qk+ezcnDU0sed4cMGkMEPV/U9 Ky7GqkXRjdYka8fUcNPNogi5BMWneceQ0Q28Fy4fCvdm4Afb16zmzKwgdKBj9WB7NNsH XlETjWQOzzSxLb0ieluROgRQgbWYmfLw3YrQhybuKpvEfp7FHjShZSDmByBSsVBpWc6V KVnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=9Ec/dfChHzbu24aSTR8eaEX8Jxqw2DpYVeDTQt2W91c=; b=VRoFldpDS19W0xgnn3ZeW52Nc63YKQs4UzQnWPtHQcYIHyCYrTgEc74LTYw+Bts0vD za6lPc27AYnkjPCO1u6Mpq9r2s83k//Szz7OCMqi7GqAag4oEo7lwnAvyVu9ouOVl6HJ gdb40gvJaycEP2lkBQQ+ORSZjnD9dMhe0whYQxYES9QM9vn4eNbzEXcJx0KELO+B8Cl2 7DzGQHgAV0/wBjPZDHRjQToEc4Rkv+exIfUGsWgJLrxMjRgFJFXeOD3d65CZYeX0Uavm /I7NpiUXYLhw9m7V8/OU1RZyCI/ND8hXMU5CTFHlzrmNVD0ncHJQiB0QZGEzrkGFdIjR OYVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k17-20020a50ce51000000b00423dc7e8859si10741862edj.297.2022.06.04.05.42.16; Sat, 04 Jun 2022 05:42:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347739AbiFCSVG (ORCPT + 99 others); Fri, 3 Jun 2022 14:21:06 -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 X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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