Received: by 2002:a05:7208:3188:b0:7e:5202:c8b4 with SMTP id r8csp842069rbd; Fri, 23 Feb 2024 05:25:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXxmE2U9zw+S6AKDA0JmqlFyLoaxf5GQ8myZt+eBqD9Kl9cqYG/KjceON3t9+JInhnzjUeipm8NoeEjizSFyqiZAuFbg1qQLFIFzUf3vQ== X-Google-Smtp-Source: AGHT+IFgdRkYZHlHIRcDEkq4OrUT3TcWqu3lhG/7PPaR3LZwYwk84dbk9vL3Ihmq3cYM2LRGsMOn X-Received: by 2002:a17:906:164a:b0:a3d:590:195e with SMTP id n10-20020a170906164a00b00a3d0590195emr1417684ejd.4.1708694743396; Fri, 23 Feb 2024 05:25:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708694743; cv=pass; d=google.com; s=arc-20160816; b=Z+zausORQ7W6z6Bxxnc5Fh74U5YKDvEyPknWZCc1sRQzbBtSFKYf2LAs60pkzggJZu 3iEeY16coYWjV49yoGVf5wn7H34WStAoFxUrhi7p9jdce0diUwj5cnVeub2VCXSlbjmu QcEcvsbYttxBkPTycHLyiGC895bFOpUxYW3J80O7UcXDLB9jVe1CWfAV6HhAdpq/VYRU duA/tqRyF09kFDrFU2pkhrktsZQ6C/u+BfDHqd7s2hIxmjAmCQ0iWve/ECH2qvCE/2wp fJbzA1a8zdQyOELAlY0bIGFXDZ80+XXqsmZhKcRT3/2iH7gRS1aTk68od4nSUAKuO48V rTgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=19cp42f8tFvnJXMehM3M7grgDYIRgHH0G4ve9idhWWk=; fh=3ENuT4xqArofz5WHlC27yh0hIRT/cFjU0QRavJDtDXg=; b=pAe3ERln+nY9ednfoeKnBP8h7iauqH35qcrLjE+KK0tXNJStLq1E89RlcEaGhVSL8s RnqrEgGfXcqm7ARryC4O/8FUE6C+jQzyzYWyEWvak2KuYsTEme4ogYccqciqD9afjSX7 XLwZdyuHcv8UBrd2qYg8KKDtfMPlKCSgTczMCl0ehVyYQENzEZT+zHtZLTPt9YTDiE/o VhfutI+WaAsqKDTQfR05iART2qvEXVp7d764fL2R9mHjK9850hEheWF6Qp+BrTxA+xzo L4drPvypt5o6hRxDzKyrjtUh8ieU1I98PY3VcJl+6bLqE+HCOzycn90EsBx+mICAmapX MN1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o3M2njpe; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-78371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78371-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ho13-20020a1709070e8d00b00a3e9b5d0a62si4704462ejc.337.2024.02.23.05.25.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 05:25:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o3M2njpe; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-78371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78371-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 035521F24B3A for ; Fri, 23 Feb 2024 13:25:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A193A7EEEC; Fri, 23 Feb 2024 13:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="o3M2njpe" Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AA686FBF for ; Fri, 23 Feb 2024 13:25:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708694736; cv=none; b=LdNOTq3oFhIRZWyJ6mgGaQq8U65ZFghcmN4AeOfl+ZetnQ1IpcgB91MWefxI6PuQB+kX6WleaUHa9RVPBRyjMb/3TbjfQ2Ahx/xMOAaKF2uj3QFZVK7jbjjYa3yr2NBFdvqEY21Mhu04ns11PWkXErG2g/BYq2DQ7xYQj2Rg2pI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708694736; c=relaxed/simple; bh=8W2YjE8PwlPeNRufHAAQFYoxCLTiN7XteQ72PTA9h8k=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=H2e44bV6uroJ7IA+Xz3sB+Mxu5GK4zSCtWVdECA2b+zPhrjXtef9h7DsANeKLeEIBUsrye+WWNmxMxtcFHvMfY1+RY8Hrn0ejb+6HGgtV1c+dmHX8beQs/LPKcpKfgZtffTxM1J9DNYSQxvru6ulPOI3EP9efk16JERFiIb7Qzc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=o3M2njpe; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-512e4f4e463so1188473e87.1 for ; Fri, 23 Feb 2024 05:25:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708694732; x=1709299532; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=19cp42f8tFvnJXMehM3M7grgDYIRgHH0G4ve9idhWWk=; b=o3M2njpeL/tuzIO1oFzZzMJCpD6Hdk2fJVFhpyePe0qsHq3kgJNe3b8Nb1dbrDiGnE OzTj67DixlT4sA+hBBy5btC/RA0+SdwksT7ls/pI25X6fBIyRwk76XJLV39RuceE9BIf AM4YcfdCCELHtcMk24265lwTnhZcmWGKB1MP/AnmM3zbm5cByVZUYSOOIX6k9GuDrfjn 766Zd/CjS6XvNchU30aIn6vHso/WgDiM7FvfZzLVqppwVyMkjrC9ROJvIueSFlkqfSEx 1KUGLksiucro09yn8O+qzqZv8Arv7ivZyBLmSdNOp+SD8nj4Li61BNgdkVlBy9FkBWaw oX2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708694732; x=1709299532; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=19cp42f8tFvnJXMehM3M7grgDYIRgHH0G4ve9idhWWk=; b=YHstZXBwePtRSZWP6SzyU2XuIDFkFjPPZkFbATs40RhGhRVyXQeExncmMdywOefU5e gruSOVzcCWL987ospygQkKRUS93ZXEhsT6G0FwtBrMP4Ut5SXoC0gDvzXXug0WbdUpVn TNa2CV6lGQTjgRAwrXSaX2cclzpDMQoOYxPyrq1OVpKfYSgaG5BCqQop2QyS6WZZ9eWA 3hC5vGB95rQlSA99rY/Y4GyUxcqC/wtKItncANb9J9Gd6Ut1pvLmOT+5Te9kEvfJGluG 4kxyBXvb/e+lSXMYV48lDq7xekPhEtlo5+RS7RmWwklaC77XRM41NbuNppv2Gm2GLPIl BolA== X-Forwarded-Encrypted: i=1; AJvYcCXzzikq9bpc5tnWQpkk6dpnicGjeDi4aafQOvW+jMX65N78BOraRZihc+VKmG6YrvVZXh1W+jNi7ZHKXxSg29yha6maem3nR8dab5GT X-Gm-Message-State: AOJu0YwlOjfcvBQ0F6qS8vjch267/MNYGNox/mMZTFOpiIHVxXRohtJP aLtfHg+a3+FpKit3pJESdTMhLclq8UV9s9XXkX971AmDeBMp+Tjds1KaezWeNxWPw6GmFchSodV u7zFed3Rw3if0EPlrU7gl8tWIxPVl5mrqYIutN0NE8TI5kBenQlY= X-Received: by 2002:ac2:5d48:0:b0:512:df5b:ee91 with SMTP id w8-20020ac25d48000000b00512df5bee91mr1425719lfd.30.1708694732339; Fri, 23 Feb 2024 05:25:32 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240215030002.281456-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20240215030002.281456-3-sathyanarayanan.kuppuswamy@linux.intel.com> <7feb889f-f78e-4caa-a2f4-9d41acf6ca76@linux.intel.com> In-Reply-To: <7feb889f-f78e-4caa-a2f4-9d41acf6ca76@linux.intel.com> From: Ilias Apalodimas Date: Fri, 23 Feb 2024 15:24:56 +0200 Message-ID: Subject: Re: [PATCH v2 2/2] efi/libstub: Add get_event_log() support for CC platforms To: Kuppuswamy Sathyanarayanan Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Apologies for the late reply, On Mon, 19 Feb 2024 at 09:34, Kuppuswamy Sathyanarayanan wrote: > > 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. Ok thanks, that makes sense. That document also says the services should be implemented on a virtual firmware. I am unsure at the moment though if it's worth checking that and reporting an error otherwise. Thoughts? Thanks /Ilias > > https://uefi.org/specs/UEFI/2.10/38_Confidential_Computing.html#confidential-computing > > > Thanks > > /Ilias > > -- > Sathyanarayanan Kuppuswamy > Linux Kernel Developer >