Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1736906rwi; Thu, 3 Nov 2022 08:31:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7tOi9nU9IMQCWi8f+AyDwIdkrOlSxoKA7AejK06pOHDoCviQnWDj8j7aKmG1vdWlN+np9G X-Received: by 2002:aa7:dcd5:0:b0:461:5fad:4215 with SMTP id w21-20020aa7dcd5000000b004615fad4215mr32078485edu.332.1667489511434; Thu, 03 Nov 2022 08:31:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667489511; cv=none; d=google.com; s=arc-20160816; b=hl4v7SRYYSTgrWmNBhVnLujBiD5jkrXKth64IWMtJxw3XHwOPKtG9rKlDFcjWysM3j IOex26hu1XTyYpb7weVuJzzjLLuFAW3neWY+jqQIu4R1oNpCyDQjjsmW5aAHSv0iUVfj RlVskVqpYMDtBO4SGQZxmmJxKviPSXy9q6AjH9VPWIqb8/MYEcTaj4EWKHnA3R+mcxJM OQKhgRlCtY2EtfvbT+LCExUZLU4WLBuve83TaBn1FJmFiStm5r9GLlgB7oJIze46XuOS aSOtHEIy6RE7gE0begTGnad5PNx6RMFN9kxXMY0rqFJwh+ysIqzfyoFPauD0dRihvyU3 rt/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RmkWPOL1u3ues7pd/2HhAt4Yr/mzyj8+9VduS6DHyJ4=; b=g9doKjRz1HlRAQEIaywKBVPe486scymImzcI/nRtg73i3Wr0aqZ2G8kDwD/ryJZB5n TnpLmfmGZAio3ALGFPFqgQDYRhU7ne63Ph9wCEOH+NUzcQs8AWW5/FeMwKzhjzSnalaQ rdfST3BzGeSxculFnDM+IXQxVKeke7p5JvIU5MC9zBgj82Pj2abd2a+oRycCjr8LVg1+ zCW4v9f9ISmT3lQiSYVdjuiwEmVF0sQYDvPaiVreRrdQO8i8TkcThD97dr2vXxnof2Zc he9XWPXVGu/b1WRO8qEJ28aoBKao9nM49gP5is6o+fz63G/9QuIC54yAYQ7EgBfb4aGq 8kyA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb9-20020a0564020d0900b00456b734ceebsi2039775edb.436.2022.11.03.08.31.19; Thu, 03 Nov 2022 08:31:51 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231917AbiKCOxH (ORCPT + 98 others); Thu, 3 Nov 2022 10:53:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231921AbiKCOwq (ORCPT ); Thu, 3 Nov 2022 10:52:46 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E90219018 for ; Thu, 3 Nov 2022 07:52:16 -0700 (PDT) Received: from ip5b412258.dynamic.kabel-deutschland.de ([91.65.34.88] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oqbZd-0006qR-Fy; Thu, 03 Nov 2022 15:52:05 +0100 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Michael Riesch Cc: Joerg Roedel , Will Deacon , Robin Murphy , Benjamin Gaignard , Simon Xue , Michael Riesch Subject: Re: [PATCH] iommu/rockchip: fix permission bits in page table entries v2 Date: Thu, 03 Nov 2022 15:52:04 +0100 Message-ID: <4780234.31r3eYUQgx@diego> In-Reply-To: <20221102063553.2464161-1-michael.riesch@wolfvision.net> References: <20221102063553.2464161-1-michael.riesch@wolfvision.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SPF_HELO_TEMPERROR 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 Am Mittwoch, 2. November 2022, 07:35:53 CET schrieb Michael Riesch: > As pointed out in the corresponding downstream fix [0], the permission bits > of the page table entries are compatible between v1 and v2 of the IOMMU. > This is in contrast to the current mainline code that incorrectly assumes > that the read and write permission bits are switched. Fix the permission > bits by reusing the v1 bit defines. > > [0] https://github.com/rockchip-linux/kernel/commit/e3bc123a2260145e34b57454da3db0edd117eb8e > > Fixes: c55356c534aa ("iommu: rockchip: Add support for iommu v2") > Signed-off-by: Michael Riesch Reviewed-by: Heiko Stuebner > --- > drivers/iommu/rockchip-iommu.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c > index a3fc59b814ab..a68eadd64f38 100644 > --- a/drivers/iommu/rockchip-iommu.c > +++ b/drivers/iommu/rockchip-iommu.c > @@ -280,19 +280,17 @@ static u32 rk_mk_pte(phys_addr_t page, int prot) > * 11:9 - Page address bit 34:32 > * 8:4 - Page address bit 39:35 > * 3 - Security > - * 2 - Readable > - * 1 - Writable > + * 2 - Writable > + * 1 - Readable > * 0 - 1 if Page @ Page address is valid > */ > -#define RK_PTE_PAGE_READABLE_V2 BIT(2) > -#define RK_PTE_PAGE_WRITABLE_V2 BIT(1) > > static u32 rk_mk_pte_v2(phys_addr_t page, int prot) > { > u32 flags = 0; > > - flags |= (prot & IOMMU_READ) ? RK_PTE_PAGE_READABLE_V2 : 0; > - flags |= (prot & IOMMU_WRITE) ? RK_PTE_PAGE_WRITABLE_V2 : 0; > + flags |= (prot & IOMMU_READ) ? RK_PTE_PAGE_READABLE : 0; > + flags |= (prot & IOMMU_WRITE) ? RK_PTE_PAGE_WRITABLE : 0; > > return rk_mk_dte_v2(page) | flags; > } >