From patchwork Wed Feb 26 04:54:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1244661 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=dLEOXeoS; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 48S3RF330Jz9sPR for ; Wed, 26 Feb 2020 15:56:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3A9088101A; Wed, 26 Feb 2020 05:55:45 +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="dLEOXeoS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C694C8101B; Wed, 26 Feb 2020 05:55:16 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (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 BC8538079C for ; Wed, 26 Feb 2020 05:55:11 +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-pl1-x644.google.com with SMTP id y1so780648plp.7 for ; Tue, 25 Feb 2020 20:55:11 -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=dLEOXeoSBRm3O9B1JO2zfPPrwcKs2B8VWfppuVKjeqhxTXrI9BaH2QidJ3Vg95RLS+ cISPpkRwsKxPZEvC5DNQklkeZ2NTICb84lCXJ99rCm3IPAnQuaRZifwAMF5CuSqvH+JH LD/4ntXfg/FwFAcp5JqEz4QjkFvRHpUZ2kH2Bc47GpuqABHKgCaTHfdWHoIGQrCytMa2 i66N3zZQVxVhHO8BhGr21g1njzHtSefCRQsh79zMUlsIUMfFdXNbmGyYe5STeH41oWro BLElZh0P+f6S9qXnWSbXWEweWlIMdbzcr6v4G+MTyTy60tvT7zczuf8gLiI41zwfpcbo QcaA== 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=RbKHofqlITHhiHsYaNAeKN/TF2Ge8cxAhP6/DW1MQzlmfQm3Fx9I/4aaqYvo+0uTMJ dmH3PgAdr/rmYTogyUEPvajN7Ns9kpvczXT0h+YnqpM50mZehzB7MBpUHo29nz3pmw8N AcWNyKnL70IqkNiyhvAFlcP8I5V+05Fei/kunkpPLX0eBt+tNIsuymsVNzwiNfT2LKsL O7DB2nosKCCE6zokZMptVUr/wkkvoRx45Pny3YRVcZGYxrLECfqKvfvK33a9FW+fiYS2 46QOMo9SP9qBDQCuFIIcEtawbGgIycWLQ/5TUYlnSnhOcYbmaOTfEXyjrMCa1B2FCumq oksw== X-Gm-Message-State: APjAAAV3anF1L8ovL1KqD/wZLM53fJ2EeRZ92QkrRvJ97yinat2boLww FymYGYLWTokvN0wH1Ki/olphqQ== X-Google-Smtp-Source: APXvYqwFF5U7JC60tuOnwAGGumBaoq1V+zksSLHly+48KzffPlVOkPRsrUymzCUwkvTQ+Frqx5lovg== X-Received: by 2002:a17:90a:bf0c:: with SMTP id c12mr2842750pjs.112.1582692910226; Tue, 25 Feb 2020 20:55:10 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id z30sm812285pff.131.2020.02.25.20.55.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Feb 2020 20:55:09 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, trini@konsulko.com Cc: sjg@chromium.org, ilias.apalodimas@linaro.org, mail@patrick-wildt.de, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v6 08/16] efi_loader: set up secure boot Date: Wed, 26 Feb 2020 13:54:40 +0900 Message-Id: <20200226045448.2453-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200226045448.2453-1-takahiro.akashi@linaro.org> References: <20200226045448.2453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 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)