On Tue, 14 Jul 2026 17:06:00 +0200 "Arnd Bergmann" <[email protected]> wrote:
> On Tue, Jul 14, 2026, at 15:34, David Laight wrote: > > On Tue, 14 Jul 2026 13:55:18 +0200 > > "Arnd Bergmann" <[email protected]> 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
