From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A109C43381 for ; Fri, 29 Mar 2019 22:07:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 028182184D for ; Fri, 29 Mar 2019 22:07:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730420AbfC2WHA (ORCPT ); Fri, 29 Mar 2019 18:07:00 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:37886 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730233AbfC2WHA (ORCPT ); Fri, 29 Mar 2019 18:07:00 -0400 Received: by mail-oi1-f196.google.com with SMTP id v84so2892613oif.4; Fri, 29 Mar 2019 15:06:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xMejZq18/+Wxs5n8oH4gqh9wWmcSonpiJfOlZddBtnY=; b=NyPgix371uB4hs+hxccZIHJGjhTjlX/+2Hb7w/cfX4p/DGsnSdipHvjTboO3rfDpwj LKWfVPM56iBssZFjp9DtflI5nqZo0emJUGJBQKV/4VUDJUKD+8f079XtnNoFW6AvXm95 HZzELfoD3oBqBubEelL1pfcpqAeMfbabbETMCbIhqPBVQ7qhPa7w73buBqR4ve40IB5u Ejn2jUmJyqt9AOU5TzE1fcUEz6YBfS7w6chyPU94hqQ5NQA3Uxvctvca41YmwSVhg0+U dY4B9iSivJzGzdWAl8k1fFIFvQBArWvJEhc9QIm0sZWH3/e7sONnWJCtmuR9oeC+C/JV 3ysA== X-Gm-Message-State: APjAAAV5TgLDVschNpk5jUm4KlHXznelNbyid52AgllWa4Tj2PWTz8Rr LEkS2otnSszMDuhpkO4eU4t5cr21Kqo= X-Google-Smtp-Source: APXvYqx2t8j621CXtdcf0yX0DtSmIM8onrrEjJEVYUhk7UM0Rl+hYEHgmF2+3jV/MVVDq4CV/MGaYw== X-Received: by 2002:aca:c782:: with SMTP id x124mr5261837oif.61.1553897218647; Fri, 29 Mar 2019 15:06:58 -0700 (PDT) Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com. [209.85.210.49]) by smtp.gmail.com with ESMTPSA id q23sm1362602oic.45.2019.03.29.15.06.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 15:06:58 -0700 (PDT) Received: by mail-ot1-f49.google.com with SMTP id m10so3534174otp.2; Fri, 29 Mar 2019 15:06:57 -0700 (PDT) X-Received: by 2002:a9d:6a47:: with SMTP id h7mr3522537otn.158.1553897217564; Fri, 29 Mar 2019 15:06:57 -0700 (PDT) MIME-Version: 1.0 References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-6-laurentiu.tudor@nxp.com> In-Reply-To: <20190329140014.8126-6-laurentiu.tudor@nxp.com> From: Li Yang Date: Fri, 29 Mar 2019 17:06:45 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 05/13] soc/fsl/bqman: page align iommu mapping sizes To: Laurentiu Tudor Cc: Netdev , madalin.bucur@nxp.com, Roy Pledge , camelia.groza@nxp.com, David Miller , Linux IOMMU , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linuxppc-dev , lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 29, 2019 at 9:01 AM wrote: > > From: Laurentiu Tudor > > Prior to calling iommu_map()/iommu_unmap() page align the size or > failures such as below could happen: > > iommu: unaligned: iova 0x... pa 0x... size 0x4000 min_pagesz 0x10000 > qman_portal 500000000.qman-portal: failed to iommu_map() -22 > > Seen when booted a kernel compiled with 64K page size support. This will silently incease the actual space mapped to 64K when the driver is actually trying to map 4K. Will this potentially cause security breaches? If it is really safe to map 64K, probably the better way is to increase the region size to 64k in the device tree explicitly. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_ccsr.c | 2 +- > drivers/soc/fsl/qbman/qman_ccsr.c | 4 ++-- > drivers/soc/fsl/qbman/qman_portal.c | 2 +- > 3 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c > index b209c79511bb..3a6e01bde32d 100644 > --- a/drivers/soc/fsl/qbman/bman_ccsr.c > +++ b/drivers/soc/fsl/qbman/bman_ccsr.c > @@ -230,7 +230,7 @@ static int fsl_bman_probe(struct platform_device *pdev) > /* Create an 1-to-1 iommu mapping for FBPR area */ > domain = iommu_get_domain_for_dev(dev); > if (domain) { > - ret = iommu_map(domain, fbpr_a, fbpr_a, fbpr_sz, > + ret = iommu_map(domain, fbpr_a, fbpr_a, PAGE_ALIGN(fbpr_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "failed to iommu_map() %d\n", ret); > diff --git a/drivers/soc/fsl/qbman/qman_ccsr.c b/drivers/soc/fsl/qbman/qman_ccsr.c > index eec7700507e1..8d3c950ce52d 100644 > --- a/drivers/soc/fsl/qbman/qman_ccsr.c > +++ b/drivers/soc/fsl/qbman/qman_ccsr.c > @@ -783,11 +783,11 @@ static int fsl_qman_probe(struct platform_device *pdev) > /* Create an 1-to-1 iommu mapping for fqd and pfdr areas */ > domain = iommu_get_domain_for_dev(dev); > if (domain) { > - ret = iommu_map(domain, fqd_a, fqd_a, fqd_sz, > + ret = iommu_map(domain, fqd_a, fqd_a, PAGE_ALIGN(fqd_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "iommu_map(fqd) failed %d\n", ret); > - ret = iommu_map(domain, pfdr_a, pfdr_a, pfdr_sz, > + ret = iommu_map(domain, pfdr_a, pfdr_a, PAGE_ALIGN(pfdr_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "iommu_map(pfdr) failed %d\n", ret); > diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c > index dfb62f9815e9..bce56da2b01f 100644 > --- a/drivers/soc/fsl/qbman/qman_portal.c > +++ b/drivers/soc/fsl/qbman/qman_portal.c > @@ -297,7 +297,7 @@ static int qman_portal_probe(struct platform_device *pdev) > */ > err = iommu_map(domain, > addr_phys[0]->start, addr_phys[0]->start, > - resource_size(addr_phys[0]), > + PAGE_ALIGN(resource_size(addr_phys[0])), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (err) > dev_warn(dev, "failed to iommu_map() %d\n", err); > -- > 2.17.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0390C43381 for ; Fri, 29 Mar 2019 22:08:38 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3F5F2184D for ; Fri, 29 Mar 2019 22:08:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3F5F2184D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44WG8g2sKpzDqQV for ; Sat, 30 Mar 2019 09:08:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=209.85.210.65; helo=mail-ot1-f65.google.com; envelope-from=pku.leo@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44WG6s0lgVzDqQ9 for ; Sat, 30 Mar 2019 09:07:00 +1100 (AEDT) Received: by mail-ot1-f65.google.com with SMTP id e5so3392632otk.12 for ; Fri, 29 Mar 2019 15:07:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xMejZq18/+Wxs5n8oH4gqh9wWmcSonpiJfOlZddBtnY=; b=smKBQJcmckr63ysbPssIO2dZgggKkZ2sVlEa3PhW74HN7LY25M03e4GWfKHtM394ol +l6iL3p6m2ywBHj5RGsJGxOfPnpLOETBMwQcfeghSr3+IpKAPuJ2OmvY0jxv+xhOLuE2 o21lF2jyRYA/NeJEOLAkZdQblk3/pOnaTuM4293/9cDjJUmEb7oFqtYDlPfk3DN6WrMC n9Ws34cZysPQQ6xIPb+MsRzMqs9XMxaXwp3evObL9rODwupkHsxdGayyULo8dXnqmWjo 9v5JOLLSeZXvZfA5QFuZlcF9h/hLSk6kzyE/U8TWRPy5pDTcav+C5ooTERITX40+kUBh 5LAA== X-Gm-Message-State: APjAAAU+NN8OguvZM6Jlf3CPIP1zziRULYPXiCcuK1iZgzpTndaUvPXO C9lYE0r4ensEiRxkyU+zluNDgSj9D5M= X-Google-Smtp-Source: APXvYqy8Umu1rHUnRnIw3MAKPYMQ+x5JQCTTqnMGOurIltryIXqVtlq5Vz2kdM71I0zM2xiqhGuMNA== X-Received: by 2002:a9d:7e91:: with SMTP id m17mr10273219otp.78.1553897218458; Fri, 29 Mar 2019 15:06:58 -0700 (PDT) Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com. [209.85.210.47]) by smtp.gmail.com with ESMTPSA id l63sm1269589oia.47.2019.03.29.15.06.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 15:06:57 -0700 (PDT) Received: by mail-ot1-f47.google.com with SMTP id e80so3427933ote.5 for ; Fri, 29 Mar 2019 15:06:57 -0700 (PDT) X-Received: by 2002:a9d:6a47:: with SMTP id h7mr3522537otn.158.1553897217564; Fri, 29 Mar 2019 15:06:57 -0700 (PDT) MIME-Version: 1.0 References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-6-laurentiu.tudor@nxp.com> In-Reply-To: <20190329140014.8126-6-laurentiu.tudor@nxp.com> From: Li Yang Date: Fri, 29 Mar 2019 17:06:45 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 05/13] soc/fsl/bqman: page align iommu mapping sizes To: Laurentiu Tudor Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: madalin.bucur@nxp.com, Netdev , Roy Pledge , lkml , Linux IOMMU , camelia.groza@nxp.com, linuxppc-dev , David Miller , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Mar 29, 2019 at 9:01 AM wrote: > > From: Laurentiu Tudor > > Prior to calling iommu_map()/iommu_unmap() page align the size or > failures such as below could happen: > > iommu: unaligned: iova 0x... pa 0x... size 0x4000 min_pagesz 0x10000 > qman_portal 500000000.qman-portal: failed to iommu_map() -22 > > Seen when booted a kernel compiled with 64K page size support. This will silently incease the actual space mapped to 64K when the driver is actually trying to map 4K. Will this potentially cause security breaches? If it is really safe to map 64K, probably the better way is to increase the region size to 64k in the device tree explicitly. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_ccsr.c | 2 +- > drivers/soc/fsl/qbman/qman_ccsr.c | 4 ++-- > drivers/soc/fsl/qbman/qman_portal.c | 2 +- > 3 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c > index b209c79511bb..3a6e01bde32d 100644 > --- a/drivers/soc/fsl/qbman/bman_ccsr.c > +++ b/drivers/soc/fsl/qbman/bman_ccsr.c > @@ -230,7 +230,7 @@ static int fsl_bman_probe(struct platform_device *pdev) > /* Create an 1-to-1 iommu mapping for FBPR area */ > domain = iommu_get_domain_for_dev(dev); > if (domain) { > - ret = iommu_map(domain, fbpr_a, fbpr_a, fbpr_sz, > + ret = iommu_map(domain, fbpr_a, fbpr_a, PAGE_ALIGN(fbpr_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "failed to iommu_map() %d\n", ret); > diff --git a/drivers/soc/fsl/qbman/qman_ccsr.c b/drivers/soc/fsl/qbman/qman_ccsr.c > index eec7700507e1..8d3c950ce52d 100644 > --- a/drivers/soc/fsl/qbman/qman_ccsr.c > +++ b/drivers/soc/fsl/qbman/qman_ccsr.c > @@ -783,11 +783,11 @@ static int fsl_qman_probe(struct platform_device *pdev) > /* Create an 1-to-1 iommu mapping for fqd and pfdr areas */ > domain = iommu_get_domain_for_dev(dev); > if (domain) { > - ret = iommu_map(domain, fqd_a, fqd_a, fqd_sz, > + ret = iommu_map(domain, fqd_a, fqd_a, PAGE_ALIGN(fqd_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "iommu_map(fqd) failed %d\n", ret); > - ret = iommu_map(domain, pfdr_a, pfdr_a, pfdr_sz, > + ret = iommu_map(domain, pfdr_a, pfdr_a, PAGE_ALIGN(pfdr_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "iommu_map(pfdr) failed %d\n", ret); > diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c > index dfb62f9815e9..bce56da2b01f 100644 > --- a/drivers/soc/fsl/qbman/qman_portal.c > +++ b/drivers/soc/fsl/qbman/qman_portal.c > @@ -297,7 +297,7 @@ static int qman_portal_probe(struct platform_device *pdev) > */ > err = iommu_map(domain, > addr_phys[0]->start, addr_phys[0]->start, > - resource_size(addr_phys[0]), > + PAGE_ALIGN(resource_size(addr_phys[0])), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (err) > dev_warn(dev, "failed to iommu_map() %d\n", err); > -- > 2.17.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li Yang Subject: Re: [PATCH 05/13] soc/fsl/bqman: page align iommu mapping sizes Date: Fri, 29 Mar 2019 17:06:45 -0500 Message-ID: References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-6-laurentiu.tudor@nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <20190329140014.8126-6-laurentiu.tudor@nxp.com> Sender: linux-kernel-owner@vger.kernel.org To: Laurentiu Tudor Cc: Netdev , madalin.bucur@nxp.com, Roy Pledge , camelia.groza@nxp.com, David Miller , Linux IOMMU , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linuxppc-dev , lkml List-Id: iommu@lists.linux-foundation.org On Fri, Mar 29, 2019 at 9:01 AM wrote: > > From: Laurentiu Tudor > > Prior to calling iommu_map()/iommu_unmap() page align the size or > failures such as below could happen: > > iommu: unaligned: iova 0x... pa 0x... size 0x4000 min_pagesz 0x10000 > qman_portal 500000000.qman-portal: failed to iommu_map() -22 > > Seen when booted a kernel compiled with 64K page size support. This will silently incease the actual space mapped to 64K when the driver is actually trying to map 4K. Will this potentially cause security breaches? If it is really safe to map 64K, probably the better way is to increase the region size to 64k in the device tree explicitly. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_ccsr.c | 2 +- > drivers/soc/fsl/qbman/qman_ccsr.c | 4 ++-- > drivers/soc/fsl/qbman/qman_portal.c | 2 +- > 3 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c > index b209c79511bb..3a6e01bde32d 100644 > --- a/drivers/soc/fsl/qbman/bman_ccsr.c > +++ b/drivers/soc/fsl/qbman/bman_ccsr.c > @@ -230,7 +230,7 @@ static int fsl_bman_probe(struct platform_device *pdev) > /* Create an 1-to-1 iommu mapping for FBPR area */ > domain = iommu_get_domain_for_dev(dev); > if (domain) { > - ret = iommu_map(domain, fbpr_a, fbpr_a, fbpr_sz, > + ret = iommu_map(domain, fbpr_a, fbpr_a, PAGE_ALIGN(fbpr_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "failed to iommu_map() %d\n", ret); > diff --git a/drivers/soc/fsl/qbman/qman_ccsr.c b/drivers/soc/fsl/qbman/qman_ccsr.c > index eec7700507e1..8d3c950ce52d 100644 > --- a/drivers/soc/fsl/qbman/qman_ccsr.c > +++ b/drivers/soc/fsl/qbman/qman_ccsr.c > @@ -783,11 +783,11 @@ static int fsl_qman_probe(struct platform_device *pdev) > /* Create an 1-to-1 iommu mapping for fqd and pfdr areas */ > domain = iommu_get_domain_for_dev(dev); > if (domain) { > - ret = iommu_map(domain, fqd_a, fqd_a, fqd_sz, > + ret = iommu_map(domain, fqd_a, fqd_a, PAGE_ALIGN(fqd_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "iommu_map(fqd) failed %d\n", ret); > - ret = iommu_map(domain, pfdr_a, pfdr_a, pfdr_sz, > + ret = iommu_map(domain, pfdr_a, pfdr_a, PAGE_ALIGN(pfdr_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "iommu_map(pfdr) failed %d\n", ret); > diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c > index dfb62f9815e9..bce56da2b01f 100644 > --- a/drivers/soc/fsl/qbman/qman_portal.c > +++ b/drivers/soc/fsl/qbman/qman_portal.c > @@ -297,7 +297,7 @@ static int qman_portal_probe(struct platform_device *pdev) > */ > err = iommu_map(domain, > addr_phys[0]->start, addr_phys[0]->start, > - resource_size(addr_phys[0]), > + PAGE_ALIGN(resource_size(addr_phys[0])), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (err) > dev_warn(dev, "failed to iommu_map() %d\n", err); > -- > 2.17.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87C43C43381 for ; Fri, 29 Mar 2019 22:07:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51CAC2184D for ; Fri, 29 Mar 2019 22:07:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cCfHejk0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51CAC2184D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aBqcSbZm5nvewE3gPGm0S+JdTw+SQv5uW05R1SkDBg0=; b=cCfHejk0qGc7zU eFRNA8ckc3E947aQcKd+bulpMQ2r6cY287paVq43atAX0nCibNvtk6Xwf6XyddBkQv1ILERB4ps35 kdT5wrhPxzYqoJcTjmZJ+OnZ2dOqbN3x9T4sBa69i/55J/zGMON3j/Z7gvOzvBuMJj+FXoRtbBfYv mHrsBt00NrFoYjmw24YIK3h0LGXfYLOm2AUjK6MwI2VYu1Bw1DioZAqGWSqPW0GuzMJ7X2v5PC6xB w3s5icmAomSkMs2wdl9kve04U4n4XPITzI05X+XhH3XYKUIW0UA9ddxi2T7ZHzBDaa5Kd+ehB0GX+ MrwzKy0Xn6BpRVt2+kHw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9zeU-0004jT-3K; Fri, 29 Mar 2019 22:07:06 +0000 Received: from mail-ot1-f68.google.com ([209.85.210.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9zeR-0004ip-1E for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2019 22:07:04 +0000 Received: by mail-ot1-f68.google.com with SMTP id e80so3428025ote.5 for ; Fri, 29 Mar 2019 15:06:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xMejZq18/+Wxs5n8oH4gqh9wWmcSonpiJfOlZddBtnY=; b=nSpqBm7mhk2jYQUBi61KfjPBwh9RVs4UmZnjNSD+RJGPcCt4nzlCj89WTcmEtu+PF4 j3Ud7Tabog1W8HtqzPxOVHo2SCnpYvqDpQ/YPsqrucDkj1zPyE9X/u7awYbSBHFLXUrC 4s8l+TFNXVhgtWI7kdViqv0+Yu2+elhJSCo+0Z93kIu+pmRf1YDyp8W9qYILMLTQtYBa AcIa4OOhUZGI4nCiYApI4cU2iPRqBEvdWyvIn0kGMLu7xQ25io0gYyqbRjI+rxENWLp6 M0pUzqyeiSMot1yNWirfmviT4sbyYqBJnQ6nUVLM9xNySlkYHj8MU2jHei9I5QZh0Nmc mG4g== X-Gm-Message-State: APjAAAUgGMkQHPbRiSXiQheDnA8pvwdpfRV2DVAat0/N+Dgm70X9uCK4 FroWu1SSObxphqC03sds8E5S1YFW0rw= X-Google-Smtp-Source: APXvYqwOqle/qCsZ+aArPBAX8FcAUFAQWLSVmlI+ptg5clfXEBigQoPxL94v7x4e2VIJVgwYBrRb+g== X-Received: by 2002:a9d:191a:: with SMTP id j26mr36246321ota.327.1553897218587; Fri, 29 Mar 2019 15:06:58 -0700 (PDT) Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com. [209.85.210.46]) by smtp.gmail.com with ESMTPSA id o1sm1476087otj.11.2019.03.29.15.06.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 15:06:58 -0700 (PDT) Received: by mail-ot1-f46.google.com with SMTP id s24so3393108otk.13 for ; Fri, 29 Mar 2019 15:06:57 -0700 (PDT) X-Received: by 2002:a9d:6a47:: with SMTP id h7mr3522537otn.158.1553897217564; Fri, 29 Mar 2019 15:06:57 -0700 (PDT) MIME-Version: 1.0 References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-6-laurentiu.tudor@nxp.com> In-Reply-To: <20190329140014.8126-6-laurentiu.tudor@nxp.com> From: Li Yang Date: Fri, 29 Mar 2019 17:06:45 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 05/13] soc/fsl/bqman: page align iommu mapping sizes To: Laurentiu Tudor X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190329_150703_077235_49485044 X-CRM114-Status: GOOD ( 17.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: madalin.bucur@nxp.com, Netdev , Roy Pledge , lkml , Linux IOMMU , camelia.groza@nxp.com, linuxppc-dev , David Miller , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Mar 29, 2019 at 9:01 AM wrote: > > From: Laurentiu Tudor > > Prior to calling iommu_map()/iommu_unmap() page align the size or > failures such as below could happen: > > iommu: unaligned: iova 0x... pa 0x... size 0x4000 min_pagesz 0x10000 > qman_portal 500000000.qman-portal: failed to iommu_map() -22 > > Seen when booted a kernel compiled with 64K page size support. This will silently incease the actual space mapped to 64K when the driver is actually trying to map 4K. Will this potentially cause security breaches? If it is really safe to map 64K, probably the better way is to increase the region size to 64k in the device tree explicitly. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_ccsr.c | 2 +- > drivers/soc/fsl/qbman/qman_ccsr.c | 4 ++-- > drivers/soc/fsl/qbman/qman_portal.c | 2 +- > 3 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c > index b209c79511bb..3a6e01bde32d 100644 > --- a/drivers/soc/fsl/qbman/bman_ccsr.c > +++ b/drivers/soc/fsl/qbman/bman_ccsr.c > @@ -230,7 +230,7 @@ static int fsl_bman_probe(struct platform_device *pdev) > /* Create an 1-to-1 iommu mapping for FBPR area */ > domain = iommu_get_domain_for_dev(dev); > if (domain) { > - ret = iommu_map(domain, fbpr_a, fbpr_a, fbpr_sz, > + ret = iommu_map(domain, fbpr_a, fbpr_a, PAGE_ALIGN(fbpr_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "failed to iommu_map() %d\n", ret); > diff --git a/drivers/soc/fsl/qbman/qman_ccsr.c b/drivers/soc/fsl/qbman/qman_ccsr.c > index eec7700507e1..8d3c950ce52d 100644 > --- a/drivers/soc/fsl/qbman/qman_ccsr.c > +++ b/drivers/soc/fsl/qbman/qman_ccsr.c > @@ -783,11 +783,11 @@ static int fsl_qman_probe(struct platform_device *pdev) > /* Create an 1-to-1 iommu mapping for fqd and pfdr areas */ > domain = iommu_get_domain_for_dev(dev); > if (domain) { > - ret = iommu_map(domain, fqd_a, fqd_a, fqd_sz, > + ret = iommu_map(domain, fqd_a, fqd_a, PAGE_ALIGN(fqd_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "iommu_map(fqd) failed %d\n", ret); > - ret = iommu_map(domain, pfdr_a, pfdr_a, pfdr_sz, > + ret = iommu_map(domain, pfdr_a, pfdr_a, PAGE_ALIGN(pfdr_sz), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (ret) > dev_warn(dev, "iommu_map(pfdr) failed %d\n", ret); > diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c > index dfb62f9815e9..bce56da2b01f 100644 > --- a/drivers/soc/fsl/qbman/qman_portal.c > +++ b/drivers/soc/fsl/qbman/qman_portal.c > @@ -297,7 +297,7 @@ static int qman_portal_probe(struct platform_device *pdev) > */ > err = iommu_map(domain, > addr_phys[0]->start, addr_phys[0]->start, > - resource_size(addr_phys[0]), > + PAGE_ALIGN(resource_size(addr_phys[0])), > IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > if (err) > dev_warn(dev, "failed to iommu_map() %d\n", err); > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel