[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fa65d0ed-ccd0-4cca-9ac4-fad423e498b6@redhat.com>
Date: Thu, 12 Jun 2025 08:46:19 +0200
From: David Hildenbrand <david@...hat.com>
To: Dan Williams <dan.j.williams@...el.com>, linux-kernel@...r.kernel.org
Cc: linux-mm@...ck.org, nvdimm@...ts.linux.dev, linux-cxl@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Alistair Popple <apopple@...dia.com>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>, Vlastimil Babka
<vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>,
Suren Baghdasaryan <surenb@...gle.com>, Michal Hocko <mhocko@...e.com>,
Zi Yan <ziy@...dia.com>, Baolin Wang <baolin.wang@...ux.alibaba.com>,
Nico Pache <npache@...hat.com>, Ryan Roberts <ryan.roberts@....com>,
Dev Jain <dev.jain@....com>, Oscar Salvador <osalvador@...e.de>,
stable@...r.kernel.org
Subject: Re: [PATCH v2 1/3] mm/huge_memory: don't ignore queried cachemode in
vmf_insert_pfn_pud()
On 12.06.25 06:34, Dan Williams wrote:
> David Hildenbrand wrote:
>> We setup the cache mode but ... don't forward the updated pgprot to
>> insert_pfn_pud().
>>
>> Only a problem on x86-64 PAT when mapping PFNs using PUDs that
>> require a special cachemode.
>
> This is only a problem if the kernel mapped the pud in advance of userspace
> mapping it, right?
Good question, PAT code is confusing.
What I understood is that drivers like vfio will register the range with
the expected cachemode, and then rely on vm_insert_* to fill out the
cachemode for them.
Peter explained it in the dicussion here [1] how e.g., vfio triggers
that early registration.
Regarding vfio, I can see that we do in vfio_pci_core_mmap()
unconditionally:
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
and probably rely on us querying the actual cachemode to be used later.
vfio can map all kinds of different memory types ...
[1] https://lkml.kernel.org/r/aBDXr-Qp4z0tS50P@x1.local
>
> The change looks good.
>
> Reviewed-by: Dan Williams <dan.j.williams@...el.com>
>
> ...but I am struggling with the scenario where this causes problems in
> practice, where vm_page_prot is the wrong cachemode.
Yeah, it's all confusing.
But as long as we don't conclude that pfnmap_setup_cachemode_pfn() can
be removed entirely (esp. also from pte / pmd case), this seems to be
the right thing to do and was accidental change in the introducing commit.
Is it actually stable material? I don't know, but possibly getting
cachemodes wrongs sounds ... bad?
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists