From patchwork Fri Oct 1 11:18:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 515029 Delivered-To: patch@linaro.org Received: by 2002:a02:606e:0:0:0:0:0 with SMTP id d46csp683782jaf; Fri, 1 Oct 2021 04:19:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFxE+wRsSr9Y7S/+JfFyB9c2D4TuUb2oalNhyvQbOIh7SC70ynMS1EmnwAlk9eyF8fWqcY X-Received: by 2002:a50:da06:: with SMTP id z6mr13972208edj.355.1633087192200; Fri, 01 Oct 2021 04:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633087192; cv=none; d=google.com; s=arc-20160816; b=pcR0mtV/es3feOVmyqVWk3mIjiCrPkOS07XCUouQ5L1cLfJ5rB9XIZI1ZuSFrqV8nE gHQQGQufsIhZGIed6YZ4MxgWJAkIsLDFZvn43bt72jO35nFuL6V5mLsH+0BvWTn5h2qq J2yMfQJwYjGLZ0nINOrVNNgiRDOMiFyc4uX78QIEm0JbeEPrfpW47lzqCX29t2TJNMGr 8dtodHErP6oZO32Lh0VfWpCRBTb8cAe7ji0G9FSmtCmxOZJMyKT9fxbtkxhKEx4bFHWh vO632DFN/i6eb4C9AxZtmyPxxTP9eSIZpMff3qyGONeftMfy0wlLr+8aH7E28ER9wg3u HT4A== 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=Jsw/e912MSWr+5izVXg2CWImiLVUrNCjAxOBHQQLH0A=; b=lfYl/PvYvxRznGV/yEKj2NZJvsp8MSxQG74y404xqJnl3+E+17sagCsiW5BZFxVSlN 0xIvNOhumCAxu/9fp570e3fem1C97OUdnoydpXyK2u4NjSU0bD9Iv8lZK2a3CYcrkeup IQLaEsBedTdnjW7JxUkFw4MJ3Lx6ndXPyoT+B7Baz+rgBTr5NaxhWHAGL2+F5k5Gdf/1 eABTNON/ccLA8N6aLcZ9CQgl4CsrFj/c8Fsx38LHFYW4f35wttAFHbIw8P0vpH/RvoBr 1IW7lvX5oGErdWrNQsveaVLlsR8ezL2CE/lP67GOJ+/W4kgQAMXlp+JEuWoF154NvlZ/ d9Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PuN5Yh3C; 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 hp5si10738634ejc.447.2021.10.01.04.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 04:19:52 -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=PuN5Yh3C; 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 D20778323E; Fri, 1 Oct 2021 13:19:34 +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="PuN5Yh3C"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 729C283178; Fri, 1 Oct 2021 13:19:25 +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-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (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 5E29783143 for ; Fri, 1 Oct 2021 13:19:16 +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-pg1-x531.google.com with SMTP id 66so8698462pgc.9 for ; Fri, 01 Oct 2021 04:19:16 -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=Jsw/e912MSWr+5izVXg2CWImiLVUrNCjAxOBHQQLH0A=; b=PuN5Yh3CcU7JrdykhrimqlXXDXpcFBckDwMDc1bdnQRO6EcDBrCb1cIshC5gd/J4Vi PDY/q8cXJmQ1cZx9UGdvSlDClPpQGvQBcg4k7wmNU3fseUCQ0Cdkbl8tdNAk4u1LCxH6 yoXnpcSN6ifKe0TLsDNv9o8bY5pWB+cAKZ5WJsWV480G6NlN9fvUG8BD932Y4owcyvBh j0r1m490t8KSNJHpdyozj+oUV+OFjNmOZ1nsJFVhPP4FZh4zb7+xCNg2sq/JuHcTX6eA d+3wF6+0/qljt+IooNiRuReuUmo9id+pTLn2xT9Vgz5e/ytriPPgUyHvvHgr/QrB/ddE vS+g== 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=Jsw/e912MSWr+5izVXg2CWImiLVUrNCjAxOBHQQLH0A=; b=PEcS3ontLeIj/lag47gBXUiwGw7ysxfYEsQELskH/H2LtCbpFJAyBILGJ8PksqlwVk ot+zRabjq4XjPMMtb9zOkyR15hLhJB6Dfm3J3L839finaycGcrDqjqz+gwbdQqevwo3J lcndTNVNHGXZT7Iamlf1QeKQFocon5hj+CpUoJQQftJIMdDxkJWY6jm4JY7WUF0ynzoM 8DKAh3EpeXyiDhlxxeKwL7/mBtV8X680MYpae4XxTCYrSLqwMhY+6fozdd4L90Df4y7V 4UPFJIVC2XFe7wJKPyEy7wfxyhDiZ84qZVpjxQIuIVm6ZGuNicG7Z9OeOLsuHqly61yH koyQ== X-Gm-Message-State: AOAM531fQbYTIAGdAvabIPDm0jdhpIaKCriuPxVYlOS5K+YPWv0AYJo2 tDGzuYAkgii1QVuxlhb3WhcNSVM6evg9Hg== X-Received: by 2002:a62:1943:0:b0:444:f894:e19d with SMTP id 64-20020a621943000000b00444f894e19dmr9580557pfz.36.1633087154700; Fri, 01 Oct 2021 04:19:14 -0700 (PDT) Received: from localhost.localdomain ([2400:2411:502:a100:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id w12sm5689829pjf.27.2021.10.01.04.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 04:19:14 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima , Alexander Graf Subject: [PATCH v3 3/3] efi_loader: add DeployedMode and AuditMode variable measurement Date: Fri, 1 Oct 2021 20:18:44 +0900 Message-Id: <20211001111844.7422-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211001111844.7422-1-masahisa.kojima@linaro.org> References: <20211001111844.7422-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 --- Changes in v3: - read variable first, then mesure the variable lib/efi_loader/efi_tcg2.c | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) -- 2.17.1 diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 28e0362bf2..7fba4bc458 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 @@ -1822,6 +1823,53 @@ 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; + + 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; + + 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); + 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 * @@ -1885,6 +1933,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; }