From nobody Thu Apr 25 17:20:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1650533646288972.3082759222846; Thu, 21 Apr 2022 02:34:06 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 3AC8616E3D0B; Thu, 21 Apr 2022 09:34:01 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 87DA216E3655 for ; Thu, 21 Apr 2022 09:33:31 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-321-xSYxy4-8PGq7lT1CpXcD7g-1; Thu, 21 Apr 2022 05:33:29 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D0B173C172CF for ; Thu, 21 Apr 2022 09:33:28 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E75F43E782; Thu, 21 Apr 2022 09:33:28 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id B2268180039F; Thu, 21 Apr 2022 11:33:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650533610; 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=DgWjSqy31tqcl9CuBnhLtks75MX6Rls+PcHPn4NNUJw=; b=IXnZDRT2rSeqDbTplJzC46sQlk8EQgn/aAVhs54aV8YIzUzEcrQVmm302aIe3APD+W0IpX eMRARTzWFfMPC/1SaMyjdphHsNFpbKPRbsRgqn5g/1RPACZt0HtUi6WSr6pUPo6UJa0e6u 4V2kfj1uHZQ+p0izL+FzvmTYGuOkE+Y= X-MC-Unique: xSYxy4-8PGq7lT1CpXcD7g-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Thu, 21 Apr 2022 11:33:25 +0200 Message-Id: <20220421093326.1382452-2-kraxel@redhat.com> In-Reply-To: <20220421093326.1382452-1-kraxel@redhat.com> References: <20220421093326.1382452-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: AWSWY2CC7YYVATKH2MPII3ASVZA4FVMO X-Message-ID-Hash: AWSWY2CC7YYVATKH2MPII3ASVZA4FVMO X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.5rc1 Precedence: list Subject: [SeaBIOS] [PATCH 1/2] malloc: add on demand ZoneHigh expansion support List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: ------ X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1650533647633100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When running out of memory in ZoneHigh go alloc memory from ZoneTmpHigh, add it as reserved to the e820 map and expand ZoneHigh Signed-off-by: Gerd Hoffmann --- src/malloc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/malloc.c b/src/malloc.c index 3733855caf2c..02067b5370f9 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -226,6 +226,20 @@ zonelow_expand(u32 size, u32 align, struct allocinfo_s= *fill) return alloc_new(&ZoneLow, size, align, fill); } =20 +static u32 +zonehigh_expand(u32 size, u32 align, struct allocinfo_s *fill) +{ + u32 xsize =3D ALIGN(size, BUILD_MAX_HIGHTABLE); + u32 xalign =3D align > PAGE_SIZE ? align : PAGE_SIZE; + u32 xdata =3D malloc_palloc(&ZoneTmpHigh, xsize, xalign); + if (!xdata) + return 0; + + alloc_add(&ZoneHigh, xdata, xdata + xsize); + e820_add(xdata, size, E820_RESERVED); + return alloc_new(&ZoneHigh, size, align, fill); +} + =20 /**************************************************************** * tracked memory allocations @@ -245,6 +259,8 @@ malloc_palloc(struct zone_s *zone, u32 size, u32 align) u32 data =3D alloc_new(zone, size, align, &tempdetail.datainfo); if (!CONFIG_MALLOC_UPPERMEMORY && !data && zone =3D=3D &ZoneLow) data =3D zonelow_expand(size, align, &tempdetail.datainfo); + if (!data && zone =3D=3D &ZoneHigh) + data =3D zonehigh_expand(size, align, &tempdetail.datainfo); if (!data) return 0; =20 --=20 2.35.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org