From patchwork Thu Mar 28 22:29:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 783637 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp2960230wrt; Thu, 28 Mar 2024 15:30:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVU5eDAsdfPnqSog8Htawiy+v2ShwjoNFrpaDbafAKqG3Jw9J959pS9Hcun3+QN4e6HGcba+CIHDdk4ipCMQFh7 X-Google-Smtp-Source: AGHT+IHErnZOmtdRac6ty7Mp5HQ8Z6TZoZp8Ji0l2RGnIVai5uDNGJHUoUccfMzQQhnxe3RwSvo2 X-Received: by 2002:a5d:5091:0:b0:33e:d229:35a1 with SMTP id a17-20020a5d5091000000b0033ed22935a1mr198353wrt.65.1711665009343; Thu, 28 Mar 2024 15:30:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711665009; cv=none; d=google.com; s=arc-20160816; b=nX5bJRHnoTwxGq89FiL+C9iSHfYKUGvN9nac+iVcrJRHdxeQxngwKK0MjlE5zShGFP I4BsA9ja/tnK1QwntiUh5O3v4EsYFL6FcgF0feUBrui/+BkZGONL1nI8CUZk+QBH+ZUR kz69kiesc/H9EV+Dw2as/+siVgEDRyvE/fO+bfBjy/C6faYNju3EWmZE/8NmaYW4bNvt nTL+uygDO96iwCebuzMbFcUseR6HhBgzBRRn5HGgCDz62fmj6xqZloFMvaWMAJUrS4wy CmJ6S+slHAYCi+nAQe1uhPdmXCayZRN8vjJ/BwTVdHdsawvUd4arE9kXeVOa9JDbSQB/ JtaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pqiti0bNe3BX+VY7a+1ktOo3ZCQegloD5+euTZJ86L8=; fh=nYTXNuhqq3VUFpsvMIgRjs9qwSk8UduzQEjWa1WCPps=; b=j3BtaUTqbkISJQbZpNgQp3dOOlVnUDMotThyz+9BXzhrAlacoHb1pyQMtPyMrLZQd6 hDqLMjq9dR4nPVFTsgvDMaxOggVS5+Bj23viR9dlGPHWwseJokav7oWu6KaM/ZyMR3OF bfYhWskclAM9xRQIH/1smXIoOhvwDKexNE9yYIowS9vq2KXS4TaBNAWI4UL24Oo9uT7M ZqJs0Sja2/ae1nf7BAurIqsxcRt7Oc4j40YlCRuQPoT2v1OaB5E0Rr7CfyTzaQaoH0ge CaPNuS3YZ0Orjd1xGEm5BwvTYM/fn3dchYEPLyREOXb6i/9ujrE+5/GsTTh/8tIKhwa1 BSrg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uIkP2GIO; 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 Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id b16-20020adff250000000b00341662172cdsi1278858wrp.499.2024.03.28.15.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:30:09 -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=uIkP2GIO; 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 Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AD13F8820D; Thu, 28 Mar 2024 23:29:57 +0100 (CET) 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="uIkP2GIO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C660B87D43; Thu, 28 Mar 2024 23:29:56 +0100 (CET) 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-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) (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 5F6D78820C for ; Thu, 28 Mar 2024 23:29:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6e675181ceaso875329a34.2 for ; Thu, 28 Mar 2024 15:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711664993; x=1712269793; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pqiti0bNe3BX+VY7a+1ktOo3ZCQegloD5+euTZJ86L8=; b=uIkP2GIOtyMrMuTa21Ju8eBBvWVmMnf8FkO1t3r63tn1IJkTABiPp3f+3XZpCD73b/ YLUZbBBx0H2n4DVC64JQkGL25+njpLY5lOmK8n5PamMnifHgf5lvDy3a9yett3PD9bOI 1WlD5nTnOFM9D/0Nf9aORFc9BJVbyJSq7AhHp2fE6KPSUNr79oQgsblvQoBagbKuqG78 o524knfo3HhUFtjwUrLmdS4vIgPS4wJiW4ZFOHMlTAY9LTedr53xmVkiiC9zU3Q0vy8w +UnzQR4fk5MRcMVuqwNA8xo7zMmOMHY2mcH93G0wsoMvPzaAo/1U0Bwpy+0CzuV9AA8r wH8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711664993; x=1712269793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pqiti0bNe3BX+VY7a+1ktOo3ZCQegloD5+euTZJ86L8=; b=b/ssidGw03HY2cfw5QOtVjmBx26onou1m18yJSeW6E0RhOrneUklQq01Bf8LiVpitf Sn3hHrc/FN68IBNqoLYWt+ZQFUBFJv9dRx+YCfF/sMgOTRZVOt/iv8A2wsAGJRZoflJ7 j1LuSriybOx/4mew3sh6LNe1fh/n8rSKvJR7KN8B72jQnCC0Gw7M2b7GNqFZZlit7C0b VM7qZDN8UIvMmnOLH9qA7AuxWUBYGXImGzpwwm8fgEhz4qShKkKDMK0EvB5fLlcM/grm LvzWEqBt4/ablfDJ1nB4sq62Nnm8Yv+OSt0+0ycAWyPIT9P9MooegzZDiaHvE2IcvbB5 HR5A== X-Forwarded-Encrypted: i=1; AJvYcCUQuXJoqhRTHiKW29OfBunf1Irb0+JcAp4FoXti//t5746gAZ/xlTkTCPpF2khrN/36FKTUw/7+3jW4DTPnBDz05A4vxA== X-Gm-Message-State: AOJu0Yzhl4q60AUdAE7cOdRGgdEiIObRB7u1T6/sXK8tnMzavJ42vR4N JrIPjx7flpSKRXs8NbJhHt4jS0xfrvWIzIwHRSK16UENOX8biwa7C0kN29vwJxyEJK1Em7O7089 m X-Received: by 2002:a05:6870:51b:b0:221:91dd:6ea6 with SMTP id j27-20020a056870051b00b0022191dd6ea6mr536482oao.58.1711664993084; Thu, 28 Mar 2024 15:29:53 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id fs14-20020a056870f78e00b0022273a66aadsm610497oab.34.2024.03.28.15.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:29:52 -0700 (PDT) From: Sam Protsenko To: Tom Rini Cc: Simon Glass , Bin Meng , Heinrich Schuchardt , Johan Jonker , Joshua Watt , Steve Rae , Petr Kulhavy , Richard Retanubun , u-boot@lists.denx.de Subject: [PATCH 2/2] part: efi: Treat unused partition type GUID as a valid case Date: Thu, 28 Mar 2024 17:29:51 -0500 Message-Id: <20240328222951.11431-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328222951.11431-1-semen.protsenko@linaro.org> References: <20240328222951.11431-1-semen.protsenko@linaro.org> 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 Some platforms use the "unused" (all-zero) GUID as a partition type GUID to make some partitions hidden from the OS. For example, Samsung phones and other devices often have GPT partition tables like that, created by their "gpt_builder" tool [1]. All partitions with FILESYS=0 value (second column in [2] file) will be created in a way that: 1. Partition type GUID will be all-zero ("unused") 2. Attributes[48:49] bits will be set to 0 (whereas non-zero values mean the partition is visible to the OS: 1=raw, 2=ext4, 3=f2fs) Although it's true that Linux kernel verifies the partition type GUID to be non-zero (in block/partitions/efi.c, is_pte_valid() function), where its U-Boot counterpart code was borrowed from originally, in case of U-Boot we want to handle partitions with "unused" GUIDs the same way as any other valid partitions, to allow the user to interact with those (e.g. list partitions using "part list", be able to flash those via fastboot, etc). [1] https://gitlab.com/Linaro/96boards/e850-96/tools/gpt/ [2] https://gitlab.com/Linaro/96boards/e850-96/tools/gpt/-/blob/master/gpt_layout Fixes: 07f3d789b9be ("Add support for CONFIG_EFI_PARTITION (GUID Partition Table)") Signed-off-by: Sam Protsenko --- disk/part_efi.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 4ce9243ef25c..6b138abae0a6 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -1166,28 +1166,17 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *desc, */ static int is_pte_valid(gpt_entry * pte) { - efi_guid_t unused_guid; + /* + * NOTE: Do not check unused (zero) GUIDs here, it's considered a valid + * case in U-Boot. + */ if (!pte) { log_debug("Invalid Argument(s)\n"); return 0; } - /* Only one validation for now: - * The GUID Partition Type != Unused Entry (ALL-ZERO) - */ - memset(unused_guid.b, 0, sizeof(unused_guid.b)); - - if (memcmp(pte->partition_type_guid.b, unused_guid.b, - sizeof(unused_guid.b)) == 0) { - - log_debug("Found an unused PTE GUID at 0x%08X\n", - (unsigned int)(uintptr_t)pte); - - return 0; - } else { - return 1; - } + return 1; } /*