Message ID | 20221102063553.2464161-1-michael.riesch@wolfvision.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3443008wru; Tue, 1 Nov 2022 23:48:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM52ZVmD+6GBkOa+PPvwV2fVnof/0Nkuid3Kl8bdXB+4cMgOx+1aIAJURt0NYlF/OtMmnWP5 X-Received: by 2002:a17:90a:1b65:b0:1f7:4725:aa6e with SMTP id q92-20020a17090a1b6500b001f74725aa6emr23666603pjq.179.1667371702193; Tue, 01 Nov 2022 23:48:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667371702; cv=pass; d=google.com; s=arc-20160816; b=Qa16NDcWbPjF+FS2vOqpoqpZeIG7xmjucF2s0a+ZaIy+0Q9PDJPVFHoe3U4/WUMoLe nkGiGNLnBHFWDVWPmB9W4u5TxgbIwhTp89G9/Ybeo/bZu/QiwPy9SdV7VfIgGk+4yoSj t6V6oHzlpLu7jchmyEcZ8R+B7O9YEN47jsIvQaVzEAU9Te7GsKzas104D+jJSH9P64ZR lzme6m1+1DyyuPTHGG7jzTpBOQtEbaRDnIeX9q73QnQU95JYFr6gIwxwiNmIGElT3ITv lPu6f36jiYZsmeJEGwqjBc/Hi4WFK5psfhhO0OC/TaN39IU2NYtMo8s/AD6X5/x/RQPX k0Lw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=++80gqbVUTcBqH4xW79UJARVRVB585J1tmdHb+KsZzg=; b=e/KqbvOZa/K9XH5ToymtAFekNkndJQmx+/MRvAmcGhKm+n/xUgLZMn12BlSi22uHwN DdIzUIC6L9K6mMaDlLslh/56tuOEbTjDyKlO75oNGL6fRNG8/ZCrdqj6395LpM471haN Aw3kFfGTE8U9bIcB5jKaojxPxAJ1gFv1CMWRrOWjQj8jYZKY/+LbrFTahukxZkQ5bd4H SNcY4CSpaXampWb2nt8Bh6cJgHfGP1R7BB+bnUGXFRWeh9ARruCr3LGofyiALyaqU7Vz 3oWZJkdqVNq5Th/DrrqKEETGJQ4MHoMJyZqTT5Xb6FG2ec6UNS2P+eCKXau2uDwHCMgJ MUHQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=rwT7Ql2G; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be5-20020a170902aa0500b00178a33faa42si13497101plb.66.2022.11.01.23.48.09; Tue, 01 Nov 2022 23:48:22 -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; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=rwT7Ql2G; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbiKBGgN (ORCPT <rfc822;rua109.linux@gmail.com> + 99 others); Wed, 2 Nov 2022 02:36:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbiKBGgL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 02:36:11 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3442D25EA0 for <linux-kernel@vger.kernel.org>; Tue, 1 Nov 2022 23:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LNTLeIQqt5bc9kUEM4ri2frMiYVDeKUv+SNEQeWz4LFK7uzWVHmSFoCnZ0ovNUkLEwoj9kwPxxGmeaTtG1cY7HsWnQewFQp0Kbm8HGzjqb4P+iOsoBOHBE+b0kc03jvBOvWp5Dnk1iIhGd/P+4wXmz30V5pHptl2b1dqbKW0lOIKaGwoFvcfS1A88yPlNIT/b2yRreWb4PDvxyyIVXshBAucNzajYVlc8R/5kR+mFvQmFN+k12GT1+nYBOpOVqzr3aeI4Rc3sNpi/y4cJZ0/rfiIc11in2yqUPWHnSkcSocrJev9ro5FcyuheKUdR1cJYYE4wx//gol9z8NWWNPQ5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=++80gqbVUTcBqH4xW79UJARVRVB585J1tmdHb+KsZzg=; b=ZizmY3uDKwAfpG73SP4fQ+OGHmqzmmHDkisvHkgq1h0dP6hZ4nB7zLAZfUD0H3c6wgpvL/ZdGPyxMjxr71RAOtFFjssZFKxJLkhgtj3Das5es60V07hQWv2Vc1EsrRTshWiW54peqS65OeGqUFg4um3jwe9n59DEuDWzk60/oZCGKIQH9m8CMLbH1MxFl6yd3YnRCr7pWPSP00oyJvyTJ7iWsO94EqC31+X/NC60QzrTR60TLsUzXNnD3DtKZXMhdV43M/KGVzuoBx2YJwoJ6+jsk+ifzy+o7RbjUm9MhRLmVgnQySpPYgFoIODEOBofDs5/NPNLEwC4tm+Uw/A7/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=++80gqbVUTcBqH4xW79UJARVRVB585J1tmdHb+KsZzg=; b=rwT7Ql2G4H2C1/Oj6m3mPak7v+tKFGUHc5WGznuf6KE7TJb2D8voFVXciHipzcmg7BRGSjeu5GaW1yvoJiyFl0ipR4NtoXV/a3Q5R90niW65wikjzkMhhJaYxkbQXPWSjj7ajG6Zd3hwD5mUu9B3fpj2zRCsQfMkdbFzy5U6kb0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from DU0PR08MB9155.eurprd08.prod.outlook.com (2603:10a6:10:416::5) by AM0PR08MB5459.eurprd08.prod.outlook.com (2603:10a6:208:186::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.21; Wed, 2 Nov 2022 06:36:06 +0000 Received: from DU0PR08MB9155.eurprd08.prod.outlook.com ([fe80::3643:6226:28c:e637]) by DU0PR08MB9155.eurprd08.prod.outlook.com ([fe80::3643:6226:28c:e637%2]) with mapi id 15.20.5769.019; Wed, 2 Nov 2022 06:36:05 +0000 From: Michael Riesch <michael.riesch@wolfvision.net> To: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>, Robin Murphy <robin.murphy@arm.com>, Heiko Stuebner <heiko@sntech.de>, Benjamin Gaignard <benjamin.gaignard@collabora.com>, Simon Xue <xxm@rock-chips.com>, Michael Riesch <michael.riesch@wolfvision.net> Subject: [PATCH] iommu/rockchip: fix permission bits in page table entries v2 Date: Wed, 2 Nov 2022 07:35:53 +0100 Message-Id: <20221102063553.2464161-1-michael.riesch@wolfvision.net> X-Mailer: git-send-email 2.30.2 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: ZR0P278CA0004.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::14) To DU0PR08MB9155.eurprd08.prod.outlook.com (2603:10a6:10:416::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR08MB9155:EE_|AM0PR08MB5459:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cb72067-b268-4473-eebf-08dabc9c84e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: au1DiVCuVkexk3Nq7hc/egyl4eGg3QoODZsUEs5XQ5eOrfndd6h4QI0Z920s+slAYAHqOMRaYfHbbYcKEdZqrcYCQGk/OA+aCRXPSmClxlEhDjlF4nNe6YBeLoGy3+/md+3Zq/NHWR8cYXWSSA/3Wd1ipPn3y9tJJQPpq/aIhhG9MQcLLqpye+LB4oyvRwwP5WTZP6bznOSd0LASKUhKarEJ4KWW2MwYfAFhSgLpkfdXP+DnayG8l9ZIabG3dqyLvkXB8QtCU/XL56ueGd+tAzaMmN6BYubt8AM9CEuhGy0BPuyYN63Lfqvo7BWp43vM9oAiWUkRILBngVtv44XNbDKvfbJDI6ppzdG2FEzX6I8oXH+WtTCbUe1S0I0jC9nL7OATtkcsU1gjKfclxVv7TP7ct9iWfhP2HSWOaN8n27CKNo3cHCrNTyTTzRfzrLK3cuoWTmVyT1HYxWdOhk3qJvANWRI8t+tAlSqvcBhNMzT+sKXzlFlrmkGTfXHil2R+CXlZF2cBBmLXpe1r2aFobX6rRE78yhHWGfmXgdWVjVIW9Lcvg5C0Y+jbixCHywrHgoUVNCEhSb7EcoLBoJTfoztgofsv3hFfNQlXibCsy1itYJjz+P4zbVn9pCl7mZIGEqkkLkZwS0V7bVKAdO7hEUNFA6ba8QGaAGwsDlKP/kRB39Dd9f964OcHSi9gWUKFjscRZtwJNsJvdcWlEEU/XNAsow+WLDRlrh2sl1DARec= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR08MB9155.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(366004)(376002)(39840400004)(136003)(396003)(451199015)(478600001)(966005)(6486002)(186003)(2906002)(1076003)(2616005)(44832011)(6506007)(4326008)(6666004)(107886003)(54906003)(36756003)(316002)(8676002)(66476007)(52116002)(83380400001)(38100700002)(66946007)(66556008)(5660300002)(7416002)(8936002)(6512007)(86362001)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gRJsmnxn+SeF8rkDgqsXQW2pA7WRslPlFsyoQSFsG45M1vK9QYGUYNlf1AEeXNgKvvSIGrFv3obXTQKCxmyxqHjeK22Scmw0c3sFM+ORv/ELSL/KbuSQd+WAM9Q8va7+1YMyfJj5I4cT8ntB6QeQ2EpKzmhlw3iRMwS2jVMI7LiM4BtAAtSwgf4Po5LtQAKonw8hp7/NdM5rapWptBfXkUa2mJoKcnGIu3z72uNUSAvI3p2pNuU4UfIDLI4UW7uQ7d4at2VNTM2K8bgjinr+bo8Wjh3Idq9lYADiNt5rrdwy1WsIfGZCEEPIKjWJqhUjHAXUVgGm08Hn7N3/1cpZXiDqurhi6B2ODijlW6r8w9NwmzkRjZJxK+vvwhGcYB7hynEU0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plYNvAcUjNYhTYS3iewj0gCgpn21QwSoCgHDdJAtnN08d/ckxHML4ackzSc4QP8dN6dJbINvPWsS3CnaFm62rSYH34nyJ9hUSrOSsIcVQ+12b7I2rtm8d1ZvUvYLg36KI9ID20oBMX2j/iNHSSs7leiwemcP5jVvCfq6XegOjdRCQ4AuE9OYJ796EuL9Z4EI8csPWu/4VRJN/NTMGnRQ75HYA== X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 1cb72067-b268-4473-eebf-08dabc9c84e7 X-MS-Exchange-CrossTenant-AuthSource: DU0PR08MB9155.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2022 06:36:05.8308 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wikYqcQw9xFy8XtF4b6yiyueizbFy+HUc3haRF2QDqiei+R+4+HSm8lyhnaecQhWlM8xUGGU1/ERtJ/aSxK5Uyna37cCuUVLKSzki0X/xss= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5459 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748365949840971608?= X-GMAIL-MSGID: =?utf-8?q?1748365949840971608?= |
Series |
iommu/rockchip: fix permission bits in page table entries v2
|
|
Commit Message
Michael Riesch
Nov. 2, 2022, 6:35 a.m. UTC
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 <michael.riesch@wolfvision.net>
---
drivers/iommu/rockchip-iommu.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
Comments
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 <michael.riesch@wolfvision.net> Reviewed-by: Heiko Stuebner <heiko@sntech.de> > --- > 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; > } >
On Wed, Nov 02, 2022 at 07:35:53AM +0100, Michael Riesch wrote: > drivers/iommu/rockchip-iommu.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) Applied, thanks.
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; }