Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1640576rdd; Thu, 11 Jan 2024 05:23:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfAn++kMu4FHZZsSQD90uw1fQYjmIbAoLxtvnq156Q5jTZoG8h5l+QKQLTEslIXIc2zRnG X-Received: by 2002:a05:6a20:a729:b0:199:dcc4:2512 with SMTP id by41-20020a056a20a72900b00199dcc42512mr844850pzb.103.1704979424270; Thu, 11 Jan 2024 05:23:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704979424; cv=none; d=google.com; s=arc-20160816; b=vnc51MsHerQVwNC6AN5G/cb7oVuhv5mQmAgJKt2xZwcMUo4cO2cj/WwILmUfMSkzMi 3v6xZyWwhfn+km59UMY2QMkSXLPHZGSiAgy5Zi8Q8Ak6opIccmTMte2/bverjl677pPP EOnMZp9bW4/sWWPALnD3RAoI5LCfY1RLf5WuRp7THFlYCVNNsGf1ybrFhKn2dW65wi/x UJpL98j7+itvqiXsjRjUB1ok5DdQkmGIFCmcvh6r3hkRFQOx9DkIam1Ht/fB71v1DqFb t4g8d1jQTygkTlhprMX50L6zmPgDuLxTB+OC1Z2oiaVhLs2Cwa1uWj+1tRct0k3mPDrL /7/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=kU+J1evnA/wXmkWiFkKLutX9UNytdvOjifYvR0icVXQ=; fh=PidVlsZtdEU+4/7APAnVqOowN/d59jKlFvuFPIuFEjo=; b=tPo+0t7kOG9SgREa8NsObQ0ROE19FOE1wEzOKmXPasWqjIIA/0l/v9FlAjYM1X9FqK ljbHD7OroVBuRLSV7zVY7WYZj4sI0dzWRVw3xJqSi1X5uUGaQZeiqY22Y1hzX/PgoNAe 1EA/M5y0Er7YA03Z+utTPAFMuLDOEvEB8segPArDr16Ei2VnVnVx4C0naoOtGupweHTL mVBwycQQqSl14dF0CExOiCcCeHCP1W+kExSSewULOQdPBTuAFZnMw4u3kfxN+jWkHhX7 AB7LE3gJJXrPrNCFhR2Tz9z1SOZI7OX3g7Zri/g2ijZzoyWpHKo91AjKPvm5MFdm3bWE XurQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-23646-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23646-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id c32-20020a631c20000000b005ced6c45233si1061102pgc.712.2024.01.11.05.23.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 05:23:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23646-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-23646-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23646-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 59D4AB24C33 for ; Thu, 11 Jan 2024 13:22:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 221BF16409; Thu, 11 Jan 2024 13:19:26 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A179215EBD; Thu, 11 Jan 2024 13:19:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C866C433F1; Thu, 11 Jan 2024 13:19:20 +0000 (UTC) Message-ID: Date: Thu, 11 Jan 2024 23:19:18 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [Automated-testing] Call for nommu LTP maintainer [was: Re: [PATCH 00/36] Remove UCLINUX from LTP] Content-Language: en-US To: Geert Uytterhoeven , Rob Landley Cc: Petr Vorel , Tim Bird , Cyril Hrubis , "ltp@lists.linux.it" , Li Wang , Andrea Cervesato , Jonathan Corbet , Randy Dunlap , John Paul Adrian Glaubitz , Christophe Lyon , "linux-m68k@lists.linux-m68k.org" , "linux-kernel@vger.kernel.org" , Linux ARM , linux-riscv , Linux-sh list , "automated-testing@lists.yoctoproject.org" , "buildroot@buildroot.org" , Niklas Cassel References: <20240103114957.GD1073466@pevik> <5a1f1ff3-8a61-67cf-59a9-ce498738d912@landley.net> <20240105131135.GA1484621@pevik> <90c1ddc1-c608-30fc-d5aa-fdf63c90d055@landley.net> <20240108090338.GA1552643@pevik> <20240110141455.GC1698252@pevik> <40996ea1-3417-1c2f-ddd2-e6ed45cb6f4b@landley.net> From: Greg Ungerer In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 11/1/24 23:11, Geert Uytterhoeven wrote: > Hi Rob, > > On Wed, Jan 10, 2024 at 8:17 PM Rob Landley wrote: >> You can't fork() on nommu because copies of the mappings have different >> addresses, meaning any pointers in the copied mappings would point into the OLD >> mappings (belonging to the parent process), and fixing them up is 100% >> equivalent to the "garbage collection in C" problem. (It's AI-complete. Of the >> C3PO kind, not the "autocorrect with syntax checking" kind.) People get hung up >> on the "it would be very inefficient to do that because no copy-on-write" >> problem and miss the "the child couldn't FUNCTION because its pointer variables >> all contain parent addresses" problem. > > Actually you can implement fork(), if you teach the compiler to use > separate stacks for return addresses and data: > - The first stack would contain only absolute addresses, to be > relocated after copying, > - The second stack would contain integers and relative pointers > (see FDPIC below), which do not need relocation after copying. > >> The OTHER fun thing about nommu is you can't run conventional ELF binaries, >> because everything is linked at fixed address. So you might be able to run ONE >> instance of the program as your init task, assuming those addresses were >> available even then, but as soon as you try to run a second one it's a conflict. >> >> The quick and dirty work around is to make PIE binaries, which can relocate >> everything into available space, which works but doesn't scale. The problem with >> ELF PIE is that everything is linked contiguously from a single base pointer, >> meaning your text, rodata, data, and bss segments are all one linear blob. So if >> you run two instances of bash, you've loaded two copies of the test and the >> rodoata. This fills up your memory fast. >> >> AND PIE requires contiguous memory, which nommu is bad at providing because it >> has no page tables to remap stuff. With an mmu it can coalesce scattered >> physical pages into a virtually contiguous range, but without an mmu you can >> have plenty of memory free but in tiny chunks, none big enough to satisfy an >> allocation request. >> >> So they invented FDPIC, which is ELF with FOUR base pointers. Each major section >> (rodata, text, data, and bss) has its own base pointer, so you need to find >> smaller chunks of memory to load them into (and thus it can work on a more >> fragmented system), AND it means that two instances of the same program can >> share the read-only sections (rodata and text) so you only need new copies of >> the writeable segments (data and bss. And the heap. And the stack.) > > Or Amiga LoadSeg() relocatable binaries and shared libraries ;-) > As this supported splitting code, data, and bss in lots of smaller > hunks, it could counter fragmented memory quite well. > > BTW, can't you run and thus test nommu-binaries under normal Linux, too? Yes, you can. The flat format loader can be built for MMU arm and m68k Linux. It will happily load and run flat format binaries on normal VM Linux. I test that often on m68k (on ColdFire platforms). Regards Greg