From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A5A7606A31A for ; Tue, 1 Dec 2026 18:11:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ZcJhazT2; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Gc226y7i DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=9WJ8uCqZDH35ivqvLe4wCVytk82GnNryG6+wBjELq0I=; b=ZcJhazT2a6HJc5 Zt6+QRgnSwFW1OkqUzcLxwksjjC+L5IVz1DNOU0GJV3yMCS6Cgq9Z1y9bxPdZIiiUG7U3t3NPDXhw vjsvA7h6XRuAeZuurbo89JZJxkmjJxJdRhNy3nqXMho+NdIaLmZXtGPqtIudEIq7Vag6wc/tjeVUd EKexZfR17wrRzY+vo1Fhf7zGaO72Vj2Adte6K16pedIvcGUeHxdEPwcnWHuSAgdHu34HfmEg7lEyS PZR9j9IKqahqJmg/0cc4+yGsboCLi1PrEIDVXAkjAEuUX5iDfsFTRTluWyfhOOvp5zSyyA+QhsKnm 4JW2hzlUHU+7IW3ms6Qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYRWV-00000008ttD-37is; Tue, 01 Dec 2026 17:20:11 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYRWV-00000008tsy-10d0 for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 17:20:11 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id C9D1040643; Tue, 1 Dec 2026 17:20:10 +0000 (UTC) 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-Archived-By: 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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