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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8421CA0EE5 for ; Fri, 30 Aug 2024 06:47:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E4966B00C6; Fri, 30 Aug 2024 02:47:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 494C76B00C7; Fri, 30 Aug 2024 02:47:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35B926B00C8; Fri, 30 Aug 2024 02:47:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 18FFE6B00C6 for ; Fri, 30 Aug 2024 02:47:14 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BCCF212158B for ; Fri, 30 Aug 2024 06:47:13 +0000 (UTC) X-FDA: 82507979946.28.9621997 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by imf18.hostedemail.com (Postfix) with ESMTP id B7A9F1C0008 for ; Fri, 30 Aug 2024 06:47:10 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=RukbArmv; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf18.hostedemail.com: domain of ying.huang@intel.com designates 192.198.163.16 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725000331; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2VN+aQdrvHvJ1objEmEJcvkcWjbRAza4NJIKho0ae8g=; b=wXf0yUeXGtE4yGR5OtmVIbbyWJxVbPY7R7keOyi4iZK9P1GdaibzWnbe6G9INlFNaWbl4F h4UTFiAl0AHd7liX1gUm+AnAnSHwom29dnKjptsEnUVhsvl6oVKhqkAy1XXIXo4/qibMZ+ bKUA95lSc79nc58xO8Rh9ym6NPJYaTk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725000331; a=rsa-sha256; cv=none; b=2SRKP3a44ohokfRqmkWlXKfU9U3V51OcKKUIa4WYh8/IyYrOrv6VZotXDhyyqrCnr3hZ05 pOT/7kNF4uQzWD3HGjQLYPRpajlgs5p/j618QTeCNsdu/0OGzX0GGoDehKcd3jvIpPjHxI xuGEsysFsK5tWT5/UCL9fCnLasCoLKw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=RukbArmv; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf18.hostedemail.com: domain of ying.huang@intel.com designates 192.198.163.16 as permitted sender) smtp.mailfrom=ying.huang@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725000431; x=1756536431; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=9u2NqNAZxyH1bxD3bDF0tMDXFzDorwQV4MNtYJzaT4E=; b=RukbArmv41jZwJFubau3oYT8vgSBAKiWi+yv8TsUL9YDOghFkz2tx90x 5RVLTDXiyefvZ+U1sazxCeMcXbLrd2KY+lFSJpHBRxTj8YzMr0p5rq2TN EeBAHhfT2y3Un9Q/oHaeRFo8RIxle9IF6tzvm6pL3qOY9grlJhoEJOTzM 6cs+VPX0KodFy/S2Hi7DdoIuy63ICeP72Fo8e03xOms3zpgdUee/CLXX5 REdBH4ElAAJC3jJQkz1vNiyZKxO3vJiLZeTpT0Y0EIqiogsolqQRrXj3z 9/F63CmSJG0+zh97F/QTFTYJLlgN2bmD705Q/ipXPY4ARYq1G4ZsYp5sT g==; X-CSE-ConnectionGUID: KJnuAxlwSAqFLiGdJ0FmVQ== X-CSE-MsgGUID: /NDoc5WMTNOr8SufnRuFNA== X-IronPort-AV: E=McAfee;i="6700,10204,11179"; a="13293387" X-IronPort-AV: E=Sophos;i="6.10,188,1719903600"; d="scan'208";a="13293387" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2024 23:47:09 -0700 X-CSE-ConnectionGUID: JCyq5GFqRwmdUMOVp3v6Lw== X-CSE-MsgGUID: A5ioDctSRmeYvZMdNk8v6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,188,1719903600"; d="scan'208";a="68472946" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2024 23:47:06 -0700 From: "Huang, Ying" To: Dan Williams Cc: Bjorn Helgaas , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, David Hildenbrand , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Alistair Popple , Andy Shevchenko , Bjorn Helgaas , Baoquan He Subject: Re: [PATCH -v2] Resource: fix region_intersects() for CXL memory In-Reply-To: <66c697cf7b95a_760529414@dwillia2-mobl3.amr.corp.intel.com.notmuch> (Dan Williams's message of "Wed, 21 Aug 2024 18:43:43 -0700") References: <20240819023413.1109779-1-ying.huang@intel.com> <20240821184615.GA262749@bhelgaas> <66c697cf7b95a_760529414@dwillia2-mobl3.amr.corp.intel.com.notmuch> Date: Fri, 30 Aug 2024 14:43:32 +0800 Message-ID: <87ikvih5nv.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B7A9F1C0008 X-Stat-Signature: jrzduyoadh4tuxbzgppegwc79d5mnnmq X-Rspam-User: X-HE-Tag: 1725000430-153536 X-HE-Meta: U2FsdGVkX1+MPcbVJIkKSUlejZawdziYfnYXSJOGokVYb5pS5uuBwaA5r03i7BiPbulwaBs6KuqxklLfhGPVKK6wrEdMYNfvS6abqWHxcH6dJkuGauXhXS6KAU2Z263Mp2031lHIN8fvbBXl+dTkb5yje8TtY+/RbBiR2zye5I1yUviZHJHzDDB3Urb8zKDrHdrthfH71m7F5lc98AIR0vHgrMdmYyy/+99SbKwBGxLCClixEEDTX0BK22FXPSDehUk0MJgOhDVHfENdtYBcadDZEB5L6WsEBZOL8j5ai136+0dOKO+u/Jy7jHWAx2s9uNITCsN3ofMilUEWyCmrqD/nl44pk5RDFdzhQ9pvR0ElkcFNVObLuF23+97PTft17QA9Nmx2aO9U5NsVXMzITU5YxeciyTOA40wSjOeBxO3ubJ8OHd6PLOKdRbodPuY1oDOdzqtOfkv/e1YUB5qSeU6fxeyrcluVYJ7dp1XoQixFyudIFq5k9JJ5zQ1MUbBt2uDYICDA09HyfdIa4/YeKtvYZllCd744RJ5qqh9BON/XWxKj5Nw9qj+bZFy+CeHF+/2ygMj/fOtLkqlU0st2fmeZQ/kvW9Dh1zgiTiuDSET/GxPfy9i+FrnF0zJFuZ3OrjWyrtPion5T+mKaj4a5+xiYUOI2Z8lMNuFNIQje7bYu+TLiLDJ5rlE+bJb7GqGYyoN7T6NkfupOi6K8MfQQ0V2/3RtAeFLNaaBZoHhyDfQrNF2d39HMbSuM3ah4BmkWLtruPMh/WoS+Y6b2kGmapq8tTGXWDUz0aqgN/PNugXsBso3XAOhFPoCf8hQNiJrKcCnXj7DSOFL/EUC+peh5jjBGf11+NOaBVT3DboJn9ohgNbLamrcmWe150ZSb/Vptw+i+gcRohxKVae34+F3A7VC74kQERuYP+HE68a0uO9sjMIdvWLwcopYtBQyAR1OJ5lnmtQCP80ys24tbqVN kWyOhgao dQVadpXKwM+yhlxlOYYHQTXsKc9XJKMTZwwMs+XJKOllM+NR0+kfA5E9iHIMdcZX12VkWqW/LFNf4aDzEqPH8svaY5ZeZ8cenmcMw07E8IeQHBBAiwbJXH6nMCCPxjM4OrdIksvWf2mbejrEjiT08AA3WJKQCkks7nl/DI0wQ3ETK/0MmkDc8U/V5ZumVhsa3+hNO9GeV6sWv4mTcqzgbkaBYUw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi, Dan, Dan Williams writes: > Hi Bjorn, > > Ying is out for the next week or so, so I will address your comments and > resubmit as I think this is a potentially urgent fix. Just come back. Thank you very much for your kind help! > Bjorn Helgaas wrote: >> On Mon, Aug 19, 2024 at 10:34:13AM +0800, Huang Ying wrote: >> > On a system with CXL memory installed, the resource tree (/proc/iomem) [snip] >> > In the above resource tree, "System RAM" is a descendant of "CXL >> > Window 0" instead of a top level resource. So, region_intersects() >> > will report no System RAM resources in the CXL memory region >> > incorrectly, because it only checks the top level resources. >> > Consequently, devmem_is_allowed() will return 1 (allow access via >> > /dev/mem) for CXL memory region incorrectly. Fortunately, ioremap() >> > doesn't allow to map System RAM and reject the access. >> > >> > However, region_intersects() needs to be fixed to work correctly with >> > the resources tree with CXL Window as above. To fix it, if we found a >> > unmatched resource in the top level, we will continue to search >> > matched resources in its descendant resources. So, we will not miss >> > any matched resources in resource tree anymore. In the new >> > implementation, >> > >> > |------------- "CXL Window 0" ------------| >> > |-- "System RAM" --| >> > >> > will look as if >> > >> > |-- "System RAM" --||-- "CXL Window 0a" --| >> >> Where did "0a" come from? The /proc/iomem above mentioned >> "CXL Window 0"; is the "a" spurious? Same question applies to the >> code comment below. > > Not sure where that came from, will clean up and provide a test that can > upstreammed as well. Sorry for confusing! >> > |-- "System RAM" --||-- "CXL Window 0a" --| This isn't the real resource tree. The real resource tree is still >> > |------------- "CXL Window 0" ------------| >> > |-- "System RAM" --| While, >> > |-- "System RAM" --||-- "CXL Window 0a" --| is just used to demonstrate the effect of the algorithm. That is, a part of "CXL Window 0" is covered (or masked) by "System RAM" now. The remaining effective part of "CXL Window 0" is smaller, I used "CXL Window 0a" to designate that it comes from "CXL Window 0", but it's not exactly "CXL Window 0". -- Best Regards, Huang, Ying