From nobody Fri Nov 29 14:48:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1638035562; cv=none; d=zohomail.com; s=zohoarc; b=hcB0OsMfxEcJ0e3/aOE7CGGzCKi8jchktEo00Dqz6J5DtBnWXW5BxZI+ByOLQDIRUyBJKWbnz9GKCHeJBzDlu9XxG6eqU7CVRVy3PlSrdXA4BtU5KS2prt2eQm4XB2ktq0v+TUxmWpN7gvyjil0TfMnyKSyBWh57vPRJ5tjHmfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638035562; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=9mwKxUIwhhcxHHJvoR//K+R5uyZjNpj3vGJfrB5GvpE=; b=fdrNJ3SDqn71EQzTfs/i0oApdTOw51kAx3UcB0yoDVGlkjFwIVKzucYNDe2gaScilIZW3omOMeT6OqpzkRr8kfgpstMoP740apQLwnBKMKly7DF0y4RFU9NC4J5LstT58OqmE06WP29o8w2ApV3qXU28XZX+fZIuPkb86Ec+xOo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1638035562711682.43490745094; Sat, 27 Nov 2021 09:52:42 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234024.406237 (Exim 4.92) (envelope-from ) id 1mr1rl-0005gC-SW; Sat, 27 Nov 2021 17:52:01 +0000 Received: by outflank-mailman (output) from mailman id 234024.406237; Sat, 27 Nov 2021 17:52:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mr1rl-0005a2-Cx; Sat, 27 Nov 2021 17:52:01 +0000 Received: by outflank-mailman (input) for mailman id 234024; Sat, 27 Nov 2021 17:51:59 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mr1rj-0004Ih-70 for xen-devel@lists.xenproject.org; Sat, 27 Nov 2021 17:51:59 +0000 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [2a00:1450:4864:20::236]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b76e45a3-4faa-11ec-976b-d102b41d0961; Sat, 27 Nov 2021 18:51:58 +0100 (CET) Received: by mail-lj1-x236.google.com with SMTP id t11so25402118ljh.6 for ; Sat, 27 Nov 2021 09:51:58 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id f18sm827075ljc.104.2021.11.27.09.51.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Nov 2021 09:51:57 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b76e45a3-4faa-11ec-976b-d102b41d0961 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9mwKxUIwhhcxHHJvoR//K+R5uyZjNpj3vGJfrB5GvpE=; b=qDeQAJJ31P7G7QELGdWqVpRKdBqwlB1dl4ZaEtNbeanyul9cN5u+XKjwuE3kLD8pMk /ArkzsiQlMqYSryeb6gcaem2YrsYapAj6wDRivNekiyAXVIX4rTkVImheWkBaaNHe2db vXzMOHihqaeAvU4py1v+r1MUeNqagliEcbzyzQtivgruVHm4mT0rrkIPzEmNHL58iHX9 IyQnUdoBu5QTr4sHDZZoCFu2j6sP6wRiJo+eWBiM6LEczjcvEmisqscRs9smH90/1Ika 5If9mFKok1p0C7I3MGWs4fag2r6fiuxDyMawcur//wIaxVATtcVT0VpoXy3G38C4SJmh B/0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9mwKxUIwhhcxHHJvoR//K+R5uyZjNpj3vGJfrB5GvpE=; b=antodVBPpdietpaYh0WRVLk+ga0wHJYJaMBmO+TkYuO7gslmqgcdRclehSJXt+HPwf Ue3VU3v3m8QsKH9hw3C2m6h1Kw4kXcM6x+lkukQNz5p+3Pj0cdz2aFXgC8PG5IITcqc2 t6tiKBiTAIxkEtCXAinsvPk+oKwefwBNJ/CInfzlV3d6uKMY7MhnGk4UuCn8y92OarD1 CH11nocCW90fwWmiJWFTwrj0IYiQeHdKSVBUBABhfw+ILyvH/JITmBlaf+g8fuyitTLN o5LxsJUCb5O9dK1c/36GZDY5KLRqNUpO78dW6vN35ypyZH7qvkWUsa3W7FCHyexLYoGY NYXg== X-Gm-Message-State: AOAM531Vpp9QS2r6rgkEAsiBWSPcIUzynKfU7IwS9u6uarpaS8I60jFh WBLRLAKXvPcfvOuBkhzxw4nMSWEKybI= X-Google-Smtp-Source: ABdhPJzwRSgX3LO7rkTFBgXUFHakRdHRaiO5rIt2ufLYVazG5ZhRv4hKgatv+rgHZrI0MwnNO98nCg== X-Received: by 2002:a2e:95cb:: with SMTP id y11mr38339192ljh.461.1638035517879; Sat, 27 Nov 2021 09:51:57 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Yoshihiro Shimoda Subject: [PATCH 08/10] iommu/ipmmu-vmsa: Set IPMMU bit IMSCTLR_USE_SECGRP to 0 Date: Sat, 27 Nov 2021 19:51:43 +0200 Message-Id: <1638035505-16931-9-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1638035505-16931-1-git-send-email-olekstysh@gmail.com> References: <1638035505-16931-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1638035564622100021 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko Based on the following commits from the Renesas BSP: 8fba83d97cca709a05139c38e29408e81ed4cf62 a8d93bc07da89a7fcf4d85f34d119a030310efa5 located at: https://github.com/renesas-rcar/linux-bsp/tree/v5.10.41/rcar-5.1.3.rc5 Original commit messages: commit 8fba83d97cca709a05139c38e29408e81ed4cf62 Author: Nam Nguyen Date: Wed Apr 28 18:54:44 2021 +0700 iommu/ipmmu-vmsa: Set IPMMU bit IMSCTLR_USE_SECGRP to 0 Need to set bit IMSCTLR_USE_SECGRP to 0 because H/W initial value is unknown, without this dma-transfer cannot be done due to address translation doesn't work. Signed-off-by: Nam Nguyen commit a8d93bc07da89a7fcf4d85f34d119a030310efa5 Author: Nam Nguyen Date: Tue Sep 7 14:46:12 2021 +0700 iommu/ipmmu-vmsa: Update IMSCTLR register offset address for R-Car S4 Update IMSCTLR register offset address to align with R-Car S4 H/W UM. Signed-off-by: Nam Nguyen ********** It is still a question whether this really needs to be done in Xen, rather in firmware, but better to be on the safe side. After all, if firmware already takes care of clearing this bit, nothing bad will happen. Please note the following: 1. I decided to squash both commits since the first commit adds clearing code and only the second one makes it functional on S4. Moreover, this is not a direct port. So it would be better to introduce complete solution by a single patch. 2. Although patch indeed does what it claims in the subject, the implementation is different in comparison with original changes. On Linux the clearing is done at runtime in ipmmu_domain_setup_context(). On Xen the clearing is done at boot time in ipmmu_probe(). The IMSCTLR is not a MMU "context" register at all, so I think there is no point in performing the clearing each time we initialize the context, instead perform the clearing at once during initialization. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Volodymyr Babchuk --- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthr= ough/arm/ipmmu-vmsa.c index 8dfdae8..22dd84e 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -229,6 +229,9 @@ static DEFINE_SPINLOCK(ipmmu_devices_lock); #define IMUASID0(n) (0x0308 + ((n) * 16)) #define IMUASID32(n) (0x0608 + (((n) - 32) * 16)) =20 +#define IMSCTLR 0x0500 +#define IMSCTLR_USE_SECGRP (1 << 28) + #define IMSAUXCTLR 0x0504 #define IMSAUXCTLR_S2PTE (1 << 3) =20 @@ -979,6 +982,10 @@ static int ipmmu_probe(struct dt_device_node *node) set_bit(0, mmu->ctx); } =20 + /* Do not use security group function. */ + reg =3D IMSCTLR + mmu->features->ctx_offset_stride_adj; + ipmmu_write(mmu, reg, ipmmu_read(mmu, reg) & ~IMSCTLR_USE_SECGRP); + spin_lock(&ipmmu_devices_lock); list_add(&mmu->list, &ipmmu_devices); spin_unlock(&ipmmu_devices_lock); --=20 2.7.4