Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp584879pxb; Tue, 15 Feb 2022 22:55:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyknXjtaZmmrL+xez2zXkWfZtmtNoXmYq8crRxZxw4tH7nEtZA78oYGFc0pTPTMEB5Jea34 X-Received: by 2002:a63:a509:0:b0:36c:6a53:7cd with SMTP id n9-20020a63a509000000b0036c6a5307cdmr1119048pgf.403.1644994536400; Tue, 15 Feb 2022 22:55:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644994536; cv=none; d=google.com; s=arc-20160816; b=Sc3EX0LyeQsgU4cgqXMZsHKwuOP+strcRw/f2P5iTY53+eGy8yKm/3umkrwmrAoQMK v+dMgBstlpTj0ZvxVtTxA1KzUnyK3DjRwjK1Rn770yIstE4Mvtqu0hEN27NozO/eB22W QpgpBgLjcaA5mhdPP3rLi2AWV6cXJisyLIeoXVZsd8a0qmO4y6IWg2nGAcLG0eDFH4zO FrI4pvUpxZu9yJsudbRgIhMn3Ucdp7jeB59BY2mVbXpFCWJe4qm+DNIK4NW/QMQuwLEw QiOOtFrdvh6vJWzyQ8Og1bN9dYQYoPgZCXdHMQxV3zg1k71hgEeQjjWXiS0z8Cm7pJT8 lxkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CDBQKjrOHx1jFqanGpjTZz0mkLi+B8rGvMm6ZK2mah0=; b=qH0q5VbHS75x/Msm8ZobpapUXJVQHY+h4LAOOzxkw9J3A52ijsFM+QGv8QWV+g2iJT 3zslrxRwRNWuHw/tMrOcz8RRVW6RtKVYnzlSBpTvxbU1sooONWh+QZBRU/VU3cZyjcfE 3zXVGgbpSJyXCDeAsBJZOOnmFs3I6Of9+0h5NBLEdnLKQVvgWKS/5IjLcWh73HtQBBkX fQbmsuxOYII/S65sU+3EY2IXMM9FKneefyLa7ffGloDVEQLrYks1R5mYBi5Z7PkWZjmN uhfz8CPaxstQ+Xdg9JOrt0aX8FamjPMiViR0W+XwcRuxCSjtBXA+baiht2TlZqLDOb6C K5UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ANYaNLWF; 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=chromium.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q12si17160671pls.332.2022.02.15.22.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:55:36 -0800 (PST) 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=@chromium.org header.s=google header.b=ANYaNLWF; 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=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E94B1ACF34; Tue, 15 Feb 2022 22:38:00 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230358AbiBPGGY (ORCPT + 99 others); Wed, 16 Feb 2022 01:06:24 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:52022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiBPGGW (ORCPT ); Wed, 16 Feb 2022 01:06:22 -0500 Received: from mail-oo1-xc2e.google.com (mail-oo1-xc2e.google.com [IPv6:2607:f8b0:4864:20::c2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BA3B15B995 for ; Tue, 15 Feb 2022 22:06:10 -0800 (PST) Received: by mail-oo1-xc2e.google.com with SMTP id d134-20020a4a528c000000b00319244f4b04so1348812oob.8 for ; Tue, 15 Feb 2022 22:06:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CDBQKjrOHx1jFqanGpjTZz0mkLi+B8rGvMm6ZK2mah0=; b=ANYaNLWFCQkj69oiskZkSh6DjZmPGeiq9PrEgU2cP3v3dn1nkwLwYm7cx+4vS6oOKw RwNzEIyq3NLxuuxq6/pXX241+VkGVJtb86AlOXZXiNaOF+o9MwFTZ3Ial6STIS1UiAA5 dhBgfFPAMgGgTKfxv7tknbGcdLXT5auCslnVM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CDBQKjrOHx1jFqanGpjTZz0mkLi+B8rGvMm6ZK2mah0=; b=wgHhQk8R3gdDhW32y0vBYZSQ4nh+Oa62SQkZ5whSFdQ9rAZ9o5xSymWJCxNDWtoYZn hnUNbtzTwc+kHCtIKG7/ffGLmgbcV4S+/2hhuKPAq1zPKatHzrFj+dN+FEcZlidyweb5 l7x3CiyokN4oSvCxN30uPp8BrKJASY1XHhaewywd2uEME6fkrlAZoFOdR2u6L0YbjNgC +wCvPgK0W8254FgMTTsC+Rl7RH3bTrpZgcpNeGykL2hUEs7V6v2KRbynvz3wir5HcQY2 dCQisHu/8lGwpOZ5/VRzTFjt0BSf/Xzg5PQVrvb44gCa4lYKObBRKGaZ7vjPIywdcugV PSLA== X-Gm-Message-State: AOAM5313vqIgaBUp47OEG0XSsMZGq54c07oFEEPP6xu5cDNjgyGU3gI7 GfvY5d8zHpn8CSgpuhvQqTpLqLB/h3CJjpPHkbE= X-Received: by 2002:a05:6870:30e:b0:bf:9b7f:7c63 with SMTP id m14-20020a056870030e00b000bf9b7f7c63mr11622oaf.84.1644991569849; Tue, 15 Feb 2022 22:06:09 -0800 (PST) Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com. [209.85.210.48]) by smtp.gmail.com with ESMTPSA id x12sm14646616otq.6.2022.02.15.22.06.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Feb 2022 22:06:09 -0800 (PST) Received: by mail-ot1-f48.google.com with SMTP id g6-20020a9d6486000000b005acf9a0b644so853269otl.12 for ; Tue, 15 Feb 2022 22:06:09 -0800 (PST) X-Received: by 2002:a0d:c383:0:b0:2d0:f04e:7ada with SMTP id f125-20020a0dc383000000b002d0f04e7adamr1070020ywd.229.1644991156422; Tue, 15 Feb 2022 21:59:16 -0800 (PST) MIME-Version: 1.0 References: <20220125085634.17972-1-yong.wu@mediatek.com> <20220125085634.17972-9-yong.wu@mediatek.com> In-Reply-To: From: Tomasz Figa Date: Wed, 16 Feb 2022 14:59:05 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 08/35] iommu/mediatek: Use kmalloc for protect buffer To: Yong Wu Cc: AngeloGioacchino Del Regno , Robin Murphy , Krzysztof Kozlowski , linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, Hsin-Yi Wang , youlin.pei@mediatek.com, anan.sun@mediatek.com, xueqi.zhang@mediatek.com, yen-chang.chen@mediatek.com, mingyuan.ma@mediatek.com, yf.wang@mediatek.com, libo.kang@mediatek.com, chengci.xu@mediatek.com, Joerg Roedel , Rob Herring , Matthias Brugger , Will Deacon Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Wed, Feb 16, 2022 at 2:55 PM Yong Wu wrote: > > On Thu, 2022-01-27 at 12:08 +0100, AngeloGioacchino Del Regno wrote: > > Il 25/01/22 09:56, Yong Wu ha scritto: > > > No need zero for the protect buffer that is only accessed by the > > > IOMMU HW > > > translation fault happened. > > > > > > Signed-off-by: Yong Wu > > > > I would rather keep this a devm_kzalloc instead... the cost is very > > minimal and > > this will be handy when new hardware will be introduced, as it may > > require a bigger > > buffer: in that case, "older" platforms will use only part of it and > > we may get > > garbage data at the end. > > Currently this is to avoid zero 512 bytes for all the platforms. > > Sorry, I don't understand why it is unnecessary when the new hardware > requires a bigger buffer. If the buffer becomes bigger, then clearing > it to 0 need more cost. then this patch is more helpful? > > The content in this buffer is garbage, we won't care about or analyse > it. I think we should zero it for security reasons regardless of any other aspects. With this patch it's leaking kernel data to the hardware. At the same time, we're talking here about something executed just 1 time when the driver probes. I don't think the cost would really matter. Best regards, Tomasz