linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
To: Donet Tom <donettom@linux.ibm.com>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org
Cc: Ritesh Harjani <ritesh.list@gmail.com>
Subject: Re: [PATCH] book3s64/radix : Align section vmemmap start address to PAGE_SIZE
Date: Thu, 06 Mar 2025 09:41:31 +0530	[thread overview]
Message-ID: <yq5amsdyssr0.fsf@kernel.org> (raw)
In-Reply-To: <d4b3fdbc-645f-4a43-bd9c-d29f4e4dacbc@linux.ibm.com>

Donet Tom <donettom@linux.ibm.com> writes:

> On 3/3/25 18:32, Aneesh Kumar K.V wrote:
>> Donet Tom <donettom@linux.ibm.com> writes:
>>
>>> A vmemmap altmap is a device-provided region used to provide
>>> backing storage for struct pages. For each namespace, the altmap
>>> should belong to that same namespace. If the namespaces are
>>> created unaligned, there is a chance that the section vmemmap
>>> start address could also be unaligned. If the section vmemmap
>>> start address is unaligned, the altmap page allocated from the
>>> current namespace might be used by the previous namespace also.
>>> During the free operation, since the altmap is shared between two
>>> namespaces, the previous namespace may detect that the page does
>>> not belong to its altmap and incorrectly assume that the page is a
>>> normal page. It then attempts to free the normal page, which leads
>>> to a kernel crash.
>>>
>>> In this patch, we are aligning the section vmemmap start address
>>> to PAGE_SIZE. After alignment, the start address will not be
>>> part of the current namespace, and a normal page will be allocated
>>> for the vmemmap mapping of the current section. For the remaining
>>> sections, altmaps will be allocated. During the free operation,
>>> the normal page will be correctly freed.
>>>
>>> Without this patch
>>> ==================
>>> NS1 start               NS2 start
>>>   _________________________________________________________
>>> |         NS1               |            NS2              |
>>>   ---------------------------------------------------------
>>> | Altmap| Altmap | .....|Altmap| Altmap | ...........
>>> |  NS1  |  NS1   |      | NS2  |  NS2   |
>>>
>>                              ^^^ this should be allocated in ram?
>>
>
> Yes, it should be allocated from RAM. However, in the current
> implementation, an altmap page gets allocated. This is because the
> NS2 vmemmap section's start address is unaligned. There is an
> altmap_cross_boundary() check. Here, from the vmemmap section
> start, we identify the namespace start and check if the namespace start
> is within the boundary. Since it is within the boundary, it returns false,
> causing an altmap page to be allocated. During the PTE update, the
> vmemmap start address is aligned down to PAGE_SIZE, and the PTE is
> updated. As a result, the altmap page is shared between the current
> and previous namespaces.
>
> If we had aligned the vmemmap start address, the
> altmap_cross_boundary() function would return true because the
> vmemmap section's start address belongs to the previous
> namespace. Therefore normal page gets allocated. During the
> PTE set operation, since the address is already aligned, the
> PTE will updated.
>

So the nvdimm driver should ensure that alignment right? I assume other things
will also require that to be properly aligned.?

-aneesh


  reply	other threads:[~2025-03-06 13:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26  4:34 [PATCH] book3s64/radix : Align section vmemmap start address to PAGE_SIZE Donet Tom
2025-03-03 13:02 ` Aneesh Kumar K.V
2025-03-04  5:33   ` Donet Tom
2025-03-06  4:11     ` Aneesh Kumar K.V [this message]
2025-03-07  6:41       ` Donet Tom
2025-03-08  3:46 ` Aneesh Kumar K.V
2025-03-09 11:02   ` Donet Tom

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=yq5amsdyssr0.fsf@kernel.org \
    --to=aneesh.kumar@kernel.org \
    --cc=donettom@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=ritesh.list@gmail.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;
as well as URLs for NNTP newsgroup(s).