Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1qLZnn-0002ve-Dg for mharc-grub-devel@gnu.org; Mon, 17 Jul 2023 21:46:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLZnk-0002vQ-Qu for grub-devel@gnu.org; Mon, 17 Jul 2023 21:46:58 -0400 Received: from jupiter.guys.cyano.uk ([45.63.120.176]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLZni-0001UE-M2 for grub-devel@gnu.org; Mon, 17 Jul 2023 21:46:56 -0400 Message-ID: <1b38e855-e41c-2a84-d9da-a311c0418283@cyano.uk> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cyano.uk; s=dkim; t=1689644746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fR72bc8NKpywFcgD2BcQdIFEabT7gx8F+p0AUSe60qQ=; b=XbPAKn95nqWC6zgBTqPl292EbS6ab60WOUAqpj/6MCrijtv6+nW4Ycu7p30U98c3Quu6c+ 0qamgA+3v8MQN7KRYzDGGMDFHtRxPPfkwAEEzAvUvNrqDYsZpHGMFCBqP8LNjZ+xLWvuni g5z7JmzSmDoLf9uLIiAbAF8JSvwAv2smsr1UTz21NuVVOPKSZm730hlCVoIwOK9pD7oUOP HWAAKd55GvQJNmiEhb/1aGpxBOU4b9H1Ijqrhj9ITpMpbt8sbeFraUhS7VabdiBOOQE24Y +DXp0gaisDT6peMfSzz/HtXopNJxVhjzA9y6S6VaYrmyp03K8N1CAdTHJqUiKA== Date: Tue, 18 Jul 2023 09:45:41 +0800 MIME-Version: 1.0 Subject: Re: How to detect the amount of RAM on non-EFI platforms? Content-Language: en-US To: grub-devel@gnu.org References: <84e90f38-bc75-3725-333e-a529fa60dfa1@cyano.uk> <20230713183845.fdijjaxm4vqdnmjj@tomti.i.net-space.pl> <812cd4da-9b3b-edbe-23e4-208bb4b5d926@cyano.uk> From: Cyan Yang In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Authentication-Results: jupiter.guys.cyano.uk; auth=pass smtp.mailfrom=cyan@cyano.uk X-Spamd-Bar: / Received-SPF: pass client-ip=45.63.120.176; envelope-from=cyan@cyano.uk; helo=jupiter.guys.cyano.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jul 2023 01:46:58 -0000 Hi, On 2023/7/14 22:04, Vladimir 'phcoder' Serbinenko wrote: > > Just add an option to consider "reserved" memory as available. User's > choice. Fire you it's a single if. > Thanks for the tip, but I don't think it will work out - if we add up the reserved section, the result will be more than actual amount. I ran a test to show this. Consider a VM with EFI firmware (x86_64-efi) with 16,384MiB of RAM, I built and ran the module with memory map info printed out. Here's the result (output is way too long): grub> phymem Memory map 0001 @ 0x0000000000000000, with size of 0x87000 Memory map 0001 @ 0x0000000000087000, with size of 0x1000 Memory map 0001 @ 0x0000000000088000, with size of 0x18000 Memory map 0001 @ 0x0000000000100000, with size of 0x706000 Memory map 0001 @ 0x0000000000806000, with size of 0x1000 Memory map 0001 @ 0x0000000000807000, with size of 0x4000 Memory map 0001 @ 0x000000000080b000, with size of 0x1000 Memory map 0001 @ 0x000000000080c000, with size of 0x14000 Memory map 0001 @ 0x0000000000820000, with size of 0xce0000 Memory map 0001 @ 0x0000000001500000, with size of 0x5b548000 Memory map 0001 @ 0x000000005ca48000, with size of 0x1f576000 Memory map 0001 @ 0x000000007bfbe000, with size of 0x20000 Memory map 0001 @ 0x000000007bfde000, with size of 0x22f3000 Memory map 0001 @ 0x000000007e2d1000, with size of 0x25000 Memory map 0001 @ 0x000000007e2f6000, with size of 0x26000 Memory map 0001 @ 0x000000007e31c000, with size of 0x10000 Memory map 0001 @ 0x000000007e32c000, with size of 0x1000 Memory map 0001 @ 0x000000007e32d000, with size of 0x1000 Memory map 0001 @ 0x000000007e32e000, with size of 0x79e000 Memory map 0001 @ 0x000000007eacc000, with size of 0xa7000 Memory map 0001 @ 0x000000007eb73000, with size of 0x26000 Memory map 0001 @ 0x000000007eb99000, with size of 0x9e000 Memory map 0001 @ 0x000000007ec37000, with size of 0x3c000 Memory map 0001 @ 0x000000007ec73000, with size of 0x5000 Memory map 0001 @ 0x000000007ec78000, with size of 0x1000 Memory map 0001 @ 0x000000007ec79000, with size of 0x20000 Memory map 0001 @ 0x000000007ec99000, with size of 0x1000 Memory map 0001 @ 0x000000007ec9a000, with size of 0x7000 Memory map 0001 @ 0x000000007eca1000, with size of 0x2000 Memory map 0001 @ 0x000000007eca3000, with size of 0xa000 Memory map 0001 @ 0x000000007ecad000, with size of 0x1000 Memory map 0001 @ 0x000000007ecae000, with size of 0x11000 Memory map 0001 @ 0x000000007ecbf000, with size of 0x2000 Memory map 0001 @ 0x000000007ecc1000, with size of 0x4000 Memory map 0001 @ 0x000000007ecc5000, with size of 0x4000 Memory map 0001 @ 0x000000007ecc9000, with size of 0x1a000 Memory map 0001 @ 0x000000007ece3000, with size of 0x5000 Memory map 0001 @ 0x000000007ece8000, with size of 0x14000 Memory map 0001 @ 0x000000007ecfc000, with size of 0xb000 Memory map 0001 @ 0x000000007ed07000, with size of 0x15000 Memory map 0001 @ 0x000000007ed1c000, with size of 0x1000 Memory map 0001 @ 0x000000007ed1d000, with size of 0x7000 Memory map 0001 @ 0x000000007ed24000, with size of 0x7000 Memory map 0001 @ 0x000000007ed2b000, with size of 0x1c000 Memory map 0001 @ 0x000000007ed47000, with size of 0x2000 Memory map 0001 @ 0x000000007ed49000, with size of 0x14000 Memory map 0001 @ 0x000000007ed5d000, with size of 0x7000 Memory map 0001 @ 0x000000007ed64000, with size of 0x6000 Memory map 0001 @ 0x000000007ed6a000, with size of 0x1000 Memory map 0001 @ 0x000000007ed6b000, with size of 0x1d000 Memory map 0001 @ 0x000000007ed88000, with size of 0x3000 Memory map 0001 @ 0x000000007ed8b000, with size of 0xe000 Memory map 0001 @ 0x000000007ed99000, with size of 0x2000 Memory map 0001 @ 0x000000007ed9b000, with size of 0x14000 Memory map 0001 @ 0x000000007edaf000, with size of 0x2000 Memory map 0001 @ 0x000000007edb1000, with size of 0xd000 Memory map 0001 @ 0x000000007edbe000, with size of 0x3000 Memory map 0001 @ 0x000000007edc1000, with size of 0x6000 Memory map 0001 @ 0x000000007edc7000, with size of 0x2000 Memory map 0001 @ 0x000000007edc9000, with size of 0x1000 Memory map 0001 @ 0x000000007edca000, with size of 0x1000 Memory map 0001 @ 0x000000007edcb000, with size of 0x5000 Memory map 0001 @ 0x000000007edd0000, with size of 0x5000 Memory map 0001 @ 0x000000007edd5000, with size of 0x12000 Memory map 0001 @ 0x000000007ede7000, with size of 0x2000 Memory map 0001 @ 0x000000007ede9000, with size of 0x6000 Memory map 0001 @ 0x000000007edef000, with size of 0x2000 Memory map 0001 @ 0x000000007edf1000, with size of 0xf000 Memory map 0001 @ 0x000000007ee00000, with size of 0x200000 Memory map 0001 @ 0x000000007f000000, with size of 0xc000 Memory map 0001 @ 0x000000007f00c000, with size of 0x5000 Memory map 0001 @ 0x000000007f011000, with size of 0x12000 Memory map 0001 @ 0x000000007f023000, with size of 0x2000 Memory map 0001 @ 0x000000007f025000, with size of 0x1000 Memory map 0001 @ 0x000000007f026000, with size of 0x1000 Memory map 0001 @ 0x000000007f027000, with size of 0x7000 Memory map 0001 @ 0x000000007f02e000, with size of 0x7000 Memory map 0001 @ 0x000000007f035000, with size of 0x4000 Memory map 0001 @ 0x000000007f039000, with size of 0x6000 Memory map 0001 @ 0x000000007f03f000, with size of 0x4000 Memory map 0001 @ 0x000000007f043000, with size of 0x2000 Memory map 0001 @ 0x000000007f045000, with size of 0x2b000 Memory map 0001 @ 0x000000007f070000, with size of 0xa000 Memory map 0001 @ 0x000000007f07a000, with size of 0xa000 Memory map 0001 @ 0x000000007f084000, with size of 0x4000 Memory map 0002 @ 0x000000007f088000, with size of 0xc1000 Memory map 0001 @ 0x000000007f149000, with size of 0x15000 Memory map 0001 @ 0x000000007f15e000, with size of 0x3000 Memory map 0001 @ 0x000000007f161000, with size of 0x3000 Memory map 0001 @ 0x000000007f164000, with size of 0x2000 Memory map 0001 @ 0x000000007f166000, with size of 0x5000 Memory map 0001 @ 0x000000007f16b000, with size of 0x1000 Memory map 0001 @ 0x000000007f16c000, with size of 0x1000 Memory map 0001 @ 0x000000007f16d000, with size of 0x1000 Memory map 0001 @ 0x000000007f16e000, with size of 0x1000 Memory map 0001 @ 0x000000007f16f000, with size of 0x1000 Memory map 0001 @ 0x000000007f170000, with size of 0x1000 Memory map 0001 @ 0x000000007f171000, with size of 0x2000 Memory map 0001 @ 0x000000007f173000, with size of 0x3000 Memory map 0001 @ 0x000000007f176000, with size of 0x2000 Memory map 0001 @ 0x000000007f178000, with size of 0x1000 Memory map 0001 @ 0x000000007f179000, with size of 0x42000 Memory map 0001 @ 0x000000007f1bb000, with size of 0xc000 Memory map 0001 @ 0x000000007f1c7000, with size of 0x1000 Memory map 0001 @ 0x000000007f1c8000, with size of 0x1000 Memory map 0001 @ 0x000000007f1c9000, with size of 0x1000 Memory map 0001 @ 0x000000007f1ca000, with size of 0x1000 Memory map 0001 @ 0x000000007f1cb000, with size of 0x2000 Memory map 0001 @ 0x000000007f1cd000, with size of 0x6000 Memory map 0001 @ 0x000000007f1d3000, with size of 0x400000 Memory map 0001 @ 0x000000007f5d3000, with size of 0x4000 Memory map 0001 @ 0x000000007f5d7000, with size of 0x1000 Memory map 0001 @ 0x000000007f5d8000, with size of 0x2000 Memory map 0001 @ 0x000000007f5da000, with size of 0x2000 Memory map 0001 @ 0x000000007f5dc000, with size of 0x1000 Memory map 0001 @ 0x000000007f5dd000, with size of 0x1000 Memory map 0001 @ 0x000000007f5de000, with size of 0x9000 Memory map 0001 @ 0x000000007f5e7000, with size of 0x3000 Memory map 0001 @ 0x000000007f5ea000, with size of 0x3000 Memory map 0001 @ 0x000000007f5ed000, with size of 0x302000 Memory map 0002 @ 0x000000007f8ef000, with size of 0x100000 Memory map 0014 @ 0x000000007f9ef000, with size of 0x100000 Memory map 0002 @ 0x000000007faef000, with size of 0x80000 Memory map 0003 @ 0x000000007fb6f000, with size of 0x10000 Memory map 0004 @ 0x000000007fb7f000, with size of 0x80000 Memory map 0001 @ 0x000000007fbff000, with size of 0x201000 Memory map 0001 @ 0x000000007fe00000, with size of 0xe9000 Memory map 0001 @ 0x000000007fee9000, with size of 0x20000 Memory map 0001 @ 0x000000007ff09000, with size of 0x1a000 Memory map 0001 @ 0x000000007ff23000, with size of 0x42000 Memory map 0001 @ 0x000000007ff65000, with size of 0x17000 Memory map 0002 @ 0x000000007ff7c000, with size of 0x84000 Memory map 0001 @ 0x0000000100000000, with size of 0x380000000 Memory map 0002 @ 0x00000000b0000000, with size of 0x10000000 Memory map 0002 @ 0x00000000ffc00000, with size of 0x400000 The total system memory is 16643 MiB (17452105728 Bytes). As you can see, the reported amount will be more than actual amount. This is even twice the amount if a machine has only a hundred of RAM. BTW, I am considering to move the thread to discuss the way to precisely detect the amount of system memory, as the original issue was resolved. Thanks, Cinhi Young