From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Michael Ellerman <mpe@ellerman.id.au>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "songyuanzheng@huawei.com" <songyuanzheng@huawei.com>,
"npiggin@gmail.com" <npiggin@gmail.com>
Subject: Re: [PATCH v4 1/2] Revert "powerpc: Set max_mapnr correctly"
Date: Fri, 1 Apr 2022 12:07:46 +0000 [thread overview]
Message-ID: <2f89bb08-6946-3dab-1cb4-ad6f950c035e@csgroup.eu> (raw)
In-Reply-To: <87ee2hf3on.fsf@mpe.ellerman.id.au>
Le 01/04/2022 à 13:23, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>> Le 28/03/2022 à 12:37, Michael Ellerman a écrit :
>>> Kefeng Wang <wangkefeng.wang@huawei.com> writes:
>>>> Hi maintainers,
>>>>
>>>> I saw the patches has been reviewed[1], could they be merged?
>>>
>>> Maybe I'm just misreading the change log, but it seems wrong that we
>>> need to add extra checks. pfn_valid() shouldn't return true for vmalloc
>>> addresses in the first place, shouldn't we fix that instead? Who knows
>>> what else that might be broken because of that.
>>
>> pfn_valid() doesn't take an address but a PFN
>
> Yeah sorry that was unclear wording on my part.
>
> What I mean is that pfn_valid(virt_to_pfn(some_vmalloc_addr)) should be
> false, because virt_to_pfn(vmalloc_addr) should fail.
Yes that's probably how it should be but none of the main architectures
do that.
The best we find is some architecture that WARN_ON(some valloc addr) in
virt_to_pfn(). That's wouldn't help in our case, as it would then WARN_ON()
>
> The right way to convert a vmalloc address to a pfn is with
> vmalloc_to_pfn(), which walks the page tables to find the actual pfn
> backing that vmalloc addr.
>
>> If you have 1Gbyte of memory you have 256k PFNs.
>>
>> In a generic config the kernel will map 768 Mbytes of mémory (From
>> 0xc0000000 to 0xe0000000) and will use 0xf0000000-0xffffffff for
>> everything else including vmalloc.
>>
>> If you take a page above that 768 Mbytes limit, and tries to linarly
>> convert it's PFN to a va, you'll hip vmalloc space. Anyway that PFN is
>> valid.
>
> That's true, but it's just some random page in vmalloc space, there's no
> guarantee that it's the same page as the PFN you started with.
Yes sure, what I meant however is that pfn_valid(some_valid_pfn) should
return true, even if virt_to_pfn(some_vmalloc_address) profides a valid PFN.
>
> Note it's not true on 64-bit Book3S. There if you take a valid PFN (ie.
> backed by RAM) and convert it to a virtual address (with __va()), you
> will never get a vmalloc address.
>
>> So the check really needs to be done in virt_addr_valid().
>
> I don't think it has to, but with the way our virt_to_pfn()/__pa() works
> I guess for now it's the easiest solution.
>
At least other architectures do it that way. See for instance how ARM
does it:
#define virt_addr_valid(kaddr) (((unsigned long)(kaddr) >= PAGE_OFFSET
&& (unsigned long)(kaddr) < (unsigned long)high_memory) \
&& pfn_valid(virt_to_pfn(kaddr)))
high_memory being the top of linear RAM mapping
Christophe
next prev parent reply other threads:[~2022-04-01 12:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-16 12:11 [PATCH v4 1/2] Revert "powerpc: Set max_mapnr correctly" Kefeng Wang
2022-02-16 12:11 ` [PATCH v4 2/2] powerpc: Fix virt_addr_valid() check Kefeng Wang
2022-03-09 16:01 ` [v4,2/2] " Christophe Leroy
2022-03-09 16:00 ` [v4,1/2] Revert "powerpc: Set max_mapnr correctly" Christophe Leroy
2022-03-26 7:55 ` [PATCH v4 1/2] " Kefeng Wang
2022-03-28 10:37 ` Michael Ellerman
2022-03-28 10:59 ` Christophe Leroy
2022-04-01 11:23 ` Michael Ellerman
2022-04-01 12:07 ` Christophe Leroy [this message]
2022-03-28 14:12 ` Christophe Leroy
2022-03-29 11:32 ` Kefeng Wang
2022-04-04 12:31 ` Michael Ellerman
2022-04-06 2:21 ` Kefeng Wang
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=2f89bb08-6946-3dab-1cb4-ad6f950c035e@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=songyuanzheng@huawei.com \
--cc=wangkefeng.wang@huawei.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).