Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796145611; b=yedoCDWezODYnhgYv/9pWdwVkjytftx5JvQN7WTKbrJzNSQhhHxT1AKAq8LZ0mIl2w81 hL51kAFZbTdYtW3+su6I60gQg0C+1zmao2VIJ+FeeZ02b8k9/NCA6S6iPOLKPEDU9bzPn 6YfDqgDIIJ3qvbHv86ZjwYOAxByblq8nOMMqbkXsH75T7pNYvJL8dddLeF5KBib5zYEkQ uPQEdktf7nGlUFcV9NZ6SEvOqXWtVwYBaxhSPiPhvM6USPrZ6yrdCGrEu4eyhJmaozy0y fBfU04prEBjqjnHLoE5Z4oMm403QLB8rs//z8T18MWGdo7Bh6MOwLR1A11DfyaODm3A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796145611; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=9WJ8uCqZDH35ivqvLe4wCVytk82GnNryG6+wBjELq0I=; b=dNihmdhsOzphKe0pn7V9y8krNS2r6zNTXHGh9wtvui29B4vVbmx3YDSgL7n6vT1iYJPu aW/IWF5Mp/Tsf1KpOo/sPxx6ccCXj/nmg1DkHnJQ7VBj7qsRuMnM52WASRWGK4XYcZKQ+ WM85eHJBMtrgL6N04CD9n/0eJGLsd57/TUBS6fLS4IYQsUv/38PhcNbopuFT52z9eMxBN FeBIjhFXe2BIkwqnvMvCVnkHWXPRqrOkwJClf/y6NKo/QClTeZtGsHO/FIx3wQ3O8zZWv cIwW0q/oWhLIyhsYOpcZRa3ea9eruHzX2TI2RsNQDgkaaJbSEHu7F8LY1DFm3USt9LA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Gc226y7i; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2043F606A31A for ; Tue, 1 Dec 2026 17:20:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Gc226y7i Received: by smtp.kernel.org (Postfix) with ESMTPSA id F20211F00893; Tue, 1 Dec 2026 17:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796145610; bh=9WJ8uCqZDH35ivqvLe4wCVytk82GnNryG6+wBjELq0I=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=Gc226y7iZ+CcUyD7SyT79RFcxj8jYCdEugP+o2BnqbzGxrQl4KQKNGhcD3jXc+YLb a1iB2WitdTUCg3u2K/r8LUo5U90agZ7VDyIdzd02AlSDt1JK8QIphKkxRdNfsvAati lpyIEkWvURkcMgNUSt9c6mxkYAZ8eeC2yDZXBw23hiooyrOnIicfgDwkpSJ1/yi8wD 4EiPA32a5J7kOMzQMEYR8wJSITmzpwswsb16BuHpYoc3T+kZPaERXrRcLDOvs6IGgh MNS0kOC05lO12p5/6FEjSm6pD6vIR721I2qLyJuM3I/RMlC98Hz/sj1xfHm8kAtDPo iDi5S17KzaspQ== Message-ID: <408cb5f5-7497-4318-b7a5-fb3dbc707a53@kernel.org> Date: Tue, 1 Dec 2026 18:19:59 +0100 X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 04/10] powerpc: kvm: allow flexible PAGE_OFFSET To: Arnd Bergmann , Arnd Bergmann , linux-mm@kvack.org, Crystal Wood , Alexander Graf Cc: Andreas Larsson , Andrew Morton , Dave Hansen , "David Hildenbrand (Red Hat)" , "H. Peter Anvin" , Ingo Molnar , Jason Gunthorpe , Linus Walleij , Lorenzo Stoakes , Lucas Stach , Madhavan Srinivasan , Malin Jonsson , Matthew Wilcox , Michael Ellerman , Michal Simek , Mike Rapoport , Nicholas Piggin , Nishanth Menon , Richard Weinberger , Russell King , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org References: <20261116124832.662455-1-arnd@kernel.org> <20261116124832.662455-5-arnd@kernel.org> <83495d02-4e09-40f0-94fe-e57a1e73d1a3@app.fastmail.com> <14e28b99-12dc-4000-a704-8b46cfeb3c0f@kernel.org> <93593ec2-0f7e-43a9-9166-dee90a9cd2c3@app.fastmail.com> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: <93593ec2-0f7e-43a9-9166-dee90a9cd2c3@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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