From nobody Wed Dec 22 11:56:10 2021 X-Original-To: dev-commits-src-main@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 C50B11900267; Wed, 22 Dec 2021 11:56:10 +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 4JJsGy3sXqz3mBt; Wed, 22 Dec 2021 11:56:10 +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 627581C7D1; Wed, 22 Dec 2021 11:56:10 +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 1BMBuAlR041168; Wed, 22 Dec 2021 11:56:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BMBuAKg041167; Wed, 22 Dec 2021 11:56:10 GMT (envelope-from git) Date: Wed, 22 Dec 2021 11:56:10 GMT Message-Id: <202112221156.1BMBuAKg041167@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Toomas Soome Subject: git: 221376db0cb7 - main - loader.efi: to preserve heap space, use AllocatePages() for shadow_fb List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 221376db0cb77035e325baf8b54d6224925b41f8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640174170; 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=WTxCa/j2YBr0Xut8X72pOeonZapvRS1KxPGIsfGMtuc=; b=REDn2V/TnXk4HQwQye0DxsE9Z0pCPcGryimn+b4y53L+3MFzK3jIABU7zRxYob/bhTaQUe vFiUY27ufPGRV+OzWeqZ7ZaEHTQ9TPxQwxzwpAB/XT8K0slCI85nSTEXDYOGVp8FlSIDCn rBKdyqyf4IDzaEbD2/L0lwyFQeNoiKlni5yaaTNKXeJ7k7PIwzWVqgUXgvKn+WbRIocYhr VXN9fVXu0wsQZwA+1KeS97WDi6wmB4xrW6ttpnbVrmDiDfC06QE1i0X5z6VAZZbrg/8fzu pFgqufIaas1sYSyrk1GcVssvAIvmGXwWLq+EglvzTRRBC87EOU8Nyv6QujUWuQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640174170; a=rsa-sha256; cv=none; b=P+NzTWK0idmvnBRuyseg4r/qtQ9DBdLIbeZ7ISp8y0CP1fxUDaVBRDFzji6PCVnXITRyuT aI2D37mo5bCePovn1jhGk3Pn7NATTVhI5hBLZ8c1n7xAtr13G7VMVA8/4kkioeEZMF3xNW ZmSemrGnLnQGPGUp0WvRYH3i0DoZaFc/Vf2jYDq+7M3wJxRU1YydbwJPmxt/AMSk2XGh5f 8dK9VPlywr8mQwExFGTRh3GR60xDO6wkrxIVoJO3Z3vL6SY2S33i5QI+xHzCdeNJmVSW/u SRm8/S2/vPuU5p/PhcAxFYuOsMMSQkjSCLSSp2gCtRN8y5bbd81CLdRnV+gfNQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=221376db0cb77035e325baf8b54d6224925b41f8 commit 221376db0cb77035e325baf8b54d6224925b41f8 Author: Toomas Soome AuthorDate: 2021-12-17 13:10:05 +0000 Commit: Toomas Soome CommitDate: 2021-12-22 09:39:28 +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 MFC after: 2 weeks --- 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 e55f6fc13fe5..f5747e065daf 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; } teken_gfx_t; 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); }