Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2396315iof; Wed, 8 Jun 2022 04:12:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysbkhL97bBB66CJtvROcwxBl2u2BAWx5xm7vBUfyffdiGCiWwGqLqHo4XJJ9VUGzs829Kq X-Received: by 2002:a17:903:2645:b0:167:92f1:15c0 with SMTP id je5-20020a170903264500b0016792f115c0mr8216398plb.100.1654686738808; Wed, 08 Jun 2022 04:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654686738; cv=none; d=google.com; s=arc-20160816; b=GNx4k3mf3Zdzi0WhJbI7gbCRzRXw/ZcWJWwxiclFMrNvVDakS6FN7H7t7h2Q4t0G0I BcEjz2jARSGQK+wdAv3lKJtMjM2U0qam9jyLumBhXH7KupCRrsTl+7r2+tXPzfoAoqun zj8Z5YLlHzPBMDVUS9dcm1Oq6BQNE7F42hHjJhagRlkGcVQLPjMMrFsl1s7LxVrP8teP cL33t+lEOz04kxuHdMs9C6JPpm6/yLnxT0oJgpdcMw2B+JG4NzrwpkVWsysmtyq1W8hj gunIyp5jCalIIkx+PVOnLxZtk4C/24KptL/Qe6eL0VllSdaLssAphIdE25QSCVkNODyw jBsw== 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:dkim-signature; bh=XnIYUn8Gr1eOoX+n269Tpa/VZAChq+i3zQw+jBL8eXk=; b=HliypP5i82DyQPMyQ8NuQueF9/RIivn11fuGLUOLzQvfUx6bWDWgnOfKx3NTfkwNje R7fMOMhAbqTvyc8eOXJ8uVlZd598EQ7aCUf6i/1tWcvqyK4pf4sBpmg2Yt1gPV8/BI63 GybavACjjr4qU0iqeexNY6p+HdJSHbB8C8IfGotMbvRhqs/gDHitkP+U59wIrLnOskCF ZWQiQ7t0MYCtD2onKbeQcMs0uOt2Uu1AnL11ju2GYjvvDqXUq9D5i9DUf793SrrINg0D inrGdWKmVeBOqUrQlmWYBqRRmMZYDFKoUONz0N9uH4H66q8fomaC+OxhFczqs0KFD/dK mg9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JL6CAQRz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h11-20020a056a00218b00b0051b8e74bc32si30027402pfi.169.2022.06.08.04.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 04:12:18 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JL6CAQRz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CFDB732343A; Wed, 8 Jun 2022 03:36:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237476AbiFHKfc (ORCPT + 99 others); Wed, 8 Jun 2022 06:35:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236929AbiFHKdB (ORCPT ); Wed, 8 Jun 2022 06:33:01 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 107FB1C4203; Wed, 8 Jun 2022 03:25:59 -0700 (PDT) Received: from [192.168.1.100] (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 246C0660181B; Wed, 8 Jun 2022 11:25:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1654683948; bh=CbCEHZf0MESeLkAV+KaRIb58SJLwsWDBEd1XfSKloiU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=JL6CAQRzPNxS11sdv1lqG3+jYQQBX0szDXfzGlqNeAmSTxcSN4hrnxHXiJK4TI/5o 4lG3gsRwQhONwG+w5NxnfRzA+cI5lF3VjstoVw0s3HPCKYvYr7kER2ucKauN9+qgMT mTsntlQDlE0JrPQUTJURaOqHDSkyIi90kFHMkUae1FEGncdiXfftKujwqhZzPtMcGC hldbDeeSFn1Hvs5EIWixyoS9jStUbJyl1AVxxnbAxcZhEJiSgkRbwBUWK0306fSYfO mWuaO/tU/mF4L7Eqymam34ABQMq66ZhWoW9r442GAmDfk2QCk2U4rXjVa10NTpdz0t 8aV3MpGHtXuKQ== Message-ID: <4f6f1ec4-2c68-5446-e0e0-85e1631a84cf@collabora.com> Date: Wed, 8 Jun 2022 12:25:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH 1/6] iommu/qcom: Use the asid read from device-tree if specified Content-Language: en-US To: Konrad Dybcio , 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 , Martin Botka , AngeloGioacchino Del Regno , Marijn Suijten , jamipkettunen@somainline.org, Andy Gross , 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> <6efeafbc-d366-bddd-faa4-4359f3a56f4a@somainline.org> From: AngeloGioacchino Del Regno In-Reply-To: <6efeafbc-d366-bddd-faa4-4359f3a56f4a@somainline.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Il 03/06/22 20:03, Konrad Dybcio ha scritto: > > > 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 > I can confirm that it's the latter, as described by Konrad. The inability of programming the global registers from Linux is due to the hypervisor disallowing that (in different ways depending on the SoC's firmware but with the same outcome: AP reset by HYP). Cheers, Angelo