Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp259574rwe; Wed, 31 Aug 2022 02:14:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR4XfkFgRpjYnayLtQ8C7ovdRf/SiNdV/19BGAEwZr8EWL8qHTIg4AVwPq/n5iqJGXXa9Cjx X-Received: by 2002:a63:1853:0:b0:41d:70c0:978e with SMTP id 19-20020a631853000000b0041d70c0978emr21624323pgy.32.1661937247570; Wed, 31 Aug 2022 02:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661937247; cv=none; d=google.com; s=arc-20160816; b=JhdHvyvHjts/yULNEPi0ZTuNKumtfHiEqzwxCkuCMwjlCsGGSl0ytLb/JBgJsbFEUr yHur0atKlSG7iU8D1hwx7xBNBBptzHujh/oym2BCJg4IxAxICkYC50WYZdE0fOaleA9W I+fsEPu/yIU2+msHhyT2CNCQikNdqppIw053qaH4dfcVGOqHkNPBYHS0pPPFUy2xdxrg MHtujamUdFXdchztXzOQMFeMQf8aBEMUCvp1LMljq75H3V9TFUg6jEw0fqbrxIxTZAf6 MJA8VB7Yk0dTvr3aBxb2x1K6ZzRv09XJ3SflzrY73i1QkI2xMzMc6MF7Y08b/IEAwdC5 tysg== 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:subject:cc:to:from:date; bh=pDMYg8zFXoQhZ//PcRW4XFmWxXNomhHfQU70RgAeu6U=; b=wFGRkMQ0FPxXi2aruAI1tlSYSwI9IggPK7+0guNP1u5lW0EweoQFtnQXehPMgJ6TU+ U5FNIm+1hdqE8EVrWgSEBsZD4S+MqlLKBXlw7Cot1m/8bVJF9UGGaTKqtw9sWK9Uc4kK xVCdCH4GhFvKQXiClOYoYWYiSVTwZ0NhkYJAKmkWLo5daaP4zUNvB5EHhoaeYCUNiplJ GAThKdkturY1E+IFz4o4QDHyufv9ucCgDv8Z6uuRSU4grkPKlfG/yTZAOuZLnkUVvyOk L4Njx8BPhB96E4GfCKEa9E1NbB8fjMP+vNkVweXaGo1bHdVljT6ZbjAzlyLb0ZIa5jaV g3Rg== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a656ab8000000b0042af14719edsi4537614pgu.295.2022.08.31.02.13.54; Wed, 31 Aug 2022 02:14:07 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231707AbiHaI6N (ORCPT + 99 others); Wed, 31 Aug 2022 04:58:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231819AbiHaI5c (ORCPT ); Wed, 31 Aug 2022 04:57:32 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1187CCD797; Wed, 31 Aug 2022 01:56:59 -0700 (PDT) Received: from fraeml712-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MHdHT34dFz67yhg; Wed, 31 Aug 2022 16:53:09 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml712-chm.china.huawei.com (10.206.15.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 31 Aug 2022 10:56:53 +0200 Received: from localhost (10.202.226.42) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 31 Aug 2022 09:56:52 +0100 Date: Wed, 31 Aug 2022 09:56:51 +0100 From: Jonathan Cameron To: Robert Richter CC: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams , , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown Subject: Re: [PATCH 02/15] cxl/core: Check physical address before mapping it in devm_cxl_iomap_block() Message-ID: <20220831095651.00000c73@huawei.com> In-Reply-To: <20220831081603.3415-3-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> <20220831081603.3415-3-rrichter@amd.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.42] X-ClientProxiedBy: lhrpeml100006.china.huawei.com (7.191.160.224) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Wed, 31 Aug 2022 10:15:50 +0200 Robert Richter wrote: > The physical base address of a CXL range can be invalid and is then > set to CXL_RESOURCE_NONE. Early check this case before mapping a > memory block in devm_cxl_iomap_block(). An example of when it is invalid would be a useful addition to this description. Feels to me like this is papering over the cracks in something we should have ruled out earlier in the flow. Jonathan > > Signed-off-by: Robert Richter > --- > drivers/cxl/core/regs.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c > index 39a129c57d40..f216c017a474 100644 > --- a/drivers/cxl/core/regs.c > +++ b/drivers/cxl/core/regs.c > @@ -165,6 +165,9 @@ void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, > void __iomem *ret_val; > struct resource *res; > > + if (addr == CXL_RESOURCE_NONE) > + return NULL; > + > res = devm_request_mem_region(dev, addr, length, dev_name(dev)); > if (!res) { > resource_size_t end = addr + length - 1;