From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A36BC07E95 for ; Wed, 7 Jul 2021 18:56:26 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E7E1861C2F for ; Wed, 7 Jul 2021 18:56:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7E1861C2F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D282782DFA; Wed, 7 Jul 2021 20:56:21 +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="EyKxKEll"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 168E982991; Wed, 7 Jul 2021 20:56:20 +0200 (CEST) Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 CFA8F82991 for ; Wed, 7 Jul 2021 20:56: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=ilias.apalodimas@linaro.org Received: by mail-wm1-x335.google.com with SMTP id o22so2531610wms.0 for ; Wed, 07 Jul 2021 11:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=yt/LWVFIlnqZAEv1bCXJ7N7H+6uS6B3oM+U+GAgwHRc=; b=EyKxKEllakBVR1tN1dxMrWOWRW8A2EG3axV7KOu6WvH++uxktsER4nehgtLdobJ1OY T+JPs0RhyY4AWCLwDlEApRIG7rxfWMdU0I0XU9Ok3W++fmaeGQGq5mjUs9VF71hFCyGQ YEJddYQDbvrOWLR87nLb8R9u6t81wkmDLkEzlVN6wzrSBksyxXZzVwxt/ztNPjnFcMYt YpMuNjAw72PGK20qffPS+J3dNcgCZgzHA2uWN5tMAo8sOkLhniHXZ3FcIb3M6ZWMBv8u oL+tibGiZzf7dnA118Koih2IGCQVvBo4kivYAhdu/1xhyIX/JV9LK0ITGQz9/rZHsI03 X7rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yt/LWVFIlnqZAEv1bCXJ7N7H+6uS6B3oM+U+GAgwHRc=; b=MF5qVGdVMT22hYaj6tpMQV0gU0aWCBM5IsuF6D+pmCQCLjQFnjRaQDV6uFeiY9kr+H 1s8MJssOfAumcOeQmBX6Gek+MPJP1C0c2wEY9MBC8BN8fhRnHgfC4Kbq8FxRETVslika TiDB2U015i2FKgIyd4M/XnBcXi1bXGUwux71+ikBMJulmWWBGPlDBqlriWbXCdMO4LmT iem8ApsV/LwyuXDuWPINpLytPl0mmhgmBN4bpDmxTLi39948/HigqmwRHTvBJzjc2+Qn ARgxQ8bpxIeRApdLMJyuIAkJGhvssdNntRwU4X0CGtbkB/r2wLg222QRJQDR++X/gnGB GI7w== X-Gm-Message-State: AOAM530PZ1t7gDvb111vCFG6mW44mKWdoMiwjsMwnFWmEH5hfBRgM3nR IQp4KZ+1yqEQ9oMyKcMJx5HPnA== X-Google-Smtp-Source: ABdhPJzSTV6QJ8UeDhk7CpsJf5ha42D4eBkW6xvdMEA+ne+eyRKlVI1LsqXooNyCLlNYnJwvahqqlA== X-Received: by 2002:a1c:f206:: with SMTP id s6mr27640279wmc.102.1625684176388; Wed, 07 Jul 2021 11:56:16 -0700 (PDT) Received: from enceladus (ppp-94-66-242-227.home.otenet.gr. [94.66.242.227]) by smtp.gmail.com with ESMTPSA id y8sm21103173wrr.76.2021.07.07.11.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 11:56:16 -0700 (PDT) Date: Wed, 7 Jul 2021 21:56:13 +0300 From: Ilias Apalodimas To: Masahisa Kojima Cc: Heinrich Schuchardt , Alexander Graf , Simon Glass , Dhananjay Phadke , u-boot@lists.denx.de Subject: Re: [PATCH 3/5] efi_loader: add boot variable measurement Message-ID: References: <20210707133638.12630-1-masahisa.kojima@linaro.org> <20210707133638.12630-4-masahisa.kojima@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210707133638.12630-4-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 Hi Kojima-san, > +{ [...] > + u16 *boot_order; > + u16 var_name[] = L"BootOrder"; > + u16 boot_name[] = L"Boot0000"; > + u16 hexmap[] = L"0123456789ABCDEF"; > + u8 *bootvar; > + efi_uintn_t var_data_size; > + u32 count, i; > + efi_status_t ret; > + > + boot_order = efi_get_var(var_name, &efi_global_variable_guid, > + &var_data_size); > + if (!boot_order) { > + log_info("BootOrder not defined\n"); > + ret = EFI_NOT_FOUND; > + goto error; > + } > + > + ret = tcg2_measure_variable(dev, 1, EV_EFI_VARIABLE_BOOT2, var_name, > + &efi_global_variable_guid, var_data_size, > + (u8 *)boot_order); > + if (ret != EFI_SUCCESS) > + goto error; > + > + count = var_data_size / sizeof(*boot_order); > + for (i = 0; i < count; i++) { > + boot_name[4] = hexmap[(boot_order[i] & 0xf000) >> 12]; > + boot_name[5] = hexmap[(boot_order[i] & 0x0f00) >> 8]; > + boot_name[6] = hexmap[(boot_order[i] & 0x00f0) >> 4]; > + boot_name[7] = hexmap[(boot_order[i] & 0x000f)]; Can you use efi_create_indexed_name() instead? [...] > + for (pcr_index = 0; pcr_index <= 7; pcr_index++) { > + ret = tcg2_measure_event(dev, pcr_index, EV_SEPARATOR, > + sizeof(event), (u8 *)&event); I assume adding a separator event on all these PCRs is described on the standard? > + if (ret != EFI_SUCCESS) > + goto out; > + } > + > + tcg2_efi_app_invoked = true; > +out: > + return ret; > +} > + > +/** > + * efi_tcg2_measure_efi_app_exit() - measure efi app exit > + * > + * Return: status code > + */ > +efi_status_t EFIAPI efi_tcg2_measure_efi_app_exit(void) > +{ > + efi_status_t ret; > + struct udevice *dev; > + > + ret = platform_get_tpm2_device(&dev); > + if (ret != EFI_SUCCESS) > + return ret; > + > + ret = tcg2_measure_event(dev, 4, EV_EFI_ACTION, > + strlen(EFI_RETURNING_FROM_EFI_APPLICATION), Do we need a NUL terminator on this string or not? Regards /Ilias