From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id E8405D8094F for ; Mon, 29 Apr 2024 09:40:57 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Kw9HZ9PsDx3xarW4hL7SM0hf4UQ2PXyyWu1iGf/qfpY=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type; s=20240206; t=1714383656; v=1; b=A8cGmFGljbaBRLmbPZnYCPIZXHXsXY96Fzy2Qa87Fdi7uwMdDEWLuhEWMqha65NmX6KpSqaA s8KWWuANzrQ0DIHElSfpNNfZc41gf8CiNCXpan2vDr2svvxZS1MeoRpjVHNJrgcA+wy2lusCe1b ErQErQgtNJxqWJv5f/uLBkMKUzohEOl/LACBU3IRpln6oZJtMYzVeTLv5PVkxAXsxlw9R7YUouz +3DWGtRcUTkCUFfWy0DRuKTXOZGDOgOG4cZ33rcqMshcN3yHouxwhwdQjbU/6oRe0FCNrCPwjBk gIxp9ERcIU/Rm7pBh9zG5kwJmrAGkAE7wg/IU7j9sLmIw== X-Received: by 127.0.0.2 with SMTP id 49IkYY7687511xUecFOqL4OO; Mon, 29 Apr 2024 02:40:56 -0700 X-Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mx.groups.io with SMTP id smtpd.web11.12510.1714363610348678210 for ; Sun, 28 Apr 2024 21:06:51 -0700 X-Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VSV7H0zLPz1R9pK for ; Mon, 29 Apr 2024 12:03:39 +0800 (CST) X-Received: from canpemm500008.china.huawei.com (unknown [7.192.105.151]) by mail.maildlp.com (Postfix) with ESMTPS id CE970180A9F for ; Mon, 29 Apr 2024 12:06:46 +0800 (CST) X-Received: from canpemm500001.china.huawei.com (7.192.104.163) by canpemm500008.china.huawei.com (7.192.105.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 29 Apr 2024 12:06:46 +0800 X-Received: from canpemm500001.china.huawei.com ([7.192.104.163]) by canpemm500001.china.huawei.com ([7.192.104.163]) with mapi id 15.01.2507.035; Mon, 29 Apr 2024 12:06:46 +0800 From: "Zhoujian (jay) via groups.io" To: "devel@edk2.groups.io" CC: "zhengyaohui (A)" , "Wangxin (Alexander)" Subject: [edk2-devel] [Question] VM failed to start with secure boot and TPM 2.0 Thread-Topic: [Question] VM failed to start with secure boot and TPM 2.0 Thread-Index: AdqZ6oVEwzyZmpA5RHKIe2tsitMDSQ== Date: Mon, 29 Apr 2024 04:06:46 +0000 Message-ID: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.173.125.127] MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Mon, 29 Apr 2024 02:40:51 -0700 Resent-From: jianjay.zhou@huawei.com Reply-To: devel@edk2.groups.io,jianjay.zhou@huawei.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: HBDaage9fZMTcYZR3vNtQhS0x7686176AA= Content-Language: zh-CN Content-Type: multipart/alternative; boundary="_000_bcbeb1a6918148afb54beb9607cf9f4dhuaweicom_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=A8cGmFGl; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=pass (policy=none) header.from=groups.io --_000_bcbeb1a6918148afb54beb9607cf9f4dhuaweicom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi all, We encountered a problem that the virtual machine failed to start. Our Configuration is as follows: 1. Use qemu 4.1.0 and edk2 202011 for x86 test, and qemu 7.1.0 and edk2 202= 011 for arm test 2. Enable secure boot and TPM 2.0. 3. Import the PK [1]\KEK [2]\db [3]\dbx [4]certificates. 4. VM started with 60 disks and 7 network cards The log of serial port reported the errors: ``` Could not create MokListRT: Volume full Could not create MokListXRT: Volume full Could not create SbatlevelRT: Volume full Could not create MokListTrustedRT: Volume full Something has gone seriously wrong: import_mok_state() failed : Volume Full ``` TPM measures part of UEFI variables, include PK/KEK/db/dbx, BootOrder and s= o on. It calls Tcg2HashLogExtendEvent (edk2 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c= ) to write to event log. Currently the event log length is 64 KB, if full, Tcg2HashLogExtendEvent returned EFI_VOLUME_FULL which caused the VM failed to start. I found some description about variable area length and event log area leng= th. After using tpm2-tool to parse the event logs, we found that event log of a variable contains variable data. Theoretically, the variable size can excee= d 64KB, as long as it does not exceed 256KB. Maybe event log area length should be greater than variable area length ? In section 9.2 of TCG PC Client Platform Firmware Profile Specification [5]= : ``` The Log Area Minimum Length for the TCG event log MUST be at least 64KB. ``` In source code [6] of edk2: ``` ## This PCD defines minimum length(in bytes) of the system preboot TCG even= t log area(LAML). # For PC Client Implementation spec up to and including 1.2 the minimum log= size is 64KB. # @Prompt Minimum length(in bytes) of the system preboot TCG event log area= (LAML). gEfiSecurityPkgTokenSpaceGuid.PcdTcgLogAreaMinLen|0x10000|UINT32|0x00010017 ``` In source code [7] of edk2: ``` !if $(FD_SIZE_IN_KB) =3D=3D 4096 <- - - - - - # it is true in our conf= iguration # Size: 0x40000 (gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSi= ze) - # 0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) =3D 0x3ffb8 # This can speed up the Variable Dispatch a bit. 0xB8, 0xFF, 0x03, 0x00, !endif ``` Based on the above analysis, We tried two solutions: 1. We modify the TcgCommLogEvent function in edk2 to ignore the EFI_VOLUME_FULL error, return EFI_SUCCESS but not write event log. This ide= a refers to [8]. 2. We increase the value of PcdTcgLogAreaMinLen because TCG only defines minimum length. And tpm2-tools has supported event logs longer than 64KB [9= ]. Both solutions can make the virtual machine start successfully but not sure= if they introduce other problems. For the first solution, we are worried that the missing part of the event log will affect the TPM's function. For the second solution, we are not sure if this change will have any impact on oth= er components. Could you give us some advices? Thanks References: [1] https://go.microsoft.com/fwlink/?linkid=3D2255361 [2] https://go.microsoft.com/fwlink/p/?linkid=3D321185 [3] https://go.microsoft.com/fwlink/?LinkId=3D321192 [4] https://uefi.org/sites/default/files/resources/x64_DBXUpdate.bin [5] https://trustedcomputinggroup.org/resource/pc-client-specific-platform-= firmware-profile-specification/ [6] https://github.com/tianocore/edk2/blob/master/SecurityPkg/SecurityPkg.d= ec [7] https://github.com/tianocore/edk2/blob/master/OvmfPkg/Bhyve/VarStore.fd= f.inc [8] https://github.com/rhboot/shim/pull/657 [9] https://github.com/tpm2-software/tpm2-tools/pull/2683 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#118382): https://edk2.groups.io/g/devel/message/118382 Mute This Topic: https://groups.io/mt/105797435/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --_000_bcbeb1a6918148afb54beb9607cf9f4dhuaweicom_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi all,

 

We encountered a problem that t= he virtual machine failed to start. Our

Configuration is as follows: 1. Use qemu 4.1.0 and edk2 202011 for x86 test, and qemu 7.1.0 and edk2 202= 011

for arm test
2. Enable secure boot and TPM 2.0.
3. Import the PK [1]\KEK [2]\db [3]\dbx [4]certificates.
4. VM started with 60 disks and 7 network cards

 

The log of serial port reported= the errors:
```
Could not create MokListRT: Volume full
Could not create MokListXRT: Volume full
Could not create SbatlevelRT: Volume full
Could not create MokListTrustedRT: Volume full
Something has gone seriously wrong: import_mok_state() failed : Volume Full=
```

TPM measures part of UEFI variables, include PK/KEK/db/dbx, BootOrder and s= o

on. It calls Tcg2HashLogExtendE= vent (edk2 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c)

to write to event log. Currentl= y the event log length is 64 KB, if full,

Tcg2HashLogExtendEvent returned= EFI_VOLUME_FULL which caused the VM

failed to start.


I found some description about variable area length and event log area leng= th.

After using tpm2-tool to parse = the event logs, we found that event log of a

variable contains variable data= . Theoretically, the variable size can exceed

64KB, as long as it does not ex= ceed 256KB. Maybe event log area length

should be greater than variable= area length ?

 

In section 9.2 of TCG PC Client= Platform Firmware Profile Specification [5]:
```
The Log Area Minimum Length for the TCG event log MUST be at least 64KB. ```


In source code [6] of edk2:

```
## This PCD defines minimum length(in bytes) of the system preboot TCG even= t log area(LAML).
# For PC Client Implementation spec up to and including 1.2 the minimum log= size is 64KB.
# @Prompt Minimum length(in bytes) of the system preboot TCG event log area= (LAML).
gEfiSecurityPkgTokenSpaceGuid.PcdTcgLogAreaMinLen|0x10000|UINT32|0x00010017=
```


In source code [7] of edk2:

```
!if $(FD_SIZE_IN_KB) =3D=3D 4096     <- - - - - -&nb= sp; # it is true in our configuration
# Size: 0x40000 (gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSi= ze) -
# 0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) =3D 0x3ffb8
# This can speed up the Variable Dispatch a bit.
0xB8, 0xFF, 0x03, 0x00,
!endif
```

Based on the above analysis, We tried two solutions:
1. We modify the TcgCommLogEvent function in edk2 to ignore the<= /span>

EFI_VOLUME_FULL error, return E= FI_SUCCESS but not write event log. This idea

refers to [8].
2. We increase the value of PcdTcgLogAreaMinLen because TCG only defines

minimum length. And tpm2-tools = has supported event logs longer than 64KB [9].

Both solutions can make the virtual machine start successfully but not sure= if

they introduce other problems. = For the first solution, we are worried that

the missing part of the event l= og will affect the TPM’s function. For the

second solution, we are not sur= e if this change will have any impact on other

components. <= /p>

 

Could you give us some advices?=

 

Thanks

 

References:

[1] https://go.microsoft.com/fwlink/?linkid=3D2255361

[2] https://go.microsoft.com/fwlink/p/?linkid=3D321185

[3] https://go.microsoft.com/fwlink/?LinkId=3D321192

[4] https://uefi.org/sites/default/files/resources/x64_DBXUpdate.bin

[5] https://trustedcomputinggroup.org/resource/pc-client-specific-platform-firm= ware-profile-specification/

[6] https://github.com/tianocore/edk2/blob/master/SecurityPkg/SecurityPkg.dec

[7] https://github.com/tianocore/edk2/blob/master/OvmfPkg/Bhyve/VarStore.fdf.in= c

[8] https://github.com/rhboot/s= him/pull/657

[9] https://github.com/tpm2-sof= tware/tpm2-tools/pull/2683

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#118382) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_bcbeb1a6918148afb54beb9607cf9f4dhuaweicom_--