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: 1535289 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: bilbo.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=PuN5Yh3C; dkim-atps=neutral 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HLSLy2TTXz9sRK for ; Fri, 1 Oct 2021 21:19:54 +1000 (AEST) 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-Google-Smtp-Source: ABdhPJyTnTIAtkGhUcLRBu1kQTEN/NkaagyQES1B0EPKQewwLKXQHRpjI5u3sueRInSO2pnTygA8Sg== 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(+) 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; }