From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2201A429CF6 for ; Tue, 14 Jul 2026 21:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784065559; cv=none; b=PBsVjbE1hYo64d6OciC4OvSVjXikAh0ILMznbvWOFOZFOgbdAoXLQCiEE0eS7uTG4f+vQBTclBS/Svmr0EQfU6ED8eRAh5z8CinIfHJZwVMtTD6fFSMAIF0GELIOwXGLPeNSSuc1MDpxraCdaXHph9UUS0IHDvOmViYZNi+Dj9U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784065559; c=relaxed/simple; bh=cAVW45uqQg2SRPEYKmKtszJRvMO//7p4A7xPCiBzVyY=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PnP6cQ271+YGv9XrJ+L69oWAfbfo0vS9a2ElcsEy84LSge37Lo/KLXvsCJp8YyXqd3vGowNj90gAuuEwn4QXVNk11lUhNl36HsF7a7KQPD5DbB83IlDfNo77oWErFNPpGD8UDTBkfxFCSDToPoElh/ubHuobqjSRYqCaDjYJMHc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KkjWbcaa; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KkjWbcaa" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-493f2e39e81so19477005e9.2 for ; Tue, 14 Jul 2026 14:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784065556; x=1784670356; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=lsgDUhCPZi1cUpPkNQ/I7/JmqQLLDAJpIhlyKeHE0tE=; b=KkjWbcaazAke3wXuU80om0NUqMSXZObBDwLbhD/9EV5XAxe3Xq6GRLNsM8aoBv3HdJ dW6MdyWIupPBH2Pyr/S2bwdL+ClHqaQ+LVgx1JLKA3G7ASLVatx3lX6lE9fjL0rnJHk0 mgr8pokiOu++KxonyRuT5nChTpiJjJJvrt+8/3YGXm2owcmxJq+uLW6Nb7l9ECyS/Orx st30PZQ9xPol8bl0v8EPr0EvpfEw9W1w9i/+AKCg+uiX6MGJUTK5ZR2y4OdhKvq767CH o1bGfs4S9DJxz9Enexow/bW+AjFBUIAXPf1g9uElm0dnJZz8kvTDpQjfcUuTr/+eMVO5 mVWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784065556; x=1784670356; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=lsgDUhCPZi1cUpPkNQ/I7/JmqQLLDAJpIhlyKeHE0tE=; b=G5nLOphsVE4gaIARd2YDVtxGD3qNJ7gnrXeWyAxaONOjVp0GLayVjfkSMSXXMJyV23 yjGvQz2KAEyTN21OXLvOlzKbx0jmzOETkAIAejPZ3DdEC3aOUmluEMJMdBPfMpn5s+V3 Yu7V0WebnjA32m2uKIrulaesT2R2kiTY5TcWO1FqO5JWHIiXjZmXTCqqi53AsxRFHqGN jtNCyUyE6gZOQmpwCKhnFD5HENU9NEJn32F3JMazcJykeVLJlbcXpYK8FGFVyGel7tHk kzSX0AlxNx0dAAd4rF5aZT2nDtmsEFaOWBF1Wsh2Jf698P1e8XgxCukVodroBEmY/PFz v4eg== X-Forwarded-Encrypted: i=1; AHgh+RrP03yVfwZ0rL1jW57ShxLdZCXYBKkpEeCxRrYCCj+RmVujE2KIIlRSwm2Zx9zRT78ibKpNW3MuqPgI@vger.kernel.org X-Gm-Message-State: AOJu0Yz3ZT2x6fZwqnI1cAxG6ElFACDJF/TRJgLINjrpJUND2r4C+Wyp 9tKfUVYEMOp/8K1vvu+AB6HFdCTjuxOqlHtHQD9F1wEB4+HSlj+2VcX7 X-Gm-Gg: AfdE7clUtTuC7zgn+tP83/AsjejZu1tTIZhz7qXUHJwP78UvgrQ29tsAP2bxZnNmSG5 fJPLI0HPnITCxzKhaEHLyFQOh71W37UpENMGu3TsPZNB012YilN1nkzQJ87e8dr3+kaimrtkzlv n/ZjbHkEOvzrC2LGyW1NnY7Ebi9Q8v9BzPmnI8COhump5n8SqApHH1mfM+4OPGKdc1d4l201sLr wSHxGEBiLALv9H6IH7lXu3KnJBFsXrkawVN07bJveGm49aScxft2DEyWhHOBBfTGBC5F5VepdJi Elh+dzU024PAp3XbtVELc3/y0qbTEdVJl5kOHZWsbdxZRyLUAuZjPvuzmE2WGC3jqLfaqMtJsOM f/gavR55J3z93gMUkOIW+s6dJHV2RkgILY364Aa6U1C9Wn0UTH2rwEkeovADFiiAvOWVfYSAoD9 x47xl65v+uRrnjweUmOHKfOMNtfGKpBTTgr4UZmtpoRkC8/big/w== X-Received: by 2002:a05:600c:4e8f:b0:493:b307:6777 with SMTP id 5b1f17b1804b1-4953c273de7mr4061435e9.22.1784065556082; Tue, 14 Jul 2026 14:45:56 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4950a32b9f3sm118533945e9.13.2026.07.14.14.45.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 14:45:55 -0700 (PDT) Date: Tue, 14 Jul 2026 22:45:53 +0100 From: David Laight To: "Arnd Bergmann" Cc: "Pedro Falcato" , "Yeoreum Yun" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, Linux-Arch , kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, x86@kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com, "linux-csky@vger.kernel.org" , linux-m68k@lists.linux-m68k.org, "linux-openrisc@vger.kernel.org" , "David Hildenbrand (Red Hat)" , "Russell King" , "Andrew Morton" , "Ankur Arora" , "Mike Rapoport" , "Magnus Lindholm" , "Christophe Leroy" , "Klara Modin" , "Huacai Chen" , "WANG Xuerui" , "Kirill A. Shutemov" , zhangtianyang@loongson.cn, wangyuli@aosc.io, "Thomas Bogendoerfer" , "Lorenzo Stoakes" , "Jason Gunthorpe" , "Catalin Marinas" , "Will Deacon" , "Ryan Roberts" , "Pasha Tatashin" , "Rohan McLure" , "Baolin Wang" , "Tejun Heo" , "Kevin Brodsky" , "Anup Patel" , atish.patra@linux.dev, "Paul Walmsley" , "Palmer Dabbelt" , "Albert Ou" , "Alexandre Ghiti" , "Dave Hansen" , "Andy Lutomirski" , "Peter Zijlstra" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "H. Peter Anvin" , "Johannes Weiner" , "Michal Hocko" , qi.zheng@linux.dev, "Shakeel Butt" , "Kairui Song" , "Barry Song" , "Axel Rasmussen" , "Yuanchu Xie" , "Wei Xu" , "Andrey Ryabinin" , "Alexander Potapenko" , "Andrey Konovalov" , "Dmitry Vyukov" , "Vincenzo Frascino" , "Anshuman Khandual" , "Yang Shi" , chaitanyas.prakash@arm.com, "Ard Biesheuvel" , guoren , yang.li85200@gmail.com, "Alexander Viro" , "Dinh Nguyen" , "schuster.simon@siemens-energy.com" , "Vivian Wang" , junhui.liu@pigmoral.tech, "Muchun Song" , "Vishal Moola (Oracle)" , "Nam Cao" , "Pavel Machek" , djbw@kernel.org, yu-cheng.yu@intel.com, "Baolu Lu" , "Jonathan Cameron" , "Coiby Xu" , "Andreas Larsson" , "Liam R. Howlett" , "Vlastimil Babka (SUSE)" , "Suren Baghdasaryan" , "Michal Hocko" , "Geert Uytterhoeven" , "Stafford Horne" , "Jonas Bonn" , "Stefan Kristiansson" Subject: Re: [RFC PATCH 02/34] ARM: mm: make 2-level pgd_t a scalar Message-ID: <20260714224553.583c8445@pumpkin> In-Reply-To: References: <20260713135614.1618183-1-yeoreum.yun@arm.com> <20260713135614.1618183-3-yeoreum.yun@arm.com> <20260714143450.61a94085@pumpkin> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-csky@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 14 Jul 2026 17:06:00 +0200 "Arnd Bergmann" wrote: > On Tue, Jul 14, 2026, at 15:34, David Laight wrote: > > On Tue, 14 Jul 2026 13:55:18 +0200 > > "Arnd Bergmann" wrote: > >> > I see the compiler has an awkward time returning a u64 struct (see > >> > https://godbolt.org/z/qejbv6j9a), but if this doesn't work maybe we should > >> > get rid of the STRICT_MM_TYPECHECKS stuff? I seriously doubt anyone is > >> > purposefully toggling it on for testing from time to time. > >> > >> As far as I can tell, the #ifdef was originally in i386 and > >> got copied to all other architectures at the time, but was > >> removed in linux-2.3.23 from the original copy when CONFIG_X86_PAE > >> was introduced. > > > > For x86-32 the makefiles request 64bit structures be returned in registers > > (at the same place regparm=3 is set - probably added at the same time > > between 2.4 and 2.6). > > > > Note that arm32 can will return a 32bit struct in a register and > > arm64 will return a 128bit struct in two registers. > > > > The only problem is returning a 64bit struct in 32bit mode. > > > > I'm sure this code is arm64 only. > > The file we are talking about is arch/arm/include/asm/pgtable-2level-types.h, > which is definitely 32-bit only and force a 64-bit struct return > on the stack. I've clearly failed to detect the environment :-( The 'struct return by reference' is part of the ABI. > I checked some trivial tests that show that arm-linux-gnueabihf-gcc-16 > also still produces badly optimized object code with structures > passed by value, and will spill those to the stack for no apparent > reason. clang handles those just fine as a pair of registers. I'd have thought it would be ok if the structure had two 32bit values and they were directly accessed. The silly test I did earlier didn't spill. Taking the address could easily force a spill in the function itself. So that ((int (*)[2])&var)[0] (which is just ((int *)&var)[0]) is likely to be problematic - or certainly heading in that direction. > For the 2-level page table, this only concerns pgd_t, which is > rarely passed around or returned by value. The 3-level page > table has a 64-bit pte_t, which means we probably won't > want STRICT_MM_TYPECHECKS there. I did do some mmu setup for a strongarm a long time ago. I do remember in being odd. But I was only moving the software frame buffer away from the physical frame buffer to steal a load of screen rows for a keyboard. Is the 64bit pte_t needed to get the extra modified and accessed flags there aren't free bits for in the hardware pte? Would it have been possible to use bits that are fixed in the hardware pte for the extra bits and write the value to pte[0] and pte[256] fixing up the value written to pte[0] (that the hardware reads). The arm docs seem hard to read... (the left-right scroll doesn't help!) David > > Arnd