From: David Hildenbrand <david@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org,
Wupeng Ma <mawupeng1@huawei.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v1] x86/mm/pat: fix VM_PAT handling in COW mappings
Date: Thu, 14 Mar 2024 17:42:20 +0100 [thread overview]
Message-ID: <1f2a8ed4-aaff-4be7-b3b6-63d2841a2908@redhat.com> (raw)
In-Reply-To: <5bc9de2f-c3ba-46e7-a234-3d3a46e53ba1@redhat.com>
On 12.03.24 20:38, David Hildenbrand wrote:
> On 12.03.24 20:22, Matthew Wilcox wrote:
>> On Tue, Mar 12, 2024 at 07:11:18PM +0100, David Hildenbrand wrote:
>>> PAT handling won't do the right thing in COW mappings: the first PTE
>>> (or, in fact, all PTEs) can be replaced during write faults to point at
>>> anon folios. Reliably recovering the correct PFN and cachemode using
>>> follow_phys() from PTEs will not work in COW mappings.
>>
>> I guess the first question is: Why do we want to support COW mappings
>> of VM_PAT areas? What breaks if we just disallow it?
>
> Well, that was my first approach. Then I decided to be less radical (IOW
> make my life easier by breaking less user space) and "fix it" with
> minimal effort.
>
> Chances of breaking some weird user space is possible, although I
> believe for most such mappings MAP_PRIVATE doesn't make too much sense
> sense.
>
> Nasty COW support for VM_PFNMAP mappings dates back forever. So does PAT
> support.
>
> I can try finding digging through some possible user space users tomorrow.
As discussed, MAP_PRIVATE doesn't make too much sense for most PFNMAP
mappings.
However, /dev/mem and /proc/vmcore are still used with MAP_PRIVATE in
some cases.
Side note: /proc/vmcore is a bit weird: mmap_vmcore() sets VM_MIXEDMAP,
and then we might call remap_pfn_range(), which sets VM_PFNMAP. I'm not
so sure if that's what we want to happen ...
As far as I can see, makedumpfile always mmap's memory to be dumped
(/dev/mem, /proc/vmcore) using PROT_READ+MAP_PRIVATE, resulting in a COW
mapping.
In my opinion, we should use this fairly simple fix to keep it working
for now and look into disabling any MAP_PRIVATE of VM_PFNMAP separately,
for all architectures.
But I'll leave the decision to x86 maintainers.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-03-14 16:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 18:11 David Hildenbrand
2024-03-12 19:22 ` Matthew Wilcox
[not found] ` <5bc9de2f-c3ba-46e7-a234-3d3a46e53ba1@redhat.com>
2024-03-14 16:42 ` David Hildenbrand [this message]
2024-03-14 17:12 ` David Hildenbrand
2024-03-25 2:57 ` mawupeng
2024-03-26 8:33 ` Ingo Molnar
[not found] ` <922c5f99-1194-4118-9fe2-09b4f4a8cf04@redhat.com>
2024-03-26 8:53 ` Ingo Molnar
2024-03-26 8:57 ` David Hildenbrand
2024-04-01 9:45 ` Ingo Molnar
2024-04-02 9:14 ` David Hildenbrand
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=1f2a8ed4-aaff-4be7-b3b6-63d2841a2908@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mawupeng1@huawei.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=willy@infradead.org \
--cc=x86@kernel.org \
/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