From patchwork Wed Dec 18 00:45:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1211842 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="iMJcFE+8"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47cxBn3MK4z9sRl for ; Wed, 18 Dec 2019 11:45:53 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 538AB816B4; Wed, 18 Dec 2019 01:44:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (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=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="iMJcFE+8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C5D7D8169C; Wed, 18 Dec 2019 01:44:31 +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=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (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 1115E81675 for ; Wed, 18 Dec 2019 01:44:28 +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=takahiro.akashi@linaro.org Received: by mail-pj1-x1043.google.com with SMTP id s94so536563pjc.1 for ; Tue, 17 Dec 2019 16:44:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TEAEDj9erVipp4yLLE2gQ4KtxKQihSj29/GQcgpNpqU=; b=iMJcFE+8OClA88B823GY8Dh7msXOktGlK92COGqgX/JN2kCM+CN4KMopivob9xwytS k+qeFpJvyN5Ex5J4ELKXctaZM2tx9dFVwYj6vOTqExe9RxDNde0GLHR0F/HdZUfB9HBe BdZXP5DM5twjX18SNFufF7qTPxaIdN6vgK14NYq0nnjf5MIe8xwkFLaNuBz+hLkuyvmz 1KHY98k6aoHb6cK9ATPkoFQfXOEKzCXQf2R9IYXrnbHL/DzbkbxomFPDcymRSw7F8SMn ucEP2Fo9Mlexx7voe5OXMJCf+a4dMCQh+RqvT/lly/sikezpCYbOrccj+ALOzmjWrp0U 8C4w== 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=TEAEDj9erVipp4yLLE2gQ4KtxKQihSj29/GQcgpNpqU=; b=D0ZGs6AsQTE5FLB4KvIXRF4yNCycSFQmXF9o1f1NyV1GeV6r36Zx30JEotUcxgVP76 b4Xd6b1PP5QVunGJa+kOaU8WATQ+BsjLCKQ5sLBQ0lcTipWcCzoIfmpHqannP0qddTor q81OXDIPGbWw4W5mq4rYJNJB3BI2s70FQSV6obkJ72PojjzApQTs28Z72VIUlRBg8vXl xuDTcT+TaPSgNBoB0Yh7MKbpFaqe4ami0So01DS7zy28theQfMiv0UuG6srjRcDarVoN MGq2ehTpIq2tzYLe1iUHaevsfviXT1ydD0SXJvtGMbMh87K3UUvu7ztd4PjfOMn1T8Hl W7qg== X-Gm-Message-State: APjAAAVO0ZADCYL2VLdYSdCqR0/IoIDQ9gZ/townsUUEr204IctDJz1v 0YzsD3kpvTIvKhXWUc/3dhC9dg== X-Google-Smtp-Source: APXvYqxEydMM2UJ6s/NDuaHqP1sfb/MlPE2RxuVQ7eqW+Z28AbbFKv9wIAWdBy40SK9e8aeHZMJjqg== X-Received: by 2002:a17:90a:e98a:: with SMTP id v10mr153618pjy.67.1576629866660; Tue, 17 Dec 2019 16:44:26 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id q8sm185269pgg.92.2019.12.17.16.44.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 16:44:26 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, trini@konsulko.com Subject: [PATCH v4 09/16] efi_loader: set up secure boot Date: Wed, 18 Dec 2019 09:45:05 +0900 Message-Id: <20191218004512.24939-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191218004512.24939-1-takahiro.akashi@linaro.org> References: <20191218004512.24939-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de, mail@patrick-wildt.de Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean The following variable is exported as UEFI specification defines: SignatureSupport: array of GUIDs representing the type of signatures supported by the platform firmware Signed-off-by: AKASHI Takahiro --- lib/efi_loader/efi_setup.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index de7b616c6daa..50cef1b4dfde 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -82,6 +82,39 @@ out: return ret; } +#ifdef CONFIG_EFI_SECURE_BOOT +/** + * efi_init_secure_boot - initialize secure boot state + * + * Return: EFI_SUCCESS on success, status code (negative) on error + */ +static efi_status_t efi_init_secure_boot(void) +{ + efi_guid_t signature_types[] = { + EFI_CERT_SHA256_GUID, + EFI_CERT_X509_GUID, + }; + efi_status_t ret; + + /* TODO: read-only */ + ret = EFI_CALL(efi_set_variable(L"SignatureSupport", + &efi_global_variable_guid, + EFI_VARIABLE_BOOTSERVICE_ACCESS + | EFI_VARIABLE_RUNTIME_ACCESS, + sizeof(signature_types), + &signature_types)); + if (ret != EFI_SUCCESS) + printf("EFI: cannot initialize SignatureSupport variable\n"); + + return ret; +} +#else +static efi_status_t efi_init_secure_boot(void) +{ + return EFI_SUCCESS; +} +#endif /* CONFIG_EFI_SECURE_BOOT */ + /** * efi_init_obj_list() - Initialize and populate EFI object list * @@ -122,6 +155,11 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; + /* Secure boot */ + ret = efi_init_secure_boot(); + if (ret != EFI_SUCCESS) + goto out; + /* Indicate supported runtime services */ ret = efi_init_runtime_supported(); if (ret != EFI_SUCCESS)