From nobody Mon Jan 10 12:28:01 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 45D331941DE1; Mon, 10 Jan 2022 12:28:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JXY4x6z5sz4dyB; Mon, 10 Jan 2022 12:28:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CE9F9251B3; Mon, 10 Jan 2022 12:28:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20ACS1Tv006603; Mon, 10 Jan 2022 12:28:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20ACS1xc006602; Mon, 10 Jan 2022 12:28:01 GMT (envelope-from git) Date: Mon, 10 Jan 2022 12:28:01 GMT Message-Id: <202201101228.20ACS1xc006602@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: 835f59f32444 - stable/13 - loader.efi: to preserve heap space, use AllocatePages() for shadow_fb List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 835f59f3244418fbfb8ecc32c243732935db4783 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641817682; 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; bh=Zf4LZS5yYq1sg3YMRsM0BXk3T2+MAOnZlne38vhCk5w=; b=JKilsMjH/tlbYX6OUnKl1gAVBuJbRw1IqsidKGQJF4JlTRBS/6wDUlpMmT5XtOSadnp7S/ J3k6s1LhoXMsPkF/6rmiRGZ5HPwTNWFvZPtes7Okg9VNeVx5jCyb31Db+03prE0P9iCYHm JjuYt8nhBvD88m0+/F3Q6RsWwqulXGihysv1aquqM5JL7fbErRU1S9cfrnzgeLFqYvNrLx dFOlGELzMWlmKtf+bQbCTTGXoz9W1gIaN8U8VvnsWKPBgNqOCrtFlU9wnYPIIGIlh3lI6L XiyMUt6ujS8aIoazmyHEJbYYwLLL4nRDDoFxXnANn7vaHIBSJaD1VA6ojd2dmg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641817682; a=rsa-sha256; cv=none; b=ytDmBjUdXFUzUk29BIQtnUI8ZTVkRS1aHV5YLEJkHT4HqlE1OemFUIf9qWajQ/823CZQ3F mj5zetAFmLlrSZFLwfUMLKmCp03GGShJpqsFJ7fHzJ7hjQT15iKFuS6n+5l9pOtqHr6eLG bL8FJf9eHRIzEm4eiXyvG2uxTsYv+ZuH4qRg3ffiNmgEV7eXe+sCwloqt7Czd84fyuWKMK VICLrl3WzcByBUxKjk5zUz2sQNYABi1S7uGR+FwWcncqZddrg0pwOjejYdcROcvox18yIi GVFWj8bbdWUVvLhSyzI2bYUl21XsylCfmEObiFQiBX050ohx0141tVAHihIE9A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=835f59f3244418fbfb8ecc32c243732935db4783 commit 835f59f3244418fbfb8ecc32c243732935db4783 Author: Toomas Soome AuthorDate: 2021-12-17 13:10:05 +0000 Commit: Toomas Soome CommitDate: 2022-01-10 10:28:30 +0000 loader.efi: to preserve heap space, use AllocatePages() for shadow_fb shadow FB size could be rather large and depends on resolution, instead of using heap, allocate dedicated space outside of heap. Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D33600 (cherry-picked from 221376db0cb77035e325baf8b54d6224925b41f8) --- stand/common/gfx_fb.h | 1 + stand/efi/loader/framebuffer.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/stand/common/gfx_fb.h b/stand/common/gfx_fb.h index 0a2bc966d445..5599ce7b3ae0 100644 --- a/stand/common/gfx_fb.h +++ b/stand/common/gfx_fb.h @@ -217,6 +217,7 @@ typedef struct teken_gfx { struct vt_font tg_font; struct gen_fb tg_fb; uint32_t *tg_shadow_fb; /* units of 4 bytes */ + size_t tg_shadow_sz; /* units of pages */ teken_funcs_t *tg_functions; void *tg_private; bool tg_kernel_supported; /* Loaded kernel is supported */ diff --git a/stand/efi/loader/framebuffer.c b/stand/efi/loader/framebuffer.c index 0a00b3645b36..d5504c9cff35 100644 --- a/stand/efi/loader/framebuffer.c +++ b/stand/efi/loader/framebuffer.c @@ -634,9 +634,18 @@ efi_find_framebuffer(teken_gfx_t *gfx_state) gfx_state->tg_fb.fb_bpp = fls(efifb.fb_mask_red | efifb.fb_mask_green | efifb.fb_mask_blue | efifb.fb_mask_reserved); - free(gfx_state->tg_shadow_fb); - gfx_state->tg_shadow_fb = malloc(efifb.fb_height * efifb.fb_width * + if (gfx_state->tg_shadow_fb != NULL) + BS->FreePages((EFI_PHYSICAL_ADDRESS)gfx_state->tg_shadow_fb, + gfx_state->tg_shadow_sz); + gfx_state->tg_shadow_sz = + EFI_SIZE_TO_PAGES(efifb.fb_height * efifb.fb_width * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); + status = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, + gfx_state->tg_shadow_sz, + (EFI_PHYSICAL_ADDRESS *)&gfx_state->tg_shadow_fb); + if (status != EFI_SUCCESS) + gfx_state->tg_shadow_fb = NULL; + return (0); }