From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1j2Cyd-0003rt-OZ for mharc-grub-devel@gnu.org; Thu, 13 Feb 2020 06:48:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34794) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2CyO-0003r4-Jy for grub-devel@gnu.org; Thu, 13 Feb 2020 06:48:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2CyN-0005BR-69 for grub-devel@gnu.org; Thu, 13 Feb 2020 06:48:00 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:36736) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j2CyM-0005B3-Pr for grub-devel@gnu.org; Thu, 13 Feb 2020 06:47:59 -0500 Received: by mail-wr1-x441.google.com with SMTP id z3so6305689wru.3 for ; Thu, 13 Feb 2020 03:47:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=0ifvk3zVWghEPmuoYiEbeQlYCPKoz1ZgT05nzwgaxKM=; b=rJti4u4qA/zqyqbsl/vJc79gUFg18uOhsKYBeJ44amtZskAMnfm2Cs5nGISVQFWNXA K2VlRaYQ1F8syLK5cMuam575WIWwl32xX8Gb106jiwcX/qpztdwDaj1Qt4DAq4gN8A79 e3as0OcsIeDcMuIJbUG7FFBUSLwIXfg5TJpn60NgxZtv40lZvwg9L4w5JaR1uX019j6i SrRltyoLFvXNZKSQxuojStbOOjpkNg93xKlQ3+70PbDiWiYtQKQawM4FNhXGiEJNWCUK LaTdz+/fKi8mbs/CVtELon7bIF/q5VMftIp4jc8mQTTb92dyIfI7v0+DsF5vAqPDWpp0 f6CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=0ifvk3zVWghEPmuoYiEbeQlYCPKoz1ZgT05nzwgaxKM=; b=UNwwQwuae+EIwjIVchXAZc2Q4gtYAjmSKqctSHPUvmXlLVOdfxtvGCo70mtWXXC6A7 mCt+r84mNSegC+VlLVJ8QiVf/nMjyhUBPwgS9Yyjm4mHV7tv2FeByCwSOF8dYrbiuf5n Jbf+nan3JGHEfVEB78vW84uy73q88EvQ2RFJ6XIXVlLb1plM+PhZ9vqggwyQaMNq8ZQK gkpHTrgx8LgnEf5PSlDtetZO5J4/ZeoIbXfpsB3inLmhmqU/BpGzMd+TWKsQ2P5LAYro AaXwvSBVbxQBvctRctjnMEcKcKTLMW0rCOFuWM9ozWLc3H2G5tUcjz/DQmesF5H/qpag pwEQ== X-Gm-Message-State: APjAAAU+Tdn0I/wteTi+JEOoHtgm8vLoe/6I0PAKbKYYI4nmV+KGHnOg /6ltz34B0yp+rk2VCUuNW0L5HMxoZr5boUlhJM+KbXRPC7UibQ2Ypa4yWp6/f6qBhNXUGiTKhs4 fVxPMtOqjredxH3BG4qiNjZHqbE+mc+Gd8hz/8zQ8y6fg/nA1YBtfH3Ngw/PG X-Google-Smtp-Source: APXvYqx0Dmne7Q2iy1OXTZIMpv+sE6AZLkiD/tDjj66MBRh5zrNmKOsBroUFC1gIeirW/G6Alu+RfQ== X-Received: by 2002:adf:f847:: with SMTP id d7mr20910089wrq.35.1581594476912; Thu, 13 Feb 2020 03:47:56 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id y1sm2573802wrq.16.2020.02.13.03.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2020 03:47:56 -0800 (PST) Date: Thu, 13 Feb 2020 11:47:54 +0000 From: Leif Lindholm To: The development of GNU GRUB Cc: Patrick Steinhardt , Daniel Kiper Subject: Re: [PATCH 1/5] efi: Allocate half of available memory by default Message-ID: <20200213114754.GK23627@bivouac.eciton.net> References: <53cdfdc2703c934d5f0c03130972eeae67fb4318.1580998938.git.ps@pks.im> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53cdfdc2703c934d5f0c03130972eeae67fb4318.1580998938.git.ps@pks.im> User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Feb 2020 11:48:11 -0000 On Thu, Feb 06, 2020 at 15:27:29 +0100, Patrick Steinhardt wrote: > By default, GRUB will allocate a quarter of the pages it got available > in the EFI subsystem. On many current systems, this will amount to > roughly 800MB of RAM assuming an address space of 32 bits. This is > plenty for most use cases, but it doesn't suffice when using full disk > encryption with a key derival function based on Argon2. > > Besides the usual iteration count known from PBKDF2, Argon2 introduces > two additional parameters "memory" and "parallelism". While the latter > doesn't really matter to us, the memory parameter is quite interesting. > If encrypting a partition with LUKS2 using Argon2 as KDF, then > cryptsetup will default to a memory parameter of 1GB. Meaning we need to > allocate a buffer of 1GB in size in order to be able to derive the key, > which definitely won't squeeze into the limit of 800MB. > > To prepare for Argon2, let's thus increase the default and make half of > memory available, instead of a quarter only. This amounts to about > 1600MB on above systems, which is sufficient for Argon2. I was never a huge fan of the "grab a percentage of RAM" in the first place, and I think "grab twice that" is not the best solution here. (Real) corner cases that would be affected by this are: 1) chainloading grub from grub 2) OS loaders (loaded by GRUB) requiring large amounts of RAM before ExitBootsevices(). If you have a known minimum requirement, can we work towards that instead? For a least-invasive approach, that could be something like - rename required_pages target_heap_pages - add a required_pages var initialized to ... something real and then if (target_heap_size < required_pages) target_heap_pages = required_pages. The MIN/MAX heap size could move into the "something real" calculation, getting rid of the current (arbitrary) clamping of MAX_HEAP_SIZE to 1.6G.. / Leif > Signed-off-by: Patrick Steinhardt > --- > grub-core/kern/efi/mm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c > index b02fab1b1..d1f9d046b 100644 > --- a/grub-core/kern/efi/mm.c > +++ b/grub-core/kern/efi/mm.c > @@ -599,10 +599,10 @@ grub_efi_mm_init (void) > filtered_memory_map_end = filter_memory_map (memory_map, filtered_memory_map, > desc_size, memory_map_end); > > - /* By default, request a quarter of the available memory. */ > + /* By default, request half of the available memory. */ > total_pages = get_total_pages (filtered_memory_map, desc_size, > filtered_memory_map_end); > - required_pages = (total_pages >> 2); > + required_pages = (total_pages / 2); > if (required_pages < BYTES_TO_PAGES (MIN_HEAP_SIZE)) > required_pages = BYTES_TO_PAGES (MIN_HEAP_SIZE); > else if (required_pages > BYTES_TO_PAGES (MAX_HEAP_SIZE)) > -- > 2.25.0 > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel