From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39A36606A327 for ; Tue, 1 Dec 2026 17:20:17 +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 kanga.kvack.org (Postfix) id 45D036B05B8; Tue, 1 Dec 2026 12:20:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 40D026B05CB; Tue, 1 Dec 2026 12:20:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FE1E6B05C9; Tue, 1 Dec 2026 12:20:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 01A4C6B0627 for ; Tue, 1 Dec 2026 12:20:13 -0500 (EST) Received: from smtpin17.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 899541C4597 for ; Tue, 1 Dec 2026 17:20:13 +0000 (UTC) X-FDA: 85496077506.17.D001489 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf01.hostedemail.com (Postfix) with ESMTP id A888740010 for ; Tue, 1 Dec 2026 17:20:11 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Gc226y7i; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of chleroy@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=chleroy@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796145611; b=11z/JrjulYtOHxWffgfnAcYG2oMg5pC1tDIeN5jVHmYfGneQh04BUqnvp2fZWDuWhCQY+2 kINPS0R2Zz1x5TBDfmtDxkJdWqQjHxgfIZ7GpOM/l1EaKVFu8GjO+spzb334vgzYrMHiDu XUWdObF5tYBqE9cXHmDhya2mu4E5G7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796145611; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9WJ8uCqZDH35ivqvLe4wCVytk82GnNryG6+wBjELq0I=; b=ttvK+58ysYzWXn+Tlq57ru2H53lCEbl6x/eEZ0ubakzblN42RVJsD/OvGuxBeipVMqCTaX ptF8GHg4M9bQJrxsdqkhh2vypxAqOqxVGgS30Xzc9FHeeBeh872XDG9BCqBeOlKH5SQxXi DSE2i5T9GOXLdXHPX7uz0U9on9INRoo= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Gc226y7i; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of chleroy@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=chleroy@kernel.org 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-Stat-Signature: qd9ksn8b1cmhisnnh4pgu31x9yuxhw3z X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A888740010 X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_PASS, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=4.0.1 X-HE-Tag: 1796145611-8747 X-HE-Meta: U2FsdGVkX1+2ul+odnqxHQB8UDUz6FkDGvm6nzawy3dg2SvQUaLjoJklwdC+kVnKNlX8QKf3wImYqFF8sM/sPR6KwaURLA+qTFaJ/0cDxZhIxS7b0O3lELZf0Xi9hSd/PgjA1UNsYAiVKdOQaCEYQFgPYl7I7PSsGUK/XlseMkAepvHZ6rzJUKbObWsH/lcI+IlvTfwI43ZUR5G7Uqb+sim3viZUUO4wSlkY/ma4+HvMs6JKH9Sdbwm1PbyjhcgQ0PL6Dk1j+mT9nQPas1ApE5HjztOxw76g31KYy4b0tn1j5595Jl45ZFUJrx18vzxQ4tjuZGUJDojas+02hHxsp3Q1akYI6Uc2LdEGR5DxD2vhkrXsmtSbYu0r2v7pOw0Mf69AUm7CmwbWoY+fsF3LVlmFqGU2hoGJA8ygbj00SJKJA3F+iQ7bjtu+B1SuD463HMPl4h/L5FdgEEMPHwY8f3K7KhD21/FTrZjTY7GrjV/DSdZWTOMnsQqQ72HxoZvVIO22IPBJA1BlCvZeA66eGwjtKiucr3yt+zBEHJCtCcb30HFHeTl6DiOUBnoFg/5suRopDLRdIlJvxdf9cPwqBU0c3JDSNyQo/gzjAijosj2qnGXhGkdLuPFokqZXSYC9QqlY6tBZtmO+mHKhVt6OBqPW0iKqQWkUyX2M+swbazze9dSnL8I0gugE1EiF4obcruS/5vnVXJQQIFQOcCDohjG63xyyvZ+qECrY5ZcIYjJezKjItLEqZG05ddQmyqe1cXPM72r1Ef2JgOn3XCO7RyhWPk9zlFVdnXx+HUiYCKb5+Ev1rTdPw3BZD6CXYe0gXPT385OSr1IH0v0DNjPeGkuSCAdOVOlRsBZAroo0E1qrUQAZt4/XN2naXeNsmAOp9siyJXgNOemeUX39zGnMC3Ww0khTdvpk4Qan7SifiOh+j6irI1dVBw7oBE3mKKL5+KBhIlIXnocdtBltz4u 47feTBAt yZVRjsS7iUHEcM25tNc6FsQr/N0b+0AhjhxMojfWKcqophfZ7baGkYyFGpuI1DAjFE/VgNK3MpMkdMAdKvj+uqBq1+w8LKEiUuId2F9PAgVJoZNtGfwltd7+RfEJjfUpIjDwgfW4MgfXpa073XIsYsO9q1Rg/AAXwk3JTzuhjWopQ6DmVOxV1b3WsYi4O+9UItw2iXiOHQH5AL/rMSDS86p4nVkidI9bi6chbLBR8bIBkCHnHZIgWNT00wd+M7G00gCIRPaHYgPRo2uce6eZK+VPiDLVmMMCemhe/NlMsYqn8PQnMwyt7Bf7B7UyX9pG4KJtfXEKKRM53aWRFSQOiPK7ChJFXrbwwkFN9Kcf+9ysipHNsPZybJ2lYw+Ub1s7RbjKWkaLOqSiHbThEwNGwgNAWeEth6SwcMlm0zSKY0xIgndFgSW6fUbgsZ0TFfor3C3KhjXFJ28AY3hpcrvUfpZn5SNCuWCafrL2E/0UsIIy0I3zr4/4xdLqLP/57OJe7SoozBaxwiYuGvAZb7HX+bYqXthx0uZfGzplXmgYiMuxkp8ZrAltb8nq0klYjkzZq4xlNjszvSt6gGGE= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: 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