Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1045540rdb; Mon, 19 Feb 2024 02:24:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUjyfFBnEtHxm8IH+r/5LRR6xnaF0QUWSHz7wAxVw8VuT1P9uMO/U/FxEf8y9HiipztqGTju9ORLWEpJ0m2HJiOdRlBl0iKQhIoWa8F4w== X-Google-Smtp-Source: AGHT+IGKga24YSRUaWa/iBxfYMKfv9+zxXRCiXV4WxPILqE4eXnWN9b20eeHjNYocs6N2XPLBIgb X-Received: by 2002:a05:6358:6f1a:b0:17b:2bc6:e970 with SMTP id r26-20020a0563586f1a00b0017b2bc6e970mr8070911rwn.25.1708338290210; Mon, 19 Feb 2024 02:24:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708338290; cv=pass; d=google.com; s=arc-20160816; b=igtOxCWF0epJUqSDupUwbp8+X/2jWFmNj2YbVxxwensNUB9vIMlwknNhHjrXNBxJBR UzRWTjhC0zRlxX3rVXZYbK5It54aFlQ7hOJgUP+OIpOZv5eCHAm+s2n3v3JwXB4gdZAM qoysRIcUGMsL4Wb9eQoRHQNyMH8wZAiEDoxPbvKCCAxhPhXujphVk8mQQcoHoD/dN5Xu TODtlHpzAV5Mfu5gT4KqeWmroq4gM2T5fvrq13TTGItXO6VejNcts3IEjTVoYqsrE8wc 8trCTl8a6M8CeL/t1WQPTpK5Orw7St/Gt+pqNIn+VWG725b0lPY0QoJO086alk48ZCU7 rnWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=185YW2CtfEhgFdVqSbHTSVqx1KE9rOVE9un7aoQuCPE=; fh=RLfEU3EVI8Zj4xf6NftA9y22yPgM7OH8JrANIVSpRIQ=; b=XrIVEgwkNxFwkaH8AhRgwVhWbYlQ1hLmFkNd0iQC9Of3W3pRH+0yscl5Iswy2S7wL6 d6gMhb9l1jcIZDvBRg3tFFIEGTD7dSf9HcNni0hDM3jqzENbMC0a1T/jHEQ/CxjgPVIl AicePBafPvxqToWrOu22418VnU88QWYmBl9eYQo5w3UijtUYsQPhitvv+CqsqZEvUWkK q8qxSIsQelZQAZaVi/cij/rv35ZmHR67Ppdd8tjyA5swJDgCZZW3ndyEeDxAfFuuxHhi RF5CT4f+rWqMIGZ2UMq/pL6DOVUokPZSVXBmLaeuhq30kHImz2SGxeeHtVUIC1tcDCla 8gww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ivwMq1Sh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-70836-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70836-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bn16-20020a056a02031000b005dcc8a4590esi4334569pgb.680.2024.02.19.02.24.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 02:24:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70836-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ivwMq1Sh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-70836-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70836-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7C14228229F for ; Mon, 19 Feb 2024 07:34:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87E4B20B35; Mon, 19 Feb 2024 07:34:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ivwMq1Sh" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1166620B0E; Mon, 19 Feb 2024 07:34:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708328068; cv=none; b=L/ndf2ch6jh760DAX6FWZM0yNym6AAxXzmY3XeOve0jXn6eOroROFLU9OTvdy57H/F8G8H7587Fsu0hlW/XvVYmcV/Vr+PlziAXCzAS1aoSshquYUh9P7hnSPf/h9fLhIyr9ANYs6tv4SvqGXOi/eg49hvjuQhqKnNE6wjpbs1g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708328068; c=relaxed/simple; bh=nG+e0xfx4vtsde8hCf9gGVh7ZBbgR70WURJo1H2ry3E=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WAZuyCc/ZCWyhRmNZg5EH+zACpR6CEk5GWVYSjcO7Rgvd1q79t34IR02uJMxF81FM4fWPUk7Epe7UDVQ203Fpo7Mlihsj028yIuo67rQPI/nyNsj0GM5R703Fl7eTQs6Nq1K9dXfMUeKDfp2YgzhuCOrDo8yxFnM1rIhjQzSqNs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ivwMq1Sh; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708328067; x=1739864067; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=nG+e0xfx4vtsde8hCf9gGVh7ZBbgR70WURJo1H2ry3E=; b=ivwMq1Sh0968tUK0gIeSVA4F8Pn9Y0YKlFLZ3uPh86b9IkiI0Ld806o3 AkQZrMvwJD/uSBVzAZEiI/+Q4YIDqJEyzBwFUVIHG/k6g+7EyJzqksPz9 HkGTzj7y59CuwN4GlDp1dY827rRyApQyKQJvq1MTvEDS3nWtWGshE8lif oYEte3YEyLJIQXN4zA1ODtpQxbLiUyPPMUKUiGN1En1PaitQhhSWGT8rA TlD7NucZn3xtz9duE5P2BoqZQVDNxaHxoOnk33RQaFAk22o7z6K2JiyKf JE01vxd1QlvVnA/b3XXd8hUlf/b5OTRQ6dapVlKznynj2W9XUWrmd7j9G A==; X-IronPort-AV: E=McAfee;i="6600,9927,10988"; a="13503078" X-IronPort-AV: E=Sophos;i="6.06,170,1705392000"; d="scan'208";a="13503078" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2024 23:34:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,170,1705392000"; d="scan'208";a="27579484" Received: from mojammel-mobl.amr.corp.intel.com (HELO [10.209.58.186]) ([10.209.58.186]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2024 23:34:24 -0800 Message-ID: <7feb889f-f78e-4caa-a2f4-9d41acf6ca76@linux.intel.com> Date: Sun, 18 Feb 2024 23:34:23 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] efi/libstub: Add get_event_log() support for CC platforms To: Ilias Apalodimas Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org References: <20240215030002.281456-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20240215030002.281456-3-sathyanarayanan.kuppuswamy@linux.intel.com> Content-Language: en-US From: Kuppuswamy Sathyanarayanan In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Ilias, On 2/18/24 11:03 PM, Ilias Apalodimas wrote: > On Thu, 15 Feb 2024 at 05:02, Kuppuswamy Sathyanarayanan > wrote: >> To allow event log info access after boot, EFI boot stub extracts >> the event log information and installs it in an EFI configuration >> table. Currently, EFI boot stub only supports installation of event >> log only for TPM 1.2 and TPM 2.0 protocols. Extend the same support >> for CC protocol. Since CC platform also uses TCG2 format, reuse TPM2 >> support code as much as possible. >> >> Link: https://uefi.org/specs/UEFI/2.10/38_Confidential_Computing.html#efi-cc-measurement-protocol [1] >> Signed-off-by: Kuppuswamy Sathyanarayanan > [...] > >> +void efi_retrieve_eventlog(void) >> +{ >> + efi_physical_addr_t log_location = 0, log_last_entry = 0; >> + efi_guid_t cc_guid = EFI_CC_MEASUREMENT_PROTOCOL_GUID; >> + efi_guid_t tpm2_guid = EFI_TCG2_PROTOCOL_GUID; >> + int version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2; >> + efi_tcg2_protocol_t *tpm2 = NULL; >> + efi_cc_protocol_t *cc = NULL; >> + efi_bool_t truncated; >> + efi_status_t status; >> + >> + status = efi_bs_call(locate_protocol, &tpm2_guid, NULL, (void **)&tpm2); >> + if (status == EFI_SUCCESS) { >> + status = efi_call_proto(tpm2, get_event_log, version, &log_location, >> + &log_last_entry, &truncated); >> + >> + if (status != EFI_SUCCESS || !log_location) { >> + version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2; >> + status = efi_call_proto(tpm2, get_event_log, version, >> + &log_location, &log_last_entry, >> + &truncated); >> + if (status != EFI_SUCCESS || !log_location) >> + return; >> + } >> + >> + efi_retrieve_tcg2_eventlog(version, log_location, log_last_entry, >> + truncated); >> + return; >> + } >> + >> + status = efi_bs_call(locate_protocol, &cc_guid, NULL, (void **)&cc); >> + if (status == EFI_SUCCESS) { >> + version = EFI_CC_EVENT_LOG_FORMAT_TCG_2; >> + status = efi_call_proto(cc, get_event_log, version, &log_location, >> + &log_last_entry, &truncated); >> + if (status != EFI_SUCCESS || !log_location) >> + return; >> + >> + efi_retrieve_tcg2_eventlog(version, log_location, log_last_entry, >> + truncated); >> + return; >> + } >> +} > [...] > > I haven't looked into CC measurements much, but do we always want to > prioritize the tcg2 protocol? IOW if you have firmware that implements > both, shouldn't we prefer the CC protocol for VMs? According the UEFI specification, sec "Conidential computing", if a firmware implements the TPM, then it should be used and CC interfaces should not be published. So I think we should check for TPM first, if it does not exist then try for CC. https://uefi.org/specs/UEFI/2.10/38_Confidential_Computing.html#confidential-computing > Thanks > /Ilias -- Sathyanarayanan Kuppuswamy Linux Kernel Developer