From patchwork Fri Oct 22 11:24:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 516119 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp960504imj; Fri, 22 Oct 2021 04:23:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHwGrkqUarHQBAcgyApnwWOvLmCu4RUIzhDOOCSHr7W3GB0TIEb+C3M01v2GEYAI7ZrCIA X-Received: by 2002:a05:6402:50c7:: with SMTP id h7mr16442474edb.191.1634901808908; Fri, 22 Oct 2021 04:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634901808; cv=none; d=google.com; s=arc-20160816; b=fC+uDmAct1acawIsHRfRpHqESCs7Y67sZxpBHJot/I9Elm9BENDZ/uUZuxwRd/a/LN I+qWEiOrV4DqYJaJQh48i/eo9Dc6oywAYs/jmyVOrQtNyfyf7Y8rwgnj9c3dXUXlD0H1 X0ZqkVpd6m/gvwH8kdQ9r6kfmBkpoGnebzbeTxAPAsyCIkrjowgwNw/9QKMeGmuqngAm xrzL8xOOHE3XvVedEbDYNvKHd0UOliNztdaTr5madiASi4x3watGJdhQt8jyPEBwlBce jf/J1jyyZwO5fsgHjhCHQNwo9wvw8FuZ5A0iya7pF1KUdV0YOsGdf4pNLuB2sCJWGyXB 9vxQ== 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:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=e7hXx220eRfdl1N4Fqbv8Hdm2FvUXagzoe7JjW9DXS8=; b=lE7Ou8Pu7K11iMT+IJNncIw/Q/D6PKSHHgNINPp7sBmJ+mRQ6SFwLbvpv3Q9RdCSMz 6jpRVH115NGpB7hXAXxSL2YPs91RMbUmLOh9dQKupMnzkh3DxrIADRCcbHE/XjyIJWf6 PfcRmJzDxfkSi3O5Uqf+Nw+skKBOmL8B1yK2+RFF+t3kyjAgagaY7/dvNWD8wE0fTZ5s mFhnfG9Kb/KLFFrfYDVFVtt5DyPpRI33wLyox4yd9RZM9HRvi6DzbPktV2DpQLOiObyX 9f6/ONPfl6Wof2nOMW+SXvmozv3qIDHmIIXnw8scwALLEOoZLjaCCSgbe1TFDmoTmd79 ZJuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l3Vj72gj; 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 k13si10132721eja.414.2021.10.22.04.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 04:23:28 -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=l3Vj72gj; 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 0B0BB834AA; Fri, 22 Oct 2021 13:23:26 +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="l3Vj72gj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6547F834B5; Fri, 22 Oct 2021 13:23: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-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) (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 43FF7833AE for ; Fri, 22 Oct 2021 13:23:20 +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-x1031.google.com with SMTP id u6-20020a17090a3fc600b001a00250584aso5452218pjm.4 for ; Fri, 22 Oct 2021 04:23:20 -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:mime-version :content-transfer-encoding; bh=e7hXx220eRfdl1N4Fqbv8Hdm2FvUXagzoe7JjW9DXS8=; b=l3Vj72gjOfv0be06EZTktDXMv1sbwpkf2Yez1VlweR46BQdigPANvbxqTMI2BBNndu lWbu4UYnEuYnVWoVtDM5F15mUIhWWu6XmiU1Vf8NbYtxOIvzSlUA99T27UGTenPMAPAH XbvwW5bo4SLQXpBEQ3hVHW7pKTF0Hd8A/b0/DcezhKylB21Ad2WZCaNn3ohTnZXdqkTg WQdv8Ev2ExqR8qFMrhgQYi/yZo5fJe68Ei1OEC0/oT3gCdM377Ed08i9ldRFSnc6QpsZ ppdkRxpDz+QhUbYE0aJpspDRUO2/7lDs5ptYDRiyG+RNDyFBCQxBOlM46c/HPryE/S6F 0kxw== 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:mime-version :content-transfer-encoding; bh=e7hXx220eRfdl1N4Fqbv8Hdm2FvUXagzoe7JjW9DXS8=; b=c6GaDkQRCJX9tuLMt9B/5GAMowYR+wo/seR8ToDxI1zdKKmLeKz7y8Q2IT1QjbLKW9 T52KJcrR7g61N1VKeaBiMdq5w/yoU1Wo87ByxzMr0Y/iJti3/4+6Z4hIba/j/LH1HGrR Wv/Qu2cfdZBvuopMwPIL2Lp7HLjNHnLdd2KsIFCpS5n/TopzoCKZKk5QA4Voy9Z7cHO9 1W8djOjEnBzQTGfIhZfhEAyMzynBZdbDd+z6P0oH2O1HXyEdiahGlXNzuzFwXs4xafLH umLuNcHFFvpon+nNPMmVHaNgHjwJ09KYgx27+JuFbmUtws8dzfW37MFrAvZBlWQOx573 RMLw== X-Gm-Message-State: AOAM5308FQWdXYLq0yFo3QDB+9tK31Chsb0yNQSTjNp9hlWZN7fqqOat mewVp2tT7YVh3HTpQr2ZV0AxiVV5szJQiw== X-Received: by 2002:a17:90b:354:: with SMTP id fh20mr13976737pjb.188.1634901798715; Fri, 22 Oct 2021 04:23:18 -0700 (PDT) Received: from localhost.localdomain ([2400:2411:502:a100:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id m4sm1701908pjl.11.2021.10.22.04.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 04:23:18 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Masahisa Kojima Subject: [PATCH 0/2] add selftest for EFI_TCG2_PROTOCOL and Measured Boot Date: Fri, 22 Oct 2021 20:24:23 +0900 Message-Id: <20211022112426.25009-1-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 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 patch series adds the selftest for the EFI_TCG2_PROTOCOL and Measured Boot flow. This selftest is verified on qemu with swtpm. This covers most of the functionalities, but there are some limitations and TODO items. [Limitation] - tcg2 selftest must run at the beginning of the efi_selftest because some measurement occurs in efi_tcg2_register() and boottime->image_load(). Need to configure the efi_selftest with "setenv efi_selftest tcg2; bootefi selftest" - Skip ExitBootService measurement test - EFI application can not read PCR after calling ExitBootService - Skip EventLog Validation - Measured Boot measures U-Boot version, so EventLog varies every build having different commit hash. - Skip PCR[0] validation - PCR[0] include U-Boot version measurement, this value varies every build having different commit hash. - Skip PCR[7] validation - Secure Boot Variables can not be updated through efi_selftest. - The initial PCR value of PCR[17 - 22] is all 0xff, I'm not sure it is expected or not. [TODO] - GPT measurement test - Secure Boot Variable test - Eventlog validation Masahisa Kojima (2): efi_loader: add missing const qualifier efi_selftest: add selftest for EFI_TCG2_PROTOCOL and Measured Boot include/efi_api.h | 2 +- lib/efi_loader/efi_boottime.c | 5 +- lib/efi_selftest/Makefile | 10 + .../efi_selftest_miniapp_measuredboot.c | 93 ++ lib/efi_selftest/efi_selftest_tcg2.c | 804 +++++++++++++++++- 5 files changed, 910 insertions(+), 4 deletions(-) create mode 100644 lib/efi_selftest/efi_selftest_miniapp_measuredboot.c -- 2.17.1