From nobody Tue May 7 09:52:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+69321+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69321+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1608555171; cv=none; d=zohomail.com; s=zohoarc; b=eZks0b3WxyijsLxbtlUvXDZTqn/ALtHMJH1kMwWHZP/4GTTdx9fqDHo+fV5QlyxN2YAcq8Bi0vPcFzFIrU1ktDkF2XwtIBDceOzfpyKelGGPJsy1JzoVuv4kVgeu91tPd3qAyI0BppUBc6EiPBefepfroFW3FNQ+8h0B6mrqlmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608555171; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=TTdQCCA4BSPvkOTYiWbyGJLORkriPP6dRarhvFAIjMQ=; b=TnJFt7W9VhuWU9HTuUBj2RhEB8tTDDG+j1ORn8FIT3NLDbYEL/uHBVrZWcINKBYC6bvpS02LM6NZlj17q7Gk1U/RFFZE8OUZ+kIqgzmkAiFewbozESEXOqQuidZDZG02Ax54Hg1p4vWOyJElyI9JuDmmDVT4Te0ILVMXSYPqlxo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69321+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1608555171136670.4680202575158; Mon, 21 Dec 2020 04:52:51 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id MFkrYY1788612xEXTdhGJTY8; Mon, 21 Dec 2020 04:52:50 -0800 X-Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mx.groups.io with SMTP id smtpd.web12.38505.1608555170380111401 for ; Mon, 21 Dec 2020 04:52:50 -0800 X-Received: by mail-pl1-f180.google.com with SMTP id be12so5569641plb.4 for ; Mon, 21 Dec 2020 04:52:50 -0800 (PST) X-Gm-Message-State: g8tKN6FvsJFduqvWm6TsK0nbx1787277AA= X-Google-Smtp-Source: ABdhPJxWVJVtvuJMtSHaUFUOeLZ+lz1w+ojA8H1qk38yil0OeAFdmOJZJirRGLAUQi79CIcgLc7u+g== X-Received: by 2002:a17:90a:1748:: with SMTP id 8mr17175840pjm.47.1608555169208; Mon, 21 Dec 2020 04:52:49 -0800 (PST) X-Received: from localhost ([121.95.100.191]) by smtp.gmail.com with ESMTPSA id k9sm15784736pjj.8.2020.12.21.04.52.47 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Dec 2020 04:52:48 -0800 (PST) From: "Masahisa Kojima" To: devel@edk2.groups.io Cc: Masahisa Kojima , Ard Biesheuvel , Leif Lindholm , Graeme Gregory , Radoslaw Biernacki , Tanmay Jagdale , Shashi Mallela Subject: [edk2-devel] [PATCH edk2-platforms 1/4] SbsaQemu: Build infrastructure for StandaloneMm image Date: Mon, 21 Dec 2020 21:53:54 +0900 Message-Id: <20201221125357.17744-2-masahisa.kojima@linaro.org> In-Reply-To: <20201221125357.17744-1-masahisa.kojima@linaro.org> References: <20201221125357.17744-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,masahisa.kojima@linaro.org Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608555170; bh=XtqaBvyEAVzDUa+bt6XWkHxELz+eBf0b0ZeWp1rzF8I=; h=Cc:Date:From:Reply-To:Subject:To; b=hLRspZBvQi6WzQIOef4hgL+lMz/CbItcAZ9gYBO7MTEINIxpSS4/ZZeycUk7uUCpncX RZw7zc1WKaDMmZx9cDAiR2fD7djKBiLp3/ltvE0VouKA8ClJ95plCa3DFlVyLd8kML8w4 V8aE63zXW+CRrha+lwQR5WNexKyDIdiRBZw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add the build infrastructure for compilation of StandaloneMm image. Signed-off-by: Masahisa Kojima --- Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.dsc | 132 ++++++++++++++++++++ Platform/Qemu/SbsaQemu/SbsaQemu.fdf | 6 +- Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.fdf | 93 ++++++++++++++ 3 files changed, 228 insertions(+), 3 deletions(-) diff --git a/Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.dsc b/Platform/Qem= u/SbsaQemu/SbsaQemuStandaloneMm.dsc new file mode 100644 index 000000000000..87f5ee351eaa --- /dev/null +++ b/Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.dsc @@ -0,0 +1,132 @@ +# +# Copyright (c) 2020, Linaro Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +##########################################################################= ###### +# +# Defines Section - statements that will be processed to create a Makefile. +# +##########################################################################= ###### +[Defines] + PLATFORM_NAME =3D SbsaQemuStandaloneMm + PLATFORM_GUID =3D A64CC0F5-7ACD-4975-BBE7-7EF6739C8668 + PLATFORM_VERSION =3D 1.0 + DSC_SPECIFICATION =3D 0x00010011 + OUTPUT_DIRECTORY =3D Build/$(PLATFORM_NAME) + SUPPORTED_ARCHITECTURES =3D AARCH64 + BUILD_TARGETS =3D DEBUG|RELEASE|NOOPT + SKUID_IDENTIFIER =3D DEFAULT + FLASH_DEFINITION =3D Platform/Qemu/SbsaQemu/SbsaQemuStanda= loneMm.fdf + DEFINE DEBUG_MESSAGE =3D TRUE + + # LzmaF86 + DEFINE COMPRESSION_TOOL_GUID =3D D42AE6BD-1352-4bfb-909A-CA72A6EAE889 + +##########################################################################= ###### +# +# Library Class section - list of all Library Classes needed by this Platf= orm. +# +##########################################################################= ###### +[LibraryClasses] + # + # Basic + # + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf + DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseD= ebugPrintErrorLevelLib.inf + ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib= /PrePiExtractGuidedSectionLib.inf + FvLib|StandaloneMmPkg/Library/FvLib/FvLib.inf + HobLib|StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHo= bLib.inf + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf + MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf + MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmCoreMemoryAlloca= tionLib/StandaloneMmCoreMemoryAllocationLib.inf + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseRepor= tStatusCodeLibNull.inf + + # + # Entry point + # + StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint= /StandaloneMmDriverEntryPoint.inf + + ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf + StandaloneMmMmuLib|ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmL= ib.inf + ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf + CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMainte= nanceLib.inf + PeCoffExtraActionLib|StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActi= onLib/StandaloneMmPeCoffExtraActionLib.inf + + # ARM PL011 UART Driver + PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartCloc= kLib.inf + PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf + SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortL= ib.inf + + StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntry= Point/StandaloneMmCoreEntryPoint.inf + + # + # It is not possible to prevent the ARM compiler for generic intrinsic f= unctions. + # This library provides the instrinsic functions generate by a given com= piler. + # And NULL mean link this library into all ARM images. + # + NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + +[LibraryClasses.common.MM_STANDALONE] + HobLib|StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf + MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/Standalon= eMmServicesTableLib.inf + MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocation= Lib/StandaloneMmMemoryAllocationLib.inf + +##########################################################################= ###### +# +# Pcd Section - list of all EDK II PCD Entries defined by this Platform +# +##########################################################################= ###### +[PcdsFixedAtBuild] + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x800000CF + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xff + gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0f + + ## PL011 - Serial Terminal + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x60040000 + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 + + gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x2 + +##########################################################################= ######################### +# +# Components Section - list of the modules and components that will be pro= cessed by compilation +# tools and the EDK II tools to generate PE32/PE32+/C= off image files. +# +# Note: The EDK II DSC file is not used to specify how compiled binary ima= ges get placed +# into firmware volume images. This section is just a list of module= s to compile from +# source into UEFI-compliant binaries. +# It is the FDF file that contains information on combining binary f= iles into firmware +# volume images, whose concept is beyond UEFI and is described in PI= specification. +# Binary modules do not need to be listed in this section, as they s= hould be +# specified in the FDF file. For example: Shell binary (Shell_Full.e= fi), FAT binary (Fat.efi), +# Logo (Logo.bmp), and etc. +# There may also be modules listed in this section that are not requ= ired in the FDF file, +# When a module listed here is excluded from FDF file, then UEFI-com= pliant binary will be +# generated for it, but the binary will not be put into any firmware= volume. +# +##########################################################################= ######################### +[Components.common] + # + # MM Core + # + StandaloneMmPkg/Core/StandaloneMmCore.inf + StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf + +##########################################################################= ######################### +# +# BuildOptions Section - Define the module specific tool chain flags that = should be used as +# the default flags for a module. These flags are a= ppended to any +# standard flags that are defined by the build proc= ess. They can be +# applied for any modules or only those modules wit= h the specific +# module style (EDK or EDKII) specified in [Compone= nts] section. +# +##########################################################################= ######################### +[BuildOptions.AARCH64] + GCC:*_*_*_DLINK_FLAGS =3D -z common-page-size=3D0x1000 -march=3Darmv8-a+= nofp diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf b/Platform/Qemu/SbsaQemu/S= bsaQemu.fdf index 3bcf0bf0040a..47ada7df9f2c 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.fdf @@ -21,10 +21,10 @@ =20 [FD.SBSA_FLASH0] BaseAddress =3D 0x00000000 -Size =3D 0x00200000 +Size =3D 0x00400000 ErasePolarity =3D 1 BlockSize =3D 0x00001000 -NumBlocks =3D 0x200 +NumBlocks =3D 0x400 =20 ##########################################################################= ###### # @@ -47,7 +47,7 @@ [FD.SBSA_FLASH0] FILE =3D Platform/Qemu/Sbsa/bl1.bin =20 # and FIP (BL2 + BL31) -0x00008000|0x00020000 +0x00008000|0x00300000 FILE =3D Platform/Qemu/Sbsa/fip.bin =20 ##########################################################################= ###### diff --git a/Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.fdf b/Platform/Qem= u/SbsaQemu/SbsaQemuStandaloneMm.fdf new file mode 100644 index 000000000000..a1acefcfb0a7 --- /dev/null +++ b/Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.fdf @@ -0,0 +1,93 @@ +# +# Copyright (c) 2020, Linaro Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +##########################################################################= ###### +# +# FD Section +# The [FD] Section is made up of the definition statements and a +# description of what goes into the Flash Device Image. Each FD section +# defines one flash "device" image. A flash device image may be one of +# the following: Removable media bootable image (like a boot floppy +# image,) an Option ROM image (that would be "flashed" into an add-in +# card,) a System "Flash" image (that would be burned into a system's +# flash) or an Update ("Capsule") image that will be used to update and +# existing system flash. +# +##########################################################################= ###### + +[FD.STANDALONE_MM] +BaseAddress =3D 0x20001000|gArmTokenSpaceGuid.PcdFdBaseAddress +Size =3D 0x00e00000|gArmTokenSpaceGuid.PcdFdSize # The size in by= tes of the device (14MiB). +ErasePolarity =3D 1 + +BlockSize =3D 0x00001000 +NumBlocks =3D 0x0e00 + +0x00000000|0x00280000 +gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize +FV =3D FVMAIN_COMPACT + +[FV.FVMAIN_COMPACT] +FvAlignment =3D 16 +ERASE_POLARITY =3D 1 +MEMORY_MAPPED =3D TRUE +STICKY_WRITE =3D TRUE +LOCK_CAP =3D TRUE +LOCK_STATUS =3D TRUE +WRITE_DISABLED_CAP =3D TRUE +WRITE_ENABLED_CAP =3D TRUE +WRITE_STATUS =3D TRUE +WRITE_LOCK_CAP =3D TRUE +WRITE_LOCK_STATUS =3D TRUE +READ_DISABLED_CAP =3D TRUE +READ_ENABLED_CAP =3D TRUE +READ_STATUS =3D TRUE +READ_LOCK_CAP =3D TRUE +READ_LOCK_STATUS =3D TRUE + + INF StandaloneMmPkg/Core/StandaloneMmCore.inf + INF StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf + +##########################################################################= ###### +# +# Rules are use with the [FV] section's module INF type to define +# how an FFS file is created for a given INF file. The following Rule are = the default +# rules for the different module type. User can add the customized rules t= o define the +# content of the FFS file. +# +##########################################################################= ###### + + +##########################################################################= ## +# Example of a DXE_DRIVER FFS file with a Checksum encapsulation section = # +##########################################################################= ## +# +#[Rule.Common.DXE_DRIVER] +# FILE DRIVER =3D $(NAMED_GUID) { +# DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_= NAME).depex +# COMPRESS PI_STD { +# GUIDED { +# PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi +# UI STRING=3D"$(MODULE_NAME)" Optional +# VERSION STRING=3D"$(INF_VERSION)" Optional BUILD_NUM=3D$(BUILD_N= UMBER) +# } +# } +# } +# +##########################################################################= ## + +[Rule.Common.MM_CORE_STANDALONE] + FILE SEC =3D $(NAMED_GUID) RELOCS_STRIPPED FIXED { + PE32 PE32 Align =3D Auto $(INF_OUTPUT)/$(MODULE_NAME).efi + } + +[Rule.Common.MM_STANDALONE] + FILE MM_STANDALONE =3D $(NAMED_GUID) { + SMM_DEPEX SMM_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING=3D"$(MODULE_NAME)" Optional + VERSION STRING=3D"$(INF_VERSION)" Optional BUILD_NUM=3D$(BUILD_NUMBE= R) + } --=20 2.17.1 -=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 (#69321): https://edk2.groups.io/g/devel/message/69321 Mute This Topic: https://groups.io/mt/79124570/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue May 7 09:52:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+69322+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69322+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1608555184; cv=none; d=zohomail.com; s=zohoarc; b=N50R6NTO9PAtqimLqFhPGQmcSX9T8VL0SUPloUoc2a2RR7HQghSLb0xvppaqSi8lDC/s/ZfJ4Uz2ly7NvUieQ8R1l1tYJHjKQVjwbsDjTUgVMJmhQMDhOfJZyt/YELr7xMG5UAGBZwcwt1i69aMQtQfNPHlS4TWf8wLujG84mhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608555184; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=yKpXbCRxk82gt5cCovMMJcjcYmHR+KRYNZ1fu/SVijQ=; b=NibTs4d7Mi8P3QZ0Lty0l/2N22MgjT358i/+QdBE0QIPdDCCVpGFrn6FaBiPKy+kMcgVVDOBbb2+NDB5Q2GeaM5PyCyZaBT1fNxHHDVb4yINoLFb4cZ5Mi5IToCBM4ti4EYcx1gT18IzeXcq7rufbBozGGL1MDlROV27QvRtJSY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69322+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1608555184607293.3311230340446; Mon, 21 Dec 2020 04:53:04 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id i5JIYY1788612xcEsTXyLkkb; Mon, 21 Dec 2020 04:53:04 -0800 X-Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mx.groups.io with SMTP id smtpd.web11.38739.1608555178859368530 for ; Mon, 21 Dec 2020 04:52:58 -0800 X-Received: by mail-pl1-f174.google.com with SMTP id x18so5568861pln.6 for ; Mon, 21 Dec 2020 04:52:58 -0800 (PST) X-Gm-Message-State: I5UpTDkrfLkrFuUcMHz3bX7Ix1787277AA= X-Google-Smtp-Source: ABdhPJzjHedXCTfKvNFHVy5J5bxILqIPhX8hU1xQ0LmfEvyg8aqFzVFjSlWqEIPV7+8W7yyBRSqiBw== X-Received: by 2002:a17:90a:df0d:: with SMTP id gp13mr17021436pjb.151.1608555177657; Mon, 21 Dec 2020 04:52:57 -0800 (PST) X-Received: from localhost ([121.95.100.191]) by smtp.gmail.com with ESMTPSA id w9sm16016396pfj.128.2020.12.21.04.52.56 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Dec 2020 04:52:56 -0800 (PST) From: "Masahisa Kojima" To: devel@edk2.groups.io Cc: Masahisa Kojima , Ard Biesheuvel , Leif Lindholm , Graeme Gregory , Radoslaw Biernacki , Tanmay Jagdale , Shashi Mallela Subject: [edk2-devel] [PATCH edk2-platforms 2/4] SbsaQemu: add MM based UEFI secure boot support Date: Mon, 21 Dec 2020 21:53:55 +0900 Message-Id: <20201221125357.17744-3-masahisa.kojima@linaro.org> In-Reply-To: <20201221125357.17744-1-masahisa.kojima@linaro.org> References: <20201221125357.17744-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,masahisa.kojima@linaro.org Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608555184; bh=hz7FHixag776/m10TNV8q/X0eFxcI/yuhwHbQ4wnr+s=; h=Cc:Date:From:Reply-To:Subject:To; b=ga1Q0mA8K1GcO5OVUuvDRfwgCQwvwX5xH82hYR6lgigOc/vl+9eEn0HF1WQQMz4/UKU xhomK85sclkjjMLWRwcvkwBmGuPAuj1Jb1r7hgBsFxQSea+XZSE61jSSI31tfH4Up27YZ xI/NxXTwh1DouKyabRzhthDioY4zkstiFtk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This implements support for UEFI secure boot on SbsaQemu using the standalone MM framework. This moves all of the software handling of the UEFI authenticated variable store into the standalone MM context residing in a secure partition. Secure variable storage is located at 0x01000000 in secure NOR Flash. Non-secure shared memory between UEFI and standalone MM is allocated at the top of DRAM. DRAM size of SbsaQemu varies depends on the QEMU parameter, the non-secure shared memory base address is passed from trusted-firmware through the device tree "/reserved-memory" node. Signed-off-by: Masahisa Kojima --- Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 44 ++++++++--- Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.dsc | 40 ++++++++++ Platform/Qemu/SbsaQemu/SbsaQemu.fdf | 82 +++++++++++= +++++++-- Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.fdf | 7 +- Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuLib.inf | 2 + Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuMem.c | 37 ++++++++- 6 files changed, 192 insertions(+), 20 deletions(-) diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/S= bsaQemu.dsc index f6af3f9111ee..83e7cd21e0c6 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc @@ -27,6 +27,8 @@ [Defines] =20 DEFINE DEBUG_PRINT_ERROR_LEVEL =3D 0x8000004F =20 + DEFINE SECURE_BOOT_ENABLE =3D FALSE + # # Network definition # @@ -148,12 +150,10 @@ [LibraryClasses.common] # Secure Boot dependencies # TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasure= mentLib.inf - AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf =20 # re-use the UserPhysicalPresent() dummy implementation from the ovmf tr= ee PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf =20 - VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyL= ib.inf VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Var= iablePolicyHelperLib.inf =20 @@ -167,6 +167,7 @@ [LibraryClasses.common] ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibN= ull.inf =20 TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf + NorFlashPlatformLib|Silicon/Qemu/SbsaQemu/Library/SbsaQemuNorFlashLib/Sb= saQemuNorFlashLib.inf =20 CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf @@ -296,6 +297,8 @@ [PcdsFeatureFlag.common] gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE =20 + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE + [PcdsFixedAtBuild.common] gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000 gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000 @@ -511,6 +514,10 @@ [PcdsDynamicDefault.common] gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0300 gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0 =20 + gArmTokenSpaceGuid.PcdMmBufferBase|0x10000000000 + gArmTokenSpaceGuid.PcdMmBufferSize|0x00200000 + + ##########################################################################= ###### # # Components Section - list of all EDK II Modules needed by this Platform @@ -564,7 +571,6 @@ [Components.common] ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf ArmPkg/Drivers/CpuPei/CpuPei.inf =20 - MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompre= ssLib.inf @@ -588,24 +594,40 @@ [Components.common] # ArmPkg/Drivers/CpuDxe/CpuDxe.inf MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { - - NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf - # don't use unaligned CopyMem () on the UEFI varstore NOR flash regi= on - BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf - } MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { +!if $(SECURE_BOOT_ENABLE) =3D=3D TRUE NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificatio= nLib.inf +!endif } - SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDx= e.inf MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf =20 + # + # Variable services + # +!if $(SECURE_BOOT_ENABLE) =3D=3D FALSE + MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { + + NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf + AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariabl= eLibNull.inf + VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf + # don't use unaligned CopyMem () on the UEFI varstore NOR flash regi= on + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + } +!else + ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf { + + NULL|StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependen= cy.inf + } + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDx= e.inf +!endif + MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf diff --git a/Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.dsc b/Platform/Qem= u/SbsaQemu/SbsaQemuStandaloneMm.dsc index 87f5ee351eaa..9e438bc5b6b6 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.dsc +++ b/Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.dsc @@ -77,6 +77,19 @@ [LibraryClasses.common.MM_STANDALONE] HobLib|StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/Standalon= eMmServicesTableLib.inf MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocation= Lib/StandaloneMmMemoryAllocationLib.inf + AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf + BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf + IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf + NorFlashPlatformLib|Silicon/Qemu/SbsaQemu/Library/SbsaQemuNorFlashLib/Sb= saQemuNorFlashLib.inf + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf + RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf + PlatformSecureLib|SecurityPkg/Library/PlatformSecureLibNull/PlatformSecu= reLibNull.inf + SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniza= tionLib.inf + TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf + TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplat= e.inf + VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf + ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/Ar= mGenericTimerPhyCounterLib.inf =20 ##########################################################################= ###### # @@ -94,6 +107,20 @@ [PcdsFixedAtBuild] =20 gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x2 =20 + gArmTokenSpaceGuid.PcdFdBaseAddress|0x01000000 + gArmTokenSpaceGuid.PcdFdSize|0x000C0000 + + gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 + gEfiSecurityPkgTokenSpaceGuid.PcdUserPhysicalPresence|TRUE + gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 + + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x01000000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x00040000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x01040000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x00040000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x01080000 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x00040000 + ##########################################################################= ######################### # # Components Section - list of the modules and components that will be pro= cessed by compilation @@ -118,6 +145,19 @@ [Components.common] # StandaloneMmPkg/Core/StandaloneMmCore.inf StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf + ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf + MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandalon= eMm.inf + + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf { + + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf + NULL|MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLibStandal= oneMm.inf + # don't use unaligned CopyMem () on the UEFI varstore NOR flash regi= on + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePol= icyLib.inf + VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib= /VariablePolicyHelperLib.inf + } =20 ##########################################################################= ######################### # diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf b/Platform/Qemu/SbsaQemu/S= bsaQemu.fdf index 47ada7df9f2c..2373594f1fbc 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.fdf @@ -21,10 +21,10 @@ =20 [FD.SBSA_FLASH0] BaseAddress =3D 0x00000000 -Size =3D 0x00400000 +Size =3D 0x01100000 ErasePolarity =3D 1 BlockSize =3D 0x00001000 -NumBlocks =3D 0x400 +NumBlocks =3D 0x1100 =20 ##########################################################################= ###### # @@ -50,6 +50,66 @@ [FD.SBSA_FLASH0] 0x00008000|0x00300000 FILE =3D Platform/Qemu/Sbsa/fip.bin =20 +!if $(SECURE_BOOT_ENABLE) +## Place for Secure Variables. +# Must be aligned to Flash Block size 0x40000 +0x01000000|0x00040000 +gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|gEfiMdeModule= PkgTokenSpaceGuid.PcdFlashNvStorageVariableSize +#NV_VARIABLE_STORE +DATA =3D { + ## This is the EFI_FIRMWARE_VOLUME_HEADER + # ZeroVector [] + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + # FileSystemGuid: gEfiSystemNvDataFvGuid =3D + # { 0xFFF12B8D, 0x7696, 0x4C8B, + # { 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50 }} + 0x8D, 0x2B, 0xF1, 0xFF, 0x96, 0x76, 0x8B, 0x4C, + 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50, + # FvLength: 0xC0000 + 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, + # Signature "_FVH" # Attributes + 0x5f, 0x46, 0x56, 0x48, 0xff, 0xfe, 0x04, 0x00, + # HeaderLength # CheckSum # ExtHeaderOffset #Reserved #Revision + 0x48, 0x00, 0x28, 0x09, 0x00, 0x00, 0x00, 0x02, + # Blockmap[0]: 0x3 Blocks * 0x40000 Bytes / Block + 0x3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, + # Blockmap[1]: End + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ## This is the VARIABLE_STORE_HEADER + # It is compatible with SECURE_BOOT_ENABLE =3D=3D FALSE as well. + # Signature: gEfiAuthenticatedVariableGuid =3D + # { 0xaaf32c78, 0x947b, 0x439a, + # { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 }} + 0x78, 0x2c, 0xf3, 0xaa, 0x7b, 0x94, 0x9a, 0x43, + 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92, + # Size: 0x40000 (gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariabl= eSize) - + # 0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) =3D 0x3ffb8 + # This can speed up the Variable Dispatch a bit. + 0xB8, 0xFF, 0x03, 0x00, + # FORMATTED: 0x5A #HEALTHY: 0xFE #Reserved: UINT16 #Reserved1: UINT32 + 0x5A, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +} + +0x01040000|0x00040000 +gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|gEfiMdeModu= lePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize +#NV_FTW_WORKING +DATA =3D { + # EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature =3D gEdkiiWorkingBl= ockSignatureGuid =3D + # { 0x9e58292b, 0x7c68, 0x497d, { 0xa0, 0xce, 0x65, 0x0, 0xfd, 0x9f, 0= x1b, 0x95 }} + 0x2b, 0x29, 0x58, 0x9e, 0x68, 0x7c, 0x7d, 0x49, + 0xa0, 0xce, 0x65, 0x0, 0xfd, 0x9f, 0x1b, 0x95, + # Crc:UINT32 #WorkingBlockValid:1, WorkingBlockInvalid:1, Res= erved + 0x5b, 0xe7, 0xc6, 0x86, 0xFE, 0xFF, 0xFF, 0xFF, + # WriteQueueSize: UINT64 + 0xE0, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 +} + +0x01080000|0x00040000 +gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|gEfiMdeModule= PkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize +#NV_FTW_SPARE +!endif + ##########################################################################= ###### # # FD Section for FLASH1 @@ -169,15 +229,25 @@ [FV.FvMain] INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf - INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.i= nf - INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf - INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConf= igDxe.inf INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRu= ntimeDxe.inf INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.i= nf INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf =20 + # + # Variable services + # +!if $(SECURE_BOOT_ENABLE) =3D=3D FALSE + INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf + INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.i= nf + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf +!else + INF ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf + INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConf= igDxe.inf +!endif + # # Multiple Console IO support # @@ -189,7 +259,6 @@ [FV.FvMain] =20 INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf - INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf =20 # @@ -287,6 +356,7 @@ [FV.FVMAIN_COMPACT] INF ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf INF ArmPkg/Drivers/CpuPei/CpuPei.inf INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf + INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf =20 # IDE/AHCI Support diff --git a/Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.fdf b/Platform/Qem= u/SbsaQemu/SbsaQemuStandaloneMm.fdf index a1acefcfb0a7..0fd2e9964c7e 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.fdf +++ b/Platform/Qemu/SbsaQemu/SbsaQemuStandaloneMm.fdf @@ -19,8 +19,8 @@ ##########################################################################= ###### =20 [FD.STANDALONE_MM] -BaseAddress =3D 0x20001000|gArmTokenSpaceGuid.PcdFdBaseAddress -Size =3D 0x00e00000|gArmTokenSpaceGuid.PcdFdSize # The size in by= tes of the device (14MiB). +BaseAddress =3D 0x20001000 +Size =3D 0x00e00000 ErasePolarity =3D 1 =20 BlockSize =3D 0x00001000 @@ -49,6 +49,9 @@ [FV.FVMAIN_COMPACT] READ_LOCK_STATUS =3D TRUE =20 INF StandaloneMmPkg/Core/StandaloneMmCore.inf + INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf + INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStand= aloneMm.inf + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf INF StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf =20 ##########################################################################= ###### diff --git a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuLib.inf b/Si= licon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuLib.inf index c067a80cc715..1d7f12202ecc 100644 --- a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuLib.inf +++ b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuLib.inf @@ -40,6 +40,8 @@ [Pcd] gArmTokenSpaceGuid.PcdSystemMemoryBase gArmTokenSpaceGuid.PcdSystemMemorySize gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdDeviceTreeBaseAddress + gArmTokenSpaceGuid.PcdMmBufferBase + gArmTokenSpaceGuid.PcdMmBufferSize =20 [FixedPcd] gArmTokenSpaceGuid.PcdFdBaseAddress diff --git a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuMem.c b/Sili= con/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuMem.c index 8c2eb0b6a028..fa164ff455f5 100644 --- a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuMem.c +++ b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuMem.c @@ -25,15 +25,20 @@ SbsaQemuLibConstructor ( { VOID *DeviceTreeBase; INT32 Node, Prev; - UINT64 NewBase, CurBase; + UINT64 NewBase, CurBase, NsBufBase; UINT64 NewSize, CurSize; + UINT32 NsBufSize; CONST CHAR8 *Type; INT32 Len; CONST UINT64 *RegProp; RETURN_STATUS PcdStatus; + INT32 ParentOffset; + INT32 Offset; =20 NewBase =3D 0; NewSize =3D 0; + NsBufBase =3D 0; + NsBufSize =3D 0; =20 DeviceTreeBase =3D (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeBaseAddress); ASSERT (DeviceTreeBase !=3D NULL); @@ -73,9 +78,39 @@ SbsaQemuLibConstructor ( } } =20 + // StandaloneMM non-secure shared buffer is allocated at the top of + // the system memory by trusted-firmware using "/reserved-memory" node. + ParentOffset =3D fdt_path_offset(DeviceTreeBase, "/reserved-memory"); + if (ParentOffset < 0) { + DEBUG ((DEBUG_ERROR, "%a: reserved-memory node not found\n", + __FUNCTION__)); + } + Offset =3D fdt_subnode_offset(DeviceTreeBase, ParentOffset, "ns-buf-spm-= mm"); + if (Offset < 0) { + DEBUG ((DEBUG_ERROR, "%a: ns-buf-spm-mm node not found\n", + __FUNCTION__)); + } + // Get the 'reg' property of this node. 8 byte quantities for base addre= ss + // and 4 byte quantities for size. + RegProp =3D fdt_getprop (DeviceTreeBase, Offset, "reg", &Len); + if (RegProp !=3D 0 && Len =3D=3D (sizeof (UINT64) + sizeof(UINT32))) { + NsBufBase =3D fdt64_to_cpu (ReadUnaligned64 (RegProp)); + NsBufSize =3D fdt32_to_cpu (ReadUnaligned32 ((UINT32 *)(RegProp + 1))); + + DEBUG ((DEBUG_INFO, "%a: ns buf @ 0x%lx - 0x%lx\n", + __FUNCTION__, NsBufBase, NsBufBase + NsBufSize - 1)); + } else { + DEBUG ((DEBUG_ERROR, "%a: Failed to parse FDT reserved-memory node Len= %d\n", + __FUNCTION__, Len)); + } + + NewSize -=3D NsBufSize; + // Make sure the start of DRAM matches our expectation ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) =3D=3D NewBase); PcdStatus =3D PcdSet64S (PcdSystemMemorySize, NewSize); + PcdStatus =3D PcdSet64S (PcdMmBufferBase, NsBufBase); + PcdStatus =3D PcdSet64S (PcdMmBufferSize, (UINT64)NsBufSize); ASSERT_RETURN_ERROR (PcdStatus); =20 return RETURN_SUCCESS; --=20 2.17.1 -=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 (#69322): https://edk2.groups.io/g/devel/message/69322 Mute This Topic: https://groups.io/mt/79124573/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue May 7 09:52:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+69323+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69323+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1608555188; cv=none; d=zohomail.com; s=zohoarc; b=L0t3jEFSGdqlDLguo0qJVwWeB7ggZtQC7wgYZpp+eIdK6isXIyyX3lMaH9g9xJ1MW05E2gGDejqhq0fk3xN8Q6l24Jj3NVuYPxExp2PGcW66ahznQO+/OAJnCni4TB/kk2p3Ah4O86tIufDDfO4iPGAPTzqnKjIhmLKOO5tskTg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608555188; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=LDvrqJmNZgberXq1Lff+RKtHxXOUHv5DO918SAD4yRg=; b=AFQKhOxGEq/wmT1Rro20onHZoMmTaoDu4bbMfz8oQ5cuwR7UyX4tLXI4bMYSSN6Hf9VW7xVzVzqP4BMd5nP3XOTZTDI3xzFfNlXHoHyCga+behbxWJ43FAFwqi3zkouj6YoIILECFN8q21e7VkgZcC0UZVQAIJ0nuigycGGdkTY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69323+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1608555188502990.714976005688; Mon, 21 Dec 2020 04:53:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id y9uKYY1788612xgcITAnUaC1; Mon, 21 Dec 2020 04:53:08 -0800 X-Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mx.groups.io with SMTP id smtpd.web09.39237.1608555187648488286 for ; Mon, 21 Dec 2020 04:53:07 -0800 X-Received: by mail-pf1-f169.google.com with SMTP id t22so6421645pfl.3 for ; Mon, 21 Dec 2020 04:53:07 -0800 (PST) X-Gm-Message-State: gXDz1Che938JevXvZtkipNOdx1787277AA= X-Google-Smtp-Source: ABdhPJyMSRYcyyZjmObEl4Z3zRGkH4UJufYboyRmPdUPUp0YWhTjogHtC48RF3Kb0wdg9rl51FUIFQ== X-Received: by 2002:aa7:8550:0:b029:19e:46e7:913b with SMTP id y16-20020aa785500000b029019e46e7913bmr14875863pfn.58.1608555186599; Mon, 21 Dec 2020 04:53:06 -0800 (PST) X-Received: from localhost ([121.95.100.191]) by smtp.gmail.com with ESMTPSA id s7sm16380517pfh.207.2020.12.21.04.53.05 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Dec 2020 04:53:05 -0800 (PST) From: "Masahisa Kojima" To: devel@edk2.groups.io Cc: Masahisa Kojima , Ard Biesheuvel , Leif Lindholm , Graeme Gregory , Radoslaw Biernacki , Tanmay Jagdale , Shashi Mallela Subject: [edk2-devel] [PATCH edk2-platforms 3/4] SbsaQemu: add standalone MM build instruction Date: Mon, 21 Dec 2020 21:53:56 +0900 Message-Id: <20201221125357.17744-4-masahisa.kojima@linaro.org> In-Reply-To: <20201221125357.17744-1-masahisa.kojima@linaro.org> References: <20201221125357.17744-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,masahisa.kojima@linaro.org Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608555188; bh=77spJloAKQV+LLxaB9bkCWQTMBA9Dmio1ArmzZtlPoI=; h=Cc:Date:From:Reply-To:Subject:To; b=gvprSvJCMs+1ZUZnwYJmdSKqrBh05e7VD1PNgq0t8hOd5fPQnYf+z964XVLLuul657l c3u68Ll2d4pgptPKqjX614VJ91JPDzR8uRhsPR1Litqp+PAcnzUGKVvElVZUqUrGsz1sl c+WwwLudm3HsDW3mtWZUSFP+TAjR0J1Qdg4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This commit adds the standalone MM build instruction to enable UEFI secure boot. Signed-off-by: Masahisa Kojima --- Platform/Qemu/SbsaQemu/Readme.md | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Platform/Qemu/SbsaQemu/Readme.md b/Platform/Qemu/SbsaQemu/Read= me.md index 63786d9d0fd3..cdee8b41507e 100644 --- a/Platform/Qemu/SbsaQemu/Readme.md +++ b/Platform/Qemu/SbsaQemu/Readme.md @@ -104,6 +104,41 @@ Create a directory $WORKSPACE that would hold source c= ode of the components. truncate -s 256M SBSA_FLASH[01].fd ``` =20 +## Build UEFI with standalone MM based UEFI secure boot + +1. Compile standalone MM image + + ``` + cd $WORKSPACE + build -b RELEASE -a AARCH64 -t GCC5 -p edk2-platforms/Platform/Qemu/Sbsa= Qemu/SbsaQemuStandaloneMM.dsc + ``` + +2. Compile TF-A with BL32(Secure Payload) + + Detailed build instructions can be found on the following link: + https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/docs/pl= at/qemu-sbsa.rst + + Then copy `bl1.bin` and `fip.bin` to the the edk2-non-osi directory: + +3. Compile UEFI with UEFI secure boot enabled + + ``` + cd $WORKSPACE + build -b RELEASE -a AARCH64 -t GCC5 -p edk2-platforms/Platform/Qemu/Sbsa= Qemu/SbsaQemu.dsc -DSECURE_BOOT_ENABLE=3DTRUE + ``` + + Copy SBSA_FLASH0.fd and SBSA_FLASH1.fd to top $WORKSPACE directory. + Then extend the file size to match the machine flash size. + ``` + cp Build/SbsaQemu/RELEASE_GCC5/FV/SBSA_FLASH[01].fd . + truncate -s 256M SBSA_FLASH[01].fd + ``` + + To keep the UEFI variable storage after the succeeding build, use `dd` i= nstead of `cp`. + ``` + dd if=3D./Build/SbsaQemu/RELEASE_GCC5/FV/SBSA_FLASH0.fd of=3D./SBSA_FLAS= H0.fd conv=3Dnotrunc bs=3D2M count=3D8 + ``` + # Running =20 The resulting SBSA_FLASH0.fd file will contain Secure flash0 image (TF-A= code). --=20 2.17.1 -=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 (#69323): https://edk2.groups.io/g/devel/message/69323 Mute This Topic: https://groups.io/mt/79124576/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue May 7 09:52:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+69324+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69324+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1608555203; cv=none; d=zohomail.com; s=zohoarc; b=U1/AM/BpSJsW5eET9Nq11PKXUgYjP+xUoV88gCZyEh9vk3T5PASb2tg2JpWTV0ku7guV4EVDhXXcGgWEymRZJRCLu0ihZgCj/UAdzMj0AySeOipJP2BckUMz1loW7zYjO/nV29rV8Q/j0E9W/xkLEQVTv2I4XXazrJNoAvkzPEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608555203; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=0HypRNkHJ7TZ2eaM6GTj6Hm2soqkC/kwAxMqO7YaWbU=; b=N7+DqRCZLl4w4OTZ/pNYQLNTJGuKHDUYx+gqwDGFDVtV0nNkzlmZIvUsQv8e/sqvQkcPD7jRfLaKnf+GXVgp3TGuMAz4ZBwP8c8BLifksgKEvPMEAJpcoXycLTRq/nDQz72Ut/Xw6M1X0lcbXeozD+xqOH9495veZmeM9/19Kt4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69324+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1608555203353815.6414143461606; Mon, 21 Dec 2020 04:53:23 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9DLyYY1788612xFUSeXh3Mx1; Mon, 21 Dec 2020 04:53:22 -0800 X-Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mx.groups.io with SMTP id smtpd.web12.38512.1608555197511545366 for ; Mon, 21 Dec 2020 04:53:17 -0800 X-Received: by mail-pl1-f173.google.com with SMTP id r4so5552007pls.11 for ; Mon, 21 Dec 2020 04:53:17 -0800 (PST) X-Gm-Message-State: 7LjazIJfvdxVHp7jE8ZpX6ZJx1787277AA= X-Google-Smtp-Source: ABdhPJzjTcSfZOytdbbSNnzI4VS/kxQHQUyU+kRGD1QgFjgyeFB3s6sIWO11ZCrzhOp4dVUevOspOg== X-Received: by 2002:a17:90b:1294:: with SMTP id fw20mr16987376pjb.187.1608555196751; Mon, 21 Dec 2020 04:53:16 -0800 (PST) X-Received: from localhost ([121.95.100.191]) by smtp.gmail.com with ESMTPSA id q11sm16512171pgh.16.2020.12.21.04.53.15 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Dec 2020 04:53:15 -0800 (PST) From: "Masahisa Kojima" To: devel@edk2.groups.io Cc: Masahisa Kojima , Ard Biesheuvel , Leif Lindholm , Graeme Gregory , Radoslaw Biernacki , Tanmay Jagdale , Shashi Mallela Subject: [edk2-devel] [PATCH edk2-platforms 4/4] SbsaQemu: fix typo Date: Mon, 21 Dec 2020 21:53:57 +0900 Message-Id: <20201221125357.17744-5-masahisa.kojima@linaro.org> In-Reply-To: <20201221125357.17744-1-masahisa.kojima@linaro.org> References: <20201221125357.17744-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,masahisa.kojima@linaro.org Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608555202; bh=XFZm+0NdI7mOvn4N6Zk8TBMSC/1SnhGgNKwOZ8lIiPw=; h=Cc:Date:From:Reply-To:Subject:To; b=dowEbWbG2r6NTbQQ4EdE/8+1sTJE9bVauH8bd2ncEhxns3KaPCUZ9bD6/FqV8XpK50l 2ZLKNYFFuJb8VZbm3L0zkMlOrNvpjkSC959Zl1UvdmiSe4dVMnfulUgrEzL/eVDMRkx4t qrOSBtKz/wQUYKwwcGIXcy4F0IzB7XVX1sM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Fix typo in Readme.md Signed-off-by: Masahisa Kojima --- Platform/Qemu/SbsaQemu/Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/Qemu/SbsaQemu/Readme.md b/Platform/Qemu/SbsaQemu/Read= me.md index cdee8b41507e..abee24df0e9d 100644 --- a/Platform/Qemu/SbsaQemu/Readme.md +++ b/Platform/Qemu/SbsaQemu/Readme.md @@ -97,7 +97,7 @@ Create a directory $WORKSPACE that would hold source code= of the components. cd $WORKSPACE build -b RELEASE -a AARCH64 -t GCC5 -p edk2-platforms/Platform/Qemu/Sbsa= Qemu/SbsaQemu.dsc ``` - Copy SBSA_FLASH0.fd and SBSA_FLASH0.fd to top $WORKSPACE directory. + Copy SBSA_FLASH0.fd and SBSA_FLASH1.fd to top $WORKSPACE directory. Then extend the file size to match the machine flash size. ``` cp Build/SbsaQemu/RELEASE_GCC5/FV/SBSA_FLASH[01].fd . --=20 2.17.1 -=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 (#69324): https://edk2.groups.io/g/devel/message/69324 Mute This Topic: https://groups.io/mt/79124581/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-