From patchwork Tue Sep 17 09:02:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 829231 Delivered-To: patch@linaro.org Received: by 2002:a5d:44c6:0:b0:367:895a:4699 with SMTP id z6csp185882wrr; Tue, 17 Sep 2024 02:02:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWDMDmqFjNCMuo3qxvEOp+8aq9GclKosPbgrqSEbHNNzh5Q698crSP2ZwgZipk6X/S12SmR1Q==@linaro.org X-Google-Smtp-Source: AGHT+IEdhLhtNjPpgmAPYZ7P7Iw6sclzGdvcM42z7Siz7wqNsd5R9DH9zIVgPRHftBoz4gPeMl0R X-Received: by 2002:a05:6402:234b:b0:5c4:2eee:41e5 with SMTP id 4fb4d7f45d1cf-5c42eee43e5mr7965533a12.25.1726563752199; Tue, 17 Sep 2024 02:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726563752; cv=none; d=google.com; s=arc-20240605; b=geUYO2Z8BA/Bfz0rQkbZ31aBkEajnyaChdEIlZv/DXaYrDZtgUgh8EC9wiA0iAlHjL z3wYBnm1c8aywpIP+cKmrs+xgL/FK5/vQknvsAizdtxTvzLqksMoBAIXGvjsseJtmXTZ zMBJSONLEhuJoiif4mrq1X25UaR8XcT9GvXyO2Z1n8CYuNBeJnx1AMZA9qOfwZC8geRH QFiku0NSnX6LVi2E7UbIDqGNDzZ6I+rGFUv2c5/cQDrW0io1PnZlZ594alkOZW8bwQAm yRr291oCVOCL33MwLmfqj7Et+jyMyzmutiQ6FuhBXIrla1u19AGcjFYPK0RqsKFYpvoY fgRg== 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=1l1VSnhkTHTx6roKF5FnJSflHZFYfWheMEVUrJVeX30=; fh=tcpVjOOx45F17cvq1Abs21Kyxgy4HFktjXbttGe4UTY=; b=OED/2dmf9NFOHGFP3lVsQ+4251/OGSzdrU3HZQet/pHe/wJDNVSecXPaXnvsTIUFVF xmDlzEMYL6m+IljjvWp9At35hGwQzcsvzwtr1Bdc44tC+8nA1+hzE8bhV5WmleuJMLyc lZ5Y8n/Ql0tibYBNXo0LZu6Vs60oJuY1/pbWN1ZX+Atk1iFdy15uyHE+OkB3pqxCXJrh SKKE2grGZsV8oqD5iS2mF2WIX8Dw/oHUVRvGsvQJHHZFQot87IDGKZabUGiD4WHj/fr2 4YTsvEYqTQxLtik0HmJUJxPMwuik9JtbNgxOH2NkXlM0db97rjuGiyd5zypz8qPRxFHE CVPg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m9VaJMEX; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5c42bb5ad8bsi4807772a12.142.2024.09.17.02.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2024 02:02:32 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m9VaJMEX; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 1E38088D54; Tue, 17 Sep 2024 11:02:30 +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="m9VaJMEX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F03CB88AAC; Tue, 17 Sep 2024 11:02:28 +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,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (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 C8ADB88875 for ; Tue, 17 Sep 2024 11:02:23 +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-x636.google.com with SMTP id a640c23a62f3a-a7a843bef98so550929266b.2 for ; Tue, 17 Sep 2024 02:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726563743; x=1727168543; 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=1l1VSnhkTHTx6roKF5FnJSflHZFYfWheMEVUrJVeX30=; b=m9VaJMEXiDIVo9cg7ODyEXhllAeQgaQ0tOaAh7tEew6q7J7Yu6rfCy48jLfMJYGQWH Xsq35fhJgteGuKD/cMhpOM5Kdwc88h8GO+xpQKPan3/B4ZRbWtnlxwGL5xRpBYbDhPwy 6qkghlHQUOzes/ZBN1eEtqFpLPAK5Y69RwNkUewj/LREGnn6v43EuM8ApjAnQXF1Mw0c grN/BhRrqMhJBuK/nBEpPcZkD+mGE7AqfFie5fGHFKlaJkGAybaYn/UcR3r9oGVQRuk6 aqjtTLmgnXo8/JZQc09I78x1mra5p9vHmY+bmoQ9+2FWsU3DzSwVQuFSEKoQgqwcK0SI CdMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726563743; x=1727168543; 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=1l1VSnhkTHTx6roKF5FnJSflHZFYfWheMEVUrJVeX30=; b=NsaB31AE3Obko1bZ3tVFbjI0cP2MFYOOziF6CVV0P3JNm9HVvflIXtNkX9xhWDxiaC IsdE0y2bOVTB7sA2kFCmqgjgTyzcdpgJpXLyuxKA6Q3lCRBmhL7dv/Z/H+mc7tbVscYA ZVg1vlSgk+rH2Oe8GP2ytaRPD+fq7OueosVRvwzzLiY1P44INZgs4XP1ol43J6EUNDLa xIWniDqzympXJmUaPcYG5sX10OJr/tUOw/IkcoR/JkOtW9RCu2y7//Z81z6i+xjR672+ 3mqQcN+Xyc8O4kDAkhRixymC5p7fSXb0Vfb3RSmeoZ2g+PRmU9ZUUhoXiV7wxJfdDE3v j/AQ== X-Forwarded-Encrypted: i=1; AJvYcCXjT60h2UnJmHiJas3SUhgkQvkA41XSBbeDvBc+bn6eDpeAg5M2DjyymU14JwKgt+ZrdGosiBg=@lists.denx.de X-Gm-Message-State: AOJu0YyTabwAfiZz2fJ+85Ue5EFDYfqYj3TYE89k4LghpkjrwicUh5NW 1oeuMkQWuaidIxWr8fQSAeNkqwcMt4DcSB0zg/bN/0t5RNndDbvr1bcG9LeBpGA= X-Received: by 2002:a17:907:7ba2:b0:a8d:e49:c505 with SMTP id a640c23a62f3a-a9048108047mr1295232166b.45.1726563742664; Tue, 17 Sep 2024 02:02:22 -0700 (PDT) Received: from localhost.localdomain (ppp176092143132.access.hol.gr. [176.92.143.132]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90610966aasm419239566b.26.2024.09.17.02.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2024 02:02:22 -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: Don't allocate from Special purpose memory Date: Tue, 17 Sep 2024 12:02:18 +0300 Message-ID: <20240917090218.77246-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 The EFI spec defines special-purpose memory in ยง7.2. That memory serves as a hint to the OS to avoid allocating this memory for core OS data or code that can not be relocated. So let's ignore it when allocating from conventional memory. Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_memory.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index c6f1dd09456e..74732e37f8aa 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -422,7 +422,8 @@ static efi_status_t efi_check_allocated(u64 addr, bool must_be_allocated) if (addr >= start && addr < end) { if (must_be_allocated ^ - (item->desc.type == EFI_CONVENTIONAL_MEMORY)) + (item->desc.type == EFI_CONVENTIONAL_MEMORY) && + !(item->desc.attribute & EFI_MEMORY_SP)) return EFI_SUCCESS; else return EFI_NOT_FOUND; @@ -460,6 +461,9 @@ static uint64_t efi_find_free_memory(uint64_t len, uint64_t max_addr) if (desc->type != EFI_CONVENTIONAL_MEMORY) continue; + if (desc->attribute & EFI_MEMORY_SP) + continue; + /* Out of bounds for max_addr */ if ((ret + len) > max_addr) continue;