linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Dan Williams <dan.j.williams@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Huang Ying <ying.huang@intel.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-cxl@vger.kernel.org, Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Alison Schofield <alison.schofield@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Alistair Popple <apopple@nvidia.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>, Baoquan He <bhe@redhat.com>
Subject: Re: [PATCH] Resource: fix region_intersects() for CXL memory
Date: Fri, 16 Aug 2024 10:57:36 +0200	[thread overview]
Message-ID: <192dcb60-e274-4b2c-a626-608bee4dbe65@redhat.com> (raw)
In-Reply-To: <66bede74cb96f_1c18294ce@dwillia2-mobl3.amr.corp.intel.com.notmuch>

On 16.08.24 07:07, Dan Williams wrote:
> [ add David ]
> 
> Andrew Morton wrote:
>> On Fri, 16 Aug 2024 10:07:23 +0800 Huang Ying <ying.huang@intel.com> wrote:
>>
>>> On a system with CXL memory installed, the resource tree (/proc/iomem)
>>> related to CXL memory looks like something as follows.
>>>
>>> 490000000-50fffffff : CXL Window 0
>>>    490000000-50fffffff : region0
>>>      490000000-50fffffff : dax0.0
>>>        490000000-50fffffff : System RAM (kmem)
>>>
>>> When the following command line is run to try writing some memory in
>>> CXL memory range,
>>>
>>>   $ dd if=data of=/dev/mem bs=1k seek=19136512 count=1
>>>   dd: error writing '/dev/mem': Bad address
>>>   1+0 records in
>>>   0+0 records out
>>>   0 bytes copied, 0.0283507 s, 0.0 kB/s
>>>
>>> the command fails as expected.  However, the error code is wrong.  It
>>> should be "Operation not permitted" instead of "Bad address".  And,
>>> the following warning is reported in kernel log.
>>>
>>>   ioremap on RAM at 0x0000000490000000 - 0x0000000490000fff
>>>   WARNING: CPU: 2 PID: 416 at arch/x86/mm/ioremap.c:216 __ioremap_caller.constprop.0+0x131/0x35d

But we should definitely fix the warning.

>>> ...
>>>
>>
>> Presumably we want to fix earlier kernels?  If so, are you able to
>> identify a suitable Fixes: target?  Possibly 974854ab0728 ("cxl/acpi:
>> Track CXL resources in iomem_resource")?
> 
> At least that commit, but I think this problem potentially goes back
> farther to:
> 
> c221c0b0308f device-dax: "Hotplug" persistent memory for use like normal RAM
> 
> ...because that started the era of "System RAM" as a non-top-level
> resource.
> 
> David did a bunch of work to fix this back in:
> 
> 97f61c8f44ec kernel/resource: make walk_system_ram_res() find all busy IORESOURCE_SYSTEM_RAM resources
> 
> ..but the fallout in region_intersects() was missed.

Sounds reasonable.

For virtio-mem we set IORESOURCE_SYSTEM_RAM|IORESOURCE_EXCLUSIVE on our 
(highest) parent resource (to make any /dev/mem access attempts of that 
memory fail). So the problem is likely specific to other
add_memory_driver_managed() users.

I have a faint recollection that at some point we had code that would 
set IORESOURCE_SYSTEM_RAM on parent resources up the tree, but either my 
memory is wrong or that code was ripped out long ago.

Fix idea is reasonable: check if anything in that range is 
IORESOURCE_SYSTEM_RAM.

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-08-16  8:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-16  2:07 Huang Ying
2024-08-16  4:53 ` Andrew Morton
2024-08-16  5:07   ` Dan Williams
2024-08-16  8:57     ` David Hildenbrand [this message]
2024-08-16  5:01 ` Dan Williams
2024-08-16  7:43   ` Huang, Ying
2024-08-22  1:29     ` Dan Williams
2024-09-02  2:07       ` Huang, Ying
2024-09-02 11:56         ` Andy Shevchenko
2024-09-03  0:43           ` Huang, Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=192dcb60-e274-4b2c-a626-608bee4dbe65@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alison.schofield@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=apopple@nvidia.com \
    --cc=bhe@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=vishal.l.verma@intel.com \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox