From patchwork Wed Apr 3 12:25:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Urja Rannikko X-Patchwork-Id: 1075876 X-Patchwork-Delegate: philipp.tomsich@theobroma-systems.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EhIf/HQR"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44Z50B2Zffz9sSQ for ; Wed, 3 Apr 2019 23:26:02 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D7BE7C21F19; Wed, 3 Apr 2019 12:25:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 71D20C21EC3; Wed, 3 Apr 2019 12:25:52 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 917BDC21F20; Wed, 3 Apr 2019 12:25:38 +0000 (UTC) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by lists.denx.de (Postfix) with ESMTPS id B36DAC21F32 for ; Wed, 3 Apr 2019 12:25:34 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id c1so7164973wml.4 for ; Wed, 03 Apr 2019 05:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZudtQ9HZBUJQnkeMmtrc4pax0aAy/Bh2ubeMCetiMfo=; b=EhIf/HQRGEYG24FTKZl5m8oILmfHN+hbIgf6NFmKmm/YX/S020L91GhkuN58GIhHdH A5SNlC2bUCDQ75n2tUT3JVr7T0FfqMVmSJexkg9cWukbvZ9pnJcKkFBGJvZ2p5ZFmkcu rhCmDxhw7TnSbxo6Mq8UVgV7lxWaijAVg9Uxu9LrNP8e+s8k4MNoDwDLCJtd1p/D6bxN d7YEnu5Jwyi9tsXTkJWt4Fp2m1BTqy/YomiOHOX3QE99zEvVDjRfJ/7IaWFGSi7UWR6H CVSslDFjKrKmE+Yhfd/irYoxEY9Ql2rEDmSWINBX66zD5NPYssT6zdCskNUXUpDqs+mK cc2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZudtQ9HZBUJQnkeMmtrc4pax0aAy/Bh2ubeMCetiMfo=; b=WhDFBH3860uQCwSPGfa9+5YrY7hLXSFefzkAzybdJ620rAN4NGLov/PqDoeiY7D3vj 5F3aMu7KWwRbFc4pyCsgCyr2TPf8C4AiQWxJIVYziwbwqjRMB9ikGqnio5WlzP21J8Cf 6XSlXarAY2cWPZhKy+QQDMV+oHXQ2KuEudM2lP1TWRZgGMC34MD4EVRvcrMIVXxr6AuZ i4b5pBJQgjKHhEuhX6trVH6QZNav60mbeIHJ/gWa5OJGnG3rghk6lWu8AdQPI0B9WPmm nn4NHksnGd3aYrABDSxIeMRzeWZ3vUS2RMlup9MAgFXdGErRCsMOOELdts9adS+pKrLJ K/eQ== X-Gm-Message-State: APjAAAWCbax6ozsBf/HxTTp+XVaSEiib5pjpzPrF0q1XGSwbjjdVqJqZ 1mtBLcZl2Vlt9fyndmkdTcvYX0d+4w== X-Google-Smtp-Source: APXvYqzrhoHDVgHLw6JRmWNaIZDNfI0p5xLINB0FTYovO9vHvk0gsyYT3xLlBJcs6Ypp88HI0gazDg== X-Received: by 2002:a1c:1d4:: with SMTP id 203mr1999018wmb.101.1554294334211; Wed, 03 Apr 2019 05:25:34 -0700 (PDT) Received: from localhost.localdomain (esm-84-240-79-214.netplaza.fi. [84.240.79.214]) by smtp.gmail.com with ESMTPSA id u189sm9146673wme.25.2019.04.03.05.25.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 05:25:33 -0700 (PDT) From: Urja Rannikko To: u-boot@lists.denx.de Date: Wed, 3 Apr 2019 12:25:22 +0000 Message-Id: <20190403122522.1307-2-urjaman@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190403122522.1307-1-urjaman@gmail.com> References: <20190403122522.1307-1-urjaman@gmail.com> MIME-Version: 1.0 Cc: xypron.glpk@gmx.de Subject: [U-Boot] [PATCH 2/2] disk: efi: ignore 'IGNOREME' GPT header found on cros eMMCs X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Some ChromeOS devices (atleast veyron speedy) have the first 8MiB of the eMMC write protected and equipped with a dummy 'IGNOREME' GPT header - instead of spewing error messages about it, just silently try the backup GPT. Note: this does not touch the gpt cmd writing/verifying functions, those will still complain. Signed-off-by: Urja Rannikko --- disk/part_efi.c | 28 +++++++++++++++++++++------- include/part_efi.h | 2 ++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 5f935da4c2..83ba7db665 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -893,7 +893,7 @@ static int is_pmbr_valid(legacy_mbr * mbr) * gpt is a GPT header ptr, filled on return. * ptes is a PTEs ptr, filled on return. * - * Description: returns 1 if valid, 0 on error. + * Description: returns 1 if valid, 0 on error, 2 if ignored header * If valid, returns pointers to PTEs. */ static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba, @@ -919,6 +919,12 @@ static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba, return 0; } + /* Invalid but nothing to yell about. */ + if (le64_to_cpu(pgpt_head->signature) == GPT_HEADER_CHROMEOS_IGNORE) { + debug("ChromeOS 'IGNOREME' GPT header found and ignored\n"); + return 2; + } + if (validate_gpt_header(pgpt_head, (lbaint_t)lba, dev_desc->lba)) return 0; @@ -962,16 +968,24 @@ static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba, static int find_valid_gpt(struct blk_desc *dev_desc, gpt_header *gpt_head, gpt_entry **pgpt_pte) { - if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, - gpt_head, pgpt_pte) != 1) { - printf("%s: *** ERROR: Invalid GPT ***\n", __func__); - if (is_gpt_valid(dev_desc, (dev_desc->lba - 1), - gpt_head, pgpt_pte) != 1) { + int r; + + r = is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head, + pgpt_pte); + + if (r != 1) { + if (r != 2) + printf("%s: *** ERROR: Invalid GPT ***\n", __func__); + + if (is_gpt_valid(dev_desc, (dev_desc->lba - 1), gpt_head, + pgpt_pte) != 1) { printf("%s: *** ERROR: Invalid Backup GPT ***\n", __func__); return 0; } - printf("%s: *** Using Backup GPT ***\n", __func__); + if (r != 2) + printf("%s: *** Using Backup GPT ***\n", + __func__); } return 1; } diff --git a/include/part_efi.h b/include/part_efi.h index 7170b61c95..eb5797af74 100644 --- a/include/part_efi.h +++ b/include/part_efi.h @@ -25,6 +25,8 @@ #define EFI_PMBR_OSTYPE_EFI_GPT 0xEE #define GPT_HEADER_SIGNATURE_UBOOT 0x5452415020494645ULL +#define GPT_HEADER_CHROMEOS_IGNORE 0x454d45524f4e4749ULL // 'IGNOREME' + #define GPT_HEADER_REVISION_V1 0x00010000 #define GPT_PRIMARY_PARTITION_TABLE_LBA 1ULL #define GPT_ENTRY_NUMBERS CONFIG_EFI_PARTITION_ENTRIES_NUMBERS