From patchwork Wed Sep 15 05:15:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 512184 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2207868jao; Tue, 14 Sep 2021 22:13:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5XiR2V3nZ7exFJz/3OPnAqguRcmKwPwhSYSCnty3dnVlXJkjpYuy10bJR14E5GxW2azKJ X-Received: by 2002:a17:906:dbdc:: with SMTP id yc28mr6398384ejb.558.1631682837265; Tue, 14 Sep 2021 22:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631682837; cv=none; d=google.com; s=arc-20160816; b=ENiJbryLHEwU+wn5LEeyqwTFGwel4ONZ7TzbkIINbELZkH/rcxZOMo3eEcKEii7npg ZD6Z+T5wpY/y9OjfvAIL5XAmIEiSrsMKOf0XkDeznpZoLXs/bPNU6fThRgKO0SJT8kT0 VrJBxfM4qzA1vaKrALZhj9HaHj+8fuXdVH2jc7g6BPvKswjcazEQ9+iThziFj13ZsKAR v/5fVah8VcP95Z+ufB4Oj83eGKxnJB5HKiNIIJNx+yqnLodnVZotRP3CY2q20dCAcuTU xSMzdNa+8TQzvcBh67B+D3imfY3Dbhxgt72lZY4BIfnTMJeCqbbnul3yFsrnKmwY3AS9 ixfw== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=UsEBoTAMzj7nhFauMsSNt1jZ1/ThA0+NCnnPMqPBPvg=; b=VpkYlY9vCem9Y7gwuMwAR6cGzgA5bmRS9NuWrjBoRkC0HM4QuB1m825NQ2By5t8cCC jbjHphHIIbqLiC6BCa7PaNhWEmMB3CF5+Qx23ZAJEr4aSvfz2PpNGTNFQhHECtbWDgRB Fu9skMXIc5yiWJYiSHF/X20NPGTmK02AGOwbEAT5VJ9F9RDf6jWd+nNaIlUG49noG+hC qJFLE/kjOSGZupPze7zZanbCCEX3fU/d3lF9e0Lb4fZ+dau22FZgo4/KYgCachT+bHB1 CpLFsWf8vYPiHyQ5p0aFVGefl5DR3aqtRZBKw2e2hqmtOQ9Y1DDwBIH4LKLcJMtttnz6 ASHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zAF93gEB; 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 u19si16170400edo.600.2021.09.14.22.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 22:13:57 -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=zAF93gEB; 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 4275082C84; Wed, 15 Sep 2021 07:13:40 +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="zAF93gEB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A534480796; Wed, 15 Sep 2021 07:13:24 +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-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (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 980A082952 for ; Wed, 15 Sep 2021 07:13:15 +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=masahisa.kojima@linaro.org Received: by mail-pj1-x102a.google.com with SMTP id c13-20020a17090a558d00b00198e6497a4fso4047579pji.4 for ; Tue, 14 Sep 2021 22:13:15 -0700 (PDT) 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; bh=UsEBoTAMzj7nhFauMsSNt1jZ1/ThA0+NCnnPMqPBPvg=; b=zAF93gEBNNF9OCLW7rYMGcS17Sx1It58VG6rhuyJF9UboQJ0WG0BZB+ZQnvnFMOeSV ZhykN5Yo8ZT0zuo7JuvOJ/NWraRvOEpJ2yHIzYw1gvZkv+7J0dnkX607kofplxU3+HRp luPpF3y25vXQ80nZoV6y4S2IN4KlJHPePNYaEwXzdBzcUBT+nzb6mVPzQD8H99Rnttso mLlJydaylM6EQvBS6AATaljQGWuWc6MVskBZRplN3UdZwhsE74G42rHlcnhg8qIvi1po cd35d24M4tRlNxtLrzgBcAiNMUuoqWJNVGRpoEAeyljQe5MQiMvWDVSLYHfBrWDRPd1a YGVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UsEBoTAMzj7nhFauMsSNt1jZ1/ThA0+NCnnPMqPBPvg=; b=6W+67GVCewNGsUptiYYfaU8xSYVorhumR47kSJkORIIr9D3yloJpzZa0uJruVVH6Xc aVbKT1YodRhCOWNBm93vWatzm97aoJjVfkBzawO6V4CAapG1vXpSy7ImES8K3053flUh FXWj5CFT/gJw/KuxwZ26Ht55BDK3ggCysAoTKAlXDhoJHiuf7LkAkyCmipiyVZZEyFYf 13ttpHIBKKwNVIrcYPpqgyJBC67G0Mke5oi6sKNzX/u+gIjKc5+P9OUjE7lRF/Be7lfO wU2w4uigMGcUsqsA4KyPkqSDHrWZbJr3wM8M1CxgpTBXWNU9llIvgmeH6kMtBMb72n1Z DJYg== X-Gm-Message-State: AOAM532FuFyncl9fT2cYYBj00FKaMvj2rd7KgmPiMIovXcJixhVwBUWZ Ew+6W0ILMSAIEFsmlEr0n2qaRw== X-Received: by 2002:a17:902:ea11:b0:13a:db38:cfcf with SMTP id s17-20020a170902ea1100b0013adb38cfcfmr18170340plg.3.1631682794006; Tue, 14 Sep 2021 22:13:14 -0700 (PDT) Received: from localhost.localdomain ([2400:2411:502:a100:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id a10sm11858154pfo.75.2021.09.14.22.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 22:13:13 -0700 (PDT) From: Masahisa Kojima To: Heinrich Schuchardt , Ilias Apalodimas Cc: Alexander Graf , Simon Glass , Bin Meng , Christian Gmeiner , u-boot@lists.denx.de Subject: [PATCH 3/3] efi_loader: add DeployedMode and AuditMode variable measurement Date: Wed, 15 Sep 2021 14:15:46 +0900 Message-Id: <20210915051546.500-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210915051546.500-1-masahisa.kojima@linaro.org> References: <20210915051546.500-1-masahisa.kojima@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean This commit adds the DeployedMode and AuditMode variable measurement required in TCG PC Client PFP Spec. Signed-off-by: Masahisa Kojima --- lib/efi_loader/efi_tcg2.c | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) -- 2.17.1 diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 35810615ed..427d6e22b1 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -1828,6 +1829,50 @@ out: return ret; } +/** + * tcg2_measure_deployed_audit_mode() - measure deployedmode and auditmode + * + * @dev: TPM device + * + * Return: status code + */ +static efi_status_t tcg2_measure_deployed_audit_mode(struct udevice *dev) +{ + u8 deployed_mode; + u8 audit_mode; + efi_uintn_t size; + efi_status_t ret; + u32 pcr_index; + + size = sizeof(deployed_mode); + ret = efi_get_variable_int(L"DeployedMode", &efi_global_variable_guid, + NULL, &size, &deployed_mode, NULL); + if (ret != EFI_SUCCESS) + return ret; + + pcr_index = (deployed_mode ? 1 : 7); + + ret = tcg2_measure_variable(dev, pcr_index, + EV_EFI_VARIABLE_DRIVER_CONFIG, + L"DeployedMode", + &efi_global_variable_guid, + size, &deployed_mode); + + size = sizeof(audit_mode); + ret = efi_get_variable_int(L"AuditMode", &efi_global_variable_guid, + NULL, &size, &audit_mode, NULL); + if (ret != EFI_SUCCESS) + return ret; + + ret = tcg2_measure_variable(dev, pcr_index, + EV_EFI_VARIABLE_DRIVER_CONFIG, + L"AuditMode", + &efi_global_variable_guid, + size, &audit_mode); + + return ret; +} + /** * tcg2_measure_secure_boot_variable() - measure secure boot variables * @@ -1891,6 +1936,8 @@ static efi_status_t tcg2_measure_secure_boot_variable(struct udevice *dev) free(data); } + ret = tcg2_measure_deployed_audit_mode(dev); + error: return ret; }