From patchwork Thu Oct 24 11:01:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 838114 Delivered-To: patch@linaro.org Received: by 2002:adf:a399:0:b0:37d:45d0:187 with SMTP id l25csp295994wrb; Thu, 24 Oct 2024 04:02:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU4fTBHGXDQb+DUJS66eDN+PdyiIHgj/CxR9fVRTKJmrEDWtAeNT/wv3TAGVgxUdFx2ZG/JWg==@linaro.org X-Google-Smtp-Source: AGHT+IFYZt1CWkUIaJp9NGSnFzYZ6rJC27NJ6jl/xpQckJbl+amPgyOAxulMRhs4QXSjx/DVhRfI X-Received: by 2002:a05:651c:19a3:b0:2fb:7e65:cb27 with SMTP id 38308e7fff4ca-2fca81c2159mr10084541fa.6.1729767743056; Thu, 24 Oct 2024 04:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729767743; cv=none; d=google.com; s=arc-20240605; b=jh3qde+65F+XB+0OmPTRkv5v66MWHaGaLvDnQqLPhWuIsIKt+7vcqiKxfkTkHhDkCp h5DljWWF2DuXL4JGGqID7u8ehwul4RG3T47NUVuqgRK8XqcpLKxKWhH7vopM0cwdIVml YvBHo5pNRTETF+xnB4ssvS15IWtDHKFossbbvHAkxnprxH93Z/yeJWUnBGsoUyWWwUO5 XpjDF8go/zoHHU+7zdLgm4pUJ5W7y8B9GffC6C71YWzSRu97a/Z0nQLFoqSQomwFSmrM GjQOaHhjE+jZSBqfqv/kDviYvrjMn+2CIToRJg2ZHvUFK5zMYxJ5VpCBa8saVPvJarbK fJ1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=sNzap3v6utQCWiqRgZAXhaFtMkAn8PTb1BCz0semqcU=; fh=68bV36Lo1In1m/q2wQ+RXJo+B/ZBE6nf/aNydznqd8M=; b=URgK9YQLNJQgvA81fEy14Ig8bS4kSmwcaEYUlgSapQ8AusyiG6TxHgIcG7iF6IqwGj /nHcAuzW7i7h3cLN3Yaof+9rcwnXqrwa6o5/EbgBl2zRRV2+Tv525Ma6QrTNxOveTh9V RQU+Sww29BoWuK4LScChgKmvU7j6Sp/tRa3xF2kWx5o9kyZSGITUut/FQRwewIZmmdMg j4CBFbM0jVrM4mvZyTBn0ZGGBo1MdkEl30iRE7AmajteK3+VsPycwQf3XRCwn7+nOmN1 yJcIzDvbLuWwLGcKh/AMIk45IVYL23sDcXL1FVEE/ABanFayJ5oSrgFn1tEQ2PqGr7MK F2rw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sDf0BeEz; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 38308e7fff4ca-2fb9aecab20si29795561fa.623.2024.10.24.04.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 04:02:23 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sDf0BeEz; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B198A88D29; Thu, 24 Oct 2024 13:02:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="sDf0BeEz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C3C8888DDD; Thu, 24 Oct 2024 13:02:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AE6F188C7B for ; Thu, 24 Oct 2024 13:02:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a9a4031f69fso103132466b.0 for ; Thu, 24 Oct 2024 04:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729767723; x=1730372523; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=sNzap3v6utQCWiqRgZAXhaFtMkAn8PTb1BCz0semqcU=; b=sDf0BeEzSfBk+UJaR0J8ULoaVYbxUDQ7Rz8Os02dzU9VJWnXYkUOunIPm3ndf/q2cZ Pj+WOmzjcXnvAD2fPl2mWBBW+0/EEASGxPVFKtlitqW11plFZVbs/VZHe3h7RexGPVgW WDUcVesrP11uUMmL+EzYBUWfZpJ9sTSkwZDXvmJImDMoSMDHie0irxi2YzfZeEJO1bKe vyqNrp2F+GjwD8V83Tm5xUZ2kc3qVZWRQLhtpRlFtWrnl6X6Muva7xSaOSIyhE+484Sa Q5U8Y3A825dY5cPVKOs7ViDOB4p46lLJHzTDvrvDH3/U16Ks582LmIOXjVGxLZ1yU6mk qrtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729767723; x=1730372523; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sNzap3v6utQCWiqRgZAXhaFtMkAn8PTb1BCz0semqcU=; b=v6pT8GoueupeQ0cfrks6l+Y/Cwv7gdJ3UxuucgZ07z70SpYI3pQPvXWq8Q7xIzJeRg CJe4FP1GlHEqoUvftOKZ/b/IjWxOpJSN0cjE7Hk7uxm5lV5xpnsgmXYhtr/V338jcNqV sSN23fDUhlPGxurUUEEkqlJQLx2U25Lmi23KKYl5m+UKOBgCtWo9T63fqRM0KUVHAFQS 0mMGHIDUcFQWb+HbjpgSNthTYe4Bjo4mn4SRsn80Utk6qsg3+wZyWsLfNC0FDabvKT5p gDEe402XA/x13UK1UKzCfaSEv4njcVlIfBQLaa22mwqYifCy1ByHwYRtfSLJuuxMEsBA gzSA== X-Forwarded-Encrypted: i=1; AJvYcCUnwJQxpgbeZZuvjIGoW4kli5wOcYU6t21Wr1pRgAOHqAsuuv1TQL5HTuwWFZFvSKRhjFU3Rqo=@lists.denx.de X-Gm-Message-State: AOJu0YxlizVc0eI00oCWZVFdUF/utdWvCRkQL7oBbL9mL4f8A3M2R7pY ZUdjcJngzbFntj+gXwAVYC0AGg2HJDOQq6DKqCgHPCi/B9cD16W/PuAXpbfET9obUX03/GvBTDn 8 X-Received: by 2002:a17:907:2d94:b0:a9a:26dd:16bc with SMTP id a640c23a62f3a-a9ad2710a2dmr160559266b.5.1729767722857; Thu, 24 Oct 2024 04:02:02 -0700 (PDT) Received: from localhost.localdomain (ppp176092143132.access.hol.gr. [176.92.143.132]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a91572c37sm610495866b.172.2024.10.24.04.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 04:02:00 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: Ilias Apalodimas , Tom Rini , Sughosh Ganu , Simon Glass , u-boot@lists.denx.de Subject: [PATCH] efi_loader: Simplify efi_free_pages() Date: Thu, 24 Oct 2024 14:01:55 +0300 Message-ID: <20241024110156.1353756-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean We currently call efi_free_pages() with a notify flag and explicitly update the efi memory map. That's not needed as lmb_free_flags() will do that for us if the LMB_NONOTIFY flag is removed Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_memory.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 84be5532a655..e493934c7131 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -524,7 +524,6 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages) { u64 len; - uint flags; long status; efi_status_t ret; @@ -539,18 +538,17 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages) return EFI_INVALID_PARAMETER; } - flags = LMB_NOOVERWRITE | LMB_NONOTIFY; len = (u64)pages << EFI_PAGE_SHIFT; + /* + * The 'memory' variable for sandbox holds a pointer which has already + * been mapped with map_sysmem() from efi_allocate_pages(). Convert + * it back to an address LMB understands + */ status = lmb_free_flags(map_to_sysmem((void *)(uintptr_t)memory), len, - flags); + LMB_NOOVERWRITE); if (status) return EFI_NOT_FOUND; - ret = efi_add_memory_map_pg(memory, pages, EFI_CONVENTIONAL_MEMORY, - false); - if (ret != EFI_SUCCESS) - return EFI_NOT_FOUND; - unmap_sysmem((void *)(uintptr_t)memory); return ret;