Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lYXIp-0002Sf-4S for mharc-grub-devel@gnu.org; Mon, 19 Apr 2021 13:03:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYXIm-0002Ot-Cw for grub-devel@gnu.org; Mon, 19 Apr 2021 13:03:12 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:36625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lYXIk-0003pn-7X for grub-devel@gnu.org; Mon, 19 Apr 2021 13:03:12 -0400 Received: by mail-pl1-x633.google.com with SMTP id g16so1218233plq.3 for ; Mon, 19 Apr 2021 10:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6fMVPZsDmverrCsMWxmKJVensNfICwNhcZjpG6bueIk=; b=ZFjrvYkYh7RQWeyrUScEcAA/cgBE+27xqoAEGw7dUpK4Pp8m7Y/shkaqPJhGq1AfcU be1IkwNBgoq5AlHyMRHqOsKBLcxDBXlMfAW4lR0cxccn+KK/fE2GAKhg1P7x8fnnil3n cMf+hjb+n8O5J7q+83DesYFB5l4oosmnJy+IY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6fMVPZsDmverrCsMWxmKJVensNfICwNhcZjpG6bueIk=; b=b3xsoOn+EJpwMOTBDyBV0cBHC5nJIpoz2/Glm6AR3KbpkTuU+MZW3huI4zQv3+C7LN IM5nac+CoPtMGg+ZHWBfgP/KrSlt+b4xXPph7IxtPuZumwqitSuL0/5rh8vTuptor2Cy ulgGtiSWtG66wf02VpPIp5AkzAWrvgmW9kB03pnYQgOa/QV4r0hwYflc39f/hLM+YgS9 mCXKyK79Q95pUor0jmhCrtMJabCZny06CxLKJC3q3x4XhAzwIsH94kEQibggirfZvMAM T3ovn34Pc7tT2NzXNL0lhN+oznZMJU4pOaGnQFjaQbb/EGePLL3/0X3jpH5v7jYhCrep cJlw== X-Gm-Message-State: AOAM533xjCtDs52L22vTnwkPHTpHOuOQgB9ZEQ5BZ/LxiyHoja3AuZKZ oGLRqJ8rQhUrGc6aVMB5s4Ww1BXuIEemjA== X-Google-Smtp-Source: ABdhPJy6HBUgqYDsHPUrswxqc9wv0KEpMASftxE/Gir0l5BRgpz9Jt/4oTWZD673IJHJ1rR+6oyGiQ== X-Received: by 2002:a17:902:760b:b029:e9:8bda:ae44 with SMTP id k11-20020a170902760bb02900e98bdaae44mr24351077pll.26.1618851785234; Mon, 19 Apr 2021 10:03:05 -0700 (PDT) Received: from localhost (2001-44b8-111e-5c00-72e1-b42d-8acd-3b87.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:72e1:b42d:8acd:3b87]) by smtp.gmail.com with ESMTPSA id u16sm5002673pfi.158.2021.04.19.10.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 10:03:04 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: ruscur@russell.cc, Daniel Axtens Subject: [PATCH 1/3] ieee1275: drop HEAP_MAX_ADDR, HEAP_MIN_SIZE Date: Tue, 20 Apr 2021 03:02:54 +1000 Message-Id: <20210419170256.3434868-2-dja@axtens.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210419170256.3434868-1-dja@axtens.net> References: <20210419170256.3434868-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=dja@axtens.net; helo=mail-pl1-x633.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Mon, 19 Apr 2021 17:03:12 -0000 HEAP_MAX_ADDR is confusing. Currently it is set to 32MB, except on ieee1275 on x86, where it is 64MB. There is a comment which purports to explain it: /* If possible, we will avoid claiming heap above this address, because it seems to cause relocation problems with OSes that link at 4 MiB */ This doesn't make a lot of sense when the constants are well above 4MB already. It was not always this way. Prior to commit 7b5d0fe4440c ("Increase heap limit") in 2010, HEAP_MAX_SIZE and HEAP_MAX_ADDR were indeed 4MB. However, when the constants were increased the comment was left unchanged. It's been over a decade. It doesn't seem like we have problems with claims over 4MB on powerpc or x86 ieee1275. (sparc does things completely differently and never used the constant.) Drop the constant and the check. The only use of HEAP_MIN_SIZE was to potentially override the HEAP_MAX_ADDR check. It is now unused. Remove it. Signed-off-by: Daniel Axtens --- grub-core/kern/ieee1275/init.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index d483e35eed2b..c5d091689f29 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -45,9 +45,6 @@ #include #endif -/* The minimal heap size we can live with. */ -#define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024) - /* The maximum heap size we're going to claim */ #ifdef __i386__ #define HEAP_MAX_SIZE (unsigned long) (64 * 1024 * 1024) @@ -55,14 +52,6 @@ #define HEAP_MAX_SIZE (unsigned long) (32 * 1024 * 1024) #endif -/* If possible, we will avoid claiming heap above this address, because it - seems to cause relocation problems with OSes that link at 4 MiB */ -#ifdef __i386__ -#define HEAP_MAX_ADDR (unsigned long) (64 * 1024 * 1024) -#else -#define HEAP_MAX_ADDR (unsigned long) (32 * 1024 * 1024) -#endif - extern char _start[]; extern char _end[]; @@ -183,12 +172,6 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, if (*total + len > HEAP_MAX_SIZE) len = HEAP_MAX_SIZE - *total; - /* Avoid claiming anything above HEAP_MAX_ADDR, if possible. */ - if ((addr < HEAP_MAX_ADDR) && /* if it's too late, don't bother */ - (addr + len > HEAP_MAX_ADDR) && /* if it wasn't available anyway, don't bother */ - (*total + (HEAP_MAX_ADDR - addr) > HEAP_MIN_SIZE)) /* only limit ourselves when we can afford to */ - len = HEAP_MAX_ADDR - addr; - /* In theory, firmware should already prevent this from happening by not listing our own image in /memory/available. The check below is intended as a safeguard in case that doesn't happen. However, it doesn't protect -- 2.27.0