Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp417807rdb; Mon, 22 Jan 2024 08:07:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHTmZZHCwIO0GiwzgXokDWHw/SpIS/vt27VDsDsu8/jkB8Hjc3Dc2g/OUenbrRfLVSc59x X-Received: by 2002:a05:6a20:1608:b0:19c:4fd5:dd0f with SMTP id l8-20020a056a20160800b0019c4fd5dd0fmr660209pzj.98.1705939664544; Mon, 22 Jan 2024 08:07:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705939664; cv=pass; d=google.com; s=arc-20160816; b=x1mfmh+y8xDU5EI/RWBjC7jNRI+hh/BuUhmSKBmMh5rpym54fs7GSiMIcbpbSxRU9M w9ACJsLt2z4lY9mflbLg6xuz7NwFt88M3GTKNJ/u8pGF+1d7hJ1pFW9oCxeOHijTf0Kn IHOuUv9d6kfOoGiPsmxaZHMqJImmmwkG1P9pIZ7elEvYYJrVO9WChbhKl35v54jfLQEf k8Vo8W+4CZDMzNxkbcNwugK+hEhs9Rs6zlT5bESFG1Z7y0KrR3a6DwdWcnhXHEHCNugy O9h5WR/2tHzaAsK/HU/4umjwQSkYQqy4rqxzKV94YA7pUeau/2xdMtfehv3FFeqy4Wr1 1gcg== 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:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=xiN3TBxglvlpO8kq87HoPKdumhzPgDe5ReSpMnkwFpM=; fh=gEfextNQFAgz5IRRW4xFWq+7Tpy4eXXfRkpppXvVYsg=; b=wHYWivp65dmhoXmcdrHEAkzkGtleOEWhbhRlX64QFy7NhYkgqXqFroAs2NKrWSVPJv NiPaxCLLNKrYb/3fNLqKEfZLnpECItwSCe4EVaV/Sbv6iCqTz+ytr2/Q4FRdXsnmJtbl xm3vmK3R6Rgr2F67HP5It8y+l9lREg46lfAOPsssKwbOE4/b1lp/klz1Ipi/LIjtBD9O nYVBpdFe7/zJTjSWoBS9Nvvueib9f2BgBROnE1SKB4+onZ2+2x8G6P81y9X0hdbc/IsC QTTJYryjkgrG2Hwk0Rb5KG40kineUsayvn7hWf2Qso6QzlJDtLuws5VxhL6Q7Ay6loG4 pMOQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jkm+2wHU; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-33331-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33331-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s189-20020a635ec6000000b005cdf8bb3ffdsi8209665pgb.162.2024.01.22.08.07.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 08:07:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33331-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jkm+2wHU; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-33331-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33331-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 63910B2128B for ; Mon, 22 Jan 2024 15:37:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C2A3612E0; Mon, 22 Jan 2024 15:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jkm+2wHU" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 22281482C4 for ; Mon, 22 Jan 2024 15:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705935906; cv=none; b=VqrKa3tyOsZAZV4Y3idLpdSKm+HwYrwsSi/xN5eS3em6XyXDqDVHYLgCWYvj2fPJDmm9pjSAPniTOB+oow5uUAcsfQ4VG374k7jrXaTyo1sf4BFtyMLu4akvVr3DW4VhtCZHPPVOW225OuxomY9UsUgpJA/7hK2DqbA30NzugGE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705935906; c=relaxed/simple; bh=jQuHU3SaxaQhCS1YR1LSOojoTHXE2B9LKMjOeqc1Aac=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IeEt518OjYUtB+MeIwz51aJsk8gnUTUrgiGmQzDPGxO9Yw5IihEVsc3s5MPQS2F0+thg4EJARpcmpUIHutRTPwsmJ8j0oaBD8ZAGHC6hqsc+iFN8pAbEIApPkcZFTUsVBPSh0q/mvp5LUBHicimpdOCXrMlfpBWPms/pjBTbp0w= 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=jkm+2wHU; arc=none smtp.client-ip=192.198.163.7 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=1705935903; x=1737471903; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=jQuHU3SaxaQhCS1YR1LSOojoTHXE2B9LKMjOeqc1Aac=; b=jkm+2wHUb6WqqiBJCyUR41M12Xs3t0rM/+GwYhJ0HP6y18ojXEjL9eF5 WtM7DS8HWk0DkJn6l2vT2InpnOngBftkb05TruiACu1VMSq6OJLQEk+z8 FC0x/rIl9CFASP0VyPI9w60QsmphcsiMTz1xsaS5c5WeGFazAZLN4jG2V +I8Ws4sLkDI3FlCY77LRuHHlkoGx/Llv2hFULHrD+GvM6fd+gDilJsAMo 3vwzdIJLgFk4NGrcoWwHxxxD/f1EVQi/kuFO69zO9AyR3/iJts6Kqvq8W 44YmbLhilUYX7tzm4ncD6xHXt2BaCH630ilEveLkk99Ik1J5616YgqkzG A==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="22706708" X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="22706708" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 07:05:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="34062697" Received: from jmwebb-mobl1.amr.corp.intel.com (HELO [10.251.14.106]) ([10.251.14.106]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 07:04:55 -0800 Message-ID: <4ab80af9-f296-4a45-8d50-35bdaf565631@linux.intel.com> Date: Mon, 22 Jan 2024 07:04:54 -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: [RFC PATCH v1 3/4] tsm: Allow for mapping RTMRs to TCG TPM PCRs Content-Language: en-US To: Samuel Ortiz , Qinkun Bao Cc: Dan Williams , linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, jiewen.yao@intel.com, ken.lu@intel.com References: <20240114223532.290550-1-sameo@rivosinc.com> <20240114223532.290550-4-sameo@rivosinc.com> <1bbf8d3e-aa94-48c7-a1e4-76f9eefc4af7@linux.intel.com> <65a72c305291f_3b8e29484@dwillia2-xfh.jf.intel.com.notmuch> <5539c533-37b2-4b12-a5c5-056881cf8e3c@linux.intel.com> <90EDEF2B-DB43-413F-840E-3268977FDBD0@google.com> From: Kuppuswamy Sathyanarayanan In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 1/21/24 11:46 PM, Samuel Ortiz wrote: > On Sun, Jan 21, 2024 at 06:09:19PM -0800, Qinkun Bao wrote: >> >>> On Jan 21, 2024, at 8:31 AM, Samuel Ortiz wrote: >>> >>> On Tue, Jan 16, 2024 at 07:35:30PM -0800, Kuppuswamy Sathyanarayanan wrote: >>>> On 1/16/24 5:24 PM, Dan Williams wrote: >>>>> Kuppuswamy Sathyanarayanan wrote: >>>>>> On 1/14/24 2:35 PM, Samuel Ortiz wrote: >>>>>>> Many user space and internal kernel subsystems (e.g. the Linux IMA) >>>>>>> expect a Root of Trust for Storage (RTS) that allows for extending >>>>>>> and reading measurement registers that are compatible with the TCG TPM >>>>>>> PCRs layout, e.g. a TPM. In order to allow those components to >>>>>>> alternatively use a platform TSM as their RTS, a TVM could map the >>>>>>> available RTMRs to one or more TCG TPM PCRs. Once configured, those PCR >>>>>>> to RTMR mappings give the kernel TSM layer all the necessary information >>>>>>> to be a RTS for e.g. the Linux IMA or any other components that expects >>>>>>> a TCG compliant TPM PCRs layout. >>>>>>> >>>>>>> TPM PCR mappings are configured through configfs: >>>>>>> >>>>>>> // Create and configure 2 RTMRs >>>>>>> mkdir /sys/kernel/config/tsm/rtmrs/rtmr0 >>>>>>> mkdir /sys/kernel/config/tsm/rtmrs/rtmr1 >>>>>>> echo 0 > /sys/kernel/config/tsm/rtmrs/rtmr0/index >>>>>>> echo 1 > /sys/kernel/config/tsm/rtmrs/rtmr1/index >>>>>>> >>>>>>> // Map RTMR 0 to PCRs 4, 5, 6, 7 and 8 >>>>>>> echo 4-8 > /sys/kernel/config/tsm/rtmrs/rtmr0/tcg_map >>>>>>> >>>>>>> // Map RTMR 1 to PCRs 16, 17 and 18 >>>>>>> echo 16-18 > /sys/kernel/config/tsm/rtmrs/rtmr1/tcg_map >>>>>> Any information on how this mapping will be used by TPM or IMA ? >>>>>> >>>>>> RTMR to PCR mapping is fixed by design, right? If yes, why allow >>>>>> user to configure it. We can let vendor drivers to configure it, right? >>>>> I assume the "vendor driver", that publishes the RTMR to the tsm-core, >>>>> has no idea whether they will be used for PCR emulation, or not. The TPM >>>>> proxy layer sitting on top of this would know the mapping of which RTMRs >>>>> are recording a transcript of which PCR extend events. >>>> My thinking is, since this mapping is ARCH-specific information >>>> and fixed by design, it makes more sense to hide this detail in the >>>> vendor driver than letting userspace configure it. If we allow users to >>>> configure it, there is a chance for incorrect mapping. >>> I think I agree with the fact that letting users configure that mapping >>> may be error prone. But I'm not sure this is an architecture specific >>> mapping, but rather a platform specific one. I'd expect the guest firmware >>> to provide it through e.g. the MapPcrToMrIndex EFI CC protocol. >>> >>> So I agree I should remove the user interface for setting that mapping, >>> and pass it from the provider capabilities instead. It is then up to the >>> provider to choose how it'd build that information (hard coded, from >>> EFI, etc). >> The UEFI specification has defined the mapping relationship between the >> TDX RTMR and TPM PCRs (See https://uefi.org/specs/UEFI/2.10/38_Confidential_Computing.html#intel-trust-domain-extension). The current RTMR implementation in the boot loader >> is “hooked” in the implementation for the TPM. >> >> When the bootloader needs to extend the PCR value, it calls >> `map_pcr_to_mr_index` to retrieve the corresponding RTMR index and >> then extends the RTMR. Considering this behavior, I don’t think we should >> allow users to configure the mappings between the PCR and RTMR. (See https://github.com/rhboot/shim/pull/485/files ). > Just to be clear: I agree with that and I am going to send a v2 with > that user interface removed. > However I believe that we still need the TSM framework to know about > these mappings and the question is where does the kernel get it from? > > You're suggesting that for TDX these mappings are architecturally > defined, as described by the UEFI spec. For other architectures (CCA, > CoVE) they are not (yet), so I'm suggesting to leave each TSM provider > backend decide how the PCR to RTMR mapping should be built/fetched and > provide it to the TSM framework through the tsm_capabilities structure > that this patchset introduces. The TDX implementation could decide to > hardcode it to the UEFI specification. Agree. Lets leave it to TSM vendor drivers to provide this mapping. > Cheers, > Samuel. -- Sathyanarayanan Kuppuswamy Linux Kernel Developer