From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>, Arnd Bergmann <arnd@kernel.org>,
linux-mm@kvack.org, Crystal Wood <crwood@redhat.com>,
Alexander Graf <graf@amazon.com>
Cc: Andreas Larsson <andreas@gaisler.com>,
Andrew Morton <akpm@linux-foundation.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
"David Hildenbrand (Red Hat)" <david@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Linus Walleij <linusw@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
Lucas Stach <l.stach@pengutronix.de>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Malin Jonsson <malin.jonsson@est.tech>,
Matthew Wilcox <willy@infradead.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Michal Simek <monstr@monstr.eu>, Mike Rapoport <rppt@kernel.org>,
Nicholas Piggin <npiggin@gmail.com>, Nishanth Menon <nm@ti.com>,
Richard Weinberger <richard@nod.at>,
Russell King <linux@armlinux.org.uk>,
Thomas Gleixner <tglx@linutronix.de>,
linux-arm-kernel@lists.infradead.org,
linux-fsdevel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
x86@kernel.org
Subject: Re: [PATCH v3 04/10] powerpc: kvm: allow flexible PAGE_OFFSET
Date: Tue, 1 Dec 2026 18:19:59 +0100 [thread overview]
Message-ID: <408cb5f5-7497-4318-b7a5-fb3dbc707a53@kernel.org> (raw)
In-Reply-To: <93593ec2-0f7e-43a9-9166-dee90a9cd2c3@app.fastmail.com>
Le 17/11/2026 à 16:41, Arnd Bergmann a écrit :
> On Tue, Nov 17, 2026, at 16:11, Christophe Leroy (CS GROUP) wrote:
>> Le 16/11/2026 à 23:54, Arnd Bergmann a écrit :
>>> On Mon, Nov 16, 2026, at 14:38, Christophe Leroy (CS GROUP) wrote:
>>>> Le 16/11/2026 à 13:48, Arnd Bergmann a écrit :
>>>
>>> --- a/arch/powerpc/kvm/book3s_32_sr.S
>>> +++ b/arch/powerpc/kvm/book3s_32_sr.S
>>> @@ -107,14 +107,12 @@
>>> KVM_LOAD_BAT(2, r9, r10, r11)
>>> KVM_LOAD_BAT(3, r9, r10, r11)
>>>
>>> - /* Restore Segment Registers */
>>> -
>>> - /* 0xc - 0xf */
>>> -
>>> - li r0, 4
>>> + /* Restore Segment Registers, assumes PAGE_OFFSET is segment aligned */
>>> + li r0, (0x100000000 - PAGE_OFFSET) >> 28
>>
>> Fine, thank should work allthough I would have used 0x10 - (PAGE_OFFSET
>> >> 28)
>>
>>> mtctr r0
>>> - LOAD_REG_IMMEDIATE(r3, 0x20000000 | (0x111 * 0xc))
>>> - lis r4, 0xc000
>>> + LOAD_REG_IMMEDIATE(r3, 0x20000000 | (0x111 * (PAGE_OFFSET >> 28)))
>>
>> Maybe an opportunity to replace 0x20000000 by SR_KP
>
> Ok, changed both.
>
>>>>> @@ -115,7 +115,8 @@ static u32 get_host_mas0(unsigned long eaddr)
>>>>> mtspr(SPRN_MAS6, 0);
>>>>> mas4 = mfspr(SPRN_MAS4);
>>>>> mtspr(SPRN_MAS4, mas4 & ~MAS4_TLBSEL_MASK);
>>>>> - asm volatile("tlbsx 0, %0" : : "b" (eaddr & ~CONFIG_PAGE_OFFSET));
>>>>> + asm volatile("tlbsx 0, %0" :
>>>>> + : "b" (eaddr & (rounddown_pow_of_two(PAGE_OFFSET)-1)));
>>>>
>>>> I think this is not valid.
>>>>
>>>> With PAGE_OFFSET equal to 0xc0000000,
>>>>
>>>> Before:
>>>>
>>>> eaddr & 0x3fffffff
>>>>
>>>> Now:
>>>>
>>>> eaddr & (0x80000000 - 1) = eaddr & 0x7fffffff
>>>
>>> I'm probably still misunderstanding the intention of this code then,
>>> my reading of the comment was that both 0x3fffffff and 0x7fffffff
>>> would be valid choices here as both are below PAGE_OFFSET and
>>> large enough to alias the correct set.
>>>
>>> What are the actual requirements for the mask?
>>
>> I'm also struggling to understand this so I might be wrong. My
>> understanding at the moment is that here we are looking for the physical
>> address matching that effective addr in order to find the 1:1 MMU
>> mapping. The particularity of booke is that you cannot turn off the MMU,
>> so to simulate MMU off you have to have a MMU translation to translate
>> logical address 0 to physical address 0.
>>
>> Therefore IIUC the correct calculation should be (eaddr - PAGE_OFFSET)
>
> AIU that would be wrong for PAGE_OFFSET=0x70000000 if eaddr>0xf0000000
> is a valid argument here, as that would still point into the linear
> lowmem map. I've added Crystal and Alex to Cc with their current
> work emails, maybe one of them knows.
Didn't see any feedback from them. What is the way forward ?
By the way, it reminded me an additional issue, see
https://github.com/linuxppc/issues/issues/334
In addition to the hard-coding of 0xc0000000, there is also a problem
with perm bits, especially SR_NX which should be set on all kernel
segments except the one containing MODULES_VADDR/MODULES_END with
STRICT_KERNEL_RWX is set.
Christophe
next prev parent reply other threads:[~2026-12-01 18:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 12:48 [PATCH v3 00/10] mm: highmem cleanups Arnd Bergmann
2026-11-16 12:48 ` [PATCH v3 01/10] ARM: remove support for highmem on VIVT Arnd Bergmann
2026-11-18 13:08 ` Linus Walleij
2026-11-16 12:48 ` [PATCH v3 02/10] ARM: drop CONFIG_HIGHPTE support Arnd Bergmann
2026-11-16 12:48 ` [PATCH v3 03/10] ARM: pxa: support arbitrary PAGE_OFFSET Arnd Bergmann
2026-11-26 13:26 ` Linus Walleij
2026-11-16 12:48 ` [PATCH v3 04/10] powerpc: kvm: allow flexible PAGE_OFFSET Arnd Bergmann
2026-11-16 13:38 ` Christophe Leroy (CS GROUP)
2026-11-16 22:54 ` Arnd Bergmann
2026-11-17 15:11 ` Christophe Leroy (CS GROUP)
2026-11-17 15:41 ` Arnd Bergmann
2026-12-01 17:19 ` Christophe Leroy (CS GROUP) [this message]
2026-11-16 12:48 ` [PATCH v3 05/10] ARM: add CONFIG_VMSPLIT_2G_OPT option Arnd Bergmann
2026-11-26 13:27 ` Linus Walleij
2026-11-16 12:48 ` [PATCH v3 06/10] arch/*: increase lowmem size to avoid highmem use Arnd Bergmann
2026-11-16 12:48 ` [PATCH v3 07/10] ARM: defconfig: turn off highmem in favor of CONFIG_VMSPLIT_2G_OPT Arnd Bergmann
2026-11-26 13:28 ` Linus Walleij
2026-11-16 12:48 ` [PATCH v3 08/10] mm: remove ARCH_NEEDS_KMAP_HIGH_GET Arnd Bergmann
2026-11-17 10:05 ` David Hildenbrand (Arm)
2026-11-16 12:48 ` [PATCH v3 09/10] mm: drop HIGHPTE support altogether Arnd Bergmann
2026-11-16 12:48 ` [PATCH v3 10/10] mm: print pte in __print_bad_page_map_pgtable() Arnd Bergmann
2026-11-16 13:00 ` Mike Rapoport
2026-11-17 10:07 ` [PATCH v3 00/10] mm: highmem cleanups David Hildenbrand (Arm)
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=408cb5f5-7497-4318-b7a5-fb3dbc707a53@kernel.org \
--to=chleroy@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andreas@gaisler.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=crwood@redhat.com \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=graf@amazon.com \
--cc=hpa@zytor.com \
--cc=jgg@nvidia.com \
--cc=l.stach@pengutronix.de \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=ljs@kernel.org \
--cc=maddy@linux.ibm.com \
--cc=malin.jonsson@est.tech \
--cc=mingo@redhat.com \
--cc=monstr@monstr.eu \
--cc=mpe@ellerman.id.au \
--cc=nm@ti.com \
--cc=npiggin@gmail.com \
--cc=richard@nod.at \
--cc=rppt@kernel.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