From nobody Fri Aug 12 00:24:27 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M3kvK5Rylz4Z1CV; Fri, 12 Aug 2022 00:24:29 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M3kvK4nWJz3vB1; Fri, 12 Aug 2022 00:24:29 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660263869; h=from:from: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; bh=tp2qlnmDNhxu8EWpBniFfcTVmBvLL83USaDOfNt0b80=; b=FbjvCtwPacEZnAAeVeXjzAbR9U3zGIrIowCAq0QZ/jUr5/endeBOCiI39jkqh/QYQ+CfW7 Cj/1d971115Qas2gs+Fk24I+Eu5fOyc52BweaU2zPpdZCoZvx52APqyLL2QLUwLnu47xgr IHuhLeZA4lwDZnnsf2I18OiMETVZQAthqdojDgwjbxQqscFNoVbT34tGn2UzOLck0zl1I8 q/OHA+rk0Aa1mvqwoDAZ3Dv2hyqZMFDrFecz+qsEooSaDMCZM7/4vMKN7RimOWNmC8nZKm xdqjQ8P7/p63bH+bUbQBwTnl/9yAp2wtL936rkdMUcRISTrvqiN3e+V4VYoTEA== Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4M3kvJ73TTz153M; Fri, 12 Aug 2022 00:24:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Thu, 11 Aug 2022 17:24:27 -0700 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: Warner Losh Cc: Warner Losh , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202208110331.27B3Va7M007335@gitrepo.freebsd.org> <727af1f3-7432-c038-a776-682ef161f6f9@FreeBSD.org> From: John Baldwin Subject: Re: git: 39fdad34e220 - main - stand: impose 510,000 byte limit for /boot/loader and /boot/pxeldr In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660263869; h=from:from: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; bh=tp2qlnmDNhxu8EWpBniFfcTVmBvLL83USaDOfNt0b80=; b=t0mg8cBeSwTztoMh4jX56H3Qz14NE/R2c0ZoHEOU6L6Ivsscq35DirHx9yyfPWrsCm5+YD FL17hzJ3f/F+Eh9/H4pEHnQuO04gidOiNhDdN3bCw/7vxmboG1Z2fwQuhuM8//UivxDSAt JIi1tnVODlyyrkg9Y2zUSNVXOU8mMGsbSLH/RRIicJqYBa2y9T80syiZAcifAQv/Y2YU+1 ZAwzoTb5fY7VpS7TU4cqqYPrgHmpA1jQRbIaTBrdhTzw93LLF/UHtR9f9AOnUKB7/cGH7j FeWCMMs5TY9jnJJlQyzB86qBe9C/DFuXNgUYQV9c3crQZaaDrF6xQMun9If/hQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660263869; a=rsa-sha256; cv=none; b=iBAuHj84+EM+xj5+RG9SnAp8CDXRau2DinVsCSwELGyTF7RJXZk1VkOt/myD8NlveIx3tl KNuNNmC4w7xWBk+T+SU719u8kNIJfLdw+oqO4rear9Y4YfZM/VpdiLOSvJXSnIEThlkG/V Zzkptbt0Unio/4mFlFDI9h4rjaxbFokVeMVUlxSPImGXypzTWAWs/YxgYp63n7bNb4W9UI ydZ1GYmwqx3Pv37F5vnBEYMeJIaMfGcqIlLAkaLVpR7ugoT6zxiKtxQA54BwjsOGXOPj7l ok/eoskUsBHHHC0lmv0HAu9MsIyVskN5wGR/wcJAlQ4yRGPQdJo5+fBzJAVJtQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N On 8/11/22 11:18 AM, Warner Losh wrote: > On Thu, Aug 11, 2022 at 10:56 AM John Baldwin wrote: >> You really want to apply the size check to loader.bin, not loader. The >> memory >> layout down in the first 1MB for boot loaders is roughly: >> >> 0x0000: real-mode IDT >> 0x0400: BIOS data >> 0x7c00: where BIOS loads boot loaders such as /boot/mbr, etc. >> 0x1000: various BTX global data like GDT, TSS, IDT, stacks >> 0x9000: BTX kernel >> 0xa000: BTX client (loader.bin) >> 0xa0000: top of BTX client stack (though this can be a bit lower for cases >> like >> PXE booting) >> >> The real size constraint is on the BTX client (loader.bin) and the fact >> that >> it's text/data/bss plus stack need to fit into that 576k window (give or >> take). >> btxldr isn't stored in low memory, so its size isn't relevant, and BTX's >> code >> always takes up a full page even though it is much smaller. >> > > Where does 576k come from? That's 589824 bytes, but a0000-a000 is 614400 > bytes. The delta is 24k (24576). My 'observed' value of about 515,000 is > another > 75k below that, suggesting we are needing 100k of stack? Can that be right? > I knew > lua ate a lot of stack, but wow! Hmm, I converted 0xa000 to 64k instead of 40k in my head which is where the 576k came from. Yeah, the total size is 600k. 100k stack does seem like a lot. It is possible that other BIOS ROMs besides just PXE might steal data from the stack top. You could maybe try looking at some of your existing BIOS-boot machines to check the 16-bit word at physical address 0x413. That gives you the actual top of the 640k window. On my current desktop (albeit booted via UEFI and not BIOS) it is 629k: % sudo dd if=/dev/mem bs=1 iseek=0x413 count=2 | hd 2+0 records in 2+0 records out 2 bytes transferred in 0.000026 secs (75643 bytes/sec) 00000000 75 02 |u.| 00000002 % gdb ... (gdb) p/d 0x275 $2 = 629 Still, that's only 11k gone. I do think that when people have ran into trouble in the past it has been in situations that can recurse, e.g. using psuedo-filesystems like gzipfs where the gzipfs open routine tries to open the underlying "foo.gz" file, etc. -- John Baldwin