Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1ljDrz-0002Qn-Qw for mharc-grub-devel@gnu.org; Wed, 19 May 2021 00:31:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljDrg-0002JX-8a for grub-devel@gnu.org; Wed, 19 May 2021 00:31:24 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:37740) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljDre-00055a-Hf for grub-devel@gnu.org; Wed, 19 May 2021 00:31:24 -0400 Received: by mail-pj1-x1034.google.com with SMTP id gb21-20020a17090b0615b029015d1a863a91so2806674pjb.2 for ; Tue, 18 May 2021 21:31:22 -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=XzrX1fU2aqaD7zfntlRIcMZ4JDlVOpINfsaI0VoVRsk=; b=UK54Nc8Zx52OsL3uu7N20OmsK4SuYXThnn4A3QpJSCbtX2w7Enl1hTGqg2oQ28fZ4L NtrgE3PorPphPgjZws/KdBT3WWpbseVl8inRLQtloOX1lXBnU4hqkb1ngREDLIsFCAmM zADYB+xXzfxq0jbBrvelH3lozldCqhNSGsy/c= 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=XzrX1fU2aqaD7zfntlRIcMZ4JDlVOpINfsaI0VoVRsk=; b=XpIxaOFQK7GMcu96iZw0wA/SFp6okgzVZfx0fPhpc3wn7OnH3CcaI5Vu8HS/MiuSvs vhW5evc9nkT28Hb0L0p9De2JgvkNQCevWPsHZPNL/LT/HD/PXo+hPddSi9yUO/9T17vq 5+Vi6CBaxadsFD/0w2e9YfSr0lZEn5Kegz5kslqnpYwuBsAJv9kOAF6G3U6xc5UYfS1J B0q+NeJiz6WhQktGeu5MjOLKGcH2pWvHhRRF3HXnjrePyuErM1+RYkXdjvppLa5iVRl5 hrGWKPPWW/SCp34ag2D6KmhwR7AvyM+vrzY3+6XI4UvkoIsDq9NAfl+PV38HnW6ociX2 aJ1g== X-Gm-Message-State: AOAM5330LXD1Fh1FbDFeW+LEaM1ZTvPddNL0xL9d2yLykUSCKv9NVvfc c5V0PfK/Er57Wyba0u5uF8MdrIKMTyNlPQ== X-Google-Smtp-Source: ABdhPJxzEiSqywY9AJ/2U5FBCxlAa0QlRLws1PM8oR0EC3PY9LF24wPxXJcQow99sAaMhLmj/nNxtw== X-Received: by 2002:a17:90b:1d8b:: with SMTP id pf11mr9725629pjb.139.1621398680801; Tue, 18 May 2021 21:31:20 -0700 (PDT) Received: from localhost (110-175-254-242.static.tpgi.com.au. [110.175.254.242]) by smtp.gmail.com with ESMTPSA id s14sm14556411pjp.16.2021.05.18.21.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 21:31:20 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: Daniel Axtens Subject: [PATCH v2 1/3] ieee1275: drop HEAP_MAX_ADDR, HEAP_MIN_SIZE Date: Wed, 19 May 2021 14:31:09 +1000 Message-Id: <20210519043111.667796-2-dja@axtens.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210519043111.667796-1-dja@axtens.net> References: <20210519043111.667796-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=dja@axtens.net; helo=mail-pj1-x1034.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: Wed, 19 May 2021 04:31:24 -0000 X-List-Received-Date: Wed, 19 May 2021 04:31:24 -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 7a1ebdf94e06..c81cfc0320ae 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -46,9 +46,6 @@ #endif #include -/* 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) @@ -56,14 +53,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[]; @@ -184,12 +173,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