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 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91E20C433F5 for ; Fri, 25 Mar 2022 10:26:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2393684186; Fri, 25 Mar 2022 11:26:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="JR01Vg+C"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 15D1083987; Fri, 25 Mar 2022 11:26:37 +0100 (CET) Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4414084186 for ; Fri, 25 Mar 2022 11:26:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ascull@google.com Received: by mail-qk1-x732.google.com with SMTP id d65so2116843qke.5 for ; Fri, 25 Mar 2022 03:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Sgl3bjGQVXk/bNBpe48sd3Q+/EY+7qvCC4bwXnHeXxo=; b=JR01Vg+CvRRWiWXZMSf9Nv18/9Dn/tapugIJqPJ7xk2MJvKG9zWDiqbWGOSvauvDsM d8g1j0jXazTRb6vQ8Ncx10YmAjpKKaEnp7YQ4L5P3A53+68QFMtH/bUgRACn53Ka+s+y sZmSoP76V1Qxme5zbSZqYms4Z9PxmlbgNABwNFKamOwJbOmiBJXA4v9Bw+XFb1ml7RXa 4l+YSwMUWSXSx7UtqkScH3t6+X93d3jqNNGBCBNVYm+VJO/lDmxlD6j2tviCIHCMolxK ggHxfCwlWBiANU0Ykq2veHu4CB+rtaQtf8thPftK3xkVOMS+2jd6xlql6Z/2zXnuXMTw tt4Q== 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=Sgl3bjGQVXk/bNBpe48sd3Q+/EY+7qvCC4bwXnHeXxo=; b=DjcpBYuH4zJpxmC2X/oU1Xpecx1BSUg6sXLHAzhX9Mv3Ce3ojJYApXoGgOZ+5xCl9W VlE1ucc3il0wSnZjcDYAOO9prP50qVUWh+yIPYXxIEuuqzaAjNX9NUrO6GSzPWbiu8s/ a/HL6TvVQsJGARvOrZzRKP6Z+M2EpyCCiRH+Y8moxH4m7iUEJjUWAS2+KW9tVPt6vzn4 yzLe3TLnHvH02XJ3qpb18n4OEb0uNIVCuGUgjzMTacVLMtGgLzyT6V3Z2tyeDkaftscf g8776YUPnFuYEXifKW7EqhP569FpunXzd/ryaREzGd/b/lLNLmM/Uy/2iqkabPV41/4d TM9A== X-Gm-Message-State: AOAM533MXiSykOXfm6dps0wDRNEghlCKWM2H5dd/Lzji/Q48RoSWE7Cm dApfuM2ikatHEaNfyF5u7jqdE3Tujt+wf/oeuiCgmA== X-Google-Smtp-Source: ABdhPJzIQU/iqYZVnhQn8tou2UqYUIOOd46evpWeHPqY+v02TUhJlRlXkDZUtIhhxbVqph1Xh8K6LKIcdNLGeC8IBy0= X-Received: by 2002:a37:45d3:0:b0:47a:645e:137f with SMTP id s202-20020a3745d3000000b0047a645e137fmr6216341qka.535.1648203991913; Fri, 25 Mar 2022 03:26:31 -0700 (PDT) MIME-Version: 1.0 References: <20220320114118.2237795-1-ascull@google.com> <20220320114118.2237795-10-ascull@google.com> In-Reply-To: From: Andrew Scull Date: Fri, 25 Mar 2022 10:26:21 +0000 Message-ID: Subject: Re: [PATCH 09/11] pci: Add function to validate PCI address range To: Bin Meng Cc: U-Boot Mailing List , Simon Glass , Alistair Delva , Keir Fraser , =?UTF-8?Q?Pierre=2DCl=C3=A9ment_Tosi?= Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On Fri, 25 Mar 2022 at 07:14, Bin Meng wrote: > > On Sun, Mar 20, 2022 at 7:42 PM Andrew Scull wrote: > > > > Add a function to convert a PCI address range to a physical address > > range. The address range is validated to ensure it is contained within > > one of the PCI address regions and that the whole range can be indexed > > from the resulting physical address. > > I am not sure if we need to provide such an API given there is already > dm_pci_bus_to_phys() and friends. Not sure we really need this new API > to add a check against the range. ... > If we really need this, I believe we can do some refactoring on the > existing _dm_pci_bus_to_phys() to provide the new capability you > wanted. A big reason is to check the range fits in the region, not just a single pointer. It looks like evolving the existing API might not be too tricky for that. The bit that really caused me trouble was that the PCI driver adds system memory as identity mapped regions. But that system memory hasn't been declared as part of the PCI bus so why is it being added? I want to remove that but don't know the background, or have the ability to test PCI will still work properly. We can't allow a virtio device to claim it has buffers in the middle of system memory and then have the driver blindly corrupt that region of memory, so there'll need to be a way to prevent that. > > + * @size: Size of the addressrange > > need a space before 'range' Ack. > Please add a test case in test/dm/pci.c to cover this new API. I was just learning about the sandbox testing, I'll take a look.