From patchwork Tue Sep 21 07:19:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 514395 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2802802jao; Tue, 21 Sep 2021 00:17:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGYRKvgRooZjzyHthUliTwfM1T5bL55CmZZmt/zDZrvbCnrPI0qra+IA9G0bEK3Ka4Bvbl X-Received: by 2002:a17:907:2bdb:: with SMTP id gv27mr32431569ejc.483.1632208667963; Tue, 21 Sep 2021 00:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632208667; cv=none; d=google.com; s=arc-20160816; b=WtAnGv1nVXsw4LPec8eKgnVlxmHINDb/g9wjYdUtBsCkc0RfuXBZZaqvIEtYn6Nlh8 ZyHSU9ig4FC1BJ3dj/YzX8g5abdJUTehIFZ4T1ElIg+G3wYnPzKuIVsbO2gDua44QFuo VD1IEIu7mwexHRoOSlm/+dYEIyoCDIOuVv/v1fqzCEA/DBB1gSwtReus+VD+K0Vo5ITN ODyjKyH877fA+l+RzmoEaXJHt2BkZRSD0fWIOxa6Or3OABBFmo64h0HQefVvshB+RS08 uDdfMYdoYEkqKHeK+lnyCjC4wc2izWKloiwcpZ3xnN3RuwZE+rS9tdrCTdEicY+Ls1ot O7ug== 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=cyCU9zXdBZsrNNW6cAUf6N3JjkvpEVvNj48jPStK0A4=; b=cRoLkg9wAAGaCZtam45OZo4GCSj9Sej/ab56MwuvSY7T5REoXJrXl5EInjoyvwyTCp 1uoANX2rumJd6/hNDa3ribPxthRXfhFfGGr8YtqnEYLyWq7HI0xxGYBg+cPcqdhsvMWC Dt8N+OPZmwqEqTvcvLZ4ln0IPbKr+edZ4/8RRxt3OWCd+x+puAFAKUgh35j1B2R6ovte fYqwMEKQslGDQF6O0dZAhknMpLHPDmZFidW4dlFMK3XJflrXHcfCb0/uObjfMRAKFckg 9Oi7SkWBM2yNz+GhJZXKEEMEsGvdx9MkgGmwEnzm2qevzXxa1X2T5zgl94d0cRUBV/jn 2SAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oFEptCYF; 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 i27si5513776ejh.465.2021.09.21.00.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 00:17:47 -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=oFEptCYF; 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 DFB3A832A5; Tue, 21 Sep 2021 09:17:36 +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="oFEptCYF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 70DAE8328E; Tue, 21 Sep 2021 09:17: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-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 0567A83282 for ; Tue, 21 Sep 2021 09:17: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-x1035.google.com with SMTP id nn5-20020a17090b38c500b0019af1c4b31fso1860903pjb.3 for ; Tue, 21 Sep 2021 00:17:14 -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=cyCU9zXdBZsrNNW6cAUf6N3JjkvpEVvNj48jPStK0A4=; b=oFEptCYFPwOVm1jU6cpbMETXd7lT7rydw+ORydzWBJN8tvSOWrbzLi26JomWWaJsDq x5UpJ/I7FzmyLxMR13es0EgjbcsUXmuWyBB9lL1nf4iBa0kfZ9FTEL4cpPVfJJ7pxHEG n5lLuYlf8xD+uqvEmUliKd0Yl2nbQ+qg2ghwX5VCTV+KU5hHbKC8JCCasPz1PKWoT3U+ onu7G6GAiV3mw/qjl+9J9+OPZBUsqyvLbpx0cgWMAAR4gfeNTtoepTR05gWImO2jv5XB 1HDcFYYzDLiea7fw06ltI3GYniIYv6YxIl4H1OXhQ8SDexZpBOzXUrdyqb16Q0u6O8x9 JbjA== 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=cyCU9zXdBZsrNNW6cAUf6N3JjkvpEVvNj48jPStK0A4=; b=u7fwXSgjRKSnjQ/acfduwK3UpMPgm74H6hX0hQHVCDxcEKdXONQv6yD134cnewS07c SuiOwntcWJ+x7I7uRK9CYrO9aYBCejXUVeRiPSIaVke4ljFpzwFqjnPnKTa1Eb+Jl9n5 LNbyX8AgGf5iBX73RhOizvtXqRY/rX+Ym3YAjOGaHzivk27ygpJn1tLbYHC34cR6D8KD eKbXIhBYHFnnC9BS9pjltn3TV10EzgcRg4QfO0lrJhQkCiTtZ7C2QENGdVOiq3S9gjB+ JhpSTUhElgbG/8tvx4uBQ0zaxTcTsh51I0hIFFGS7n3JBPNxGeIMVJ+xLlJad+g5DpfF DNKA== X-Gm-Message-State: AOAM531Nb8AzPISaBy1MXuwn/jTdhSzU/nvOFvWKJTzG9f7tP8PR4qBa LTuTNlqbx53c8IK3p+05w+DtDu0NmQNK5qiU X-Received: by 2002:a17:902:ecc4:b0:13d:588b:d83c with SMTP id a4-20020a170902ecc400b0013d588bd83cmr20577971plh.0.1632208632989; Tue, 21 Sep 2021 00:17:12 -0700 (PDT) Received: from localhost.localdomain ([2400:2411:502:a100:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id i2sm16265093pfa.82.2021.09.21.00.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 00:17:12 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima , Alexander Graf Subject: [PATCH v2 3/3] efi_loader: add DeployedMode and AuditMode variable measurement Date: Tue, 21 Sep 2021 16:19:31 +0900 Message-Id: <20210921071931.3755-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210921071931.3755-1-masahisa.kojima@linaro.org> References: <20210921071931.3755-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 --- (no changes since v1) 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 ea2c1ead03..68542c7cd3 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; }